Commit 30f3c908f0d1865cc296e72d4c72bb8ecb7e3947

Authored by aarnaude
1 parent 346cc2f5

analyse flux midi

Showing 1 changed file with 41 additions and 7 deletions   Show diff stats
analyse_midi_keyboard.c
1 1 #include <stdio.h>
2 2 #include <stdlib.h>
3 3 #include <stdarg.h>
  4 +#include <stdio.h>
  5 +#include <stdbool.h>
  6 +#include <stdlib.h>
4 7 #include <string.h>
5 8 #include <signal.h>
6 9 #include <getopt.h>
... ... @@ -13,6 +16,18 @@
13 16  
14 17 static snd_seq_t *seq;
15 18  
  19 +
  20 +
  21 +void recup_num(){
  22 + FILE* fd;
  23 + int num_port;
  24 + fd=fopen("num_count2.txt","r");
  25 + fscanf(fd, "%d", &num_port);
  26 + printf("num = %d \n", num_port);
  27 + fclose(fd);
  28 +
  29 +}
  30 +
16 31 static void init_seq(void)
17 32 {
18 33 int err;
... ... @@ -48,13 +63,29 @@ static void connect_port(void)
48 63  
49 64 }
50 65  
  66 +void action(snd_seq_event_t *event){
  67 +
  68 + if (event->type == SND_SEQ_EVENT_NOTEON)
  69 + {
  70 + printf("note : %d , velocite : %d\n",event->data.note.note, event->data.note.velocity);
  71 + }
  72 + if (event->type == SND_SEQ_EVENT_NOTEOFF)
  73 + {
  74 + printf("noteOFF : %2d , %d velocite : %d\n", event->data.note.channel, event->data.note.note, event->data.note.velocity);
  75 + }
  76 + if (event->type == SND_SEQ_EVENT_CONTROLLER)
  77 + {
  78 + printf("programme : %2d, %d %d\n", event->data.control.channel, event->data.control.param, event->data.control.value);
  79 + }
  80 +
  81 +}
51 82  
52 83 int main(){
53   - init_seq();
54   - struct pollfd *pfds;
55   - int npfds, err;
56   - create_port();
57   - connect_port();
  84 + init_seq();
  85 + struct pollfd *pfds;
  86 + int npfds, err;
  87 + create_port();
  88 + connect_port();
58 89  
59 90 npfds = snd_seq_poll_descriptors_count(seq, POLLIN);
60 91 pfds = alloca(sizeof(*pfds) * npfds);
... ... @@ -69,7 +100,7 @@ int main(){
69 100 break;
70 101 if (event)
71 102 {
72   - if (event->type == SND_SEQ_EVENT_NOTEON) printf("coucou %d\n",event->data.note.note);
  103 + action(event);
73 104 }
74 105 } while (err > 0);
75 106 fflush(stdout);
... ... @@ -78,6 +109,9 @@ int main(){
78 109  
79 110  
80 111 snd_seq_close(seq);
81   -
  112 +
  113 +
  114 + recup_num();
  115 +
82 116 return 0;
83 117 }
... ...