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 off8n128+n2
Note on9n144+n2
Polyphonic key pressureAn160+n2
Control/Mode changeBn176+n2
Program changeCn192+n1
Monophonic channel pressureDn208+n1
Pitch bend changeEn224+n2

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 statusF0240variable
System common
MIDI Time Code (MTC)F12411
Song position pointerF22422
Song selectF32431
Tune requestF62460
End of exclusive (EOX)F72470
System real-time
Timing clockF82480
StartFA2500
ContinueFB2510
StopFC2520
Active senseFE2540
System resetFF2550

Undefined or unimplemented status bytes should be ignored along with their subsequent data bytes.