Fix corrupt MIDI file writing when meta events are present (fixes missing first note...
[ardour.git] / libs / midi++2 / midi++ / types.h
1 /*
2     Copyright (C) 2000-2007 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __midi_types_h__
21 #define __midi_types_h__
22
23 #include <inttypes.h>
24
25 namespace MIDI {
26
27         typedef char           channel_t;
28         typedef float          controller_value_t;
29         typedef unsigned char  byte;
30         typedef unsigned short pitchbend_t;
31         typedef uint32_t       nframes_t;
32         typedef uint32_t       timestamp_t;
33
34         enum eventType {
35             none = 0x0,
36             raw = 0xF4, /* undefined in MIDI spec */
37             any = 0xF5, /* undefined in MIDI spec */
38             off = 0x80,
39             on = 0x90,
40             controller = 0xB0,
41             program = 0xC0,
42             chanpress = 0xD0,
43             polypress = 0xA0,
44             pitchbend = 0xE0,
45             sysex = 0xF0,
46             mtc_quarter = 0xF1,
47             position = 0xF2,
48             song = 0xF3,
49             tune = 0xF6,
50             eox = 0xF7,
51             timing = 0xF8,
52             start = 0xFA,
53             contineu = 0xFB, /* note spelling */
54             stop = 0xFC,
55             active = 0xFE,
56             reset = 0xFF
57     };
58
59     extern const char *controller_names[];
60         byte decode_controller_name (const char *name);
61
62     struct EventTwoBytes {
63         union {
64             byte note_number;
65             byte controller_number;
66         };
67         union {
68             byte velocity;
69             byte value;
70         };
71     };
72
73     enum MTC_FPS {
74             MTC_24_FPS = 0,
75             MTC_25_FPS = 1,
76             MTC_30_FPS_DROP = 2,
77             MTC_30_FPS = 3
78     };
79
80     enum MTC_Status {
81             MTC_Stopped = 0,
82             MTC_Forward,
83             MTC_Backward
84     };
85
86 } // namespace MIDI
87
88 #endif // __midi_types_h__
89
90
91
92