A PC based home studio (part V)

Part V - Some MIDI basics

Sometimes I will refer to previous articles since I don't want to repeat myself too much.

Most of you guitarists out there have already worked with some MIDI gear. Except if you are a really purist vintage-amp and stompbox freak. But if you had (or have) a multi-FX unit and a system to switch its presets, you have worked with midi (well, in most cases...).

The MIDI device (besides a multi-FX unit) bought most often by guitarists is some kind of MIDI pedal, which is then used to remote control the change of programs (or patches or presets...) on a multiFX unit or a programmable rack preamp or whatever. But MIDI is much more. In this article I'll try to give an overview about what can be done with MIDI. Sometimes text will become a bit more technical, but there are some explanations needed about the specifications of the midi interface, to understand some of its limitations. This is so that you don't blame your software or synthesizers for imperfections that are the fault of the MIDI standard. A technical paragraph will be marked with a (t).

What does MIDI mean?

Midi is an acronym for "Musical Instrument Digital Interface". It was introduced in the early 80s (if I remember right) to have a possibility to remote control synthesizers. In the beginning there were no applications for guitar planned. MIDI is not a standard that was set by some bureaucratic institution, but some manufacturers simply started working with it, others copied it and so it became a de-facto-standard. Some effort was made to define some standardization afterwards. Today every decent MIDI device follows the same set of rules. And it has the same connectors, that you all know: those 5-pin DIN connectors. One cable can only transmit data in one direction, so most devices have a MIDI in and a MIDI out jack. A lot of devices have a MIDI thru connection also, which mirrors the incoming data of the MIDI in jack.

Synthesizers could be remote-controlled in the days before midi, but this was usually done with analog CV (control voltage) interfaces which required high electrical precision, were therefore expensive to implement and were not to reliable. MIDI opened a lot of new possibilities, for example, synthesizers without keyboards became popular (called "modules") which were played via midi. Also, MIDI allowed the recording of the playing of a keyboarder to a computer or hardware device. Those devices (and the software too) were called a "sequencer". More on this later.

Today, MIDI is used for a wide variety of purposes. I read a document once that described in great detail the usage of MIDI messages to control a moving artistic installation that contained a lot of robotics and light show etc. Also, MIDI is used to control a lot of devices for making and producing music besides synthesizers and keyboards.

What does MIDI do?

Basically, a MIDI interface sends and receives messages. There are a lot of different kinds of messages, more on that later. How a MIDI interface has to be put together is part of the MIDI transmission protocol. Simply put, there are rules, and those have to be followed, or else no successful communication will happen.

A MIDI message is made of two parts: There is the status part, which contains information about the kind of message and about its MIDI channel. And there is the data part, which contains one or several data informations, such as a note value, for example.

The MIDI channel is a kind of address in the MIDI protocol. There are 16 MIDI channels. You can for example tell your MIDI device (like your FX unit) only to receive on channel 14. The device will check all incoming midi messages, regardless of the channel, but will process only those that are sent on channel 14. A device sending MIDI messages (like a MIDI pedal or a keyboard) can be told to send on specific channels only, too. This way you can use more than one sending and more than one receiving MIDI device on one bus. This can be critical due to MIDI timing issues, though (more on that later).

What kind of MIDI messages are there?

The kind of MIDI message that you will have worked with the most time is the "program change" message. This message tells the receiving device to switch to another program (or patch or preset). Program changes have a specific channel (this is true for most MIDI messages, I will not repeat this for every message) and a value that ranges from 0-127. Most devices have their programs numbered starting with #1, so usually you have to add 1 to the program change value to find out to what program it will switch. Many midi pedals do the same thing, so you don't have to worry.

To control a synthesizer or keyboard, you need for example "Note on" and "note off" messages. These are sent at the moment that you want to play your synthesizer a certain note. They have two values: Note number and velocity. Both values range from 0-127 (as do most values in MIDI land). Note number represents a certain note pitch, #60 for example equals the middle C on the keyboard. Velocity determines how loud the note is played. Why "velocity", for heavens sake? Well, when building the first MIDI keyboards, engineers had to implement a way to find out how hard the player hit a key. This was solved by measuring the time between the beginning of the key's movement and the moment it hit the bottom of the keyboard. The harder you hit a key, the faster it moves, the higher is its velocity.

The note starts playing when the synth receives a note on message. It plays until the synth receives a note off message for that specific note.

For greater control, there are messages that are called "controller messages". Examples for these are the modulation controller (controller #1) - if you move the modulation wheel, a stream of controller #1 messages is sent. The receiving synth can interpret these in a particular way. Most often, modulation controls the depth of an oscillation of the pitch or volume of the played notes. There are controllers for volume, pitch (the pitch wheel) and various other purposes, too, there are also lots of controllers that are not standardized. What these do is up to the device - they can be used for unusual purposes that are unique to, say, a certain synthesizer model.

There is one kind of MIDI message that is not standardized at all, and this is the SysEx (System Exclusive) message. These are marked by a certain beginning and end sequence, and can contain any kinds of information, like for example a patch dump or similar things.

There are also other kinds of MIDI messages, but I won't go into further detail here. If you want to read more about this, you can find the whole MIDI specification at this site:


How is music recorded via MIDI?

If you hook up your keyboard to your PC via a MIDI interface (you need one for this purpose, remember part IIb?), you can record your keyboard playing to a special software. This software is called most often a "sequencer". Popular MIDI sequencers are Cakewalk, Cubase and Logic (see part III). All of those can handle audio, too. The important thing to remember is that

MIDI is not audio data.

In spite of that, a sequencer is controlled much like a tape machine. There's a play button, a record button, a stop button, just the usual transport controls. You press record, play on your keyboard, and the sequencer records what your play. You rewind, press play, and your music plays back. That's about the end of the analogy, because the inner workings of a sequencer program (or a hardware sequencer) are quite different from those of a tape machine.

If you record your keyboard playing via midi, the sequencer will record only what keys you pressed at what times, how hard you pressed them and other similar information. The sequencer does not know how your playing sounds. It has not recorded the sounds. It can re-transmit the information it has recorded to the synthesizer, and the synth will translate it into a sound.

The difference between MIDI data and audio data (about which I told you a lot in part IV) is like the difference between sheet music and an actual musician playing. The MIDI data, like the sheet music, contains only instructions for a device, which then has to interpret these instructions.

You might now argue that this is a damn complicated way, nowadays, since we have all those sophisticated digital audio machines - why not record everything to audio the first time?

Well, the trick is that MIDI is in some regards much more powerful than audio recording. Imagine you played a nice riff on your keyboard. You used a piano sound. This seemed to be a great idea at the time. Afterwards you add a bass and some drum tracks. Now you notice that the piano sound does not fit into the mix. Had you recorded everything to digital audio, the only things you could do are either re-do the take or try to eq it drastically. But you recorded it as a MIDI track to your sequencer. Swap to another sound on your keyboard, say, a Fender Rhodes sound. The sequencer sends all the MIDI data to your keyboard, but now your piano track has a Rhodes sound. This is only the most simple example.

If you record something as MIDI data, the pc (the sequencer software really) does know what you played. It knows the notes, how hard you hit the keys etc. If you record to digital audio, the PC cannot interpret this information (at least not so easily). But you can edit MIDI data in very sophisticated ways. Imagine you spoilt an otherwise immaculate take by playing but one wrong note. Do you want to re-do the take? You can easily transpose the one wrong note afterwards. Or you can change the tempo of the song as long as it is made entirely of MIDI data. You can play the difficult piano solo as slow as you want to, and later increase the tempo.

Should your drumtracks (or any other track) have imperfect timing, you can quantize them. That means that every note is pulled onto the perfect position in time. Since this does often sound sterile and mechanical, you can also do an only 70% quantize operation, for example. This would move the notes only 70% of the way to their destination. You can also copy the groove of one MIDI track to another - this is called groove quantization. Most sequencer programs come with a selection of pre-made grooves you can quantize your material to.

You can transpose your tracks after playing them. You can cut&paste them, copy them all over your arrangement. All this is impossible or difficult to do with digital audio, but easy with MIDI data. Therefore a MIDI sequencer is a great composing and songwriting tool. You have the power to manipulate about everything afterwards. If you want, your software can display what you played as standard notation or even as tablature.

But not all is well in MIDI-land.

Drawbacks of MIDI

As a guitarist you have noticed that all this MIDI stuff is pretty much keyboard oriented. That's unfortunately true. There are of course MIDI guitar systems, that convert what you play on the guitar into MIDI data. This process is very imperfect, because you can have so much more continuous nuances in your guitar playing than in playing a digital keyboard. Think of bendings. OK, these can be emulated with Pitch Bend messages. But what about a realistical vibrato? Or a glissando? Or the change in the tone that you get when you vary the picking position? These things cannot be captured well by those MIDI guitars. Also, in my opinion it is not practical to play, for example, big organ chords or piano parts on a MIDI guitar. Also, the MIDI guitars I have played around with were pretty good at tracking, but not perfect. I'd be happy if someone points me towards a perfect MIDI guitar. But since I can play the keyboard I rather use keys for MIDI recording.

So MIDI is somewhat limited in the depth and detail of musical expression you can create with it. This is because it has a limited resolution. For example, there are only 128 values for the volume of a note. This is a quite rough resolution. Also, because of its limited speed, the resolution in time is not as good as it should be. This is mostly due to the fact that MIDI is such an old standard. But it is also wide spread, and the manufacturers so far have not been able to provide a better replacement that is accepted by all.

Some details about the MIDI interface (t)

I quote from the MIDI specification here:
"MIDI is an asynchronous serial interface. The baud rate is 31.25 Kbaud (+/- 1%). There is 1 start bit, 8 data bits, and 1 stop bit (ie, 10 bits total), for a period of 320 microseconds per serial byte."

Let's dissect this paragraph. It contains a lot of information about the nature of the MIDI interface and its inherent limitations.

Let's take a look at the baud rate. 31.25 kbaud is really slow. The common serial port on your PC (like COM1) has normally 115.2 kbaud max, and even that is still slow. Well, MIDI is an old interface after all.

In the first sentence it says that MIDI is a serial interface. This means that any information can only be sent one after another. This implies for example that you can't send a perfect chord through a MIDI cable. A simple chord that is made of 3 notes is sent one note after another. You can not achieve perfect timing this way.

The last sentence of the quote tells us that to send one byte, the MIDI interface needs 320 microseconds or 0.320 milliseconds. Now, if we look further into the MIDI specification, it states that a "Note On" message is made of 3 bytes - one status byte, on byte for the note number and one byte for the note velocity. That means that it takes at least 0.960 milliseconds to transmit a "Note On" message through the MIDI interface. The receiving device needs probably a bit of calculation time to translate this into an actual sound.

If we put the info from the last two paragraphs together, we see that for a three note chord we have to calculate a time of 3 x 0.96 = 2.88 ms alone for the transmission through the MIDI interface. This is very short, and not audible, so we would perceive this chord as perfect, timing-wise.

Nowadays there are a lot of synthesizers that have a polyphony of 64 notes or greater. This means that they can play 64 different notes at the same time. Now imagine that you made a composition that plays at one certain point all those 64 different notes at the same time, maybe at the start of a bar (on different MIDI channels maybe, but all on one MIDI port). Now, ideally, all those 64 notes would be transferred to your synthesizer at the same time. But because of the serial (and slow) nature of MIDI, this isn't possible. So there will be a time between the first of that 64 notes and the last of at least 64 x 0.96 = 61.44 ms. This is a very audible delay. The time can be longer if there is other MIDI information to be transmitted at the same time, like controller messages, sync information etc. All this is a timing problem that cannot be solved by the MIDI interface nor by the software nor by the synthesizer. I have the feeling that many people complain of the bad timing of their sequencers and 64-voice synths etc. who simply haven't understood some of these basic facts about MIDI.

The downside of this is that you have to consider these facts when arranging your compositions - just to avoid timing inaccuracy which is caused by the interface.

Another really annoying thing is the limitation to value ranges between 0 and 127. A byte has 8 bits, so that should be 256 values, right? (see part IV). But in MIDI, the only byte that has the eighth bit set is the status byte that is sent at the begin of every MIDI messages. All other bytes have only 7 bit to store information. This way a factor of 2 of the possible resolution is wasted due to the transmission protocol alone! Some types of messages actually use 2 7bit-bytes for value transmission, this is 14 bit in total, which yields 16384 different values. Better. But sending messages with such a high resolution through the MIDI interface takes time and is bad for the MIDI timing.

How to avoid some of the MIDI drawbacks

The first thing to do if you're serious about your MIDI set up is to have a different MIDI port for every device you have connected. You can buy 8in-8out-MIDI ports for a reasonable price, nowadays, and these can be stacked, too. Daisy-chaining MIDI devices via the MIDI thru jacks is bad for the timing. But if every synthesizer and keyboard and drum machine has its own MIDI port, there is only as much traffic on every MIDI cable as necessary. Your PC is by far fast enough to feed all those slooow interfaces with data simultaneously.

Also if you record MIDI tracks that don't need certain controller data, make sure that this is not recorded. For example, if you record a drum track, it will probably not need aftertouch data. Since you play the drum track with you keyboard, a lot of aftertouch messages are generated (if your keyboard supports aftertouch, which is a method of detecting how hard your depress a key after hitting it). These aftertouch messages are unnecessary since drum sounds normally don't readt to aftertouch. But if you don't block them, they're recorded with the track, and are played back afterwards, when the only thing they do is hogging the MIDI interface and screwing the timing. So you should make sure that you only play back *necessary* continuous controller data.

Also, what you can do is push notes that play sounds with a slow attack phase a little bit behind the beat, so that the timing critical notes like drum hits have priority.

How do I mix down my MIDI tracks to a *.wav file?

(a most frequently asked question)

This is a question that is asked quite often on several online forums. The key to it is to understand what I've said above, that MIDI is not audio. So you have a software that lets you work with MIDI and audio data under the same GUI. You have MIDI tracks and audio tracks and they look very similar, you can arrange them in a similar way. Lets say you have recorded your drums and a piano part as MIDI and you have recorded some guitar tracks and an electrical bass as audio data. It's a great thing that you can work with both kinds of tracks synchronously. But it can be a bit misleading.

Most of these sequencer/audio programs have a "mixdown to audio file" function which mixes all audio tracks complete with your mixer and FX settings down to a stereo wav file which you can then burn to a CD. Note that I said audio tracks. So some beginners wonder why (in our example) the drums and the piano are missing from their mixdown. After all, the whole song still plays back correctly from inside the sequencer software.

The trick is that the sound of the MIDI instruments (the drum machine and the piano synthesizer in our example) have not been recorded to the software, so it can't mix them down. What you have to do is hook the outputs of your MIDI instruments to your soundcard inputs. You then have to prepare an audio track for recording inside your software, and then record the sound output of your MIDI instruments as audio to your harddrive. After that, you can mute your MIDI tracks (they are not needed anymore, since we have the audio of the MIDI instruments on the harddrive now). You will probably have to mix the new recorded audio tracks correctly with the already recorded material (the guitars and bass in our example). And then you can mixdown the complete song to a stereo *.wav file.

Some thoughts on resolution, another word in the digital vs. analog battle

(A "general thoughts"-paragraph)

You may have gained the impression that this resolution thingy is really chasing you when you want to make music with your computer. This is true. You have to worry about resolution in your digital audio, in your MIDI data etc. all the time to achieve the best possible results. You may now think that those resolution problems are inherent to digital solutions, but analog technology are not bothered by it. Well, you're wrong - but a lot of analogue fanatics want to make you believe exactly that. So what? Analogue methods have their resolution problems, too. Each and every piece of analogue gear has a signal-to-noise ratio, that means finite dynamics. Most of the low-to-mid-priced analog devices are in this regard much worse than their digital brethren. Analog devices introduce distortion into your signals, too. As a guitarist, I find certain kinds of distortion in certain devices highly desirable, but as someone who does recording I want only those devices to distort my signal that I set up for this purpose.

As long as you stay with your signals in the digital domain, you have a lot less problems with electrical interference. No ground hum in a digital equalizer for example.

Now I won't tell you that analogue is crap. I don't believe this, either. I love analogue stuff. But I know about its limitations, too. Don't let anybody tell you that either method - analogue or digital - is crap in itself. Keep your eyes (and especially your ears) open for new developments, new tools and the like. And trust your own judgment.

Oh, and in my opinion it always pays to know as much about the tools you are using as possible. This may seem too analytical for artistic minded people - and I had a lot of discussions about this point of view - but for me it works. If you read all this stuff so far you probably have the wish to really understand what you're doing. I hope that these ramblings of mine have helped you a bit (and will do so in the future).

The next part will be:

OK, I'm not sure what part VI will be, but now since I have covered what I consider the basics of setting up a PC based home studio, I will probably tell you something about working with it.

Since I have an exam coming, there will probably be no article next week. Please be patient. Part VI will come!

Back to Part IV

Part VI

Back to the index page

All this stuff is (c) 2000-2002 Tammo Trueper.

The trademarks I have mentioned all belong to their respective owners.

If you want to drop me a note, or ask a question, here's my eMail address: