MIDI Specifications

MIDI 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 most significant bit (MSB) set to differentiate them from data bytes, so status bytes range in value from 128 (0x80) to 255 (0xFF), while data bytes range from 0 to 127 ($7F).

MIDI Channel messages

Channel messages contain their channel number in the lower four bits of the status byte. The value 0 correspond to the channel 1. Value 15 (0x0f) is channel 16.

Message Hex Decimal Data bytes count
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 can have running status. That is, if the next channel status byte is the same as the last, it may be omitted. The receiver assumes that the accompanying data is of the same status as was last sent. Receipt of any other status byte except real-time terminates running status.

Running status is especially convenient for sending strings of note-on and note-off messages, when using “note on with velocity of 0” for note off, and for output of continuous controllers.

MIDI System messages

System messages are not encoded with channel numbers. There are three types of system messages: common, real-time, and exclusive.

Notes:

  • Real-time messages may be interspersed in the MIDI data stream, even within a multibyte message, without affecting the current status
  • System exclusive (or sysex) messages are used to transfer information that may be specific to a given MIDI device. System exclusive messages begin with the system exclusive status byte (240, or $F0), followed by a manufacturer’s ID code. As not to get stuck reading an endless system exclusive message if the EOX is missing, the MIDI specification states that any status byte (other than real-time) acts to terminate a system exclusive message.
Message Hex Decimal Data bytes count
data 00-7F 0-127 na
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
(Undefined) F4 244 0
Cable select* F5 245 1
Tune request F6 246 0
End of exclusive (EOX) F7 247 0
System real-time:
Timing clock F8 248 0
(Undefined) F9 249 0
Start FA 250 0
Continue FB 251 0
Stop FC 252 0
(Undefined) FD 253 0
Active sense FE 254 0
System reset FF 255 0

Undefined and unimplemented status

Undefined status bytes are reserved and should not be used. Any undefined or unimplemented status bytes received should be ignored. Any subsequent data bytes should be ignored until the next legal status byte is received.