From 30f3c908f0d1865cc296e72d4c72bb8ecb7e3947 Mon Sep 17 00:00:00 2001 From: aarnaude Date: Wed, 5 Apr 2017 14:19:53 +0200 Subject: [PATCH] analyse flux midi --- analyse_midi_keyboard.c | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/analyse_midi_keyboard.c b/analyse_midi_keyboard.c index 56cfc6a..d42757c 100644 --- a/analyse_midi_keyboard.c +++ b/analyse_midi_keyboard.c @@ -1,6 +1,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -13,6 +16,18 @@ static snd_seq_t *seq; + + +void recup_num(){ + FILE* fd; + int num_port; + fd=fopen("num_count2.txt","r"); + fscanf(fd, "%d", &num_port); + printf("num = %d \n", num_port); + fclose(fd); + +} + static void init_seq(void) { int err; @@ -48,13 +63,29 @@ static void connect_port(void) } +void action(snd_seq_event_t *event){ + + if (event->type == SND_SEQ_EVENT_NOTEON) + { + printf("note : %d , velocite : %d\n",event->data.note.note, event->data.note.velocity); + } + if (event->type == SND_SEQ_EVENT_NOTEOFF) + { + printf("noteOFF : %2d , %d velocite : %d\n", event->data.note.channel, event->data.note.note, event->data.note.velocity); + } + if (event->type == SND_SEQ_EVENT_CONTROLLER) + { + printf("programme : %2d, %d %d\n", event->data.control.channel, event->data.control.param, event->data.control.value); + } + +} int main(){ - init_seq(); - struct pollfd *pfds; - int npfds, err; - create_port(); - connect_port(); + init_seq(); + struct pollfd *pfds; + int npfds, err; + create_port(); + connect_port(); npfds = snd_seq_poll_descriptors_count(seq, POLLIN); pfds = alloca(sizeof(*pfds) * npfds); @@ -69,7 +100,7 @@ int main(){ break; if (event) { - if (event->type == SND_SEQ_EVENT_NOTEON) printf("coucou %d\n",event->data.note.note); + action(event); } } while (err > 0); fflush(stdout); @@ -78,6 +109,9 @@ int main(){ snd_seq_close(seq); - + + + recup_num(); + return 0; } -- libgit2 0.21.2