diff options
Diffstat (limited to 'src/midi.c')
-rw-r--r-- | src/midi.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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: |