Skip to content

Commit

Permalink
drop MIDI note-offs that don't match last note
Browse files Browse the repository at this point in the history
this helps when keyjazzing and a key is released when another one was
already pressed.
  • Loading branch information
guysv committed Jan 14, 2023
1 parent ec6e0b4 commit 2fd2929
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion schism/page_patedit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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... */
Expand All @@ -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);
Expand Down

0 comments on commit 2fd2929

Please sign in to comment.