summaryrefslogtreecommitdiff
path: root/midi.c
diff options
context:
space:
mode:
Diffstat (limited to 'midi.c')
-rw-r--r--midi.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/midi.c b/midi.c
index 3d21f79..f389826 100644
--- a/midi.c
+++ b/midi.c
@@ -5,6 +5,7 @@
5#include <alsa/asoundlib.h> 5#include <alsa/asoundlib.h>
6 6
7#include "midi.h" 7#include "midi.h"
8#include "mutex.h"
8 9
9static snd_seq_t *seq_handle; 10static snd_seq_t *seq_handle;
10static snd_seq_addr_t *ports; 11static snd_seq_addr_t *ports;
@@ -81,8 +82,12 @@ void *midi(void *arg) {
81 } 82 }
82 83
83 if (ev) { 84 if (ev) {
85 pthread_mutex_lock(&mutex);
84 switch (ev->type) { 86 switch (ev->type) {
85 case SND_SEQ_EVENT_NOTEON: 87 case SND_SEQ_EVENT_NOTEON:
88 shared_data.note = ev->data.note.note;
89 shared_data.state = 1;
90 shared_data.velocity = ev->data.note.velocity;
86 printf("%3d:%-3dNote on %2d, note %d, velocity: %3d\n", 91 printf("%3d:%-3dNote on %2d, note %d, velocity: %3d\n",
87 ev->source.client, ev->source.port, 92 ev->source.client, ev->source.port,
88 ev->data.note.channel, 93 ev->data.note.channel,
@@ -91,14 +96,23 @@ void *midi(void *arg) {
91 break; 96 break;
92 97
93 case SND_SEQ_EVENT_NOTEOFF: 98 case SND_SEQ_EVENT_NOTEOFF:
99 shared_data.note = ev->data.note.note;
100 shared_data.state = 0;
101 shared_data.velocity = 0;
94 printf("%3d:%-3dNote off\t%2d, note %d\n", 102 printf("%3d:%-3dNote off\t%2d, note %d\n",
95 ev->source.client, ev->source.port, 103 ev->source.client, ev->source.port,
96 ev->data.note.channel, 104 ev->data.note.channel,
97 ev->data.note.note); 105 ev->data.note.note);
98 break; 106 break;
107 default:
108 break;
109 }
99 110
111 shared_data.action = 1;
112 shared_data.preset = 3;
100 113
101 } 114 pthread_cond_signal(&cond_synth);
115 pthread_mutex_unlock(&mutex);
102 } 116 }
103 } 117 }
104 118