A Quick Primer on MIDI

From Garritan Wiki

(Redirected from MIDI)
Jump to: navigation, search
Miscellaneous Tutorials

Orchestration:   A Primer on TranspositionTransposition GuideRimsky-Korsakov's Principles of Orchestration
Other:   MIDIOrchestration & Instrument Specific TutorialsPlaying Technique TutorialsAdvanced TutorialsOther TutorialsOverviewsUser Tips & TechniquesGigastudio & GOS Tutorials

MIDI stands for Musical Instrument Digital Interface. It was developed in 1983 and has been one of the cornerstones of computer-based music production ever since.

One of the most important things to know is that MIDI is not audio. If you were to open a WAVE file, MP3 file, or the information on a music CD, you would find information that directly corresponds to the sound you hear. In the digital realm when recording, the pressure created by a sound wave is converted to a corresponding voltage by a microphone and measured tens of thousands of times per second (sampled). To play it back, the computer reads these recorded voltage values, fills in the gaps between the sample values with a line, and sends it to your speaker to hear. The quality of the original recording is the quality you hear.

With MIDI, however, far less information is sent. If you were to open a MID file and decode it you would basically see a list of commands giving the computer instructions on how to play music using its internal synthesizer. The quality of what you hear is dependent on the computer’s synthesizer and the detail of the instructions.

A good way to think of MIDI and audio is to compare sending someone a cake to sending them the recipe. If you send someone a duplicate of a cake you baked it will taste exactly the same as your cake, all FedEx shipping mistakes aside. That’s audio. It is an exact duplicate of the original, every time. MIDI is the recipe, telling the computer what notes to play for how long, just like a recipe says what ingredients to use and what temperature to bake at. If someone were to follow your recipe exactly, the cake still might come out a little differently because their oven is a little different from yours. The same oven though would yield the same cake. In this analogy, the synthesizer used by the computer to interpret MIDI code is the oven. So, if you and your friend are sharing a MIDI file it will sound the same if you both use the same synthesizer to play it, but it could sound different using different playback programs.

This brings us to the beauty of MIDI. Because it is only a list of instructions, it is very easy to change information around. Continuing with our cake analogy, it is pretty easy to change a recipe to bake at 350F instead of 300F or to use brown sugar instead of confectioner’s sugar, but you cannot change an angel cake into a gold cake once it is baked. With MIDI, changing the file so the trombone player has an E-flat at bar 16 is easy, but changing the audio recording so it sounds that way is nearly impossible to achieve.

Let’s take a look at some MIDI information and how we can go about changing it. We’ll be working with a public domain midi file of J.S Bach’s Polonaise in F Major obtained from the Mutopia Project. It we open it up in the default Windows Media or Quicktime synthesizer we get something that sounds like this:


It plays all the notes, and it doesn’t sound all that bad. But, you can easily tell that it is a computer playing it using the generic synthesizer. We also can’t modify the file using a MIDI player. It behaves like audio.

Contents

[edit] Sequencer Editing

Sonar 7 Track View
Sonar 7 Track View
Now let’s look at it in a sequencer, like Sonar, Cubase, or Logic. When we first open it, we are presented with two tracks, one labeled ‘upper’ and one labeled ‘lower.’ These contain the MIDI information that was entered from someone reading or playing in the score, and we can infer that the ‘upper’ track contains the right hand part and the ‘lower’ track contains the left hand. Two tracks of information exist solely because the person who made the midi file decided to do it that way. It would function equally well as a single track containing all of the note information. We will see in a little bit how we can use multiple tracks to our advantage though.

[edit] Event List

Sonar 7 Event List
Sonar 7 Event List
Selecting a track we can look at the midi information in a few different ways. First, let’s check out the Event List. This is a long set containing all of the midi commands that will be sent to the synthesizer from this particular track. Our file only has note commands, but other information can be sent via MIDI too (more on that later). Each row represents a different command or, in technical jargon, a different MIDI Event. The columns define the properties of that event. Let's look at the second row:


Trk
HMSF
MBT
Ch
Kind
Data


1
00:00:00:15
1:01:192
2
Note
F6
127
96

We see that this event is from Track number 1 (upper), occurs at 15/30ths of a second into the sequence, at measure one, beat one, tick 192, is sent on channel 2, is a NOTE event, specifically for the F in the sixth octave, and it carries a velocity of 127 and lasts for 96 ticks.

That’s a lot of information we just got! We can see that MIDI not only knows the time at which events occur, but also the measure, as if it was reading a score. This is because you can define the tempo and time signature in a midi file. They occur as midi events too though, so at any time in the sequence we can modify the tempo or the meter. This is an extremely useful if you want to write in an accelerando or switch to a waltz section.

Time was defined as hours-minutes-seconds-frames. MIDI is very compatible with synchronizing to video. The sequencer can adapt this timing display to work with many different frame rates so you can be very accurate with timings. The musical time display is in measures, beats, and ticks. You’ve probably heard of measures and beats. The tick is the way MIDI defines divisions smaller than the meter beat. Think of them as graduations on a ruler. Just like frame adaptations, the tick resolution and divisioning can be changed and your sequencer will adapt the positioning of the notes to the new resolution. Today’s sequencers operate in the range of hundreds to thousands of ticks per quarter note, which is more than adequate for all practical purposes.

The channel designation refers to where the synthesizer is supposed to direct this information. We’ll cover that a bit later when we discuss MIDI Communication.

The last bits of information are the most common things to change: the note value, its velocity value, and its duration.

The note value is its pitch. Sequencers usually define middle C on a keyboard as C3. (C, 3rd octave). Most sequencers display this note/octave format, but the computer actually deals with a number, so once in a while you might come across MIDI notes being defined that way. C3 is note number 60, and the range of notes MIDI can play goes from 0 to 127.
The velocity value relates to how hard a keyboard would be struck to play this note, where 1 is the softest (see note below) and 127 is the hardest. In many cases velocity translates to volume, but the synthesizer can interpret it in other ways too. For example, with the Garritan wind instruments, velocity affects the hardness of the attack of an instrument and another piece of MIDI information, a continuous controller, is used to control the volume of the resulting sound.

The duration information is straightforward. It uses the same measure/beat/tick display as the start point for the note.

Note: A note velocity of zero indicates that the note is to be turned off. In this manner MIDI can handle two events (Note On and Note Off) with one type of data.

[edit] Piano Roll View

Sonar 7 Piano Roll View
Sonar 7 Piano Roll View
From the editor window, you can change any of a note’s properties by adjusting the values of the cells, but it’s not a very visual way to do it, and in many cases it is very time consuming. Instead, let’s look at how to make changes to midi data using the Piano Roll View (PRV) of the sequencer.

With the piano roll, the information is displayed more graphically. We see notes displayed as long colored bars that reflect their start and end times. To the left is the keyboard indicating their pitch. Below in the pane, we see the velocity information of each note. The piano roll can be adjusted to display other sorts of MIDI information at the same time too, such as those continuous controllers that were mentioned earlier. Each sequencer’s roll functions a little differently, but all have a bunch of tools that let you create and select midi notes, adjust their timings, and alter their pitches. The panel below with velocity or controller information can be edited with line-drawing tools, which speeds up editing greatly and helps you make meaningful dynamic changes easily. Using the right tools, you can see how a note can be moved up a few octaves and stretched in length. The synthesizer can effortlessly adapt to the changes you make here.

Editied MIDI Data
Editied MIDI Data
That’s all there is to tweaking a MIDI note!


[edit] Other MIDI Commands

Here’s a quick breakdown of some other kinds of MIDI data that you might want to create or edit while you work. Some, like Continuous Controllers, you’ll want to edit in the piano roll view, while others, like time and key signature, will have their own special editing windows.

[edit] Continuous Controllers (CC’s)

There are 128 of these (CC0 through CC127), and each can have a value of 0-127. By default, certain ones are defined in the midi specification to be interpreted certain ways. For instance, CC10 should indicate the stereo position of the sound the synth is producing. CC7 usually handles volume. CC64 typically is reserved for the state of the sostenuto pedal of a keyboard. These specifications are only guidelines however, and the same controller can be used to convey many different messages, depending on its destination synthesizer.

[edit] Aftertouch (Channel and Key)

Like CC’s Channel and Key aftertouch have a range of 0-127. Aftertouch is usually applied on a keyboard, by putting pressure on a note that has already been struck. It is a good tool to control things like vibrato on notes. The Garritan Stradivari Solo Violin uses this.
Key aftertouch can transmit a different pressure value for each note on a keyboard. Channel aftertouch transmits a single value for one MIDI channel. Channel Aftertouch sensors are usually only found on higher-end MIDI controllers. Due to the prohibitive costs, key aftertouch-capable keyboards are not manufactured any longer and virtually no synthesizers will exclusively rely on input from these sensors.

[edit] Patch Change

This command is a useful way to switch between sounds on many (but not all) synthesizers. Again, the range is 0-127 patches per bank, with a total of 127 possible banks. (Seeing a trend?). The General MIDI specifications define certain instruments to correspond to specific patch numbers. A value of 0 is defined as the Acoustic Grand Piano. The Kontakt Player 2 Interface and ARIA do not respond to patch changes.

[edit] Pitch Bend

The range of the pitch bend is not 128, but 16,384 (which is 128 squared). This was done to avoid the “staircasing” effect that might occur if the range of the pitch bend (usually done on the synth) were very high. The extra numbers allow a more seamless and continuous shift from one pitch to another. A bend of zero is defined as the middle value (8192) and consequently many sequencers will display pitchbend values as -8192 to 8191.

[edit] MIDI Data Values

Why 128? Why 16,384? Why not 100 and 10,000?

MIDI data is binary: 0’s and 1’s. It was decided that seven bits of resolution (2^7 gives 128) would be adequate to express most MIDI messages. The extra bit in the byte (8 bits make a byte) is used in determining the purpose of the following seven bits. Since the information is sent in eight-bit chunks, the higher resolution MIDI data form that includes pitch bend and also data types called SysEx and NRPN needs only to send a second complete byte to finish transmitting its information.

One cool result of having all of the data be the same size is that commands can be “caught” and converted to other ones before being sent to a synthesizer. For instance, CC1 can be easily converted to CC7, or CC7 can be converted to channel aftertouch. Utilities such as MIDI-OX (PC) and MIDI Pipe (Mac) are capable of this.

[edit]
MIDI Communication

When you send someone a letter, you have to write their name and address on the envelope. This lets the information be routed properly by the postal service to the correct house and then lets the occupants within know who should be opening the letter. The same principle applies to MIDI data that is sent and received. When recording from an external keyboard or playing back from a file, the MIDI commands are transmitted over a Port to or from one specific device (the proper house). Within that port however, they are broadcast usually on only one Channel (a specific occupant). This becomes extremely useful with playback when the information is sent to a synthesizer. The synthesizer itself can be thought of a specific address (a Port). Many synths are multitimbral, meaning that they can receive and process MIDI data on multiple independent channels (they have multiple residents, keeping with the analogy). One channel of the synthesizer can be set to produce a piano sound while another can play a vibraphone sound, for example. The MIDI Specifications allow for sixteen different channels on each port. Let’s use the MIDI file we’ve been working with to illustrate this.

[edit] Configuring MIDI to work with a Synth

First we’ll need to load up our MIDI Synthesizer. Many forms of synthesizers exist and many are extremely complex and powerful, yet at theall will receive MIDI data, process it, and produce sound we can hear from it.

In addition to the General MIDI synth that comes standard on all computers, many sequencers possess the ability to load additional synths. For our example we’ll use Garritan samples powered by Kontakt Player 2. These are technically samplers- they use specially programmed, recorded sounds as their sound source to play back MIDI information.
In the Sonar sequencer that we’re using in this example, the Kontakt Player Synth is going to load as a plug-in VST. It also works as a standalone separate program. With it running in the sequencer though, it’s easier to get the MIDI file information to it, because all of our routing is confined to the sequencer.

Loading VST plug-ins varies from sequencer to sequencer, so consult your manual on how to insert the Kontakt Synth if you’re following along. Once loaded, we’ll just need to assign the routing from our MIDI tracks properly and cue up the instruments we want to use in our synth and we’ll be all set!

Assigning the Channels in the Synth
Assigning the Channels in the Synth
Assigning Channels in Sonar 7
Assigning Channels in Sonar 7
Assigning the Port to the Synth in Sonar 7
Assigning the Port to the Synth in Sonar 7



Remember how the file had two tracks? We can assign each track to a different channel. First though, let’s set our output ports from these midi tracks to the Kontakt Synth. Then, after loading some instruments in our synth (I chose a Piano and Vibraphone from the Big Band library I have), all we need to do is make sure that the output channels from our tracks line up with the right input channels on our synth, and we have some music!


[edit] MIDI Messages

Some common MIDI Continuous Controller (CC) Messages one may have to use while using Garritan products:

CC Use
1 Modulation Wheel (Controls 7 and 11 together)
7 Volume
11 Expression (Timbre)


[edit] Further Reading

MIDI on Wikipedia

MIDI for Technophobes

MIDI for the Professional

Personal tools
Garritan Wiki