MIDI isn't a sound, it's a digital instruction to trigger sounds on external or software synths.

This guide to the MIDI standard will help you manipulate and understand those MIDI messages


MIDI Messages

A MIDI message is made up of an eight-bit status byte which is generally followed by one or two data bytes.

There are a number of different types of MIDI messages (categorised below) and this tutorial is split accordingly to each type.

At the highest level, MIDI messages are classified as being either:

(Click the links if you wish to dive straight to the info, else just read-on and absorb)

Channel messages apply only to a specific Channel, so the Channel number is also included in the status byte for these messages.

System messages are not Channel-specific, so no Channel number is indicated in their status bytes.

Channel Messages

Channel Messages may be further classified as being either:

Channel Voice Messages carry musical performance data, and so they make up most of the traffic in a typical MIDI data stream.

Channel Mode messages affect the way a receiving instrument will respond to the Channel Voice messages.

Channel Voice Messages

Channel Voice Messages are used to send musical performance information.

The messages in this category are:

  • Note On
  • Note Off
  • Polyphonic Key Pressure
  • Channel Pressure
  • Pitch Bend Change
  • Program Change
  • Control Change

Note On Note Off & Velocity

Activation and release of a particular note are considered as two separate events.

When a key is pressed on a MIDI keyboard, it sends a Note On message on the MIDI OUT port.

The keyboard may be set to transmit on any one of the sixteen MIDI channels, and the status byte for the Note On message will indicate the selected Channel number.

The Note On status byte is followed by two data bytes, which specify key number (indicating which key was pressed) and velocity (how hard the key was pressed).

The key number is used by the receiving synthesiser to select which note should be played, and the velocity is normally used to control the amplitude of the note.

Note Off

When the key is released, the keyboard, or MIDI-controller, will send a Note Off message.

The Note Off message also includes data bytes for the key number and for the velocity with which the key was released.

The Note Off velocity information is normally ignored.

Polyphonic Key Pressure

Some MIDI keyboard instruments have the ability to sense the amount of pressure which is being applied to the keys while they are depressed.

Aftertouch

This pressure information, commonly called "aftertouch", may be used to control some aspects of the sound produced by the synthesizer (vibrato, for example).

If the keyboard has a pressure sensor for each key, then the resulting "polyphonic aftertouch" information would be sent in the form of Polyphonic Key Pressure messages.

These messages include separate data bytes for key number and pressure amount. It's currently more common for keyboards to sense only a single pressure level for the entire keyboard.

Channel Pressure

This "Channel aftertouch" information is sent using the Channel Pressure message, which needs only one data byte to specify the pressure value.

Pitch Bend

The Pitch Bend Change message is normally sent from a keyboard instrument in response to changes in the pitch bend wheel.

The pitch bend information is used to modify the pitch of sounds being played on a given Channel.

The Pitch Bend message includes two data bytes to specify the pitch bend value. Two bytes are required to allow fine enough resolution to make pitch changes resulting from movement of the pitch bend wheel seem to occur in a continuous manner rather than in steps.

Program Change

The Program Change message is used to select the instrument which should be used to play sounds on a given Channel.

This message needs only one data byte which specifies the new program number.

Control Change

MIDI Control Change messages are used to control a wide variety of functions in a synthesizer.

Control Change messages, like other MIDI Channel messages, should only affect the Channel number indicated in the status byte.

The Control Change status byte is followed by one data byte indicating the "controller number", and a second byte which specifies the "control value".

The controller number identifies which function of the synthesizer is to be controlled by the message. A complete list of assigned controllers is found in the MIDI 1.0 Detailed Specification.

Bank Select

Controller number zero (with 32 as the LSB) is defined as the Bank Select.

The bank select function is used in some synthesisers in conjunction with the MIDI Program Change message to expand the number of different instrument sounds which may be specified (The Program Change message alone allows selection of one of 128 possible program numbers).

The additional sounds are selected by preceding the Program Change message with a Control Change message which specifies a new value for Controller 0 (zero) and Controller 32, allowing 16,384 banks of 128 sounds each...impressive eh!

Since there is no standard way for a Bank Select message to select a specific synthesiser bank. Manufacturers, such as Roland (with "GS") and Yamaha (with "XG") , have adopted their own practices to assure some standardisation within their own product lines.

RPN / NRPN

Controller No. 6 (Data Entry), in conjunction with:

  • Controller No. 96 (Data Increment)
  • 97 (Data Decrement)
  • 98 (Registered Parameter Number LSB)
  • 99 (Registered Parameter Number MSB)
  • 100 (Non-Registered Parameter Number LSB)
  • 101 (Non-Registered Parameter Number MSB)

...extend the number of controllers available via MIDI.

The Parameter data is transferred by first selecting the Parameter Number to be edited using controllers 98 and 99 or 100 and 101, and then adjusting the data value for that parameter using controller number 6, 96, or 97.

RPN and NRPN are typically used to send parameter data to a synth in order to edit sound patches - very useful for playing around with various drum sounds to get the right sounding kit.

Registered parameters (RPN) are those which have been assigned some particular function by the MIDI Manufacturers Association (MMA) and the Japan MIDI Standards Committee (JMSC). For example, there are Registered Parameter numbers assigned to control Pitch Bend Sensitivity and Master Tuning for a synthesizer.

Non-Registered parameters (NRPN) have not been assigned specific functions, and may be used for different functions by different manufacturers. Here again, Roland and Yamaha, among others, have adopted their own practices to assure some standardisation.

Channel Mode Messages

Channel Mode messages (controller numbers 121 through 127) affect the way a synthesiser responds to MIDI data.

  • Controller number 121 is used to reset all controllers.
  • Controller number 122 is used to enable or disable Local Control(In a MIDI synthesiser which has it's own keyboard, the functions of the keyboard controller and the synthesizer can be isolated by turning Local Control off).
  • Controller number 124 selects Omni Mode On
  • Controller number 125 selects Omni Mode Off
  • Controller number 126 selects Mono Mode
  • Controller number 127 selects Poly Mode

Omni Mode On

Omni Mode On enables the synth to respond to incoming MIDI data on all channels.

Omni Mode Off

Omni Mode Off means the synthesiser will only respond to MIDI messages on one Channel.

Poly Mode

Poly Mode enables incoming Note On messages to be played Polyphonically.

This means that when multiple Note On messages are received - as when playing a chord - each note is assigned its own voice (subject to the number of voices available in the synthesizer). The result is that multiple notes are played at the same time.

Mono Mode

Mono Mode assigns a single voice per MIDI Channel.

This means that only one note can be played on a given Channel at a given time.

Most modern MIDI synthesisers will default to Omni On Poly mode of operation. In this mode, the synthesizer will play note messages received on any MIDI Channel, and notes received on each Channel are played polyphonically.

In the Omni Off Poly mode of operation, the synthesizer will receive on a single Channel and play the notes received on this Channel polyphonically.

This mode could be useful when several synthesisers are daisy-chained using MIDI THRU. In this case each synth in the chain can be set to play one part (the MIDI data on one Channel), and ignore the information related to the other parts.

Note that a MIDI instrument has one MIDI Channel which is designated as its "Basic Channel". The Basic Channel assignment may be hard-wired, or it may be selectable.

Mode messages can only be received by an instrument on the Basic Channel.

System Messages

MIDI System Messages are classified as being:

  • System Common Messages - intended for all receivers in the system.
  • System Real Time Messages - used for synchronisation between clock-based MIDI components.
  • System Exclusive Messages - can include a Manufacturer's Identification (ID) code, and are used to transfer any number of data bytes in a format specified by the referenced manufacturer.

System Common Messages

These are the System Common Messages which are currently defined:

  • MTC Quarter Frame message - part of the MIDI Time Code information used for synchronization of MIDI equipment and other equipment
  • Song Select message - used with MIDI equipment, such as sequencers or drum machines, which can store and recall a number of different songs.
  • Song Position Pointer - used to set a sequencer to start playback of a song at some point other than at the beginning.
  • Tune Request
  • End Of Exclusive (EOX) message - used to flag the end of a System Exclusive message, which can include a variable number of data bytes.

System Real Time Messages

The MIDI System Real Time messages are used to synchronise all of the MIDI clock-based equipment within a system, such as sequencers and drum machines.

Most of the System Real Time messages are normally ignored by keyboard instruments and synthesisers.

To help ensure accurate timing, System Real Time messages are given priority over other messages, and these single-byte messages may occur anywhere in the data stream (a Real Time message may appear between the status byte and data byte of some other MIDI message).

The System Real Time messages are:

  • Timing Clock
  • Start
  • Continue
  • Stop
  • Active Sensing
  • System Reset message

Timing Clock

The Timing Clock message is the master clock which sets the tempo for playback of a sequence.

The Timing Clock message is sent 24 times per quarter note. The Start, Continue, and Stop messages are used to control playback of the sequence.

Active Sensing - "Stuck Notes"

The Active Sensing signal is used to help eliminate "stuck notes" which may occur if a MIDI cable is disconnected during playback of a MIDI sequence.

Without Active Sensing, if a cable is disconnected during playback, then some notes may be left playing indefinitely because they have been activated by a Note On message, but the corresponding Note Off message will never be received.

System Reset

The System Reset message, as the name implies, is used to reset and initialize any equipment which receives the message.

This message is generally not sent automatically by transmitting devices, and must be initiated manually by a user.

System Exclusive Messages

System Exclusive messages may be used to send data such as patch parameters or sample data between MIDI devices.

Manufacturers of MIDI equipment can define their own formats for System Exclusive data. Manufacturers are granted unique identification (ID) numbers by the MMA or the JMSC, and the manufacturer ID number is included as part of the System Exclusive message.

The manufacturers ID is followed by any number of data bytes, and the data transmission is terminated with the EOX message.

Running Status - A cure for latency?

Since MIDI data is transmitted serially, ie... one instruction after another, it's possible that musical events which originally occurred at the same time, eg... a chord, must be sent one at a time in the MIDI data stream and not actually be played at exactly the same time.

With a data transmission rate of 31.25 Kbit/s and 10 bits transmitted per byte of MIDI data, a 3-byte Note On or Note Off message takes about 1 ms to be sent.

This is generally short enough to be perceived as having occurred simultaneously.

In fact, for a person playing a MIDI instrument keyboard, the time skew between playback of notes when 10 keys are pressed simultaneously should not exceed 10 ms, this would not be perceptible.

However, MIDI data being sent from a sequencer can include a number of different parts....

On a given beat, there may be a large number of musical events which should occur simultaneously, and the delays introduced by serialisation of this information might be noticeable. To help reduce the amount of data transmitted in the MIDI data stream, a technique called "running status" may be employed.

Running status considers the fact that it's very common for a string of consecutive messages to be of the same message type.

For instance, when a chord is played on a keyboard, 10 successive Note On messages may be generated, followed by 10 Note Off messages. When running status is used, a status byte is sent for a message only when the message is not of the same type as the last message sent on the same Channel.

The status byte for subsequent messages of the same type may be omitted (only the data bytes are sent for these subsequent messages).

The effectiveness of running status can be enhanced by sending Note On messages with a velocity of zero in place of Note Off messages.

In this case, long strings of Note On messages will often occur.

Changes in some of the MIDI controllers or movement of the pitch bend wheel on a musical instrument can produce a staggering number of MIDI Channel voice messages, and running status can also help a great deal in these instances.


More information on what causes latency when making music with software synths.