commit bfe79e81f902296f98f0fbf10751a753c2f4f4b1
parent 8fd8fcc8a7131117ad4606fc46ea27c33eb12aaf
Author: Matt Demanett <matt@demanett.net>
Date: Tue, 24 Mar 2020 23:37:45 -0400
ARP: fix hold mode to not allow duplicate notes.
Diffstat:
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/Arp.cpp b/src/Arp.cpp
@@ -134,24 +134,26 @@ void Arp::NoteSet::resetSequence() {
}
void Arp::NoteSet::addNote(int c, float pitch) {
- dropNote(c);
- _noteOn[c] = true;
- _notesDirty = true;
-
Note n;
n.pitch = pitch;
n.channel = c;
-
- _notesAsPlayed[_noteCount] = n;
-
int i = 0;
while (n.pitch >= _notesByPitch[i].pitch && i < _noteCount) {
+ if (n.pitch == _notesByPitch[i].pitch) {
+ return;
+ }
++i;
}
assert(i <= _noteCount);
+
+ dropNote(c);
+ _noteOn[c] = true;
+ _notesDirty = true;
+
shuffleUp(_notesByPitch, i);
_notesByPitch[i] = n;
+ _notesAsPlayed[_noteCount] = n;
++_noteCount;
assert(_noteCount <= maxChannels);
}