MIDI, or Music Instrument Digital Interface, is a standard protocol for sending musical information between electronic devices. The protocol was established in 1982 and is used by professional and amateur musicians alike. A typical setup which employs MIDI is shown below:
In this setup the sound module has sythesized or sampled sounds which we want to turn on and off at the right times to create music. The MIDI signal tells the sound module when to turn the sound on, which note and type of sound to play, and controls sound effects (such as volume, reverb, velocity, panning, etc ). Note that the MIDI signal does not contain any of the sounds themselves, that is in the sound module. If an example MIDI signal were translated into words it would simply be:
Turn sound #5 On and play a C# with a velocity of 100
Midi is a asynchronous serial connection operating at 31,250 baud. It uses a 5-pin din connector to transmit the signal. The signal consists of 1 start bit, 8 information bits, and 1 stop bit. A single MIDI message is typically 2-3 bytes long. Most MIDI messages are sent on to a single channel, which is specified in the MIDI message. Each channel is associated with a specific sound (eg. Violin, piano, harp, etc ) in the sound module which is defined at the beginning of the song. When a message such as turn note on at channel 2 is received the module knows that a piano (or whatever instrument is assigned to that channel) is supposed to be turned on. There are a maximum of 16 channels that can be used. Although this may appear limiting, the instrument associated with a channel can change throughout the course of a song. So a maximum of 16 different sounds can only sound at the same time.
There are 2 types of MIDI bytes that make up a single MIDI message: status bytes
and data bytes. A status byte defines the
action which will take place, such as note-on or note-off.
Status bytes also tell the sound module which channel the MIDI message is directed
at. Data bytes define which note is to be
played (eg. C# or Bb) and how that note is to be played (ie. Volume
or velocity). Velocity, which is typically
the second data byte of a MIDI message, defines how forcefully the note is to
be played. A typical MIDI message is shown
There are 2 types of MIDI bytes that make up a single MIDI message: status bytes and data bytes. A status byte defines the action which will take place, such as note-on or note-off. Status bytes also tell the sound module which channel the MIDI message is directed at. Data bytes define which note is to be played (eg. C# or Bb) and how that note is to be played (ie. Volume or velocity). Velocity, which is typically the second data byte of a MIDI message, defines how forcefully the note is to be played. A typical MIDI message is shown below:
MIDI controls the timing of when notes play in the simplest possible way, all MIDI events happen immediately when they are received. So no timing information is contained in the MIDI signal, the controller or keyboard is what determines the timing of MIDI events. This also means that since MIDI operates on a serial interface MIDI cannot turn more than one note on or off at a given time. It is still possible to have many notes playing simultaneously but they cannot be turned on and off at exactly the same time. The message length determines the smallest time delay between MIDI events. Since MIDI operates at 31,250 baud this time delay is usually inaudible. However, for complicated music where several messages are sent simultaneously, the delays can add up to be noticeable. To help prevent these delays the status byte will sometimes be left off in a series of MIDI messages which all have the same status byte.
The device built in this project is a MIDI controlled guitar using the HC11 Motorola Micro-controller. The guitar is solely controlled through the MIDI interface. The guitar can play the first four frets on all six strings plus all open strings. This gives the guitar a range of approximately an two and a half octaves. All out of range notes are not played. The guitar is set up to only respond to MIDI messages sent to channels 1 and 2. When the velocity portion of the MIDI message is received all values greater than 0 are played the same way. At a velocity of 0, though, the note does not sound. The guitar can be controlled using a keyboard, computer sound card, or any other controller which sends a MIDI signal. For this project we control the guitar with a keyboard and a sound card. The computer control with the sound card is achieved via MIDI sequencing software. This software enables the user to view, edit, and play MIDI events.
A block diagram of the program is shown in the figure below. This program has two main functionalities:
(1) The program reads and interprets the incoming MIDI data and prints the received message on the screen
(2) The program sends control signals to the guitar based on the received information
Interpretation of the MIDI data is based on the guidelines outlined in the MIDI Specification 1.0 published by the MIDI Manufacturers Association. The MIDI information is received through the serial port on the HC11 (Pin PD0). Since the MIDI messages must be immediately interpreted and acted on, the software uses interrupts for all MIDI processing. The software also checks for read errors, improper messages (eg. 2 status bytes sent back to back), and filters non-applicable messages (eg. Out of range notes).
The text writing portion of the program (not shown in above figure) uses a circular buffer to store the interpreted MIDI information that will be printed to the screen. The text writer functions outside of the interrupt service routine. Therefore the text writer will pause when new MIDI information is received to give the reading and interpretation of MIDI data (the interrupt portion of the program) a higher priority. If the text writer is overloaded it will stop receiving data from the MIDI interpreter until the old MIDI data is written to the screen.
The HC11 sends control signals which turn the fingering and plucking solenoids on and off. Controlling the guitar was complicated by the fact that there are only 21 outputs from the HC11 and we needed to control 35 solenoids. We solved this problem using addressable latches (these will be further discussed in the Circuitry portion of the paper). Each latch holds data in its output pins till the HC11 rewrites new data to the pin. The output pins of each latch control each solenoid. The signals that the HC11 sends to pluck and finger each note are shown in the Fingering and Plucking conversion table (below).