diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2023-11-26 16:29:00 +0200 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2023-11-26 16:29:00 +0200 |
commit | 8d17aa29baf0b33229dbdd82d8d5f6cbe3fe0240 (patch) | |
tree | bc4ec3351f8585b548ddf016c93d3715b324b64c /src/midi.c | |
parent | c03d395f6848fe9b2d1185173a9cf5ec8277394f (diff) | |
download | synth-project-8d17aa29baf0b33229dbdd82d8d5f6cbe3fe0240.tar.gz synth-project-8d17aa29baf0b33229dbdd82d8d5f6cbe3fe0240.tar.bz2 synth-project-8d17aa29baf0b33229dbdd82d8d5f6cbe3fe0240.zip |
Many changes!
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: |