Skip to content

Commit 75d5fa6

Browse files
committed
Fix note latch can't free if key is held then note latched turned on
1 parent ea1d23b commit 75d5fa6

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Applications/Note/NoteLatch.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,16 @@ void NoteLatch::ProcessNoteMessage(const MidiPacket& packet, deque<MidiPacket>&
7676
}
7777
else if (packet.status == NoteOff || (packet.status == NoteOn && packet.Velocity() == 0)) {
7878
// Note Off
79+
auto latchedIt = std::find(latchedNotes.begin(), latchedNotes.end(), note);
7980
auto holdingIt = std::find(stillHoldingNotes.begin(), stillHoldingNotes.end(), note);
8081

81-
if (holdingIt != stillHoldingNotes.end()) {
82+
if (holdingIt != stillHoldingNotes.end()) { // If it was holding then we remove it from active keys
8283
stillHoldingNotes.erase(holdingIt);
8384
}
85+
else if(latchedIt == latchedNotes.end()) // If it was, then note latch is enabled after the key is held. Add this entry
86+
{
87+
latchedNotes.push_back(note);
88+
}
8489
}
8590
}
8691

0 commit comments

Comments
 (0)