MIDI
Music as three-byte messages on a 31,250 baud serial line.
What a Note On means
Three bytes, split into bits: the top bit marks status versus data, and the rest carry type, channel, note and velocity.
Whole frame
Three bytes say: channel 1, play note 60 (middle C), at velocity 100. The top bit of each byte tells status from data, so a receiver that joins mid-stream resynchronises on the next status byte.
| Field | Offset | Example value | Meaning |
|---|---|---|---|
| Status flag | Byte 0, bit 7 | 1 | 1 = this byte starts a message |
| Message type | Byte 0, bits 6–4 | 001 = Note On | 001 = Note On. Other types: 000 Note Off, 010 poly pressure, 011 control change, 100 program change, 101 channel pressure, 110 pitch bend. |
| Channel | Byte 0, bits 3–0 | 0 = channel 1 | 0–15 on the wire, shown to musicians as channel 1–16. 0 = channel 1. |
| Data flag | Byte 1, bit 7 | 0 | 0 = a data byte, so only 7 bits remain for the value |
| Note number | Byte 1, bits 6–0 | 60 = C4 (middle C) | 0–127. 60 is middle C (C4); each +1 is one semitone. 69 is A4 = 440 Hz. |
| Data flag | Byte 2, bit 7 | 0 | 0 again: every data byte keeps the top bit clear |
| Velocity | Byte 2, bits 6–0 | 100 (fairly loud) | 0–127: how hard the key was pressed. 0 means Note Off. |
Overview
MIDI 1.0 (1983) lets keyboards, synthesizers and computers talk. It is not audio: it carries events such as 'key pressed' and 'knob turned'. The wire format is a UART at 31,250 baud, and each message is one status byte followed by one or two data bytes.
The design trick is the top bit: status bytes have it set (0x80–0xFF), data bytes have it clear (0x00–0x7F). A receiver can join the stream at any moment and find message boundaries.
Key facts
- Wires
- Current loop on 5-pin DIN (or USB)
- Speed
- 31,250 baud (8N1)
- Message size
- 1–3 bytes (+ SysEx)
- Channels
- 16
- Note range
- 0 – 127
- Direction
- One way per cable
The same message on the wire
Underneath it is plain UART: start bit, eight data bits least significant first, stop bit, three times.
Whole frame
One note-on takes about one millisecond on the wire: 30 bits at 31,250 baud. Ten notes at once take 10 ms, which is why dense chords can smear in old MIDI gear.
Start
Start bit, always 0: the same UART framing as any serial port. MIDI is simply UART at 31,250 baud, 8 data bits, no parity, 1 stop bit.
Status 0x90
The status byte: the top bit is 1 (that is how a receiver tells status bytes from data bytes), 001 means Note On, and the low nibble 0 is MIDI channel 1.
Stop
Stop bit, always 1. Note the whole message is 3 × 10 = 30 bit times, about 0.96 ms.
Note 0x3C (C4)
Data byte 1: the note number. Data bytes always have a top bit of 0, leaving 7 bits (0–127). 0x3C = 60 = middle C.
Velocity 0x64
Data byte 2: how hard the key was struck, 0x64 = 100 out of 127. A Note On with velocity 0 is treated as Note Off.
Running status
When consecutive messages share a status byte, the sender may leave it out. This was a bandwidth saver on a slow cable.
Whole frame
Running status drops repeated status bytes. A C major chord goes out in 7 bytes instead of 9, a 22% saving that mattered a lot on a 31,250 baud cable.
| Field | Offset | Example value | Meaning |
|---|---|---|---|
| Status 0x90 | Byte 0 | Note On ch.1 | Sent once: Note On, channel 1. |
| Note 60 (C4) | Byte 1 | 0x3C = 60 | First note: C4. |
| Velocity 100 | Byte 2 | 0x64 = 100 | How hard: 100. |
| Note 64 (E4) | Byte 3 | 0x40 = 64 = E4 | No status byte here! A receiver that sees a data byte (top bit 0) reuses the previous status. This is running status: the second note costs 2 bytes instead of 3. |
| Velocity 100 | Byte 4 | 0x64 = 100 | Velocity for the second note. |
| Note 67 (G4) | Byte 5 | 0x43 = 67 = G4 | A third note, again without a status byte: the C-major triad C4-E4-G4 is complete. |
| Velocity 100 | Byte 6 | 0x64 = 100 | Velocity for the third note. Total: 7 bytes instead of 9. |
Where you meet it
- Keyboards, drum pads and controllers talking to a DAW or synth
- Stage lighting and show control (MIDI Show Control)
- USB-MIDI and Bluetooth-MIDI carry the very same messages
Watch out for
- The wire format is not 38400 or 115200: it is exactly 31,250 baud, which is 1 MHz / 32. Plain PC serial ports cannot do it; microcontrollers can.
- Channels are 0–15 on the wire but 1–16 on screens. Off-by-one confusion is common.
- A stuck note usually means a Note Off was lost. Many devices respond to 'All Notes Off' (controller 123).
Standards
- MIDI 1.0 Detailed Specification (MIDI Manufacturers Association)