More about MIDI
- Introduction
- controllers
- channel voice messages
- note on
- note off
- program change
- pitch bend
- control change messages
- changing MIDI channel modes
- MIDI channels and MIDI modes
- MIDI timecode
Introduction
A MIDI message consists of a status byte and a number of data bytes.
Each byte has a start bit, 8 bits and a stop bit. With 8 bits any number from 0 to 255 can be formed. The highest value bit is called the Most Significant Bit and the lowest value bit is the Least Significant Bit.Each 8-bit byte can be divided into two 4-bit nibbles. These are sometimes referred to as the most significant nibble and the least significant nibble.
- all status bytes have the MSB set to 1.
- all data bytes have the MSB set to 0.
Controllers
The word "controller" may be used in connection with MIDI instruments in two ways..
- a device (eg. keyboard) which controls other instruments by transmitting MIDI messages,
- a message which sets the individual controls of a MIDI instrument.
Modern digital musical instruments would need a multitude of single purpose knobs and switches to make all the possible adjustments or selections. Instead a smaller number of multi-purpose buttons are usually provided with a liquid crystal display (L.Q.D.) to show which function has been selected. The MIDI instrument is normally played via its own keyboard (or whatever). If this local control is switched off then the instrument can only be played via its MIDI input. The control messages which can be sent out from the master instrument are of two types, switch controllers and variable controllers. Switch controllers simply turn a facility (eg. modulation) on or off . Variable controllers are MIDI messages which can change the parameters of a particular facility (eg. change the shape of an envelope ).
From the musician's point of view, the important control messages are the channel voice messages. These control the voices of an instrument.
Channel voice messages
Channel voice messages control the voices of a MIDI instrument by switching notes on/off, changing the "loudness" and varying the pitch etc.Note on
The note on channel voice message consists of 3 bytes. The first byte contains the channel number and the note on code. The second byte gives the note value (ie. pitch). The range of values is from 0 to 127. Each increment raises the pitch by one semitone.
The 128 note values (0 to 127) therefore give a pitch range of 10.5 octaves.
The third byte of the note on message gives the keyboard velocity.
On a conventional piano the harder you hit a key, the faster the key moves and the harder the hammer strikes the string. Hence the louder the note sounds. Keyboard velocity depends on the time taken for a piano key to move from the up position to the down position where it strikes the string. On a MIDI keyboard therefore, the digital code which determines how loudly a note is sounded is called keyboard velocity.Some instruments do not have velocity sensitive keys. Nevertheless a velocity value must always be transmitted; it will be expected by the receiving instrument. In this situation a middle value of 64 is transmitted.
So, a note-on message consists of 3 bytes...
1. Channel number + status (eg. "Ch.3" + "note-on") 2. note value (pitch) 3. keyboard velocity value (loudness).Note Off
Once a note has been switched on it will sound until it is switched off again. It is possible to switch a note off by setting the "note on" keyboard velocity value to zero. Some manufacturers use this method. However the standard method is to use a separate channel voice message, the "note off" message.Again this consists of 3 bytes..
1. Channel number + status (eg. Ch.3 + "note off") 2. Note value (pitch) 3. Velocity value (zero).
MIDI can send information about several notes on each channel and may send on several channels simultaneously. Therefore the note off message must contain the channel number and note value so as to make it clear which note is to be turned off.Program Change
The controls of a synthesizer can be preset to give a particular sound. When the controls are altered to a different series of settings a different sound is obtained. Each preset selection is called a program.A program change message permits the preset sounds (programs) of an instrument to be changed at any time. All the instrument voices may use one program or a different program may be assigned to each voice.
The program change message is a 2 byte message..
1. Channel number + status (eg. Ch.3 + "message change") 2. Program number.With 7 bits, only 128 program numbers (0 - 127) are available, so it is not practical to standardize MIDI program sounds. Program number 13 (for example) cannot be reserved to produce a flute sound from all MIDI synthesizers.Pitch bend
The pitch of a note can be altered by small amounts ie. much less than the semitone increments set by the "note on" channel voice message. This is called pitch bending.Pitch bend is a 3 byte command..
1. Channel number + status (eg. Ch.3 + "pitch bend") 2 + 3. Data bytes producing a (7 + 7 =)14 bit number.
The range of numbers available with 14 bits is 0 to 16,384. This range of numbers permits extremely fine pitch control. Unfortunately such fine control (high resolution) requires a large number of messages to be transmitted in a short period. Some manufacturers prefer to use a dummy (zero) byte for one of the 3 bytes in the pitch bend message. This provides an adequately smooth pitch variation without the problem of transmitting large amounts of data at high speed.Return to top of this page
Control change messages or "Controller messages"
Another category of MIDI message, the controller message, alters note parameters (eg. envelope amount).
The controller message is also 3 byte.1. Channel number + status (eg. Ch.2 + "control change") 2. Control number (the number of the control to be changed) 3. Value(the new value to set the control to).Some controls merely need to be switched on and off but others are variable. A range of 0 to 127 may not be adequate for some variable controls so control messages may be paired to give 14-bit resolution.As with pitch bend there is a problem with transmitting all this data at a fast enough rate. In practice therefore most equipment uses 7-bit resolution for variable controller messages.
Most of the available MIDI control change numbers are unassigned. The control numbers which are assigned by convention are given in the Table, below .
These few conventionally assigned controllers are sufficient to give basic compatibility between MIDI instruments.
Control change numbers and their functions VARIABLE CONTROLS (0 - 63) Modulation wheel 1 Breath controller 2 Foot pedal 4 Portamento time 5 Data entry 6 Main volume control 7 SWITCH CONTROLS (64 - 95) Sustain pedal 64 Portamento 65 Sostenuto 66 Soft pedal 67 UNASSIGNED CONTROLS (96 - 120) CHANNEL MODE MESSAGES (121 - 127) Reset all controls 121 Local control 122 All notes off 123 Omni mode off 124 Mono mode on 126 Poly mode on 127 The unassigned controllers enable equipment such as automated audio mixers to be set by MIDI control change messages.
Changing channel modes with control-change messages
You will notice from the table that MIDI control numbers 121 to 127 are reserved for switching MIDI modes (see below) via an interface.
Take mode 4 (omni off/mono) as an example of how to select a MIDI mode using control change messages..
- a message to controller 124 switches OMNI mode OFF
- a message to controller 126 switches MONO mode ON
- midi messages
- midi channels
- system messages
- operating modes
- using MIDI modes
- Summary
MIDI messages
MIDI information is transmitted and received one bit at a time. A small current (5mA) is switched on and off rapidly. Current on represents Logic 0, current off represents Logic 1. Each 0 or 1 in a MIDI message is called a bit. In computer jargon, a group of 8 bits is called a byte. Each MIDI message consists of a number of bytes, typically 1, 2 or 3 bytes. Each byte is preceded with a start bit and succeeded by a stop bit. The first byte in a MIDI message is sometimes called the header byte.MIDI Channels
MIDI has 16 channels, numbered 1 to 16. Channels allow MIDI messages to be directed (channelled) to a particular device. This is made possible by placing a channel number in the header byte of a MIDI message. Channel numbers allow messages to be directed to a particular instrument in a multi-instrument setup. Channel numbers also allow messages to be directed to a particular device within an instrument eg. to a particular voice.System messages
System messages do not have a channel number. These messages are responded to by all instruments in the setup that recognize the message.Operating modes
Operating modes govern how a device deals with MIDI channels.Channels may be selected by
- all instruments in a multi-instrument setup
- one or more instruments
- just one voice
There are four standard MIDI operating modes. There are also some nonstandard modes but all MIDI instruments respond to at least one of the standard modes. The standard modes are numbered 1 to 4. They are also known by names such as "Poly" and "Mono".
Mode 1
This is the most basic mode. All MIDI equipment should be able to operate in this mode. MIDI Instruments set to Mode 1 respond to messages on all channels. Channel numbers are ignored. A slave instrument in this mode will try to play everything played on the master instrument. Incoming note messages are assigned to any available voice. On polyphonic instruments all voices should therefore be set to play the same sound otherwise the results will be unpredictable.Mode 2
This mode is intended for monophonic instruments. All incoming note messages are assigned to one voice. Polyphonic instruments are downgraded to monophonic when this mode is in use. Instruments respond to information on any channel. If too many note messages are received at one time an instrument may play the highest pitched note, or the lowest , or the last received. Different manufacturers deal with this problem in different ways.Mode 3
In Mode 3 one channel is directed to all the voices of a receiving instrument. Several notes can be played at once (on a polyphonic instrument). Each receiving instrument ignores all channel messages except for those on the chosen channel. This mode allows up to 16 instruments to be played independently by a sequencer. A large setup can therefore be controlled using Mode 3 but it would be expensive to take full advantage of this feature.Mode 4
Polyphonic instruments can play a number of voices simultaneously (eg.8). A Multitimbral instrument can assign different timbres (trumpet or trombone or clarinet etc.) to each voice. Thus a multitimbral instrument can produce a number of timbres (sound qualities) simultaneously. In mode 4, each MIDI channel is assigned to a different voice and each voice is given a different timbre. An 8-voice multitimbral instrument could give 8 different timbres simultaneously. A 16-voice multitimbral instrument could give 16 different timbres simultaneously. Each channel only provides monophonic operation. Unless an instrument allows a different timbres to be assigned to each voice there is little point in using Mode 4
(use Mode 1).
MIDI modes 1 Omni On / Poly Responds to notes on all channels Polyphonic 2 Omni On / Mono Responds to notes on all channels Monophonic 3 Omni Off / Poly Responds to notes on 1 selected channel Polyphonic 4 Omni Off / Mono Responds to notes on 1 selected channel Monophonic
The names of the modes have changed over the years.
On old equipment....
OMNI = MODE 1, POLY = MODE 3, MONO = MODE 4
Using MIDI modes
Equipment must be set to the correct mode for a system to work properly. Most instruments default to Mode 1 at switch-on.Mode 1
This mode is adequate for a Master - Slave, two instrument, setup. Both instruments play in unison. Only one sound can be played.
Mode 2
This is not a very useful mode because only one note can be played at a time.
Mode 3
MIDI mode 3 directs one channel to all voices. To make full use of this mode one instrument is required for each channel. It would, therefore, be expensive to fully exploit this mode.
Mode 4
MIDI mode 4 is an affordable alternative to Mode 3. Each MIDI channel is directed to one voice. If the instrument is 16-note polyphonic and 16-sound multitimbral, 16 different sounds (timbres) can be played simultaneously.
Mode 4 uses a lot of channels to play chords. An eight note piano chord, for example, would require 8 MIDI channels.Summary
MIDI messages
- MIDI information is transmitted and received one bit at a time.
- A small current (5mA) is switched on / off.
- Current ON = Logic 0, current OFF = Logic 1.
- Each 0 or 1 is called a bit.
- A group of 8 bits is called a byte.
- A MIDI message consists of a number of bytes, often 1, 2 or 3 bytes.
- The first byte is sometimes called the header byte.
Channel messages
- Channel messages carry a channel number in the header byte.
- The channel number in the header byte allows a MIDI message to be directed to a particular instrument or to a particular voice.
System messages
- System messages do not have a channel number.
- System messages are responded to by all the setup's instruments
(that recognize the signal).MIDI channels
- MIDI has 16 channels, numbered 1 to 16.
- MIDI channels allow MIDI messages to be directed to a particular device.
Operating modes
- MIDI modes govern how a device deals with MIDI channels.
- Mode 1(Omni On / Poly) is the most basic mode.
- A polyphonic instrument set to Mode 1 responds to notes on all channels.
- Instruments usually default to Mode 1 at switch-on.
- Mode 4 (Omni Off / Mono) allows each channel to be directed to
a separate voice in a multitimbral instrument.
- Introduction
- MIDI Clock Messages
- Song Position Pointers
- MIDI Timecode
- Time stretching
- Automation
Introduction
Any MIDI device which records data (eg. a sequencer) needs timing information so that the data can be replayed at the correct rate. Those MIDI devices which do not record data (eg. synths and effects units) do not use timing information. Timing information can be transferred between MIDI devices via the MIDI link. There is no need for separate synchronization connections.MIDI Clock Messages
MIDI clock signals are not simple pulses. Each clock message is a single byte. Clock messages are sent at the rate of 6 per semiquaver
(a semiquaver = "sixteenth note" ).
A MIDI clock "beat" is the duration of one semiquaver - so there are 6 MIDI clock messages per MIDI beat.So, a MIDI sequencer refers to a position in a sequence of events in terms of musical divisions such as beats and bars. The MIDI beat does not therefore occupy a fixed amount of time. Its duration depends on the speed ("tempo") of the music. This is in contrast with timecode (SMPTE, EBU) where the timing information relates to "real" time (seconds, minutes, hours). Both methods of determining position are useful in their respective applications but in the modern studio it is necessary to reconcile the two. Nowadays recording studios integrate MIDI systems and audio recording systems. This integration is achieved by relating MIDI timing data to timecode recorded onto tape.
Song Position Pointers
When a sequencer "fast-forwards" to a new position in a song it can transmit its new position to other devices in the system by sending a song position pointer (SPP) message. This is a 3 byte message.The SPP indicates the song position in MIDI beats (semiquavers) from the start of a song. The limit of the system is 16,384 MIDI beats (semiquavers). When a controlling device sends out a SPP message , the receiving devices automatically set their counters to the received value. A receiving device may take a little while to respond to a SPP message. Song position pointers work well within music-only systems - where the tempo of the music is a common factor.
Sometimes the time that an event occurred is more important than the musical beats indicated by a SPP. Suppose, for example, sequenced music is to be dubbed onto a video sound track so that a cymbal crash coincides with a visual event at a certain time [measured from the beginning of the tape]. If the tempo of the music is changed the SPP of the cymbal crash will remain the same but in real time it will occur either sooner or later. So the SPP cannot be used to synchronize the visual and audio events if there is any variation in tempo. What is required is synchronization where MIDI events can be triggered at real times (mins, secs) regardless of the tempo.
MIDI Timecode
One way to reconcile the two timing systems is the generation of MIDI timecode (MTC). Timecode (SMPTE or EBU) read from an audio tape is changed into MIDI message format which can be transmitted around a MIDI system with other MIDI messages.There are two kinds of MTC message
Quarter-frame messages and full-frame messages can be sent in forward or reverse order so that MIDI devices can remain in sync with tape machines running forwards or backwards.
- quarter-frame messages which update the receiving device regularly when the transmitting device is running at normal speed
- full-frame messages are used during spooling, when updating at the quarter-frame rate would result in an excessive rate of data transmission
Timing information received from a tape recorder using conventional timecode (SMPTE or EBU) is thus distributed as MIDI timecode (MTC) around a MIDI system.As well as distributing timing information, MTC allows a MIDI controlling device to programme other MIDI ("slave") devices. Once the slave devices have been "setup" (programmed) they will execute predetermined events when they are cued by MIDI timecode messages. These MIDI timecode messages can be derived from the SMPTE or EBU timecodes read from a tape track.
All the cue-point information can be stored on disk along with the other MIDI information. It may also be possible to "dump" the MIDI information onto a tape track so that the 'real' music and sequenced music are archived together.
Time stretching
The relationship between the timecode and MIDI events can be changed by altering the tempo. This is referred to as time compression /expansion. A composer might, for example, alter the tempo of a piece of sequenced music to fit a scene recorded on video. Calculating the tempo change need not be a matter of trial and error. The percentage speed change can be calculated by the sequencer.Automation
In addition to the synchronization of tape recorders and sequencers, MTC is increasingly being used in a variety of automated equipment.
Mixing console automation is currently resulting in interesting developments in the integration of mixer control and MIDI sequencing. MTC can be used to control channel routing and muting, leaving the engineer free to experiment with levels, EQ, panning etc. A number of mixer settings can be prepared in advance away from the mixing console (prepared "off-line").
© D.Barnes 1997
Music Technology Handouts/revised October 1997