A Guide To The MIDI Messaging Protocol in Two Pages: by Jeff Russ 2015
A Guide To The MIDI Messaging Protocol in Two Pages: by Jeff Russ 2015
Each midi message is 3 bytes long: 1 status byte followed by 2 data bytes.
The first bit of each byte is used to identify whether it's a status byte or a data byte.
All status bytes begin with 1 and all data byte begin with 0
There for in hex the status byte is 80 and up and the data byte is 7F and down
Status's:
For statuses 80 … EF, The second hex digit in the status message is the
channel number. The 16 MIDI channels map out to 0 through F.
example: 80 … 8F are all note off commands for each of the 16 MIDI channels.
The first hex digit specifies what kind of message it it. Statuses beginning with 8 through E
(7 possible values) are channel-specific messages. The first hex is the type of message and
the second hex is the channel. F0 … FF map to various global and sysex messages.
Status 80 … EF
8_ note off
9_ note on
A_ poly aftertouch
B_ control/mode change
C_ program change
D_ channel aftertouch
E_ pitch bend
Status F0 … FF
Since data bytes waste the first bit, making it 0, we have 128 possible values
Which is 7-bit:
The first 3 types of messages are polyphonic. The second byte (1st data byte) specifies the note.
Since the first bit is wasted, we have 7 bits which gives us 128 values and 128 different notes.
It's probably best not to use the group below for assigning controllers.
96 Data Button increment 97 Data Button decrement
98 Non-registered Parameter (LSB) 99 Non-registered Parameter (MSB)
100 Registered Parameter (LSB) 101 Registered Parameter (MSB)
Do not use these no matter what unless you want to invoke these functions
120 All Sound Off 121 All Controllers Off
122 Local Keyboard (on/off) You might actually crash your keyboard.
123 All Notes Off
None of these messages used the last byte aka the second data byte. Therefore they simply
Identify themselves as a Program Change message (C_) or Aftertouch (D_)
followed by the channel number in placed of _.
Pitch bend is unusual in that it uses both of the data bytes to get finer resolution. The first bits are
of course still wasted but that leaves us with 14 bits to work which is 16,384 possible
values instead of 128. If a pitch bend wheel were to span two octaves, one up and one down,
we would have 682 possible values per half step which is 7 per each cent. Not bad!
Here is a full message for the a middle C in channel 1 with a velocity of 60:
90 3C 3C
80 3C 3C
Note that our velocity is not zero as it typically is for a "note off message."
This is that way for the rarely used feature of MIDI called aftertouch.
This can cause hanging notes on systems that expect a velocity of 00 to
turn off a note. It's advised to always send note off message as 8_ __ 00
unless you are dealing with a target that supports aftertouch.