miditest.c (529B)
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <unistd.h> 4 #include <stdint.h> 5 #include <sndio.h> 6 7 /* 8 * a simple program that sends midi NOTE ON 9 * and then NOTE OFF a second later 10 */ 11 12 int 13 main(void) 14 { 15 uint8_t msg[4]; 16 char *mdev; 17 msg[0] = 0x90; 18 msg[1] = 0x64; 19 msg[2] = 127; 20 mdev = "midithru/0"; 21 struct mio_hdl *mh; 22 mh = mio_open(mdev, MIO_OUT, 0); 23 if (mh == 0) { 24 fprintf(stderr, " can't open midi %s\n", mdev); 25 exit(-1); 26 } 27 mio_write(mh, msg, 3); 28 sleep(1); 29 msg[0] = 0x80; 30 mio_write(mh, msg, 3); 31 return 0; 32 }