Commit 32aa7df8 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Fix retrigger bugs

parent 6ae83815
......@@ -12,6 +12,7 @@
INIT_LIST(notes, NUM_NOTES);
static uint16_t current_bend;
static uint8_t current_note;
enum {
// GATE_START should be as low as possible to reduce MIDI latency, but
......@@ -63,11 +64,11 @@ mono_set_pitch(void)
return;
}
uint8_t n = l_first(notes);
current_note = l_first(notes);
for_each_voice(v) {
int16_t detune = detune_factor[v] * detune_amount;
detune += vibrato_detune();
dac_set_note2(v, n, detune, current_bend);
dac_set_note2(v, current_note, detune, current_bend);
}
}
......@@ -78,16 +79,22 @@ mono_note_off(uint8_t n)
return;
}
l_delete(notes, n);
if (l_first(notes) == current_note) {
// prevent accidental retrigger
return;
}
for_each_voice(v) {
gate_off(v);
}
l_delete(notes, n);
if (l_empty(notes)) {
gate_countdown = 0;
return;
}
// Re-trigger previously playing note
gate_countdown = GATE_START;
mono_set_pitch();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment