MIDI
Musical Instrument Digital Interface
A communications protocol created for interfacing synthesizers and other electronic musical instruments including computers
MIDI Hardware
Typical synthesizer or other computer music instrument contains:
- performance controllers
- front panel controls
- microprocessor
- memory
- voice circuitry
- MIDI in, out, thru ports
Hardware Specs
- 31.25 kBaud
- Asynchronous transfer
- Start bit/8 data bits/Stop bit
- DIN 5 pin connector
- MIDI cable, maximum length 50 ft
- MIDI messages travel in only one direction along MIDI cable (not bidirectional)
MIDI In, Out, Thru Ports
MIDI IN
Allows a device to receive MIDI messages for its microprocessor to execute
MIDI OUT
Used to transmit MIDI messages from the device's microprocessor to another device
MIDI THRU
Used to pass an unaltered copy of MIDI IN to another device
MIDI Configurations/Devices
Master/slave
Multiple slaves
- daisy-chaining (using THRU ports)
- tree branching (using a MIDI THRU box)
MIDI Channels
16 MIDI Channels
Possible to transmit as many as 16 independent performances over a single MIDI cable
MIDI instruments can be set to receive messages on specific channel(s) to play only specific data on the MIDI data cable
MIDI Terms
Monophonic
Only one note can be assigned to play on one MIDI channel
Polyphonic
More than one note can be assigned to play on one MIDI channel
Omni On
Ability to interpret messages on all MIDI channels
Omni Off
Ability to interpret messages on a single MIDI channel
MIDI Byte Formats
Status bytes - contains commands: the most significant bit (bit 7) of a status byte is always set to 1
Data bytes - the most significant bit (bit 7) of a data byte is always set to 0 (data values 0-127)
MIDI Message Formats (see handout for detail)
Channel Voice Messages
voice commands for MIDI channel(s)
Channel Mode Messages
commands for polyphonic/monophonic/omni response
System Common Messages
commands for all MIDI channels
System Real-Time Messages
high-priority messages for all MIDI channels
System Exclusive Messages
commands for specific MIDI devices only
Channel Voice Messages
1xxxnnnn 0ddddddd 0ddddddd
xxx = status type nnnn = channel number ddddddd = data value
Note Off
Note On
Polyphonic Key Pressure
Control Change
Program Change
Channel Pressure
Pitch Wheel Change
Channel Mode Messages
1011nnnn 01111xxx 0ddddddd
nnnn = channel number xxx = controller ID ddddddd = data value (optional 2nd data value)
Reset All Controllers
Local Control
All Notes Off
Omni Mode Off
Omni Mode On
Mono Mode On
Poly Mode On
System Common Messages
11110xxx 0ddddddd 0ddddddd
xxx = system common type ddddddd = data value (optional 2nd data value)
MTC Quarter Frame
Song Position Pointer
Song Select
Tune Request
End of Exclusive (EOX)
System RealTime Messages
11111xxx
xxx = system realtime type
Timing Clock
Start
Continue
Stop
Active Sensing
System Reset
System Exclusive Messages
11110000 0ddddddd ............. 11110111 11110000 00000000 0ddddddd 0ddddddd .............. 111101111
dddddddd = manufacturer ID (possibly two bytes)
Used to define special commands that only particular hardware devices can understand and execute
Writing MIDI Software
Messages arrive and transmit in the following formats:
- normal format
- running status format
- prioritized format (for system realtime messages)
Running Status
Redundant status bytes are not retransmitted for each command.
For example: if three consecutive MIDI messages have the same status byte, the status byte is transmitted with the first MIDI message
only.
Prioritized
Can interrupt any other MIDI message
Example: MIDI Clock messages are generated 96 times for each whole note length. Must be sent without delay in order to keep MIDI
devices in sync.
Parsing MIDI Data
Every incoming byte must be identified as either a MIDI status byte or a data byte.
Use a status buffer variable to hold the value of the last received channel voice or channel mode status byte, with the following exceptions:
- the buffer should be cleared on startup or whenever a system common, system exclusive or ignored channel message status is received
- the buffer should be left unaltered whenever any system realtime message is received
The parsing routine can use the value of the status buffer to select the appropriate message processing routines.
The program should ignore all incoming bytes while the status buffer value is zero.
Use a counter variable to keep track of the order of received bytes. It should be cleared whenever a new, recognized status is received. It should be incremented by one each time a subsequent data byte is received, starting with the first data byte, and set to 1 when the final byte of the message is received.
The counter should not be altered if a system realtime status byte is received.
Processing routines for each recognized message can use the counter value to determine which byte of a message they are currently processing.
Standard MIDI Files ( see handout example)
Consists of 2 types of "chunks"" header and track chunks
Three defined MIDI File Formats
- 0: one header, one track
- 1: one header, one or more tracks
- 2: one header, independent tracks
Header chunk must come first
MIDI File Meta Events
FF 58 04 nn dd cc bb - nn,dd: time signature - cc: number of MIDI clocks per beat - bb: number of 32nd notes per MIDI quarter note (24 clocks)
FF 59 02 sf mi - sf: number of sharps/flats in key (0 = note, 1 = 1 sharp, -1 = 1 flat, etc.) - mi: major/minor key (0=major, 1=minor)
FF 2F 00 end of track
COURSE INFORMATION | HOMEWORK ASSIGNMENTS
COURSE PROJECT | CS240 HELP DESK