MD_MIDIFile Standard MIDI File Processing 2.6
Library to play Standard MIDI Files (SMF)
Hardware Interface

The MIDI communications hardware is a opt-isolated byte-based serial interface configured at 31,250 baud (bps). The standard connector is a 5 pin DIN, however other types of connections (like MIDI over USB) have become increasingly common as other interfaces that had been used for MIDI connections (serial, joystick, etc.) disappeared as standard features of personal computers.

Standard MIDI IN, OUT and THRU Ports

Standard MIDI cables terminate in a 180 degree five-pin DIN connector. Standard applications use only three of the five conductors: a ground wire, and a balanced pair of conductors that carry a +5 volt signal. This connector configuration can only carry messages in one direction, so a second cable is necessary for two-way communication. These are usually labeled IN and OUT designating the messages going into and coming out of the device, respectively.

Most devices do not copy messages from their IN to their OUT port. A third type of port, the THRU port, emits a copy of everything received at the input port, allowing data to be forwarded to another instrument in a daisy-chain arrangement. Not all devices contain THRU ports, and devices that lack the ability to generate MIDI data, such as effects units and sound modules, may not include OUT ports.

Opto-isolators keep MIDI devices electrically separated from their connectors, which prevents the occurrence of ground loops and protects equipment from voltage spikes. There is no error detection capability in MIDI, so the maximum cable length is set at 15 meters (50 feet) in order to limit interference.

A circuit using the Arduino Serial interface is shown below. This can be built as a stand-alone interface or incorporated into an Arduino shield. This is based on the device described at http://www.stephenhobley.com/blog/2011/03/14/the-last-darned-midi-interface-ill-ever-build/.

![MIDI Interface Circuit] (MIDI_Interface.jpg "MIDI Interface Circuit")