Skip to content

Commit 8493a69

Browse files
committed
Fix note latch
1 parent 9a4f50b commit 8493a69

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

Applications/Note/NoteLatch.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ void NoteLatch::SetToggleMode(bool enable) {
5858

5959
void NoteLatch::ProcessNoteMessage(const MidiPacket& packet, deque<MidiPacket>& output) {
6060
uint8_t note = packet.Note();
61+
lastChannel = packet.Channel();
6162

6263
if (packet.status == NoteOn && packet.Velocity() > 0) {
6364
// Note On
@@ -136,7 +137,7 @@ void NoteLatch::ProcessAfterTouchToggleMode(const MidiPacket& packet, deque<Midi
136137
void NoteLatch::ReleaseAllLatchedNotes(deque<MidiPacket>& output) {
137138
// Send note off for all latched notes
138139
for (uint8_t note : latchedNotes) {
139-
MidiPacket noteOff = MidiPacket::NoteOff(0, note, 0); // Channel 0 for simplicity
140+
MidiPacket noteOff = MidiPacket::NoteOff(lastChannel, note, 0); // Channel 0 for simplicity
140141
output.push_back(noteOff);
141142
}
142143

Applications/Note/NoteLatch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class NoteLatch : public MidiEffect {
1212
std::vector<uint8_t> stillHoldingNotes; // Notes that are physically still being held
1313
bool disableOnNextTick = false;
1414
bool toggleMode = false;
15+
uint8_t lastChannel = 0;
1516
public:
1617
void Tick(deque<MidiPacket>& input, deque<MidiPacket>& output) override;
1718
void Reset() override;

0 commit comments

Comments
 (0)