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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
//! Constants for dealing with midi events. //! Currently, only channel events are supported. /// Constants for channel events /// /// Channel events consist of two or three bytes: /// * byte 1: event type (first four bits) and midi channel (last four bits) /// * byte 2: parameter 1 /// * byte 3: parameter 2 (used for most, but not all event types) pub mod channel_event { /// The first byte of a channel event contains both the event type /// and the midi channel in one byte. /// Use this bit mask to get the event type. /// /// ## Example /// ``` /// use midi_consts::channel_event::EVENT_TYPE_MASK; /// # fn get_byte() -> u8 { 0x94} /// let byte: u8 = get_byte(); // Suppose we got this byte somewhere. /// let event_type = byte & EVENT_TYPE_MASK; // (binary AND) /// match event_type { /// EVENT_TYPE_NOTE_OFF => { /* ... */ }, /// EVENT_TYPE_NOTE_ON => { /* ... */ }, /// // ... /// _ => { /* ...*/ } /// } /// ``` pub const EVENT_TYPE_MASK: u8 = 0b1111_0000; /// The first byte of a channel event contains both the event type /// and the midi channel in one byte. /// Use this bit mask to get the midi channel. /// /// ## Example /// ``` /// use midi_consts::channel_event::MIDI_CHANNEL_MASK; /// # fn get_byte() -> u8 { 0x94} /// let byte: u8 = get_byte(); // Suppose we got this byte somewhere. /// let midi_channel: u8 = byte & MIDI_CHANNEL_MASK; // (binary AND) /// ``` pub const MIDI_CHANNEL_MASK: u8 = 0b0000_1111; /// Event type of note off event. /// /// A channel event of this type is as follows: /// * byte 1: `NOTE_OFF | channel` /// * byte 2: note number (0-127) /// * byte 3: velocity (how hard the key was released) /// /// # Remark /// A note off event is often represented as a note on event /// with velocity `0`. pub const NOTE_OFF: u8 = 0x80; /// Event type of note on event. /// /// A channel event of this type is as follows: /// * byte one: `NOTE_ON | channel` /// * byte two: note number (0-127) /// * byte three: velocity (how hard the key was pressed) /// /// # Remark /// A note off event is often represented as a note on event /// with velocity `0`. pub const NOTE_ON: u8 = 0x90; /// Event type for polyphonic key pressure ("aftertouch"). /// /// A channel event of this type is as follows: /// * byte one: `POLYPHONIC_KEY_PRESSURE | channel`, where `channel` is the channel (0-16) /// * byte two: note number (0-127) /// * byte three: aftertouch value pub const POLYPHONIC_KEY_PRESSURE: u8 = 0xA0; /// Event type of a controller event. /// /// A channel event of this type is as follows: /// * byte one: `CONTROL_CHANGE | channel`, where `channel` is the channel (0-16) /// * byte two: controller type (0-127) /// * byte three: new controller value /// /// See the [`control_change`] module for more details. /// /// [`control_change`]: ./control_change/index.html pub const CONTROL_CHANGE: u8 = 0xB0; /// Event type of a program change. /// /// A channel event of this type has only two bytes and is as follows: /// * byte one: `PROGRAM_CHANGE | channel`, where `channel` is the channel (0-16) /// * byte two: program number (0-127) pub const PROGRAM_CHANGE: u8 = 0xC0; /// Event type of channel pressure ("channel aftertouch"). /// /// Events of this type are assumed to effect all currently /// playing notes for the specified channel. /// A channel event of this type has only two bytes and is as follows: /// * byte one: `CHANNEL_KEY_PRESSURE | channel`, where `channel` is the channel (0-16) /// * byte two: pressure amount (0-127) pub const CHANNEL_KEY_PRESSURE: u8 = 0xD0; /// Event type of a pitch bend event. /// /// A channel event of this type is as follows: /// * byte one: `PITCH_BEND_CHANGE | channel`, where `channel` is the channel (0-16) /// * byte two: least significant byte of the pitch bend amount (0-127) /// * byte three: most significant byte of the pitch bend amount /// /// By combining the two bytes that make up the pitch bend amount, you /// can get a `u16` value that describes the pitch bend amount. /// Value 8192 means "no pitch change", lower values mean decrease in pitch /// and higher values mean increase in pitch. pub const PITCH_BEND_CHANGE: u8 = 0xE0; /// Constants to represent controller change types. /// /// A control change channel event is as follows: /// * byte one: `CONTROL_CHANGE | channel`, where `channel` is the channel (0-16) /// * byte two: controller type (0-127). This module contains constants for these types. /// * byte three: new controller value /// /// # Remark /// Some control change types come in pairs: one with the most significant byte (MSB) /// and one with the least significant byte (LSB). pub mod control_change { const LSB_MASK: u8 = 0x20; /// Bank select: most significant byte. pub const BANK_SELECT_MSB: u8 = 0x00; /// Bank select: least significant byte. pub const BANK_SELECT_LSB: u8 = BANK_SELECT_MSB | LSB_MASK; /// Modulation: most significant byte. pub const MODULATION_MSB: u8 = 0x01; /// Modulation: least significant byte. pub const MODULATION_LSB: u8 = MODULATION_MSB | LSB_MASK; /// Breath controller: most significant byte. pub const BREATH_CONTROLLER_MSB: u8 = 0x02; /// Breach controller: least significant byte. pub const BREATH_CONTROLLER_LSB: u8 = BREATH_CONTROLLER_MSB | LSB_MASK; /// Foot controller: most significant byte. pub const FOOT_CONTROLLER_MSB: u8 = 0x04; /// Foot controller: least significant byte. pub const FOOT_CONTROLLER_LSB: u8 = FOOT_CONTROLLER_MSB | LSB_MASK; /// Portamento: most significant byte. pub const PORTAMENTO_TIME_MSB: u8 = 0x05; /// Portamento: least significant byte. pub const PORTAMENTO_TIME_LSB: u8 = PORTAMENTO_TIME_MSB | LSB_MASK; /// Data entry: most significant byte. pub const DATA_ENTRY_MSB: u8 = 0x06; /// Data entry: least significant byte. pub const DATA_ENTRY_LSB: u8 = DATA_ENTRY_MSB | LSB_MASK; /// Main volume: most significant byte. pub const MAIN_VOLUME_MSB: u8 = 0x07; /// Main volume: least significant byte. pub const MAIN_VOLUME_LSB: u8 = MAIN_VOLUME_MSB | LSB_MASK; /// Balance: most significant byte. pub const BALANCE_MSB: u8 = 0x08; /// Balance: least significant byte. pub const BALANCE_LSB: u8 = BALANCE_MSB | LSB_MASK; /// Pan: most significant byte. pub const PAN_MSB: u8 = 0x0A; /// Pan: least significant byte. pub const PAN_LSB: u8 = PAN_MSB | LSB_MASK; /// Expression controller: most significant byte. pub const EXPRESSION_CONTROLLER_MSB: u8 = 0x0B; /// Expression controller: least significant byte. pub const EXPRESSION_CONTROLLER_LSB: u8 = EXPRESSION_CONTROLLER_MSB | LSB_MASK; /// Effect control 1: most significant byte. pub const EFFECT_CONTROL_1_MSB: u8 = 0x0C; /// Effect control 1: least significant byte. pub const EFFECT_CONTROL_1_LSB: u8 = EFFECT_CONTROL_1_MSB | LSB_MASK; /// Effect control 2: most significant byte. pub const EFFECT_CONTROL_2_MSB: u8 = 0x0D; /// Effect control 2: least significant byte. pub const EFFECT_CONTROL_2_LSB: u8 = EFFECT_CONTROL_2_MSB | LSB_MASK; /// General purpose controller 1: most significant byte. pub const GENERAL_PURPOSE_CONTROLLER_1_MSB: u8 = 0x10; /// General purpose controller 1: least significant byte. pub const GENERAL_PURPOSE_CONTROLLER_1_LSB: u8 = GENERAL_PURPOSE_CONTROLLER_1_MSB | LSB_MASK; /// General purpose controller 2: most significant byte. pub const GENERAL_PURPOSE_CONTROLLER_2_MSB: u8 = 0x11; /// General purpose controller 2: least significant byte. pub const GENERAL_PURPOSE_CONTROLLER_2_LSB: u8 = GENERAL_PURPOSE_CONTROLLER_2_MSB | LSB_MASK; /// General purpose controller 3: most significant byte. pub const GENERAL_PURPOSE_CONTROLLER_3_MSB: u8 = 0x12; /// General purpose controller 3: least significant byte. pub const GENERAL_PURPOSE_CONTROLLER_3_LSB: u8 = GENERAL_PURPOSE_CONTROLLER_3_MSB | LSB_MASK; /// General purpose controller 4: most significant byte. pub const GENERAL_PURPOSE_CONTROLLER_4_MSB: u8 = 0x13; /// General purpose controller 4: least significant byte. pub const GENERAL_PURPOSE_CONTROLLER_4_LSB: u8 = GENERAL_PURPOSE_CONTROLLER_4_MSB | LSB_MASK; /// Damper pedal. pub const DAMPER_PEDAL: u8 = 0x40; /// Portamento. pub const PORTAMENTO: u8 = 0x41; /// Sustenuto. pub const SUSTENUTO: u8 = 0x42; /// Soft pedal. pub const SOFT_PEDAL: u8 = 0x43; /// Legato footswitch. pub const LEGATO_FOOTSWITCH: u8 = 0x44; /// Hold 2. pub const HOLD_2: u8 = 0x45; /// Sound controller 1. Default: Timber variation pub const SOUND_CONTROLLER_1: u8 = 0x46; /// Sound controller 2. Default: Timber/harmonic content pub const SOUND_CONTROLLER_2: u8 = 0x47; /// Sound controller 3. Default: Release time pub const SOUND_CONTROLLER_3: u8 = 0x48; /// Sound controller 4. Default: Attack time pub const SOUND_CONTROLLER_4: u8 = 0x49; /// Sound controller 5. pub const SOUND_CONTROLLER_5: u8 = 0x4A; /// Sound controller 6. pub const SOUND_CONTROLLER_6: u8 = 0x4B; /// Sound controller 7. pub const SOUND_CONTROLLER_7: u8 = 0x4C; /// Sound controller 8. pub const SOUND_CONTROLLER_8: u8 = 0x4D; /// Sound controller 9. pub const SOUND_CONTROLLER_9: u8 = 0x4E; /// Sound controller 10. pub const SOUND_CONTROLLER_10: u8 = 0x4F; /// General purpose controller 5: most significant byte. /// /// # Remark /// As far as I know, this has no LSB (least significant byte) variant. pub const GENERAL_PURPOSE_CONTROLLER_5_MSB: u8 = 0x50; /// General purpose controller 6: most significant byte. /// /// # Remark /// As far as I know, this has no LSB (least significant byte) variant. pub const GENERAL_PURPOSE_CONTROLLER_6_MSB: u8 = 0x51; /// General purpose controller 7: most significant byte. /// /// # Remark /// As far as I know, this has no LSB (least significant byte) variant. pub const GENERAL_PURPOSE_CONTROLLER_7_MSB: u8 = 0x52; /// General purpose controller 8: most significant byte. /// /// # Remark /// As far as I know, this has no LSB (least significant byte) variant. pub const GENERAL_PURPOSE_CONTROLLER_8_MSB: u8 = 0x53; /// Portamento. pub const PORTAMENTO_CONTROL: u8 = 0x54; /// Effects depth 1. Formerly "External Effects Depth" pub const EFFECTS_1_DEPTH: u8 = 0x5B; /// Effects depth 2. Formerly "Tremolo Depth" pub const EFFECTS_2_DEPTH: u8 = 0x5C; /// Effects depth 3. Formerly "Chorus Depth" pub const EFFECTS_3_DEPTH: u8 = 0x5D; /// Effects depth 4. Formerly "Celeste Detune" pub const EFFECTS_4_DEPTH: u8 = 0x5E; /// Effects depth 5. Formerly "Phaser Depth" pub const EFFECTS_5_DEPTH: u8 = 0x5F; /// Non-registered parameter number: least significant byte. pub const NON_REGISTERED_PARAMETER_NUMBER_LSB: u8 = 0x62; /// Non-registered parameter number: most significant byte. pub const NON_REGISTERED_PARAMETER_NUMBER_MSB: u8 = 0x63; /// Registered parameter number: least significant byte. pub const REGISTERED_PARAMETER_NUMBER_LSB: u8 = 0x64; /// Registered parameter number: most significant byte. pub const REGISTERED_PARAMETER_NUMBER_MSB: u8 = 0x65; /// Mode message: all sound off. /// /// For this event, the data byte (the third byte of the event) should be `0` pub const ALL_SOUND_OFF: u8 = 0x78; /// Mode message: reset all controllers. /// /// For this event, the data byte (the third byte of the event) should be `0` pub const RESET_ALL_CONTROLLERS: u8 = 0x79; /// Mode message: local control. /// /// When local control is on (default), the device responds to its local controls. /// When local control is off, it only responds to data recieved over MIDI. /// /// See the module [`local_control`] for possible values of the data byte /// (the third byte of the event). /// /// [`local_control`]: ./local_control/index.html pub const LOCAL_CONTROL: u8 = 0x7A; /// Constants for the data byte (3rd byte) of a local control control change event. pub mod local_control { /// Local control off: the device only responds to data recieved over MIDI. pub const LOCAL_CONTROL_OFF: u8 = 0; /// Local control on: the device also responds to local events (keys played, ...). pub const LOCAL_CONTROL_ON: u8 = 127; } /// Mode message: all notes off. /// /// For this event, the data byte (the third byte of the event) should be `0`. pub const ALL_NOTES_OFF: u8 = 0x7B; /// Mode message: omni mode off. /// /// For this event, the data byte (the third byte of the event) should be `0`. /// # Remark /// This message also causes all notes off. pub const OMNI_MODE_OFF: u8 = 0x7C; /// Mode message: omni mode on. /// /// For this event, the data byte (the third byte of the event) should be `0`. /// # Remark /// This message also causes all notes off. pub const OMNI_MODE_ON: u8 = 0x7D; /// Mode message: mono mode on /// /// For this event, the data byte (the third byte of the event) /// indicates the number of channels (omni off) or `0` (omni on). /// # Remark /// This message also causes all notes off. pub const MONO_MODE_ON: u8 = 0x7E; /// Poly mode on /// /// # Remark /// This message also causes all notes off. pub const POLY_MODE_ON: u8 = 0x7F; } }