1 # -*- coding: ISO-8859-1 -*-
3 ###################################################
4 ## Definitions of the different midi events
8 ###################################################
9 ## Midi channel events (The most usual events)
10 ## also called "Channel Voice Messages"
13 # 1000cccc 0nnnnnnn 0vvvvvvv (channel, note, velocity)
16 # 1001cccc 0nnnnnnn 0vvvvvvv (channel, note, velocity)
19 # 1010cccc 0nnnnnnn 0vvvvvvv (channel, note, velocity)
21 CONTINUOUS_CONTROLLER
= 0xB0 # see Channel Mode Messages!!!
22 # 1011cccc 0ccccccc 0vvvvvvv (channel, controller, value)
25 # 1100cccc 0ppppppp (channel, program)
27 CHANNEL_PRESSURE
= 0xD0
28 # 1101cccc 0ppppppp (channel, pressure)
31 # 1110cccc 0vvvvvvv 0wwwwwww (channel, value-lo, value-hi)
34 ###################################################
35 ## Channel Mode Messages (Continuous Controller)
36 ## They share a status byte.
37 ## The controller makes the difference here
39 # High resolution continuous controllers (MSB)
42 MODULATION_WHEEL
= 0x01
43 BREATH_CONTROLLER
= 0x02
44 FOOT_CONTROLLER
= 0x04
45 PORTAMENTO_TIME
= 0x05
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
58 # High resolution continuous controllers (LSB)
61 MODULATION_WHEEL
= 0x21
62 BREATH_CONTROLLER
= 0x22
63 FOOT_CONTROLLER
= 0x24
64 PORTAMENTO_TIME
= 0x25
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
80 PORTAMENTO_ONOFF
= 0x41
81 SOSTENUTO_ONOFF
= 0x42
82 SOFT_PEDAL_ONOFF
= 0x43
86 # Low resolution continuous controllers
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)
114 # Channel Mode messages - (Detail)
117 RESET_ALL_CONTROLLERS
= 0x79
118 LOCAL_CONTROL_ONOFF
= 0x7A
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)
127 ###################################################
128 ## System Common Messages, for all channels
130 SYSTEM_EXCLUSIVE
= 0xF0
131 # 11110000 0iiiiiii 0ddddddd ... 11110111
133 MTC
= 0xF1 # MIDI Time Code Quarter Frame
136 SONG_POSITION_POINTER
= 0xF2
137 # 11110010 0vvvvvvv 0wwwwwww (lo-position, hi-position)
140 # 11110011 0sssssss (songnumber)
148 TUNING_REQUEST
= 0xF6
151 END_OFF_EXCLUSIVE
= 0xF7 # terminator
152 # 11110111 # End of system exclusive
155 ###################################################
156 ## Midifile meta-events
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...
169 MIDI_CH_PREFIX
= 0x20 # MIDI channel prefix assignment (unofficial)
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
180 TRACK_HEADER
= 'MTrk'
182 ###################################################
183 ## System Realtime messages
184 ## I don't supose these are to be found in midi files?!
192 ACTIVE_SENSING
= 0xFE
196 ###################################################
197 ## META EVENT, it is used only in midi files.
198 ## In transmitted data it means system reset!!!
204 ###################################################
208 return (byte
& 0x80) == 0x80 # 1000 0000