HOME

CONTENTS

Basics
MIDI Electronic's
Hardware
Protocol
MIDI Instruments
Sequencers
MIDI Files
MIDI Recording Studio
Midi Effects
Micro-Tonal Midi Synthesizer
Bi-sonic Music with Midi
MMA
IMA

Midi Protocol

Now come the turn to explain the protocol part of the MIDI interface. Although the hardware is just a current loop, there are data that has to be handled through this loop. Basically the current loop is an active-low digital one: when the current is on (active) that means a logical (digital) 0 (low) in MIDI; current off means a logical 1.

As it's been said before the MIDI stream is composed by one start bit, eight data bits and two stop bits. For now forget about the start and stop bits and concentrate just in the eight data bits. These eight bits form a byte and several bytes grouped together form what is called a MIDI message. There are various message types and most of them are composed in two parts: The status part, which dictates the type of command the instrument must perform and the data part which conveys the particularities of the command.

The MIDI messages are in fact also divided in two kinds: Channel Messages and System Messages. System messages are divided in

a) System common,
b) System Real-Time and
c) System Exclusive messages. More on this later.

For example a MIDI message could be: “play an A above middle C, mezzoforte” here the status byte would be indicated by “play a note” and the data bytes would be “middle A, mezzoforte”.

You might think if it’s no too much for a byte just to say play a note. You know what? Your instinct is right. That is why this status byte carries a “channel” number.

The midi specification talks about 16 channels. A channel is just a form of organizing performance data. It’s like having 16 “virtual” wires on a single cable or 16 “tracks” at your disposal to organize your composition as your heart desires. The status byte in divided in two nibbles (four bits) to make room to these 16 channels. The high nibble (bits 7 to 4) indicates the command (play a note) and the low nibble (bits 3 to 0) says in which channel.

How do we know, you may ask, a certain byte in the stream is a status byte? Well, all the status bytes start with 1 in the MSB (Most Significant Bit or bit 7 in an eight-bit word, remember bit count start at 0).

The following table shows the summary of the status bytes

Summary of Status Bytes
Status
# of data bytes
Description
Channel Messages
1000nnnn (8x hex)
2
Note Off event
1001nnnn (9x hex)
2
Note On event (velocity =0 Note Off)
1010nnnn (Ax hex)
2
Polyphonic key pressure/aftertouch
1011nnnn (Bx hex)
2
Control change
1100nnnn (Cx hex)
1
Program change
1101nnnn (Dx hex)
1
Channel pressure/aftertouch
1110nnnn (Ex hex)
2
Pitch wheel change
Channel Mode Messages
1011nnnn (Bx hex)
2
Selects channel mode (see text)
System Messages
11110000 (F0 hex)
any
System Exclusive
11110sss (36x oct)
0 to 2
System Common
11111ttt (37x oct)
0
System Real Time


Channel Voice Messages

In musical systems, the message that most often comes down the bus is to play a note. And for this to happen two diferent status bytes are provided; the channel messages NOTE ON and NOTE OFF. Let's deal with NOTE ON messages first.

NOTE ON ($9n where n represents the channel number in binary starting at 0) requires two data bytes (as show in the table). The first byte says what note is to be played and the second byte specifies velocity (how hard the key was struck). Since data bytes must have its MSB set to 0, the maximum number is a 7 bit number and this is 127 (01111111) so there are 128 diferent numbers (remember we begin at 0). This way there will be a possibility to play 128 diferent notes and 128 diferent velocity steps. Now, a piano has only 88 keys, so that would be more than adequate, but since some of the more avant-garde music is written in micro-tonal tunnings, where the pitches between a piano's tones are also used (see Micro-Tonal Music Synthetizer), there are those that argue that 128 notes are not enough.

NOTE OFF (Status $8n) Also consist of two bytes, the note number and the "key release velocity". But typically this is seldom used as MIDI also allows to use NOTE ON status with velocity set to 0; and there is a good reason to do that way. The reason is called running status.

Running status is a way of saving bytes and bandwidth on a bus that is transmitting MIDI data. It consists on stripping off the status byte of the next message if the previous message that was transmitted was using the same status byte. So in a two note sequence, MIDI sends a NOTE ON status message, the note and velocity of the first note and the note an velocity of the second note without sending a NOTE ON for the second note. To quiet the note, instead of changing the status byte to a NOTE OFF message, MIDI is allowed to use the previous running status byte (NOTE ON) and just send the note number and a velocity of 0. As you can see this is a 33% increase in bandwidth since instead of sending 3 bytes MIDI is sending just two. This is particulary important to avoid "MIDI-Clogging" or too much information pushed through the wire which will cause audible delays between when a note sounds and when it is supposed to play.

POLYOHONIC AFTER-TOUCH (Status $An) Refers to how hard the key is being pressed rigth now. Pressing harder after the key has been depressed lets you do pitch bends, tremolos, etc. Several keyboards are aquipped with this feature. The first data byta is the key number an the second the amount of pressure.

CONTROL CHANGE (Status $Bn) Allows changes in a front panel slider or knob to be passed to other instruments. These changes are set digitally. The first data byte is the number of the control and the second is the control's new value.
Beware here is where MIDI takes an intersting approach to being able to send either low-resolution (7-bit) or high resolution (14-bit) control values.

Controls $00 - $1F are reserved for low-resolution values and are the most significant byte of the 14 bit value. Control $20 - $3F are reserved to represent the least-significant byte of a high resolution value and do not necessarily have to be sent. The most intersting part of this is that it represents a glitch in MIDI - you can't change the most-significant and least-significant byte of a high resolution control simultaneously, because they are in two different channel messages and neither one can "know" whether the other is coming or not. So what happens to the MSB when the LSB overflows from $7F to $00? The answer is that nothing happens to it until it's updated explicitly; and for a brief instant the whole 14-bit value is way out of whack.

Controls $40 - $5F are set aside as bank of switches, $60 - $79 are undefined and the last 6 controls $7A - $7F are set aside as channel mode messages.

PROGRAM CHANGE (Status $Cn) Allows an intrument to change voices or sounds like piano to flute. The single data byte says what voice (program) to change to. Modern synthesizers use a standard set of instruments refered as General Midi. These means that voice #01 for example will always be a piano regardless synthesizer's brand or model.

CHANNEL PRESSURE (Status $Dn) The same as Poly- Pressure ($An) but considering the pressure as a whole without taking into account the key. The data byte is the pressure value.

PITCH WHEEL (Status $En) Used to modulate pitch for expressive purposes. The first data byte is the least-significant byte of the value and the second is the most-significant byte. Some synthetizer use only a 7 bit resolution to cover 12 semitones of an octave. Since pitch wheels can modulate up and down, the center position is defined in the specification as $2000, but the range of the control is left to the manufacturer.

 

Channel Mode Message

The last six "controls" in the control-change group of channel-voice messages are set aside for specific functions. This functions are:

Status $7A Used to separate the synthetizer's keyboard from its tone generating section. A $00 in the second data byte disconnects the keyboard and a $7F reconnects it.

Status $7B Used to turn off all notes being played in the channel specified. Used mainly with sequencers to turn off a note that keeps playing when the sequencer is stopped (causing by a missing note off of the corresponding note on previously sent).

Status $7C Turns Omni mode off, which means that only voice messages on the system's basic channel (defined by the manufacturer) will be recognized. Second data byte is 0

Status $7D Turns Omni mode On, This way an instrument will respond to channel voice messages in all channels, but will respond to mode messages in only its basic channel, which is defined by the manufacturer.

Status $7E Selects Mono On. The synthesizer will respond to note-ons and note-offs as a monotonic instrument (one note at a time, ie: no chords). The second data byte tells the instrument to listen to a number of channels above the basic channel and $00 means to listen to all channels.

Status $7F Selects Poly On. Mono On and Poly On are mutually exclusive, (turning on one of them turns off the other) Poly mode allows many notes to be played at the same time. The second data byte is always $00.

 

System Message

There are three kinds of system messages: system common, system real-time and system exclusive. MIDI 1.0 treats system real-time and system common messages as separate things, but since real-time messages are also system common we will join them together .

MIDI has a variable speed clock that is in essence a metronome. The clock runs at 24 pulses per quarter note (abbreviated 24 ppq). In MIDI, the clock has a system real-time status byte assigned ($F8). Every time an instrument or sequencer reads a timing clock status byte, it avances in the musical score 1/24th of a quarter note and sends out any data previously recorded as happening at that time.

Besides keeping time, everything has to begin at the same time. MIDI has a status byte for that purpose: the start status byte ($FA) this status byte tells a sequencer or drum machine to start from the very beginning. If we want to stop this sequence we use the stop status byte ($FC) and to continue from the point we left we use the continue status byte ($FB). None of these status bytes have any data bytes associated with them and they can be mixed anywhere in a MIDI message (even between data bytes). Also they will not change the running status in effect at the time they are sent.

Many times we want to start from somewhere else but the very beginning thats why MIDI provides a way to address an arbitrary point in the song. This provision is called song position pointer ($F2) and, unlike most other system messages it has two data bytes which contain a value equals to the number of 1/16th notes we are into the song.

Another status byte seldom used but specified in MIDI 1.0 anyway is what is called active sensing ($FE). This is a way of telling if a MIDI instrument (keyboard, drum machine, etc.) is connected to another MIDI instrument. The instrument which want to know if another MIDI device is conected to it, must scan for this status byte. If a period of 300 ms. have elapsed and the status is not received it can be assumed that no device is connected.

SYSTEM EXCLUSIVE

MIDI has provisions for manufacturer's specific variable length messages and content. The system exclusive status ($F0), or sys-ex for short, unlike any other, does not have a fixed number of data bytes that must be sent with it.

The manufacturer uses this to send any kind of data they want. The MMA have a registered list of codes for every MIDI manufacturer in order to identify whom the sys-ex data belongs to and encourages to every manufacturer to make the format they use available in the public domain.

Since sys-ex messages may be any length, there must be some way to indicate the end of a message, and the end-of-exclusive byte (status $F7) serves that function.

 


Designed by: Alekx