Introductory Guide to MIDI

Contents

What is MIDI ?

MIDI is an acronym for Musical Instrument Digital Interface. It is both a hardware and software specification.

It allows electronic musical instruments (synthesizers, samplers, drum machines, etc) and MIDI-capable computers to be connected to one another, and for musical performance related data to be communicated between them.

The hardware aspect of the specification defines a serial type of interface, similar to RS232, though with a fixed data transfer rate of 31250 baud (which equates to approximately 3000 bytes/sec), and using 5-pin DIN connectors, and lacking the handshaking control signals of RS232. Separate connectors are needed for input and output signal paths. These are the MIDI IN and MIDI OUT ports.

It is important to use the correct type of leads for MIDI connections, i.e. only those designated as 'MIDI cables'.
The DIN - DIN type of leads intended for connecting audio signals are NOT suitable.

There may optionally also be a MIDI THRU port, which provides a copy of data arriving at the IN port. It is intended to be used to chain devices in series. However, delays to the signal incurred at each IN-THRU stage puts a limit to the number of devices that can be connected in this way, beyond which the cumulative effect of these delays becomes noticeable.

Another aspect of the hardware specification is the use of opto-isolators at the input and output stages, to help prevent the generation of earth loops (which can cause undesirable hum). A further aid to reduce the likelihood of earth loops is the requirement that pin 2 (Earth) of any MIDI IN sockets is not connected to the chassis; only pin 2 of MIDI OUT sockets is connected to the chassis.

The software aspect of the specification is essentially the language of the data, in that it specifies the structure and interpretation of the data. It enables a wide range of musical information to be conveyed via MIDI.

MIDI data is not a type of encoded sound, as with samples. Instead it is a series of commands or instructions which represent musical performance-related events. E.g. 'select voice number 5', 'start playing note C4', 'bend the pitch', 'change the volume level', 'stop playing note C4', etc.

Quick History

MIDI originated in the mid-1980s, and has since proved to be a fairly effective solution to the problem of that time of connecting synthesizers together.

In the pre-MIDI days, virtually every manufacturer had their own way of interfacing various devices (from within their own product range, of course), and as most of these methods were analogue, things got very messy when you considered polyphonic devices (which at the time were few in number and expensive).

With the advent of cheap digital electronics, a system such as MIDI was made possible. And because the facilities it provides are defined in software, the system is extendable. So, 20+ years on from its inception, MIDI is still with us, though in that time it has grown to include many new features — MIDI Time code, General MIDI, MIDI Machine Control, and Down-Loadable Sounds, to name a few.

Basic MIDI

MIDI data is a serial stream of bytes representing MIDI commands. A MIDI command comprises a status byte followed by a variable number of data bytes (possibly none).

Status bytes are identified due to their top bit being set. Consequently data bytes contain 7-bit values (0-127).

Summary of Status Bytes

Status byte Number of
data bytes
Description
Hex Binary
Channel Voice Messages
8n 1000nnnn 2 Note Off
9n 1001nnnn 2 Note On   (a velocity of zero = Note Off)
An 1010nnnn 2 Polyphonic Key Pressure (Aftertouch)
Bn 1011nnnn 2 Controller.   First data byte = 0-119
Cn 1100nnnn 1 Program Change   (i.e. instrument/voice selection)
Dn 1101nnnn 1 Channel Pressure (Aftertouch)
En 1110nnnn 2 Pitch Bend
Channel Mode Messages
Bn 1011nnnn 2 Select Channel Mode.   First data byte = 120-127
System Messages
F0 11110000 <variable> System Exclusive
F1-F7 11110xxx 0 to 2 System Common   (xxx = 1-7)
F8-FF 11111xxx 0 System Real Time   (xxx = 0-7)
Notes :
nnnn0-15 = MIDI channel 1-16.

MIDI provides control over a 10 octave (+) range of pitches – refer to this ready reckoner table of MIDI note numbers for the complete mapping.

Computer Control

Once synthesizers could talk to each other digitally via MIDI, it wasn't long before some bright spark realised that a computer could be used to record a stream of MIDI data along a timebase, in much the same way that a tape recorder can record sound. And just as it is possible to record multiple parallel tracks on a suitably capable tape recorder, so too with computer software. And so the MIDI sequencer was born.

A sequencer enables a multi-part performance to be recorded and played back, building it up track by track. Even a basic sequencer will provide 16 independent tracks, with top of the range sequencers providing an unlimited number of tracks (within the limits of available computer memory).

A sequencer has a number of advantages over a tape recorder :

Apart from the sequencer, other computer based MIDI applications include : synthesizer voice editors and librarians; sample editors (for use with samplers or wavetable based synthesizers); and numerous compositional aids. Also, MIDI Time Code messages can be used to synchronise a sequencer with various hardware devices (e.g. tape recorders) and/or Hard Disc Recorder software.

Current top of the line sequencers — e.g. Logic (Mac), Cubase (Mac/PC), Sonar (PC) and Pro Tools (Mac/PC) — have matured to a point where they are each a complete music production environment, incorporating audio tracks alongside any MIDI tracks.

MIDI Files

The MIDI Standard Files specification defines a distribution format, used to provide a common format for sequencer type data.

It differs slightly from the standard MIDI protocol in that individual events are, by necessity, time-stamped.

The use of MIDI files has become widespread, and there are many sources of such files on the internet.

General MIDI (GM)

With the advent of MIDI files, it soon became apparent that a way of standardising voice assignments was necessary, i.e. the mapping of particular instrument voices to Program Change numbers.

A MIDI file doesn't contain any information about instrumentation, i.e. which instrument sounds correspond to particular Program Change numbers (although there may possibly be some embedded textual comments advising of the intended voice assignments). Consequently, playing a MIDI file on a system other than the one it was composed on, would most likely sound completely different, due to the different voice mapping.

Enter General MIDI ...

To qualify for the label GM, a device must have the following minimum specification :

By providing this minimum specification along with its standardised set of melodic and drum sounds, the use of GM goes some way to ensuring that a composition is heard as it was intended to be heard.

GS and XG

Some manufacturers consider the GM standard to be too limiting, and have taken it upon themselves to provide enhanced GM synthesizer modules. First Roland with their GS standard, and then Yamaha with their XG standard.

GS and XG are both supersets of the GM standard, i.e. they have all the features of GM, though provide additional sound banks which are accessed using Bank Select messages.

The voices in the extra banks align with those in the standard GM bank, thus providing variants on the standard voices. This means that a MIDI file composed for use with a GS or XG device will sound okay when played using a standard GM device (because a GM device will ignore any Bank Select messages and just respond to the Program Change messages).

And obviously, as they both provide supersets of GM, either type of device will sound okay when playing MIDI files composed for use with a GM device.

Compatibility both ways, admirably following the spirit of General MIDI.

Down-Loadable Sounds (DLS)

This is one of the more recent additions to the MIDI specification. It provides a scheme whereby sounds (in the form of instrument wavetables) can be downloaded into specific memory locations (corresponding to specific Program Change numbers) within a synthesizer or other sound generating device.

DLS Level 1 devices must support MIDI Program Change messages (and, optionally Bank Select messages) in the usual way, as the means of selecting the instrument to be played on each channel. They need only provide a single bank for downloadable melodic instruments, and when in DLS mode, they may virtualise (i.e. map) incoming Bank Select messages so that they point to the device's actual DLS bank.

Although GM (and hence GS and XG) go some way towards standardising voice allocations, they do not precisely define a sound. The use of DLS ensures (by incorporating voice definitions within a MIDI file) that a composition is played back exactly as the composer intended.

MIDI Specifications

The full MIDI specification is available from the MIDI Manufacturers Association (MMA) and covers the following :

The MMA is the source for all the latest additions to the standard.

The first and last of that list (i.e. basic MIDI and MTC) are covered in my MIDI Software Specification document. There's also a document covering MIDI files, and another listing the General MIDI voice map.