Description | Communication Protocol | Hardware Interconnection
Description |
MIDI is abbreviation for Musical Instruments Digital Interface. It is standard of communication between electronic devices. Initially, it was only the interconnection of electronic musical instruments – synthesizers – that transfers only basic data to other devices. Gradually, another field of musical electronic music were added and today, the MIDI standard employs almost all technologies used by musicians. In addition to basic communication between electronic and electrified musical instruments, next types of communication are standardized:
SDS – Sample Dump Standard
SMF – Standard MIDI File
MFD – MIDI File Dump
MTS – MIDI Tune Standard
MTC – MIDI Time Control
MMC – MIDI Machine Control
MSC – MIDI Show Control
GM – General MIDI
MPE – MIDI Polyphonic Expression
and others.
The first official version of the standard was published on August 5, 1983 with the MIDI 1.0 Specification name. A year later, the MMA (MIDI Manufacturers Association) organization was founded. MMA coordinates all events in MIDI since then. In MMA publications, visitors can find details of all sections of MIDI.
Communication Protocol |
MIDI communication protocol is based on CCITT recommendations V.24 for RS232C interface. The communication is asynchronous, unidirectional. Bus idle state is represented by a logical one. The transmission starts with a start-bit with logical zero level, followed by eight data bits with logic level 0 or 1 in the order of LSB (least significant bit) → MSB (most significant bit) and transfer of the byte finishes one-stop bit with logic level 1. Baud rate is 31250 baud, the transmission of one byte therefore takes 320 microseconds (start bit + 8 data bits + stop bit = 10x (1/31250) = 0,00032 [sec]).
Each message begins with so called Status byte, followed by none, one or two Data bytes. Exceptions are special system messages (System Exclusive Messages) that contain any number of data bytes. The status and data bytes differ in the most significant bit (MSB). On its position, the status byte includes always 1 and the data byte includes always 0.
Data stream on MIDI bus
MIDI messages and commands are divided into two basic groups (see tables below):
Channel Messages
They are valid only for devices that are set to receiving channel number (1 to 16) corresponding to the number encoded in the status byte of the message. One device can respond to multiple channels, eg. multitimbral instruments are controlled for each voice by a single MIDI channel.
Common System Messages
They are valid for all devices connected to the MIDI bus.
So up to 16 devices controlled independently via channel commands (MIDI channels 1 to 16) can be connected to one MIDI bus but all these devices will react to common system commands simultaneously.
Channel messages
Status byte [hex] | Number of data bytes | Meaning |
---|---|---|
8n | 2 | Note Off |
9n | 2 | Note On |
An | 2 | Polyphonic (Key) Aftertouch |
Bn | 2 | Control Change |
Cn | 1 | Program Change |
Dn | 1 | Channel Aftertouch |
En | 2 | Pitch Wheel Change |
n represents number of MIDI channel (0h to Fh) |
System messages
Status byte [hex] | Number of data bytes | Meaning |
---|---|---|
F0 | x | Start of System Exclusive |
F1 | 1 | MTC Qtr Frame |
F2 | 2 | Song Position Pointer |
F3 | 1 | Song Select |
F4 | – | undefined |
F5 | – | undefined |
F6 | 0 | Tune Request |
F7 | 0 | End of System Exclusive |
F8 | 0 | Timing Clock |
F9 | – | undefined |
FA | 0 | Start |
FB | 0 | Continue |
FC | 0 | Stop |
FD | – | undefined |
FE | 0 | Active Sensing |
FF | 0 | Reset |
x represents any number of data bytes |
Some exceptions are applied for MIDI messages and commands transfer:
Channel messages can be received and transmitted in the “Running Status” mode. This means that the status byte can be followed with more data blocks without the need to repeat the status byte. For example, the string B0h 07h 64h 08h 40h 01h 00h is fully equivalent to string B0h 07h 64h 08h 40h B0h B0h 01h 00h. The result of usage of “Running Status” is saving two bytes and therefore the data flow acceleration.
If value of second data byte (ie. “Velocity”) of the channel message Note On is 00h, it means actually command to turn off the “note”. This enables to skip transmitting of Note Off messages in the “Running Status” mode. For example, the string 90h 80h 3Ch 7Fh 3Dh 64h is fully equivalent to string 90h 00h 3Ch 7Fh 3Dh. The difference is again only in saving status byte and the acceleration of data flow. The downstream device will work the same way in both cases.
System Real Time messages have absolute priority and they can be inserted into the data stream absolutely anywhere, even between data bytes of other messages including SysEx Messages. Real Time messages must not disrupt the other message in which are possibly inserted. Also, they don’t suspend “Running Status” mode.
MIDI device must not respond to an undefined status byte and to a messages they do not understand (not implemented in the device).
Hardware Interconnection |
Hardware of MIDI communication takes place through 5 mA current loop. Cables with 5-pin DIN 41524 (5 pins / 180°) plugs are used for interconnection of MIDI devices. Only pins Nr. 2, 4 and 5 of the cable plugs are connected. One cable always carries data in one direction only. The maximum recommended cable length is 15 meters.
Recently there are also devices (e.g. Korg) that use Jack 1/8″ plugs instead of standardized DIN 41524 plugs.
A devices capable of communication over MIDI bus are usually equipped with three DIN connectors that are labeled as MIDI-IN (input data), MIDI-OUT (output data) and MIDI-THRU (throughput data). Standard internal wiring of these connectors is shown below. The important thing is that MIDI-IN connector has not connected pin Nr. 2 (ie. cable shielding – ground). This is to the galvanic insulation of individual devices and thus to avoid malfunctions of data transmission due to the hum of their different ground potentials. For the same reason, the MIDI-IN data input is galvanically insulated with optocoupler.
The MIDI-OUT (MIDI-THRU respectively) output of a MIDI device can be connected to input (MIDI-IN) of only one next MIDI device! If you need to connect a MIDI output to two follow-up devices (ie. to split MIDI bus), connection shown on diagram below can be tolerated. However, the requirement is that both devices are permanently connected, even though it is currently used only one of them. Otherwise, the current loop is not closed. Due to the increased voltage drop on two serially connected optocouplers on both MIDI inputs, normalized loop current is not guaranteed – such solution will work with some devices and with some other it will do not.
Parallel connection of two devices to one MIDI output is totally unacceptable. In that case, the MIDI output would have to supply output current twice (but it is limited by a resistors in the output circuit). More over, it happens in parallel connection of two optocouplers on MIDI inputs that an optocoupler with a smaller dynamic resistance “pulls” the majority of the loop current to themselves and unacceptable data drop-out will be on the other optocoupler. Only usage of Thru Box, Patch Bay and similar devices ensures proper distribution of data from one MIDI output to multiple MIDI inputs.
Even more complicated situation arises when merging data from two or more MIDI output to one MIDI input is necessary. There’re no workaround exists. It is absolutely necessary to use Merge Box or similar device. When merging bus is not just about impedance and current relationships, but also the logic of passing data – integrity and continuity of the blocks of messages, message priority, the right sort data in “Running Status” etc. This can guarantee only data processing processor (e.g. Merge Box 2×1).