From 383cae76d7b50b8576de05d34fa0ef01001e64fe Mon Sep 17 00:00:00 2001 From: Oleksiy Date: Sun, 7 Mar 2021 15:51:11 +0200 Subject: [PATCH] noteoff is still messed up --- FM/FM.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/FM/FM.ino b/FM/FM.ino index 804a3e4..bb8cb3f 100644 --- a/FM/FM.ino +++ b/FM/FM.ino @@ -64,8 +64,8 @@ void noteOn(byte channel, byte note, byte velocity) { void noteOff(byte channel, byte note, byte velocity) { if (channel == MIDI_CHANNEL) { - gate = 0; updateBuffer(note, gate); + gate = 0; } } @@ -83,11 +83,13 @@ void updateBuffer(byte bNote, bool bGate) { noteBuffer[n] = noteBuffer[n + 1]; // what happens if it's the last note in buffer? } bufferIndex--; - if (i == bufferIndex) { + if (i == bufferIndex && i != 0) { bufferIndex--; //we need to play the notefrom previous cell of buffer write index, that's where -- and ++ come from gate = 1; playNote(); bufferIndex++; + } else if (i == bufferIndex && i == 0) { + gate = 0; } } }