diff options
Diffstat (limited to 'midi.c')
| -rw-r--r-- | midi.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -5,6 +5,7 @@ #include <alsa/asoundlib.h> #include "midi.h" +#include "mutex.h" static snd_seq_t *seq_handle; static snd_seq_addr_t *ports; @@ -81,8 +82,12 @@ void *midi(void *arg) { } if (ev) { + pthread_mutex_lock(&mutex); switch (ev->type) { case SND_SEQ_EVENT_NOTEON: + shared_data.note = ev->data.note.note; + shared_data.state = 1; + shared_data.velocity = ev->data.note.velocity; printf("%3d:%-3dNote on %2d, note %d, velocity: %3d\n", ev->source.client, ev->source.port, ev->data.note.channel, @@ -91,14 +96,23 @@ void *midi(void *arg) { break; case SND_SEQ_EVENT_NOTEOFF: + shared_data.note = ev->data.note.note; + shared_data.state = 0; + shared_data.velocity = 0; printf("%3d:%-3dNote off\t%2d, note %d\n", ev->source.client, ev->source.port, ev->data.note.channel, ev->data.note.note); break; + default: + break; + } + shared_data.action = 1; + shared_data.preset = 3; - } + pthread_cond_signal(&cond_synth); + pthread_mutex_unlock(&mutex); } } |
