dump.c (613B)
1 #include <u.h> 2 #include <libc.h> 3 #include "midi.h" 4 5 void 6 noteon(MidiMes m) 7 { 8 print("ch %d NoteOn %d, vel %d\n", m.channel, m.param[0], 9 m.param[1]); 10 } 11 12 void 13 noteoff(MidiMes m) 14 { 15 print("ch %d NoteOff %d, vel %d\n", m.channel, m.param[0], 16 m.param[1]); 17 } 18 19 20 void 21 main(void) 22 { 23 char buf[4]; 24 MidiMes m; 25 while (read(0, buf, 4) >= 4) { 26 midifill(&m, buf, 4); 27 switch(m.status) { 28 case NOTE_ON: 29 noteon(m); 30 break; 31 case NOTE_OFF: 32 noteoff(m); 33 break; 34 default: 35 print("%ux %ux | %ux %ux | %02ux %02ux\n", 36 m.cn, m.cin, m.status, m.channel, 37 m.param[0], m.param[1]); 38 } 39 } 40 print("%r\n"); 41 }