MIDI is a simplex local area packet network that operates at 31.25 (+/- 1%) KBaud. It is defined at the physical layer, the data-link layer and the network layer.
The physical layer definition of MIDI consists of an electrical specification. The data-link layer describes how bits are grouped into data frames (called MIDI messages). It is also responsible for flow control and error correction. These are typically defined in special data transfer protocols (i.e., MIDI Dump format). The network layer is responsible for routing MIDI messages from their source to their destination. Typically network connections are either point-to-point or broadcast. MIDI connections are typically broadcast, however, people have built the so called "MIDI Channel Filters" to act as MIDI message routers. These types of devices are classed as being in the network layer and are able to create either a point-to-point connection or a broadcast subnet [Dowty 1988] [IMA 1990]. Typically, connections in MIDI are made with shielded twisted pair wire, but the type of wire is not mentioned in the Specification. The connections are made via a 5 pin male DIN connector (i.e., Switchcraft 05GM5M). Figure 1-1 show the schematic for the connections between DIN plugs and a shielded cable. Pins 1 and 3 are used by the Atari 520ST for a MIDI through connection [Boom 1987]. But the MIDI specification says that they are to be left unconnected and the Atari use is non-standard.
Figure 1-1. DIN to DIN Connections
By using cables with uniform wiring and sex, the MIDI Specification avoids the circus which results from the RS-232 style DCE-DTE connections. The connector is viewed from the front.
Simplex communications are one-way, duplex communications are two-way. The MIDI serial stream is an asynchronous transmission with a start bit, 8 data bits and a stop bit. Thus, there are a total of 10 bits for a period of 320 microseconds per serial byte (3,125 bytes of data per second). The start bit is a logic 0 (asserted high) and the stop bit is a logic one (asserted low). Bytes are sent least significant bit first. This bit ordering is consistent with most serial data communication links (i.e., EIA-232, RS-422, etc.). The format of a MIDI byte is shown in Figure 1-2.
Figure 1-2. The Format of a MIDI Byte
The data is ordered just like a typical serial line.
Since a MIDI byte is limited to 8 data bits, it can never exceed a value of 255. In the balance of this chapter, we shall use groups of decimal numbers (base 10), to describe the MIDI messages. This is in contrast to the mixed base presentations in many text books (and in the MIDI specification itself). The reason is that this author has encountered confusion among non-professional programmers when explaining the radix changes.
MIDI communications are divided up into packets called messages. MIDI messages describe events. There are five types of midi messages, Channel Voice, Channel Mode, System Common, System Real-time and System Exclusive (SysEx). The MIDI message taxonomy is shown in Figure 1-3.
Figure 1-3. The MIDI Message Taxonomy
Channel Voice messages are used to transmit performance events to one of 16 channels. Channel Mode Messages specify channel and voice assignments. System Common messages specify preset songs and beat locations. System Real-time messages convey timing references. System Exclusive messages communicate in a brand and sometimes model specific way to an instrument.
The following is MBNF (Modified Backus-Naur form) for MIDI Packets. MBNF is a metalanguage. The symbol ::= indicates metalinguistic equivalence; a vertical bar (|) indicates a choice among a list of items; items which follow one another are concatenated. Integer ranges, i.e., 0..4, are the same as 0|1|2|3|4.
1. <MIDI Stream> ::= <MIDI msg> <MIDI Stream>
2. <MIDI msg> ::= <sys msg> | <chan msg>
3. <chan msg> ::= <chan 1byte msg> | <chan 2byte msg>
4. <chan 1byte msg> ::= <chan stat1 byte> <data singlet> <running singlets>
5. <chan 2byte msg> ::= <chan stat2 byte> <data pair> <running pairs>
6. <chan stat1 byte> ::= 192..223
7. <chan stat2 byte> ::= 128..191|224..239
8. <data pair> ::= <data singlet> <data singlet>
9. <data singlet> ::= <realtime byte> <data singlet> | <data byte>
10. <running pairs> ::= <empty> | <data pair> <running pairs>
11. <running singlets> ::= <empty> | <data singlet> <running singlets>
12. <data byte> ::= 0..127
13. <realtime byte> ::= 248 | 250..252 | 254 | 255
14. <sys msg> ::= <sys common msg> | <sysex msg> | <sys realtime msg>
15. <sys realtime msg> ::= <realtime byte>
16. <sysex msg> ::= 240 <data singlet> <running singlets> 247
17. <sys common msg> ::= 242 <data pair> | 243 <data singlet> | 246
The next four subsections describe the four types of midi messages, Channel Voice, System Common, System Real-time and System Exclusive. All MIDI messages have two things in common, they describe a single event and they start with a status byte. The format of the status byte is dependent upon the MIDI message type.
[ Index | Previuos Paragraph | Next Paragraph ]