From 8d17aa29baf0b33229dbdd82d8d5f6cbe3fe0240 Mon Sep 17 00:00:00 2001 From: gramanas Date: Sun, 26 Nov 2023 16:29:00 +0200 Subject: Many changes! --- src/midi.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/midi.c') diff --git a/src/midi.c b/src/midi.c index e711ecb..fbea43f 100644 --- a/src/midi.c +++ b/src/midi.c @@ -12,6 +12,8 @@ void midi_decode(uint32_t msg, synth_t * synth) { uint8_t channel = (status & 0x0F) + 1; // convert to human uint8_t message = status >> 4; + int flag = 1; + switch (message) { case 0x08: printf("Note Off: channel=%d, note=%d, velocity=%d\n", channel, data1, data2); @@ -28,6 +30,14 @@ void midi_decode(uint32_t msg, synth_t * synth) { synth->midi_note[data1].velocity = (float)data2 / 127.0; synth->midi_note[data1].elapsed = 0; synth->midi_note[data1].active = 1; + for (int i = 0; i < synth->midi_active_n; i++) { + if (synth->midi_active[i] == &synth->midi_note[data1]) { + flag = 0; + } + } + if (flag) { + synth->midi_active[synth->midi_active_n++] = &synth->midi_note[data1]; + } synth->active = 1; break; case 0x0A: -- cgit v1.2.3