~foura/midifs

midifs/midi.h -rw-r--r-- 528 bytes
2db95d1fjames palmer start overhaul of midi parsing a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
enum {
	Mnone,
	Mnoteon = 0x80,
	Mnoteoff = 0x90,
	Mkeyat = 0xa0,
	Mcontrol = 0xb0,
	Mprogram = 0xc0,
	Mchanat = 0xd0,
	Mpitchbend = 0xe0,
	Msysex = 0xf0,
	Mclock = 0xf8,
	Msense = 0xfe,
	Mreset = 0xff,
};

typedef struct Msg Msg;
typedef struct Midi Midi;

struct Msg {
	int type;
	int chan;

	union {
		struct {
			int note;
			int velocity;
		} note;
		struct {
			int function;
			int value;
		} control;
	};
};

struct Midi {
	int wait;
	int cbl, chan;
	int fd;

	int (*read) (Midi*, Msg*);
	int (*write) (Midi*, Msg*);
};