MIDI Audio
MIDI, the Musical Instrument Digital Interface, is a protocol for sending musical performance data between instruments and computers. It carries no audio itself; it sends short messages, up to sixteen channels of them, that a synthesiser turns into sound. A Standard MIDI File stores those messages with timing, so a whole performance can be replayed.
Overview
A MIDI stream is a sequence of byte messages. Most are channel messages tagged with one of sixteen channel numbers, so up to sixteen parts play at once, each on its own instrument. A message is a status byte followed by one or two data bytes, and running status lets repeated messages drop the status byte to save space. The classic hardware link runs at 31250 baud, but a file or an internal sequencer has no such limit.
| Property | Value |
|---|---|
| Channels | 16 |
| Message form | Status byte plus 1 or 2 data bytes |
| Note range | 128 notes (0 to 127) |
| Velocity | 7-bit (0 to 127) |
| Serial rate | 31250 baud (hardware link) |
Channel voice messages
The messages that actually make notes are the channel voice messages. Note on and note off start and stop a pitch with a velocity; program change picks the instrument for a channel; control change sets continuous parameters such as volume, pan and modulation; pitch bend slides a note; and aftertouch responds to key pressure. Each carries a channel number, so the same message type drives any of the sixteen parts.
| Message | Data | Role |
|---|---|---|
| Note on | Key, velocity | Start a note; velocity 0 acts as note off. |
| Note off | Key, velocity | Stop a note. |
| Program change | Program | Choose the channel's instrument (0 to 127). |
| Control change | Controller, value | Set a parameter: volume, pan, modulation, sustain. |
| Pitch bend | 14-bit value | Bend every note on the channel. |
| Aftertouch | Pressure | Respond to key or channel pressure. |
General MIDI
General MIDI fixes what the program numbers mean, so a file sounds broadly right on any GM device. Programs 0 to 127 name a standard instrument set grouped into families, and channel 10 is reserved for percussion, where each note number is a different drum. This is what lets a tune play back with piano as piano and drums as drums on unrelated hardware.
| Program range | Family |
|---|---|
| 0 to 7 | Pianos |
| 16 to 23 | Organs |
| 24 to 31 | Guitars |
| 32 to 39 | Basses |
| 40 to 47 | Strings |
| 56 to 63 | Brass |
| Channel 10 | Percussion kit, note number selects the drum |
Timing and files
A Standard MIDI File (SMF) stores the messages with timing. Time is measured in ticks, a division set in the header as pulses per quarter note, and tempo events say how long a tick lasts. Events are stored with delta times, the gap since the previous event. Files come in three types: one merged track, several parallel tracks, or a set of independent sequences.
| Element | Meaning |
|---|---|
| Format 0 | One track, all channels merged. |
| Format 1 | Several tracks played together. |
| Format 2 | Independent sequences. |
| Division | Ticks per quarter note (PPQN). |
| Delta time | Ticks since the previous event. |
| Tempo | Microseconds per quarter note. |
Playback and synthesis
Because MIDI makes no sound on its own, playback needs a synthesiser to render the messages: a General MIDI sound module, a wavetable card, an FM chip such as the OPL, or a software synth. In the sequencer, the MIDI data is the score, and the chosen voice, whether a real device or an emulated chip, provides the sound. This is why the same MIDI file can drive very different timbres.
| Source of sound | Notes |
|---|---|
| GM sound module or wavetable | Sample-based instruments per program number. |
| FM synth (OPL) | Register writes per note, as on AdLib. |
| Software synth | Rendered on the host from the message stream. |
Sequencer role
As a sequencer target MIDI is the common command core in protocol form. The sequence sends discrete events and continuous-controller streams, and the chosen synthesiser turns them into sound and runs the envelopes, so from the sequencer's side MIDI is all event-driven; nothing is latched in a chip.
| Command | Kind |
|---|---|
| Note on / off | Event |
| Program change | Event |
| Control change (volume, pan, modulation) | Event or automation |
| Pitch bend | Automation |