OpenTTD Source: src/music/midi.h Source File

OpenTTD Source 15.3

midi.h
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
8/* @file midi.h Declarations for MIDI data */
9
10#ifndef MUSIC_MIDI_H
11#define MUSIC_MIDI_H
12
14 struct SMFHeader {
15 uint16_t format;
16 uint16_t tracks;
17 uint16_t tickdiv;
18};
19
21enum MidiStatus : uint8_t {
22 /* Bytes with top bit unset are data bytes i.e. not status bytes */
23 /* Channel status messages, require channel number in lower nibble */
24 MIDIST_NOTEOFF = 0x80,
25 MIDIST_NOTEON = 0x90,
26 MIDIST_POLYPRESS = 0xA0,
27 MIDIST_CONTROLLER = 0xB0,
28 MIDIST_PROGCHG = 0xC0,
29 MIDIST_CHANPRESS = 0xD0,
30 MIDIST_PITCHBEND = 0xE0,
31 /* Full byte status messages */
32 MIDIST_SYSEX = 0xF0,
33 MIDIST_TC_QFRAME = 0xF1,
34 MIDIST_SONGPOSPTR = 0xF2,
35 MIDIST_SONGSEL = 0xF3,
36 /* not defined: 0xF4, */
37 /* not defined: 0xF5, */
38 MIDIST_TUNEREQ = 0xF6,
39 MIDIST_ENDSYSEX = 0xF7,
40 MIDIST_SMF_ESCAPE = 0xF7,
41 MIDIST_RT_CLOCK = 0xF8,
42 /* not defined: 0xF9, */
43 MIDIST_RT_START = 0xFA,
44 MIDIST_RT_CONTINUE = 0xFB,
45 MIDIST_RT_STOP = 0xFC,
46 /* not defined: 0xFD, */
47 MIDIST_RT_ACTSENS = 0xFE,
48 MIDIST_SYSRESET = 0xFF,
49 MIDIST_SMF_META = 0xFF,
50};
51
56enum MidiController : uint8_t {
57 /* Standard continuous controllers (MSB control) */
58 MIDICT_BANKSELECT = 0,
59 MIDICT_MODWHEEL = 1,
60 MIDICT_BREATH = 2,
61 MIDICT_FOOT = 4,
62 MIDICT_PORTAMENTO = 5,
63 MIDICT_DATAENTRY = 6,
64 MIDICT_CHANVOLUME = 7,
65 MIDICT_BALANCE = 8,
66 MIDICT_PAN = 10,
67 MIDICT_EXPRESSION = 11,
68 MIDICT_EFFECT1 = 12,
69 MIDICT_EFFECT2 = 13,
70 MIDICT_GENERAL1 = 16,
71 MIDICT_GENERAL2 = 17,
72 MIDICT_GENERAL3 = 18,
73 MIDICT_GENERAL4 = 19,
74 /* Offset from MSB to LSB of continuous controllers */
75 MIDICTOFS_HIGHRES = 32,
76 /* Standard continuous controllers (LSB control) */
77 MIDICT_BANKSELECT_LO = MIDICTOFS_HIGHRES + MIDICT_BANKSELECT,
78 MIDICT_MODWHEEL_LO = MIDICTOFS_HIGHRES + MIDICT_MODWHEEL,
79 MIDICT_BREATH_LO = MIDICTOFS_HIGHRES + MIDICT_BREATH,
80 MIDICT_FOOT_LO = MIDICTOFS_HIGHRES + MIDICT_FOOT,
81 MIDICT_PORTAMENTO_LO = MIDICTOFS_HIGHRES + MIDICT_PORTAMENTO,
82 MIDICT_DATAENTRY_LO = MIDICTOFS_HIGHRES + MIDICT_DATAENTRY,
83 MIDICT_CHANVOLUME_LO = MIDICTOFS_HIGHRES + MIDICT_CHANVOLUME,
84 MIDICT_BALANCE_LO = MIDICTOFS_HIGHRES + MIDICT_BALANCE,
85 MIDICT_PAN_LO = MIDICTOFS_HIGHRES + MIDICT_PAN,
86 MIDICT_EXPRESSION_LO = MIDICTOFS_HIGHRES + MIDICT_EXPRESSION,
87 MIDICT_EFFECT1_LO = MIDICTOFS_HIGHRES + MIDICT_EFFECT1,
88 MIDICT_EFFECT2_LO = MIDICTOFS_HIGHRES + MIDICT_EFFECT2,
89 MIDICT_GENERAL1_LO = MIDICTOFS_HIGHRES + MIDICT_GENERAL1,
90 MIDICT_GENERAL2_LO = MIDICTOFS_HIGHRES + MIDICT_GENERAL2,
91 MIDICT_GENERAL3_LO = MIDICTOFS_HIGHRES + MIDICT_GENERAL3,
92 MIDICT_GENERAL4_LO = MIDICTOFS_HIGHRES + MIDICT_GENERAL4,
93 /* Switch controllers */
94 MIDICT_SUSTAINSW = 64,
95 MIDICT_PORTAMENTOSW = 65,
96 MIDICT_SOSTENUTOSW = 66,
97 MIDICT_SOFTPEDALSW = 67,
98 MIDICT_LEGATOSW = 68,
99 MIDICT_HOLD2SW = 69,
100 /* Standard low-resolution controllers */
101 MIDICT_SOUND1 = 70,
102 MIDICT_SOUND2 = 71,
103 MIDICT_SOUND3 = 72,
104 MIDICT_SOUND4 = 73,
105 MIDICT_SOUND5 = 74,
106 MIDICT_SOUND6 = 75,
107 MIDICT_SOUND7 = 76,
108 MIDICT_SOUND8 = 77,
109 MIDICT_SOUND9 = 78,
110 MIDICT_SOUND10 = 79,
111 MIDICT_GENERAL5 = 80,
112 MIDICT_GENERAL6 = 81,
113 MIDICT_GENERAL7 = 82,
114 MIDICT_GENERAL8 = 83,
115 MIDICT_PORTAMENTOCTL = 84,
116 MIDICT_PRF_HIGHRESVEL = 88,
117 MIDICT_EFFECTS1 = 91,
118 MIDICT_EFFECTS2 = 92,
119 MIDICT_EFFECTS3 = 93,
120 MIDICT_EFFECTS4 = 94,
121 MIDICT_EFFECTS5 = 95,
122 /* Registered/unregistered parameters control */
123 MIDICT_DATA_INCREMENT = 96,
124 MIDICT_DATA_DECREMENT = 97,
125 MIDICT_NRPN_SELECT_LO = 98,
126 MIDICT_NRPN_SELECT_HI = 99,
127 MIDICT_RPN_SELECT_LO = 100,
128 MIDICT_RPN_SELECT_HI = 101,
129 /* Channel mode messages */
130 MIDICT_MODE_ALLSOUNDOFF = 120,
131 MIDICT_MODE_RESETALLCTRL = 121,
132 MIDICT_MODE_LOCALCTL = 122,
133 MIDICT_MODE_ALLNOTESOFF = 123,
134 MIDICT_MODE_OMNI_OFF = 124,
135 MIDICT_MODE_OMNI_ON = 125,
136 MIDICT_MODE_MONO = 126,
137 MIDICT_MODE_POLY = 127,
138};
139
140
142enum class MidiSysexMessage : uint8_t {
144 ResetGM,
146 ResetGS,
148 ResetXG,
150 RolandSetReverb,
151};
152
153const uint8_t *MidiGetStandardSysexMessage(MidiSysexMessage msg, size_t &length);
154
155#endif /* MUSIC_MIDI_H */
SMFHeader
Header of a Standard MIDI File.
Definition midi.h:14