Please consider a donation to the Higher Intellect project. See or the Donate to Higher Intellect page for more info.

David's MIDI Spec

From Higher Intellect Vintage Wiki
Jump to navigation Jump to search

The official MIDI Spec is tricky and hard to read. I have distilled it here for your reading pleasure. -- David Van Brink

The MIDI Specification

Serial Protocol
31250 (± 1%) baud asynchronous, with 1 start bit, 8 data bits, and one stop bit. Thus, each data byte takes 10 serial bits, and is sent in 320 microseconds. The connection is a 1.5 mA current loop, and the receiver is opto-isolated, and requires less than 5mA to turn on. Logical 0 is current "on." Rise and fall times must be less than 2 microseconds.

The MIDI Bus
The MIDI bus is designed to address 16 channels. More than this would seriously tax the bandwidth of the bus at 31.25 kbaud. Each device on the bus may receive on one or more channels. Sometimes, multiple devices may receive on the same channel, with various desired or undesired side-effects. The channels are numbered 1 to 16, and, at the low command level, are addressed as 0 to 15.

The MIDI bus operates in a one-way fashion; generally a computer and MIDI setup looks like this.


Each wire is one-way. The computer, therefore, receives no information from the two sound modules.

Message Formats
Messages consist of a byte stream. Bytes with the high-bit set establish some kind of mode and are called "status bytes." Bytes with the high-bit clear are data bytes within the most recently established mode. Using the same status byte for multiple data messages is referred to as "running status." Some status bytes are directed to a particular channel. In the chart below, the letter 'c' is used to represent a channel nibble in a status byte.


Note On, Note Off
The pitch is in the range 0 to 127, where Middle C is pitch number 60. Values outside the range of the instrument, or the particular sound, are octave-shifted into range. The "velocity" is how quickly, or hard, the key was struck. A velocity of zero in a note-on event is a note-off event. A velocity of 64 is "average," and a keyboard that cannot sense velocity should report a velocity of 64 for each keypress.

Key Pressure, Channel Pressure
Some keyboards can detect a change in pressure on each key, while they are held by the player; these keyboards can report "key pressure" over MIDI. Some keyboards may sense the overall pressure on the device, such as with a weight sensor beneath the entire keyboard. These devices can report "channel pressure."

Controller Change
Various sliders, buttons, and knobs on MIDI keyboards are referred to as "controllers." On sound modules, some of the attributes which can be changed in real-time are called "controllers." Controllers are numbered from 0 to 121, and some of them have defined purposes. The values 122-127 are reserved in the controller-change message for special mode messages.


Note that "MSB" and "LSB" refer to 7-bit values.

Program Change
A sound module may switch easily between as many as 128 different programmed sounds, numbered 0 to 127.

Many synthesizers support more than 128 programmed sounds by means of a "bank select" command. Older synths have typically used a device-specific system exclusive (see below) command. Newer synths use controllers 0 and 32 to select a bank. Unfortunately, there is no standard for whether it is, in fact, controller 0 or 32, or both, and if both, must be sent first.

Pitch Bend
The pitch bend wheel is also a continuous controller on many MIDI keyboards. Possibly, the Pitch Bend message is in its own category because it is something likely to be done frequently. The two bytes of the pitch bend message form a 14 bit number, 0 to 16383. The value 8192 (sent, LSB first, as 0x00 0x40), is centered, or "no pitch bend." The value 0 (0x00 0x00) means, "bend as low as possible," and, similarly, 16383 (0x7F 0x7F) is to "bend as high as possible." The exact range of the pitch bend is specific to the synthesizer.

System Exclusive, End of SysEx
A System Exclusive message, or "SysEx," is a message that is vendor, or synthesizer, specific. The first one or three data bytes of the sysex specifies the vendor. (Originally, it was only one byte, but now the value "0" is used as an escapement to reach the next two.) The sysex type message may legally occur at any time, including in the middle of other kinds of messages.

A sysex message may look like this: 0xF0 vendorID data ... 0xF7. Many vendors have their own format for what follows the vendor ID, specifying synthesizer number, or message length, and so on.

Song Position, Song Select
The Song Position message tells all MIDI sequencers on the MIDI bus where to start playing when a Start Song message is received. This time is specified in "Timing Ticks." The Song Select message specifies which song number to play at that time.

Unofficial Bus Select
Some vendors have produced boxes with a single MIDI input, and multiple MIDI outputs. The Bus Select message specifies which of the outputs further data should be sent to. This is not an official message; the vendors in question should have used a SysEx command.

Tune Request
Possibly obsolete in the age of digital synthesizers... supposed to tell the synthesizer to retune its oscillators.

Timing Tick
Tells all sequencers on the MIDI bus to advance by a single "tick."

Start Song, Continue Song, Stop Song
Tells all sequencers on the MIDI bus to start, continue, or stop playing.

Active Sensing
If a MIDI device receives an Active Sensing message, then it should enter "active sensing mode." In that mode, if no messages are received for 300 milliseconds, then it should silence all sound output. The Active Sensing byte itself is a valid message to inhibit this silencing. This helps make sure that a "hung" MIDI system automatically silences itself.

System Reset
This message commands a device to return to its initial, powerup state.


A Simple MIDI Stream
The following hexadecimal bytes are a simple, typical stream of MIDI data. Each message must be sent at the real-time that the synthesizer is supposed to perform the action. Sophisticated sequencers will send the message slightly ahead of time to account for the duration of the message -- one third of a millisecond per byte -- and the response time of the particular synthesizer -- perhaps several milliseconds. The perceptual improvement of accuracy under 5 or 10 milliseconds, to the untrained listener, is questionable.

90 3C 40
Play middle C (note number 60, hexadecimal 3C) on channel 1 (the zero nibble of 90), at half the full velocity (velocity 64, hexadecimal 40).

43 40
Play note G above middle C (note number 67, hexadecimal 43) at velocity 64. Note that the status byte of 90 from the first message is still in effect, and did not have to be resent.

B9 07 33
Change the volume of MIDI channel 10 to 51 (hexadecimal 33). The MIDI volume controller number is 7.

B3 07 10
Change the volume of MIDI channel 8 to 16 (hexadecimal 10). Since the channel number is different than the previous message, running status could not be used.

90 3C 00
Stop playing middle C on channel 1. The last byte of zero indicates a "key down velocity of 0" which indicates a "note-off" event.

80 43 64
Stop playing the G above middle C (key number 67, hexadecimal 43). The key is released with a velocity of 64. Since very few, if any, synthesizers implement an interpretation of the note-off volume, this message is generally equivalent to 90 43 00.

April 1994 - 11:16.AM