MIDI (Musical Instrument Digital Interface) is a protocol developed in the 1980's which allows electronic instruments and other digital musical tools to communicate with each other.  MIDI itself does not make sound, it is just a series of messages like "note on," "note off," "note/pitch," "pitchbend," and many more.  These messages are interpreted by a MIDI instrument to produce sound.  A MIDI instrument can be a piece of hardware (electronic keyboard, synthesizer) or part of a software environment (ableton, garageband, digital performer, logic...).

The advantages of MIDI include:
compact -an entire song can be stored within a few hundred MIDI messages (compared to audio data which is sampled thousands of times a second)
easy to modify/manipulate notes -change pitch, duration, and other parameters without having to rerecord
change instruments -remember, MIDI only describes which notes to play, you can send these notes to any instrument to change the overall sound of the composition.

Step 1: Note On, Note Off, and Velocity

The most common tool used to generate MIDI messages is an electronic keyboard. These messages may be routed to a digital synthesizer inside the keyboard, or they may be patched to some other MIDI instrument, like your computer.

When a key is pressed the keyboard creates a "note on" message.  This message consists of two pieces of information: which key was pressed (called "note") and how fast it was pressed (called "velocity"). 

"Note" describes the pitch of the pressed key with a value between 0 and 127.  I've copied the table in fig 2 from NYU's website, it lists all the MIDI notes and their standard musical notation equivalents.  You can see that MIDI note 60 is middle C (C4).

"Velocity" is a number between 0 and 127 that is usually used to describe the volume (gain) of a MIDI note (higher velocity = louder).  Sometimes different velocities also create different timbres in an instrument; for example, a MIDI flute may sound more frictional at a higher velocity (as if someone was blowing into it strongly), and more sinusoidal/cleaner sounding at lower velocities.  Higher velocity may also shorten the attack of a MIDI instrument.  Attack is a measurement of how long it takes for a sound to go from zero to maximum loudness.  For example, a violin playing quick, staccato notes has a must faster attack than longer, sustained notes.
something to remember- not all keyboards are velocity sensitive, if you hear no difference in the sound produced by a keyboard no matter how hard you hit the keys, then you are not sending variable velocity information from that instrument.  Computer keyboards are not velocity sensitive, if you are using your computer's keys to play notes into a software sequencer, all the notes will have the same velocity.

When a key is released the keyboard creates another MIDI message, a "note off" message.  These messages also contain "note" information to ensure that it is signalling the end of the right MIDI note.  This way if you are pressing two keys at once and release once of them, the note off message will not signal the end of both notes, only the one you've released.  Sometimes note off messages will also contain velocity information based on how quickly you've released the key.  This may tell a MIDI instrument something about how quickly it should dampen the note.

Figure 1 shows how these MIDI messages are typically represented in MIDI sequencing software environments (in this case GarageBand).  Each of the notes in the sequence are started by a note on message and ended with a note off message. In GarageBand the velocity attached to the note on message is represented by the color of the note.  In this image above the high velocity notes are white and the lower velocity notes are grey.

Figs 3 and 4 show MIDI notes recorded in Ableton.  Again you can see that the velocity associated with the note on message is represented by the color of the MIDI note- more saturated = higher velocity.  Also notice that the velocity is indicated by a line with a circle on top on the bottom of the screen.  By selecting one of your MIDI notes you can see the velocity associated with it; in fig 4 the D4 note has a velocity of 57.

Step 2: Aftertouch, Pitchbend, Channel, and Other Extra MIDI Messages

Your MIDI keyboard/controller may also generate these MIDI messages:

"Aftertouch" is the force used to press down a key after it has been initially struck, think of it as pressure sensitivity.  Like velocity, aftertouch ranges from 0 to 127.  Aftertouch may be interpreted by a MIDI instrument in a variety of ways; it may affect the volume, timbre, vibrato... you will have to experiment with your own setup to get a feel for what expression you can achieve with aftertouch.  Keep in mind that not all electronic keyboards are capable of producing aftertouch messages and not all MIDI instruments support them.  The MIDI instruments inside GarageBand do not support aftertouch, but many of the MIDI instruments in more sophisticated software like Ableton, Reason, etc, do.  Like velocity, aftertouch messages always have a note associated with them, this means you can send an individual aftertouch message for each of your keys.
Here's a good article on Wikipedia about various types of keyboard expression, including aftertouch and velocity.

You may also have a pitchbend wheel/slider attached to your MIDI keyboard, this will shift the pitch of whatever notes you are currently playing up or down by less than a semitone.  Your pitchbend wheel/slider probably generates pitchbend values from 0-127 (where 64 = no pitchbend), but some high res devices will generate values from 0-16,383 (where 8192 = no pitchbend).  Pitchbend does not have a note associated with it, this means that pitchbend is applied equally to every note you're playing.

MIDI messages can be sent on 16 different channels as well.  Channels are useful for sending certain notes and messages to one MIDI instrument and other notes/messages to another MIDI instrument.  Usually, separate MIDI channels are used for different sounding instruments to create a multitracked song, channel 0 might be a piano-sounding instruments, and channel 1 could be a guitar sound.

Here are a few other (less common) types of MIDI messages:
patch change- allows you to change the MIDI instrument from your MIDI controller (ie change from a violin sound to a piano sound in the middle of your performance)
continuous controller- allows you to assign a continuous controller (like a slider) to some kind of MIDI effect (reverb, vibrato, filter, volume... anything)
channel pressure- like aftertouch, but applied to every note in a channel.  This is usually used as a cheaper alternative to aftertouch, as it requires only one pressure sensor instead of one for each individual key.

Step 3: Editing Recorded MIDI

As I said in the intro, the great thing about recording in MIDI is that it is incredibly easy to edit your recordings after the fact.  The images above show how I edited a MIDI sequence in Ableton, most other software environments are set up similarly.

Select a MIDI note (fig 1).  Drag its associated velocity to change it (figs 2 and 3 change the velocity of a MIDI note from 127 to 41).  Drag a MIDI note up or down to change its pitch (fig 4 shifts a note from A to A#).  You can drag on the beginning and end of a MIDI note to lengthen or shorten its duration (figs 5 and 6).  You can really change the feel of the MIDI recording by changing the MIDI instrument you're using to play it back.  In figs 7 and 8 I changed the MIDI instrument from a xylophone to synth pad called "retro rave."

You can also change aftertouch, pitchbend, channel, and all the other MIDI data in post, but the interface for these varies from program to program so I won't get into the specifics of it here.

Step 4: MIDI Protocol and Microcontrollers

This instructable is an introduction to the concepts behind MIDI, for more info on the specifics of MIDI protocol and how to program an Arduino to send and receive MIDI, check out my MIDI and Arduino instructable.
<p>Does MIDI have any patent royalties associated with it?</p>
<p>i have a synth and a mac and i wanted to start making some EDM but i dont know at all what i need to do could you please help me?? im using LMMS as a software and i wanted to use my synth but i dont know howto connect it </p><p>Thanks</p>
<p>I have just come by an old digital recorder and I'm having similar thoughts...it has a MIDI port in the back, five-pin plug and that anchor thing (square one at the base...) I'm having dreams of just being able to pick up a cord at a music shop and plug it straight into the PC so that I could record synth stuff. I can't be sure...</p>
<p>Really clear explanations - you've explained several things I was wondering about. Thanks!</p>
<p>I wonder why Status byte must start with 1, and the other data bytes must start with 0. I mean, I read that this is the way the midi reciever recognize each byte. However, that doesn't make sense to me.</p><p>Why isn't it possible to use 256 values for each data bytes? What happens in the first 0-127 values of the Status byte?</p>
<p>it makes it easier for device to find the beginning of a message in a stream of bytes. If something goes wrong, and some bytes are dropped, the device doesn't have to know how many bytes were dropped to know which byte is the start of a message.</p>
<p>Thank you!</p>
<p>Now I understood what MIDI is!!!!</p><p>You did a great job for MIDI newbie like me!! I can go next step for my project now!!</p><p>Thanks!!</p>
glad to hear it!
<p>how about the messages for &quot;bank change&quot; and &quot;loop change&quot; in midi foot controllers? I would like to make a midi foot controller that can control an audio switcher for example like this</p><p><a href="http://www.voodoolab.com/manuals/gcx_manual.pdf" rel="nofollow">http://www.voodoolab.com/manuals/gcx_manual.pdf</a></p><p>thanks!</p>
they're probably using a continuous controller command or a non-musical command.<br />https://ccrma.stanford.edu/~craig/articles/linuxmidi/misc/essenmidi.html<br />if you can figure out which one, then you can copy it with Arduino or whatever hardware you plan on using.
Amanda, you are an IDOL! <br> <br>I love MIDI since I met it, many years ago. I upload some of my preferred. Look its compactness! <br> <br>One of them, Delicado.mid, was fixed by me in a note some years ago.
It seems that you can not upload MIDI files...
try putting it in a zip file first
Done, thanks!
Thanks for the files Sir! I can make good use of the information.
I'm looking all over here trying to find what software you are using to compose your music. I'm just getting started with this midi thing and don't want to drop a chunk of cash on software that doesn't work with my USB to midi converter. Any tips? I was thinking of Rose Garden. <br> I'm planning to compose some tunes, send them to my Arduino, and have it play a xylophone or something.
I've been using Rosegarden on Linux for the last 18 months and found it to be quite stable with a cheep usb-midi cable converter I found on ebay. I wasn't able to get it working with a Moto box I was gifted but I think that is a problem with Linux.
I'm using ableton and garage band, but both windows and Mac have a built in midi synth that will get you started. You can definitely find free midi software for what you want to do
This is a real informative article, especially if you're in to computer music like me.

About This Instructable




Bio: I'm a grad student at the Center for Bits and Atoms at MIT Media Lab. Before that I worked at Instructables, writing code for ... More »
More by amandaghassaei:OTCA Metapixel - Conway's Game of Life "9 Degrees of Freedom" IMU Twitter Controlled Pet Feeder 
Add instructable to: