MIDI (Musical Instrument Digital Interface)
MIDI is an acronym for an electronic digital interface, not that much unlike Ethernet or some other networking protocol and hardware interface, usually called an I/O interface or input/output interface. Like so many things that are simple in nature, are made confusing at first glance, because of the nomenclature that glues them together. In this case MIDI is an interface between musical instruments and computers that make it possible for these digital devices to communicate in musical terms. The original idea was to allow a keyboard to control a bunch of synthesizers. This way you could stack sounds and designate a portion of your keyboard to trigger bass sounds on one end, maybe middle section for horn sounds and an upper part of the keyboard for violins. Prior to MIDI, all the new synthesizers coming onto the market each had their own interfacing techniques and software drivers. In desperation a couple of guys wrote a specification that all manufacturers could use to build common interface hardware and a protocol to write software that allowed each manufacturer to be able to communicate with different manufacturer's equipment. Actually, it was created in 1983 and called the “MIDI 1.0 Detailed Specification” written by the International MIDI Association.
Because the specification was written simply and left room for future growth, the MIDI interface is one of the winners in the electronic world of digital interfaces.
Hardware – the physical interface
You don't have to be an electrical engineer to learn the basics of this interface. If you can wire a lamp or hookup a stereo, you can do this. The hardware to get a MIDI interface to work is a couple of wires running in a cable in between two MIDI equipped devices labeled "MIDI out" on one and "MIDI in" on the other. The cable is nothing special and comes with a standard 5 pin DIN connector on each end. Only 2 of the wires are signal wires. Sounds wasteful. The reason this connector was chosen is it is common around the world, easy to grab onto and is sturdy enough to stand up to road work. DIN is short for Deutsche Industrie Norm. Obviously a German standard connector type. The "MIDI out" side also uses a third wire that goes to a shield that surrounds the two signal wires. It is not connected at the other end to avoid electricity running in the shield. If all the shields were connected, you could get shocked by providing a path to ground, if the gear connected together had different potentials on their cases causing a current to flow. On a lighter note, this voltage can put a buzz on your signals as well. This is known as a "ground loop" to the techys. Any airborne electrical noise is grounded at the source end, using the MIDI design and avoids the loop. Pretty smart, eh.
Once inside the boxes, the signal is isolated from the rest of the electronics with an optical isolator. This was very thoughtful of the spec writers, since it eliminates a lot of the noise problems that other types of gear have, like guitar amps.
If you were sharp, you would have noticed the interface just described is only one way. If the gear spoken to wants to return a message, it has to have a second cable connected from its "MIDI out" to the originators "MIDI in". This is just like a stereo setup (tape out to tape in...).
To get more than two devices into the act there is a specified "MIDI thru" terminal that is basically a pass-through from the "MIDI in" circuit. So MIDI in goes two places - to the internal electronics and to the "MIDI thru" terminal to be connected to other devises in a daisy-chain fashion all nicely isolated. This brings up a couple of questions. How many devices can you link? And what do you call this kind of setup? The later question is answered by calling this setup a network or digital serial bus. The number of users is only limited by the amount of data-flow or traffic on the network or bus. The hardware is nicely isolated, and each piece of equipment in the chain supplies enough juice to avoid problems of signal strength. If the in-coming messages load up the bus, until messages being sent are delayed , then the delays become audible in the sound output of the device or could be missed, if a message is dropped. If the message dropped was - turn off the middle-C, then it would remain blasting until you pull the plug on the vocal pest, or you send another message telling the offender to cut the C please. Like all things digital, it has to be perfect or it is a mess. Staying organized is what we strive for.
Protocol - how to stay organized
MIDI
messages are serial in nature and are identified by equipment listening on a
MIDI interface by first seeing a start bit in the data-stream coming in.
That is followed by 8 bits of information (command or data) byte of data,
followed by a stop bit. So an eight bit group is called a "byte." The logic used for MIDI is confusing, since a
"on" bit is "0" and "off" is "1".
I won't bother to discuss why they chose this confusing approach, but it is
suffice to say, in digital systems, if you are consistent throughout, then all
is forgiven. It really
doesn't matter to the user, unless your are designing circuits to match this
format.
For our purposes it is only useful to know that the digital information comes in
10 bit packages with a byte of data down inside.
Digital things are really all about timing. A serial interface runs along
at some set rate or frequency-of-events per unit of time. For MIDI, that
rate is 31,250 bits per second. If you divide that by 10 bit packages you
get a maximum of 3,150 events that can happen in any given second. Here's
some new news. MIDI commands and data messages take more than one event or
byte to accomplish anything useful. Some take 3 packages, some take 2
packages per message. So now we are down to 1,000 to 1,500 events per
second. So any particular event is about 0.6 milliseconds apart. Now
things are getting tight. If you play a four note chord, each note has to
be turned-on by a command event. They can't come-on simultaneously.
Bummer. But the slight delay is not noticed. In fact, if you look at
data taken scientifically to see when notes of a chord are struck by an artist,
they seldom occur simultaneously. Of course, you can send enough event
commands through a MIDI channel to hear delays. Such things are commands
for pitch bending, modulation commands, massive multi-note chording, and patch
changes, all going on very close together, might cause a traffic jam. This
is rare and can be dealt with in other ways that I will discuss later.
I used the word "MIDI channel". This is a point of real confusion. A
channel is commonly used to mean a network cable or a particular physical
connection. And that is okay. Here is the thing you have to get
straight. In any given MIDI connection there are 16 different "MIDI
channels", or virtual channels, identified in the protocol by a code in the command word.
So when talking about MIDI connections to various pieces of gear it is best to
label them as circuits or busses or simply by ID numbers. If you use
channels your going to get confused. So what did I say? The MIDI
spec allows 16 channels of music data specified by a channel number that is
encoded within one MIDI physical connection, so a synthesizer receiving data
looks at the command event and first determines which "MIDI channel"
to send the data to or receive it from. This is significant, because I can
now address 16 different sounds, "patches", or instruments in one MIDI connection
or circuit. What's a "patch?" In the early days of electronic musical
instruments they made sound by using oscillators, envelope generators, wave
generators, etc. all ganged together to produce an analog waveform, when put
through a speaker, it made a weird sound or maybe something rather close to a real
acoustic instrument. To get all this gear connected a central patch panel
was used that made available the ends of wires going all over the place that was connected to the various sound generating electronics. Therefore, to hook
up a French horn like sound you "patched" together various oscillators
on this panel. This terminology hung around in the MIDI era as well to
describe sound types the instrument could make. A patch is also known as a
"voice".
Software - reading the data
When a MIDI device, like a keyboard key
or a drum pad, wind controller or various levers, buttons and such, is
triggered, a command consisting of three bytes is sent from a "MIDI
out" port over a MIDI connection to some other device. The first byte
describes the action done, like a keyboard key was pressed or a wheel was
turned. The second byte contains a code to distinguish, which key or devise
was pressed. The third byte informs the using device about the volume or
level of the action. For a note from a keyboard, this would be the loudness
to play. This is another area where history plays a part. In the
days of the great church organs that used air to make a sound, the time a key
was depressed was a measure of the air velocity sent to the pipe. MIDI
keyboards measure the time it takes for a key to be pressed and assumes the less
time the key takes to hit bottom, the louder the sound should be. This is
sometimes called the "velocity" data. It is divided up into 127
levels with larger numbers representing louder sound. A byte of digital
information can represent 256 different things. Zero counts as one of the
256 levels. I'll describe more later on why we only utilize half of the values.
The first byte is called the command or status byte. It comes in two
flavors. The other two bytes are called data bytes and further define the
type of command sent. The various
command and status type message packages are predefined by the MIDI spec.
There are some digital combinations left undefined for future use.
System Exclusive information is in a category by itself. This is a command that
says, "I am sending x-number of bytes to my buddy that understands what is
means, look out." This is a way for various manufactures with
completely different ways to build patches, organize circuits and display
things, to get data to or from their devise and not confuse other devises on the
connection. Remember we said several synthesizers can be daisy-chained
using the MIDI-thru port and they could all be built by different manufacturers. In the system exclusive world the various manufactures have
developed a code for each company so devices listening to the data coming in can
determine if that data is for it or not. These messages are usually broadcast
across all 16 channels of the connection to ensure their guy is reached.
This is a way, also, for a devise to down-load internal information like
patches, and settings to a computer librarian program to store or edit.
This type of information can also be up-loaded to the instrument to establish a
set of desired patches or change the content of an edited patch, etc.
You could have the 16 channels going to one synthesizer and each do something
different within the one unit.
Another use of the 16 channels in a MIDI connection is to have up to 16
different devices, synthesizers or lighting units be controlled over one
circuit. That's a lot of power. If you need more, many schemes have
been devised to accomplish this. The most direct way is to have a
interface box receive data in a port that has a high data rate, such as a
parallel port, USB port, Ethernet, or many others. Then divide the data
into multiple MIDI output ports. Now you can send out 16 channels of data
from multiple ports at a rate that is close to simultaneous due to the high data rate
coming in. Each MIDI port, though, will still be running at 31,250 bits
per second to be compatible with the MIDI spec. The sender of such data
will probably be a computer using MIDI software. Of course, to make it work you
would have to multiply the number of MIDI ports on the unit by 31,250 bits per
second and make sure that this data rate can be supported by the incoming data
connection to the computer. This is easy, since most other serial data schemes
these days are have very high data rates. The average MIDI interface box has
eight ports in and eight ports out. Some units even have more ports.
The software to make the MIDI interface work is referred as driver
software. Once inside a box, the data must be used by other software that
can make it breathe. The basic workhorse for this is the "sequencing
software." There are many brands for any chosen computer platform.
They all do basically the same thing - receive and send MIDI data. They
record incoming information and store it, and they can send data out that
represents musical thought or a lighting scheme or anything else that you can buy
a MIDI device for. They also allow editing of the recorded data to correct
or add more to the recorded track. Anything you can imagine. This
can be pitch bend, sustain of a piano pedal, change patches, etc. Then
send it back out to a system of eager synthesizers that play their hearts out
following the data precisely. I'll stick to synthesizers and things that
produce musical sounds, but realize you could also run a lighting panel or a
zillion water jets at a Las Vegas casino to music
this way or other schemes yet to be imagined.
Beyond Notes On and Notes Off
There are several standard functions that the electronic era has generated besides just making a synthesizer play a note or chords. How about sustain like a piano, or bending a pitch like a guitar player, or changing the character of the sound as it plays out - filtering the sound. These controls are set aside in the MIDI spec as defined standard devises. See the command list. There are also system messages that manage the connection. An "all note off" message avoids the panic of a stuck on note. Start, stop and song pointers to drum machines are very useful. Changing the mode of the interface. Oops, something new here. The interface can be set up to respond to data in different ways. Most of this is not so useful, but the basic ones need to be described, and that can be found in the next segment.
© 2003 John Wolf - Wolf Tracks Music