MIDI - Section 3, MIDI Message Structure and Channel Messages
Return to MIDI Introduction and
Contents
Return to Studio Technology home
page
All MIDI messages start with a 'header' byte. All header bytes have the top, or MSB (Most Significant Bit) set to 1. In multiple byte MIDI messages all subsequent bytes have the MSB set to 0. The other three bits in the top 'nibble' determine whether the MIDI message is either a CHANNEL message or a SYSTEM message, as illustrated here:
The key distinction between these two classes of MIDI message, is that
(as their names imply) SYSTEM messages are intended for all devices connected
to the MIDI interface, whereas CHANNEL messages are intended only for a
single MIDI 'channel' and should be ignored by all other channels. For
CHANNEL messages, the intended channel number is always supplied as the
lower nibble (4 bits) in the channel message header byte; it follows therefore
that there are sixteen possible MIDI channels. Before looking any further
into MIDI messages it is important to understand the role of MIDI channels,
as described in the next section.
The lower nibble (4 bits) of the channel header message byte always specify the MIDI channel, which is the intended recipient of any given MIDI channel message, as illustrated below.
Here, 'M' denotes the three bits which determine the exact type of channel message, and the 'C' bits specify the MIDI channel. By convention, MIDI channels are always numbered from 1 to 16, but are coded as the values 0 (binary 0000) to 15 (binary 1111) respectively, in the channel message header byte. MIDI channels allow a single MIDI controller (ie a keyboard or more generally a sequencer) to control multiple MIDI instruments (ie synthesisers) within a MIDI setup. By assigning each instrument to receive on a different MIDI channel we can arrange that a sequencer can send different MIDI 'note on' messages to each instrument, thus creating an ensemble. Without MIDI channels, all instruments connected in a MIDI chain would sound all notes.
In the early days of MIDI each instrument was generally mono-timbral,
that is it would only play one kind of 'instrument' at a time, and would
only require one MIDI channel. Nowadays most synthesisers are multi-timbral,
which means that they are capable of synthesising a number of different
'instruments' simultaneously (and of allowing each to be played
polyphonically). It follows that in a multi-timbral synthesiser each instrument,
or 'part' would need to be assigned to its own MIDI channel. It is easy
to see, therefore, that even in a modest MIDI setup we can quickly use
up all sixteen MIDI channels. In fact, devising ways of overcoming the
limitation of sixteen MIDI channels is a frequent challenge to today's
stage or studio synthesist.
There are seven MIDI channel messages, all carrying the channel number of the intended recipient of the message in the lower nibble (4 bits) of the channel message header byte. The complete set of channel messages is listed below:
Note Off............ 1 0 0 0 C C C C .... 80 .... 2
Note On............. 1 0 0 1 C C C C .... 90 .... 2
Poly Key Pressure... 1 0 1 0 C C C C .... A0 .... 2
Control Change...... 1 0 1 1 C C C C .... B0 .... 2
Program Change...... 1 1 0 0 C C C C .... C0 .... 1
Overall Key Pressure 1 1 0 1 C C C C .... D0 .... 1
Pitch Wheel......... 1 1 1 0 C C C C .... E0 .... 2
3.2.1 Channel Messages: Note On and Note Off
The three bytes of the MIDI Note On message have the following structure:
Byte 1: Message byte..... 1 0 0 1 C C C C
Byte 2: Note value....... 0 N N N N N N N
Byte 3: Note velocity.... 0 V V V V V V V
Byte 1: Message byte..... 1 0 0 0 C C C C
Byte 2: Note value....... 0 N N N N N N N
Byte 3: Note velocity.... 0 V V V V V V V
The term 'velocity' refers to the speed at which a key is pressed, and determines the loudness of the note which will be played, again on a scale of values from 0 to 127 (decimal). It is up to the instrument receiving the message to interpret the velocity value and use this to control the note being synthesised. With some timbres (such as an organ) the loudness remains more or less constant for the duration of the note, and the 'velocity' value will determine this level. With other timbres (piano, for example) the note has attack, sustain and decay phases, and the instrument may use the velocity value to determine the maximum loudness of the attack part of the note, or it may even use the velocity value to vary the attack time (to emulate the acoustic instrument).
The Note On message instructs the instrument to start the note, and the instrument then relies on receiving a matching Note Off message to tell it when to stop the note. Clearly, the Note Off message must have the same note value (in byte 2) as the earlier corresponding Note On message, otherwise the receiving instrument will not know which note is to be stopped. The MIDI specification also requires the same velocity value (in byte 3) of the Note Off message, as the earlier Note On, although most instruments are perfectly happy if this value is set to 0 in the Note Off message. In fact, some instruments will interpret a Note On message with a velocity value equal to 0, as a Note Off command, although this is technically not in accord with the MIDI specification.
It should be clear, at this stage, that all notes in a MIDI system require a matching pair of MIDI messages: Note On and Note Off. If you are playing a keyboard with a MIDI output then you would, for instance, expect a Note On message to be sent when a key is pressed, and the matching Note Off when the same key is released. As one might expect the vast majority of messages in a conventional MIDI based synthesis system are Note On and Note Off messages, and it is easy to see that the maximum note capacity of a single MIDI connection is, at 6 bytes per note, about 5000 notes per second. One of the most common problems in a heavily loaded MIDI system is the 'hanging note', which occurs when a Note On message has been received and acted upon correctly, but the corresponding Note Off message has been lost, missed or corrupted; the unmistakeable effect is the note that continues to sound long after everything else has stopped!
3.2.2 MIDI Messages: Polyphonic Key Pressure (aftertouch)
This is a three byte message with the following structure:
Byte 1: Message byte..... 1 0 1 0 C C C C
Byte 2: Note value....... 0 N N N N N N N
Byte 3: Note pressure.... 0 P P P P P P P
3.2.3 MIDI Messages: Control Change
This is a three byte message with the following structure:
Byte 1: Message byte..... 1 0 1 1 C C C C
Byte 2: Control Number... 0 N N N N N N N
Byte 3: Control Value.... 0 V V V V V V V
| Controller Number N (hex) | Function |
| 00 | Bank Select |
| 01 | Modulation Wheel |
| 02 | Breath Controller |
| 07 | Main Volume |
| 08 | Balance |
| 0A | Pan |
| 40 | Sustain Pedal |
| 43 | Soft Pedal |
| 60 | Data increment |
| 61 | Data decrement |
| 62 | NRPC V = LSbyte |
| 63 | NRPC V = MSbyte |
| 64 | RPC V = LSbyte |
| 65 | RPC V = MSbyte |
| 7B | All Notes Off |
| RPC Number (hex) | Parameter |
| 00 00 | Pitch Bend Sensitivity |
| 00 01 | Fine Tuning |
| 00 02 | Coarse Tuning |
3.2.4 MIDI Messages: Program Change
This is a two byte message with the following structure:
Byte 1: Message byte..... 1 1 0 0 C C C C
Byte 2: Program Number... 0 N N N N N N N
The Program Change message clearly allows up to 128 different programs, or patches, coded as values 0..127 (decimal) in the lower seven bits of the second byte.
3.2.5 MIDI Messages: Overall Key Pressure
This is a two byte message with the following structure:
Byte 1: Message byte..... 1 1 0 1 C C C C
Byte 2: Key pressure..... 0 P P P P P P P
3.2.6 MIDI Messages: Pitch Wheel (Pitch Bend)
This is a three byte message with the following structure:
Byte 1: Message byte..... 1 1 1 0 C C C C
Byte 2: Pitch (lower).... 0 L L L L L L L
Byte 3: Pitch (higher)... 0 H H H H H H H
Note that the amount by which the pitch is varied by this function is
not fixed, but can - for most synthesizers - be set using a 'Set Pitch
Bend Range' function, often implemented as one of the Registered Parameter
Number (RPN) Control Change functions.
There are 3 basic groups of MIDI System Messages: the System Exclusive
(SysEx) messages, the System Common messages, and the System
Realtime messages. These are listed, together with their status
byte values and any parameters, in the table below.
| Message | Status (hex) | Data 1 | Data 2 |
| System Exclusive | |||
| System Exclusive Start | F0 | Manufacturer's ID | Data, (data), (data), etc |
| End of SysEx | F7 | - | - |
| System Common | |||
| Quarter Frame | F1 | Data | - |
| Song Pointer | F2 | LSbyte | MSbyte |
| Song Select | F3 | - | - |
| Tune Request | F6 | - | - |
| System Realtime | |||
| Timing Clock | F8 | - | - |
| Start | FA | - | - |
| Continue | FB | - | - |
| Stop | FC | - | - |
| Active Sensing | FE | - | - |
| Reset | FF | - | - |