1.0 What is MIDI? Musical Instrument Digital Interface. It is the means by which synthesizers communicate either with a computer or another synthesizer. The term "synth" will be used throughout most of this discussion and will be used generically to include a large range of devices. These can include drum machines, sequencers, guitars and signal processors. Before MIDI, the ability of a synth to communicate with the outside world was limited. Originally, it could play a single note. The sound it made was determined by the way in which it's electronic modules were "patched" to- gether. However, as the evolution of the technology progressed, so did the complexity and capabilities of the synth. Soon, the synth had the ability to alter it's sound by entering data through it's front panel controls and to store groups of these settings as "patches". One only had to press a switch to get a new sound. With these new abilities came new problems. Only so many front panel controls could be put on the device. Only so much mem- ory could be installed. If one was to make full use of the synth, one had to gain the ability to manipulate large amounts of information. The advent of affordable computers opened the door to the world of MIDI. The computer allows the synthesist to easily program patches, store them, rearrange the order in which they are accessed from the synth and even record events that occur on the device so that they may be reproduced by the synth under control of the computer. Great efforts were made by the music community to stan- dardize the MIDI protocol and MIDI was born. 1.1 What is a MIDI Interface? Computers are much higher on the evolutionary ladder than are synths. They have been designed to suit the needs of the computer world. It was up to the musical instrument manufacturers to make their devices compatible with the standards of computers. After much deliberation, an answer was found. It was decided that the computer would receive an electronic device that would communicate with the computer using a parallel data format. That same device would communicate with the synth using a serial format. Para- llel format means sending all parts of a given piece of data at one time. This piece of data is a byte of 8 bits. Serial format means sending all parts of a given piece of data one bit at a time. This piece of data is, once again, a byte of 8 bits. But, there are 2 other bits associated with a byte when transmitted serially with MIDI. These are the START and STOP bits. The START bit is sent to allow all devices concerned time to realize that a byte is about to be sent. The STOP bit is sent to indicate the end of the byte. Thus, a total of 10 bits are sent per byte. The rate at which these bit are sent is 31,250 Hz, equivalent to approximately 32k baud in terms of a modem. This frequency can be easily derived by dividing most standard computer clock frequencies by using digital logic in the interface. The levels between which the bits shift will be described only as a logic "0" and a logic "1". The electronic theory involved in describing the logic lev- els further is beyond the scope of this particular tutorial. The START bit is always a "0" and the STOP bit is always a "1". A MIDI line that is idling is always a "1". The START bit is always obvious to the interface. The connect- ing cable over which MIDI data is transmitted has (normally) 2 con- ductors inside a shield (braided wire or foil surrounding the 2 conductors.) The connectors are refered to as DIN connectors and have 5 pins arranged in a 180 deg. arc. The housing is keyed so it will only go in one way. A MIDI port that transmits is called a MIDI "OUT" port. A MIDI "OUT" port may drive (transmit to) only one input. This is by definition in the official MIDI specification. A MIDI port that receives is called a MIDI "IN" port. Many synths also have a port called MIDI "THRU". This port is used to pass on the data the device is receiving to another synth that may be hooked up down the line. 1.2 Summary In essence, MIDI is a system that allows one or more MIDI devices to communicate via a serial data line. Furthermore, it allows for the addition of a computer interface to convert the serial data transmission to a parallel format suitable for use by that computer. Since the data has a stand- ard format, it can be easily manipulated with the computer and re- transmitted for use by the MIDI devices. Such a system is similar to the player piano of days gone by. It can literaly play itself when properly programmed. The effect of such a system is limited only by the equipment available to the user. The use of such a system is limited only by the imagination of the user. It is the intention of the author to be as accurate as possible. No single source can ever be knowledgable in every respect. It is always suggested that additional references be consulted to insure the highest quality of the knowledge sought. 2.0 MIDI Information In the beginning, the synthesist played a synth and music came out. Now with MIDI equipment, not only does music come out, but so can alot of other information. The following is a discussion of what kind of information typically comes out of the MIDI synth. The abundance of information available precludes discussing all of it at this time. However, the most common items will be covered in order to familiarize the reader with a simple MIDI system and the way it exchanges information. 2.1 The MIDI Event Typically, anything that happens within a MIDI system is called a MIDI Event. Play a note on a synth and an event occurs that describes what happened. In other words, when the note is played, specific data is output through the MIDI output port to whatever is there to receive it. There are two basic catagories of information that is transmitted. Status bytes and Data bytes. Status bytes describe what the event is. Data bytes describe how a status byte is to be utilized. As was discussed in the previous chapter, MIDI events are transmitted as a series of 1's and 0's. The first byte to be sent is the status byte. This alerts the system as to what is happening. Take the note played on the synth. The status byte for this event is called Note On. The binary representation of Note On is 1001nnnn (ignore the 4 n's for a moment.) Now, Data bytes have to be sent to tell the system WHAT note has been played and HOW it was played. The two Data bytes associated with Note On are note # and key velocity. The binary forms for these bytes are 0kkkkkkk and 0vvvvvvv. The lower case letters in these bytes represent variables. The bits found in these locations are the dynamic data that occurs when playing a synth. Their form is typical of MIDI implementation sheets found at the back of the manuals that accompany synths. The k's in note # equal the note number in binary whose range is 0 to 127. Each key on a keyboard has a standard value assigned to it (sometimes these values can be altered. But that will be left for later discussion.) There aren't 127 keys on a keyboard, but often the electronics allow for going beyond the range of the physical keyboard (an advantage of MIDI.) 0 is the lowest note and 127 is the highest. For example, A440 is note # 57. So, the note # byte would be 00111001. The v's in the second Data byte are the velocity value. Once again, the range is 0 to 127, where 0 equals the softest velocity (actually no velocity or no sound) and 127 is the loudest. The greater the velocity with which a key is struck, the louder it sounds. Some synths do not have velocity sensitive keyboards, so in order to fulfill the MIDI requirement for a Note On event, it will send a value of 64 for velocity. The byte for velocity, therefore, would be 01000000. This describes a single event. The Note On event, in its entirety, is: A440 - Status Data 1 Data 2 1001nnnn 00111001 01000000 This leaves the discussion of what the n's stand for in the Status byte. MIDI provides a means for transmitting data over seperate channels. This is the same as the way a computer separates its transmissions peripherals. One might assign various instruments to different channels. One might use one keyboard as a master controller and have another synth "slaved" to it (controlled by the master.) It might be desirable to have a third synth that is independent of the master (to avoid being affected by the master.) In this way, a computer could control the master synth (which is controlling the slave) with data on one channel and control the third synth with different data on another channel. This is only one simple possibility. So, the Status byte has two parts. The high nibble (upper 4 bits) is the event, Note On, and the lower nibble (lower 4 bits) is the channel over which the data is being sent. There are 16 channels available. The range is 1 to 16, but the binary representations of these channels are 0000 (ch. 1, binary 0) through 1111 (ch. 16, binary 15.) To transmit Note On over channel 1, the Status byte would be 10010000 (Note On=1001, nnnn=0000.) For channel 6, nnnn would be 0101, or 1111 for channel 16. The Note On event will cause the synth to play a note. Since it is designed to play that note as long as a key is held down (Note On), The synth will continue playing. It must know when to stop playing. In order to complete the exchange, a Note Off event is transmitted when the key is re- leased. The structure is the same as a Note On event except the status byte has a different value. Note Off for A440 is: A440 - Status Data 1 Data 2 1000nnnn 00111001 01000000 Once again, nnnn represents the channel number. To end the original note properly, the channel number is the same for both events. Data byte 1 is the same note (#57) and data byte 2 is the release velocity. It is more common for a synth to transmit velocity for Note On than it is to transmit velocity for Note Off. Never the less, it is there for more articulate synths. For those synths that don't transmit Note Off velocity, a value of 64 is sent to complete the event. Note: It is not uncommon for a drum machine to send out only Note On. Since percussion sounds are not normally sustained, they end quickly and naturally. Therefore, manufacturers will allow the event to end without the need for a Note Off. The advantage is that there will be less data to transmit and possibly slow down the system. The disadvantage is that if you want the drum machine to control a synth, the notes transmitted will continually play. 2.2 Status Bytes and Data Bytes Although both the Status and Data bytes are 8 bits long, there is a fundamental difference between the two. Without this difference, the system would have no way of knowing which is which. Notice the MSB (Most Significant Bit) of both bytes. The Status byte has a 1 and the Data byte has a 0. In binary, this means all Status bytes have a value of 128 (10000000) to 255 (11111111). Data bytes have a value of 0 (00000000) to 127 (01111111). From a programming standpoint, this makes it easy to identify a byte. By simply checking the MSB, a program can identify the byte as a Status byte if the MSB is SET (1) or as a Data byte if it is CLEAR (0). 2.3 Summary The most basic MIDI event described above causes a synth to play a note for a given time. The complete event is initiated by transmitting Note On and is terminated with Note Off. The entire event of bytes is commonly refered to as a MIDI Message. The MIDI message is made up of two sets of three bytes. Note On starts with a Status byte followed by two Data bytes. Note Off starts with a Status byte followed by two Data bytes. For A440, the message looks like this: Status Data 1 Data 2 1001nnnn 00111001 01000000 (Note On, #57) followed by: 1000nnnn 00111001 01000000 (Note Off, #57) This is only a small sample of the codes available. Look through the manual that accompanies a synth to see what more is available. Even that list will probably be incomplete but it will serve to expand the "vocabulary" initiated here.