From 2fd292981c652795a4321b6bc0d69b9ce0bde246 Mon Sep 17 00:00:00 2001 From: Guy Sviry Date: Sat, 14 Jan 2023 18:47:03 +0200 Subject: [PATCH] drop MIDI note-offs that don't match last note this helps when keyjazzing and a key is released when another one was already pressed. --- schism/page_patedit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/schism/page_patedit.c b/schism/page_patedit.c index 31eaad261..ac3dc1d12 100644 --- a/schism/page_patedit.c +++ b/schism/page_patedit.c @@ -105,6 +105,7 @@ int midi_playback_tracing = 0; static int panning_mode = 0; /* for the volume column */ int midi_bend_hit[64]; int midi_last_bend_hit[64]; +int midi_last_note[64]; /* blah; other forwards */ static void pated_save(const char *descr); @@ -2983,6 +2984,11 @@ static int pattern_editor_insert_midi(struct key_event *k) if (k->midi_note == -1) { /* nada */ } else if (k->state == KEY_RELEASE) { + /* don't record noteoffs of non-matching notes */ + if (k->midi_note != midi_last_note[c]) { + return 0; + } + c = song_keyup(KEYJAZZ_NOINST, KEYJAZZ_NOINST, k->midi_note); /* don't record noteoffs for no good reason... */ @@ -3006,7 +3012,7 @@ static int pattern_editor_insert_midi(struct key_event *k) if (!((song_get_mode() & (MODE_PLAYING | MODE_PATTERN_LOOP)) && playback_tracing)) { tick = 0; } - n = k->midi_note; + midi_last_note[c] = n = k->midi_note; c = song_keydown(KEYJAZZ_NOINST, KEYJAZZ_NOINST, n, v, current_channel); cur_note = pattern + 64 * current_row + (c-1); patedit_record_note(cur_note, c, current_row, n, 0);