Chapter Three: MIDI

4. MIDI Data Format: Channel Voice Messages

Almost all MIDI devices are equipped to receive MIDI messages on one or more of 16 selectable MIDI channel numbers. A device's particular voice (or patch, program, timbre) will respond to messages sent on the channel it is tuned to and ignore all other channel messages, analogous to a television set receiving only the station it is tuned to and rejecting the others. The exception to this is OMNI mode. An instrument set to receive in OMNI mode will accept and respond to all channel messages, regardless of the channel number.

The most common MIDI messages are channel voice messages listed in the chart below. They convey information about whether to turn a note on or off, what patch to change to, how much key pressure to exert (called aftertouch), etc.

The table below presents a summary of the MIDI Channel Voice Message codes in binary form.
A MIDI channel voice message consists of a status byte followed by one or two data bytes.
To read the chart, note that each letter (n,k,v,p,c,f) holds the place of a bit whose purpose is described in the Legend column.
Click here for a chart of pitch-to-MIDI note #'s.
Click here for a list of currently assigned MIDI controller numbers.
Status Byte Data Byte 1 Data Byte 2 Message Legend
1000nnnn 0kkkkkkk 0vvvvvvv Note Off n=channel* k=key # 0-127 (60=middle C) v=velocity (0-127)
1001nnnn 0kkkkkkk 0vvvvvvv Note On n=channel k=key # 0-127(60=middle C) v=velocity (0-127)
1010nnnn 0kkkkkkk 0ppppppp Poly Key Pressure n=channel k=key # 0-127(60=middle C) p=pressure (0-127)
1011nnnn 0ccccccc 0vvvvvvv Controller Change n=channel c=controller v=controller value(0-127)
1100nnnn 0ppppppp [none] Program Change n=channel p=preset number (0-127)
1101nnnn 0ppppppp [none] Channel Pressure n=channel p=pressure (0-127)
1110nnnn 0fffffff 0ccccccc Pitch Bend n=channel c=coarse f=fine (c+f = 14-bit resolution)
*0000 = MIDI channel 1, 1111 = MIDI channel 16
child plahing keyboard
Play a Loud Middle C!

A sample message for turning on a note (middle C) on MIDI channel 5 very loudly (with a velocity or force of 127, the maximum) is shown below in binary and decimal.

  Status Byte Data Byte 1 Data Byte 2
Binary 10010100 00111100 01111111
Decimal 148 60 127

The left-most four bits ( MSN ) of the status byte (1001) tell a MIDI device that the following message is a note-on command, while the right-most four bits ( LSN ) tell it what MIDI channel the message is meant for.

The channel numbers of the status byte (its last 4 bits) are offset one value higher, since Channel 1 is set by decimal 0 [binary 0000] and Channel 16 is set by decimal 15 [binary 1111].

The first data byte indicates what note to play (decimal 60 = binary 00111100 = middle C), while the second data byte indicates how loud to play the note (via key velocity). In this case the maximum velocity of 127 (binary 01111111) is sent. The note will sound until a message to turn off the same note number is received, since MIDI note messages do not include rhythmic durations.

Simultaneous events in MIDI must be sent as a string of serial commands. A 3-note chord, for example, will be transmitted as three separate note #-velocity pairs. Because of the 31.25 Kbaud transmission speed, this is normally perceived as a simultaneity. However, as polyphonic instruments (those capable of playing more than one note simultaneously) have increased their number of voices and more MIDI set-ups have networks of ever-increasing numbers of instruments and tone modules, the speed of both the interface's processor and sheer volume of serial data make large simultaneous events susceptible to glitches, undesired arpeggiations, and data errors.

To make more efficient use of the limited bandwidth, MIDI manufacturers adopted a shortcut called running status. Running status allows a single status byte's action to remain in effect for an unlimited number of data byte pairs which follow. For example, to play three 'simultaneous' notes on the same MIDI channel, a Note On status byte can be sent, followed by six data bytes representing three key#-velocity pairs. The code stream below would play a C-major chord:

Status Byte Key 1 (C) Velocity 1 Key 2 (E) Velocity 2 Key 3 (G) Velocity 3
10010100 00111100 01111111 01000000 01111111 01000011 01111111
148 (note on ch. 5) 60 127 64 127 67 127

To help minimize excessive data by using running status, the note on status can also function to turn notes off by sending a velocity value of zero for an already sounding key # at the appropriate time. This uses only the note on status that is still in effect from having turned notes on and eliminates the need to send separate note off statuses, thereby saving a great deal of data. So, a chord turned on and then off would look like:

status byte key1   vel 1 key2   vel 2 key3   vel 3 key1   vel 0 key2   vel 0 key3   vel 0
10010100 00111100   01111111
01000000   01111111 01000011   01111111 00111100   00000000 01000000   00000000 01000011   00000000
note on—ch 5 key 1 on key 2 on key 3 on key 1 off key 2 off key 3 off

Key Velocity: Many instruments transmit and respond to key velocity, the speed at which a key is depressed. Some even respond to the speed at which a key is released, which is why the status byte note off has a velocity data byte. How an instrument responds to key velocity depends on how it has been programmed. Most simply, velocity allows the note's dynamic to be controlled. Often, a particular patch may become too loud, usually in a higher range, so many instrument allow for velocity scaling across the keyboard. Some instruments or patches have the capability to alter timbre or spatial location through velocity. Very commonly now, sampling instruments often have the capacity to crossfade or switch between two or more different sounds, based upon the speed of a keystroke. For example, a piano patch may switch between three samples for each note, one recorded softly, one recorded medium, and one recorded loud, since a real piano's timbre changes with velocity.

Pitch Bend: Almost all channel voice messages assign a single data byte, which begins with a 0, to a single parameter such as key # or velocity. As mentioned earlier, these have 128 values (0-127). With seven usable bits, this is computed as 27 = 128 values). One exception is pitch bend, which uses two data bytes to create a single 14-bit value by combining the least significant 7 bits from each data byte. If pitch bend used only 128 values, discreet steps might be heard if the bend range were large (this range is set on the instrument, not by MIDI). So the last seven bits of the first data byte (called the least significant byte or LSB) are combined with the last seven bits from the second data byte (called the most significant byte or MSB) in reverse order to create a 14-bit data value, giving pitch bend data a range of 16,384 values, which equals 214.

Fine Byte Coarse Byte 14-bit Result
Binary 00111101 01011011 10110110111101
Decimal 61 91 11709

Key pressure (poly or channel): Key pressure, which is frequently referred to as aftertouch, can be generated on a MIDI keyboard by pressing the key or keys deeper into the keybed, where a rubber bumper provides resistance. The deeper into the bumper, the higher the pressure data value generated. The same data can also be added after the fact in a MIDI editor. Key pressure has been used to crossfade timbre, control vibrato or tremolo depth, sweep a filter, and control any other parameter of a patch that accepts aftertouch as a pre-programmed controlling value. Notice in the channel voice message chart above there is both polyphonic pressure and channel (mono) pressure. Polyphonic pressure will send the pressure each individual pressed key; therefore it has both a key # and a pressure value data byte. Channel (mono) pressure takes only the highest pressure of all currently depressed keys, and therefore it has only one data byte for pressure, but no key # data byte.

Program Change: Another name for generating a patch change. Patches (or sample sets) can be changed independently by MIDI channel. It is common for MIDI sequencers to have several tracks set to output to the same MIDI channel, therefore a patch change sent on one of these tracks will change the patch for all of them. As instruments evolved, the need to switch between more than 127 programs or patches arose. Therefore most modern instruments will respond to a bank change, generated by controller #32 first, and then the Program Change within that bank. Very often, MIDI program #'s are off by one, since many instruments begin with Program #1, but of course, the MIDI data byte starts at #0. There are methods to fix that in most sequencing programs or instruments.

Controller Change is examined in detail in the next section.