le logging commence à avoir une bonne tête.
[minwii.git] / src / mxmMidi / constants.py
1 # -*- coding: ISO-8859-1 -*-
2
3 ###################################################
4 ## Definitions of the different midi events
5
6
7
8 ###################################################
9 ## Midi channel events (The most usual events)
10 ## also called "Channel Voice Messages"
11
12 NOTE_OFF = 0x80
13 # 1000cccc 0nnnnnnn 0vvvvvvv (channel, note, velocity)
14
15 NOTE_ON = 0x90
16 # 1001cccc 0nnnnnnn 0vvvvvvv (channel, note, velocity)
17
18 AFTERTOUCH = 0xA0
19 # 1010cccc 0nnnnnnn 0vvvvvvv (channel, note, velocity)
20
21 CONTINUOUS_CONTROLLER = 0xB0 # see Channel Mode Messages!!!
22 # 1011cccc 0ccccccc 0vvvvvvv (channel, controller, value)
23
24 PATCH_CHANGE = 0xC0
25 # 1100cccc 0ppppppp (channel, program)
26
27 CHANNEL_PRESSURE = 0xD0
28 # 1101cccc 0ppppppp (channel, pressure)
29
30 PITCH_BEND = 0xE0
31 # 1110cccc 0vvvvvvv 0wwwwwww (channel, value-lo, value-hi)
32
33
34 ###################################################
35 ## Channel Mode Messages (Continuous Controller)
36 ## They share a status byte.
37 ## The controller makes the difference here
38
39 # High resolution continuous controllers (MSB)
40
41 BANK_SELECT = 0x00
42 MODULATION_WHEEL = 0x01
43 BREATH_CONTROLLER = 0x02
44 FOOT_CONTROLLER = 0x04
45 PORTAMENTO_TIME = 0x05
46 DATA_ENTRY = 0x06
47 CHANNEL_VOLUME = 0x07
48 BALANCE = 0x08
49 PAN = 0x0A
50 EXPRESSION_CONTROLLER = 0x0B
51 EFFECT_CONTROL_1 = 0x0C
52 EFFECT_CONTROL_2 = 0x0D
53 GEN_PURPOSE_CONTROLLER_1 = 0x10
54 GEN_PURPOSE_CONTROLLER_2 = 0x11
55 GEN_PURPOSE_CONTROLLER_3 = 0x12
56 GEN_PURPOSE_CONTROLLER_4 = 0x13
57
58 # High resolution continuous controllers (LSB)
59
60 BANK_SELECT = 0x20
61 MODULATION_WHEEL = 0x21
62 BREATH_CONTROLLER = 0x22
63 FOOT_CONTROLLER = 0x24
64 PORTAMENTO_TIME = 0x25
65 DATA_ENTRY = 0x26
66 CHANNEL_VOLUME = 0x27
67 BALANCE = 0x28
68 PAN = 0x2A
69 EXPRESSION_CONTROLLER = 0x2B
70 EFFECT_CONTROL_1 = 0x2C
71 EFFECT_CONTROL_2 = 0x2D
72 GENERAL_PURPOSE_CONTROLLER_1 = 0x30
73 GENERAL_PURPOSE_CONTROLLER_2 = 0x31
74 GENERAL_PURPOSE_CONTROLLER_3 = 0x32
75 GENERAL_PURPOSE_CONTROLLER_4 = 0x33
76
77 # Switches
78
79 SUSTAIN_ONOFF = 0x40
80 PORTAMENTO_ONOFF = 0x41
81 SOSTENUTO_ONOFF = 0x42
82 SOFT_PEDAL_ONOFF = 0x43
83 LEGATO_ONOFF = 0x44
84 HOLD_2_ONOFF = 0x45
85
86 # Low resolution continuous controllers
87
88 SOUND_CONTROLLER_1 = 0x46 # (TG: Sound Variation; FX: Exciter On/Off)
89 SOUND_CONTROLLER_2 = 0x47 # (TG: Harmonic Content; FX: Compressor On/Off)
90 SOUND_CONTROLLER_3 = 0x48 # (TG: Release Time; FX: Distortion On/Off)
91 SOUND_CONTROLLER_4 = 0x49 # (TG: Attack Time; FX: EQ On/Off)
92 SOUND_CONTROLLER_5 = 0x4A # (TG: Brightness; FX: Expander On/Off)75 SOUND_CONTROLLER_6 (TG: Undefined; FX: Reverb OnOff)
93 SOUND_CONTROLLER_7 = 0x4C # (TG: Undefined; FX: Delay OnOff)
94 SOUND_CONTROLLER_8 = 0x4D # (TG: Undefined; FX: Pitch Transpose OnOff)
95 SOUND_CONTROLLER_9 = 0x4E # (TG: Undefined; FX: Flange/Chorus OnOff)
96 SOUND_CONTROLLER_10 = 0x4F # (TG: Undefined; FX: Special Effects OnOff)
97 GENERAL_PURPOSE_CONTROLLER_5 = 0x50
98 GENERAL_PURPOSE_CONTROLLER_6 = 0x51
99 GENERAL_PURPOSE_CONTROLLER_7 = 0x52
100 GENERAL_PURPOSE_CONTROLLER_8 = 0x53
101 PORTAMENTO_CONTROL = 0x54 # (PTC) (0vvvvvvv is the source Note number) (Detail)
102 EFFECTS_1 = 0x5B # (Ext. Effects Depth)
103 EFFECTS_2 = 0x5C # (Tremelo Depth)
104 EFFECTS_3 = 0x5D # (Chorus Depth)
105 EFFECTS_4 = 0x5E # (Celeste Depth)
106 EFFECTS_5 = 0x5F # (Phaser Depth)
107 DATA_INCREMENT = 0x60 # (0vvvvvvv is n/a; use 0)
108 DATA_DECREMENT = 0x61 # (0vvvvvvv is n/a; use 0)
109 NON_REGISTERED_PARAMETER_NUMBER = 0x62 # (LSB)
110 NON_REGISTERED_PARAMETER_NUMBER = 0x63 # (MSB)
111 REGISTERED_PARAMETER_NUMBER = 0x64 # (LSB)
112 REGISTERED_PARAMETER_NUMBER = 0x65 # (MSB)
113
114 # Channel Mode messages - (Detail)
115
116 ALL_SOUND_OFF = 0x78
117 RESET_ALL_CONTROLLERS = 0x79
118 LOCAL_CONTROL_ONOFF = 0x7A
119 ALL_NOTES_OFF = 0x7B
120 OMNI_MODE_OFF = 0x7C # (also causes ANO)
121 OMNI_MODE_ON = 0x7D # (also causes ANO)
122 MONO_MODE_ON = 0x7E # (Poly Off; also causes ANO)
123 POLY_MODE_ON = 0x7F # (Mono Off; also causes ANO)
124
125
126
127 ###################################################
128 ## System Common Messages, for all channels
129
130 SYSTEM_EXCLUSIVE = 0xF0
131 # 11110000 0iiiiiii 0ddddddd ... 11110111
132
133 MTC = 0xF1 # MIDI Time Code Quarter Frame
134 # 11110001
135
136 SONG_POSITION_POINTER = 0xF2
137 # 11110010 0vvvvvvv 0wwwwwww (lo-position, hi-position)
138
139 SONG_SELECT = 0xF3
140 # 11110011 0sssssss (songnumber)
141
142 #UNDEFINED = 0xF4
143 ## 11110100
144
145 #UNDEFINED = 0xF5
146 ## 11110101
147
148 TUNING_REQUEST = 0xF6
149 # 11110110
150
151 END_OFF_EXCLUSIVE = 0xF7 # terminator
152 # 11110111 # End of system exclusive
153
154
155 ###################################################
156 ## Midifile meta-events
157
158 SEQUENCE_NUMBER = 0x00 # 00 02 ss ss (seq-number)
159 TEXT = 0x01 # 01 len text...
160 COPYRIGHT = 0x02 # 02 len text...
161 SEQUENCE_NAME = 0x03 # 03 len text...
162 INSTRUMENT_NAME = 0x04 # 04 len text...
163 LYRIC = 0x05 # 05 len text...
164 MARKER = 0x06 # 06 len text...
165 CUEPOINT = 0x07 # 07 len text...
166 PROGRAM_NAME = 0x08 # 08 len text...
167 DEVICE_NAME = 0x09 # 09 len text...
168
169 MIDI_CH_PREFIX = 0x20 # MIDI channel prefix assignment (unofficial)
170
171 MIDI_PORT = 0x21 # 21 01 port, legacy stuff but still used
172 END_OF_TRACK = 0x2F # 2f 00
173 TEMPO = 0x51 # 51 03 tt tt tt (tempo in us/quarternote)
174 SMTP_OFFSET = 0x54 # 54 05 hh mm ss ff xx
175 TIME_SIGNATURE = 0x58 # 58 04 nn dd cc bb
176 KEY_SIGNATURE = 0x59 # ??? len text...
177 SPECIFIC = 0x7F # Sequencer specific event
178
179 FILE_HEADER = 'MThd'
180 TRACK_HEADER = 'MTrk'
181
182 ###################################################
183 ## System Realtime messages
184 ## I don't supose these are to be found in midi files?!
185
186 TIMING_CLOCK = 0xF8
187 # undefined = 0xF9
188 SONG_START = 0xFA
189 SONG_CONTINUE = 0xFB
190 SONG_STOP = 0xFC
191 # undefined = 0xFD
192 ACTIVE_SENSING = 0xFE
193 SYSTEM_RESET = 0xFF
194
195
196 ###################################################
197 ## META EVENT, it is used only in midi files.
198 ## In transmitted data it means system reset!!!
199
200 META_EVENT = 0xFF
201 # 11111111
202
203
204 ###################################################
205 ## Helper functions
206
207 def is_status(byte):
208 return (byte & 0x80) == 0x80 # 1000 0000
209
210