midi.c (556B)
1 #include <u.h> 2 #include <libc.h> 3 #include "midi.h" 4 5 char * 6 midifill(MidiMes *m, char *p, int) 7 { 8 m->cn = p[0] >> 8; 9 m->cin = p[0] & 0x0f; 10 m->status = p[1] & 0xf0; 11 m->channel = p[1] & 0x0f; 12 m->param[0] = p[2]; 13 m->param[1] = p[3]; 14 return p + 4; 15 } 16 17 void 18 midinoteon(char *p, int chan, int note, int velocity) 19 { 20 p[0] = CIN_NoteOn; 21 p[1] = (chan & 0x0f) | (NOTE_ON); 22 p[2] = note; 23 p[3] = velocity; 24 } 25 26 void 27 midinoteoff(char *p, int chan, int note, int velocity) 28 { 29 p[0] = CIN_NoteOff; 30 p[1] = (chan & 0x0f) | (NOTE_OFF); 31 p[2] = note; 32 p[3] = velocity; 33 }