MIDI Specifications
References:
Data format
A MIDI message consists of one status byte, optionally followed by one or two data bytes, except for system exclusive messages which have an arbitrary number of data bytes.
Status bytes have their MSB set to 1 (values 128–255, 0x80–0xFF). Data bytes have their MSB set to 0 (values 0–127, 0x00–0x7F).
Channel messages
Channel messages contain their channel number in the lower four bits of the status byte. Value 0 corresponds to channel 1; value 15 (0x0F) is channel 16.
| Message | Hex | Decimal | Data bytes |
|---|---|---|---|
| Note off | 8n | 128+n | 2 |
| Note on | 9n | 144+n | 2 |
| Polyphonic key pressure | An | 160+n | 2 |
| Control/Mode change | Bn | 176+n | 2 |
| Program change | Cn | 192+n | 1 |
| Monophonic channel pressure | Dn | 208+n | 1 |
| Pitch bend change | En | 224+n | 2 |
Running status
Channel messages support running status: if the next channel status byte is the same as the last, it may be omitted. The receiver assumes the same status type. Running status is especially convenient for strings of Note On/Off messages.
System messages
System messages are not encoded with channel numbers. There are three types: common, real-time, and exclusive.
- Real-time messages may be interspersed in the data stream, even within a multibyte message, without affecting the current status.
- System exclusive (sysex) messages transfer device-specific information. They begin with 0xF0 followed by a manufacturer ID. Any non-real-time status byte terminates a sysex message.
| Message | Hex | Decimal | Data bytes |
|---|---|---|---|
| System exclusive | |||
| System exclusive status | F0 | 240 | variable |
| System common | |||
| MIDI Time Code (MTC) | F1 | 241 | 1 |
| Song position pointer | F2 | 242 | 2 |
| Song select | F3 | 243 | 1 |
| Tune request | F6 | 246 | 0 |
| End of exclusive (EOX) | F7 | 247 | 0 |
| System real-time | |||
| Timing clock | F8 | 248 | 0 |
| Start | FA | 250 | 0 |
| Continue | FB | 251 | 0 |
| Stop | FC | 252 | 0 |
| Active sense | FE | 254 | 0 |
| System reset | FF | 255 | 0 |
Undefined or unimplemented status bytes should be ignored along with their subsequent data bytes.