| @@ -399,16 +399,23 @@ struct MIDI_CV : Module { | |||||
| // Set last note if monophonic | // Set last note if monophonic | ||||
| if (channels == 1) { | if (channels == 1) { | ||||
| if (!heldNotes.empty()) { | if (!heldNotes.empty()) { | ||||
| // Replace note with last held note | |||||
| uint8_t lastNote = heldNotes.back(); | uint8_t lastNote = heldNotes.back(); | ||||
| notes[0] = lastNote; | notes[0] = lastNote; | ||||
| } | } | ||||
| else { | |||||
| // Disable gate | |||||
| gates[0] = false; | |||||
| } | |||||
| } | } | ||||
| // Clear notes that are not held if polyphonic | // Clear notes that are not held if polyphonic | ||||
| else { | else { | ||||
| for (int c = 0; c < channels; c++) { | for (int c = 0; c < channels; c++) { | ||||
| if (!gates[c]) | if (!gates[c]) | ||||
| continue; | continue; | ||||
| // Disable all gates | |||||
| gates[c] = false; | gates[c] = false; | ||||
| // Re-enable gate if channel's note is still held | |||||
| for (uint8_t note : heldNotes) { | for (uint8_t note : heldNotes) { | ||||
| if (notes[c] == note) { | if (notes[c] == note) { | ||||
| gates[c] = true; | gates[c] = true; | ||||