From 0015cc0418c04c88ce125def27e1c0fb1e077f4e Mon Sep 17 00:00:00 2001 From: Oleksiy Date: Wed, 3 Mar 2021 13:06:56 +0200 Subject: [PATCH] Buffer works, but noteoff sometimes stops the wrong note, and triggers high pitched sound, need to investigate --- FM/FM.ino | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/FM/FM.ino b/FM/FM.ino index a751147..804a3e4 100644 --- a/FM/FM.ino +++ b/FM/FM.ino @@ -81,13 +81,13 @@ void updateBuffer(byte bNote, bool bGate) { // Removing the note from the array and shifting everything to close the gap for (int n = i; n <= bufferIndex; n++) { noteBuffer[n] = noteBuffer[n + 1]; // what happens if it's the last note in buffer? - } - if (i == bufferIndex) { //this does not fire - bufferIndex--; + } + bufferIndex--; + if (i == bufferIndex) { + bufferIndex--; //we need to play the notefrom previous cell of buffer write index, that's where -- and ++ come from gate = 1; - playNote(); - } else { //this does fire - bufferIndex--; + playNote(); + bufferIndex++; } } }