Prevent playing the same note on 2 channels

This commit is contained in:
Jeff Epler 2023-04-05 16:20:27 -05:00
parent 6df88ac948
commit 9993b4b01c
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
1 changed files with 3 additions and 0 deletions

View File

@ -160,6 +160,9 @@ STATIC int find_channel_with_note(const synthio_midi_span_t *span, uint8_t note)
}
bool synthio_span_change_note(synthio_midi_span_t *span, uint8_t old_note, uint8_t new_note) {
if (new_note != SYNTHIO_SILENCE && find_channel_with_note(span, new_note) != -1) {
return false; // note already pressed, do nothing
}
int channel = find_channel_with_note(span, old_note);
if (channel != -1) {
span->note[channel] = new_note;