Hi, I'm making good progress on my HANPAN project but I'm stuck on this. When I change scale it works:
NoteOn ,ch: 1 , Note: 57, Velocity: 90
NoteOff ,ch: 1 , Note: 57, Velocity: 0
NoteOn ,ch: 1 , Note: 55, Velocity: 70
NoteOff ,ch: 1 , Note: 55, Velocity: 0
the noteOff is well stored and then it's released. Perfect !
But when I change octave I have this :
NoteOn ,ch: 1 , Note: 69, Velocity: 45
NoteOff ,ch: 1 , Note: 57, Velocity: 0
NoteOn ,ch: 1 , Note: 81, Velocity: 45
NoteOff ,ch: 1 , Note: 57, Velocity: 0
NoteOn remains pressed and she plays continuously, NoteOff does not update
Thanks for your help
NoteOn ,ch: 1 , Note: 57, Velocity: 90
NoteOff ,ch: 1 , Note: 57, Velocity: 0
NoteOn ,ch: 1 , Note: 55, Velocity: 70
NoteOff ,ch: 1 , Note: 55, Velocity: 0
the noteOff is well stored and then it's released. Perfect !
But when I change octave I have this :
NoteOn ,ch: 1 , Note: 69, Velocity: 45
NoteOff ,ch: 1 , Note: 57, Velocity: 0
NoteOn ,ch: 1 , Note: 81, Velocity: 45
NoteOff ,ch: 1 , Note: 57, Velocity: 0
NoteOn remains pressed and she plays continuously, NoteOff does not update
Thanks for your help
Code:
///////PAD1/////////////////
void peakDetect1(int voltage) {
// "static" variables keep their numbers between each run of this function
static int state; // 0=idle, 1=looking for peak, 2=ignore aftershocks
static int peak; // remember the highest reading
static elapsedMillis msec; // timer to end states 1 and 2
switch (state) {
case 0:
if (voltage > thresholdMin) {
Serial.print("begin peak track ");
Serial.println(voltage);
peak = voltage;
msec = 0;
state = 1;
}
return;
// Peak Tracking state: capture largest reading
case 1:
if (voltage > peak) {
peak = voltage;
}
if (msec >= peakTrackMillis) {
Serial.print("peak = ");
Serial.println(peak);
int velocity = map(peak, thresholdMin, 1023, 1, 127);
if(octave_index == 1)
usbMIDI.sendNoteOn(scale[scale_index][0]+12, velocity, channel);
else if(octave_index == -1)
usbMIDI.sendNoteOn(scale[scale_index][0]-12, velocity, channel);
else if(octave_index == 2)
usbMIDI.sendNoteOn(scale[scale_index][0]+24, velocity, channel);
else if(octave_index == -2)
usbMIDI.sendNoteOn(scale[scale_index][0]-24, velocity, channel);
else
usbMIDI.sendNoteOn(scale[scale_index][0], velocity, channel);
msec = 0;
state = 2;
leds.setColorRGB(0, 255, 0, 0); // Led Color ON RED
etat1 = 1;
startTime1 = millis();
}
return;
// Ignore Aftershock state: wait for things to be quiet again.
default:
if (voltage > thresholdMin) {
msec = 0; // keep resetting timer if above threshold
} else if (msec > aftershockMillis) {
usbMIDI.sendNoteOff(scale[scale_index][0], 0, channel);
state = 0; // go back to idle when
}
}
}