MIDI notes

From Helpful
Jump to: navigation, search
This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

MIDI buses

Serial MIDI

The classic, seen on thirty years of devices.

This is a fairly standard serial port, in one direction, sending octet packets, at 31250 (±1%) baud.

The plug is the 180-degree 5-pin DIN variant (see also IEC 60130-9).

DIN pin numbering
(note that some pinout charts use their own numbering, so pay attention)
  • 1 NC
  • 2 Shield (disconnected on the receiving side)
  • 3 NC
  • 4 Source
  • 5 Sink

Each device connection (pin 4+5) is a ~5mA current loop (rather than voltage-referenced), so being able to drive ~5mA comfortably much is more important than precise voltage.

...and in most devices you effectively drive the LED part of an optocoupler, so you mostly just need to add a reasonable resistor for the voltage you have (and the max current your output pin can sink, which these days is rarely limiting).

MIDI cables may only have 3 wires, but might have 5.

This isn't relevant to standard uses of MIDI, since pins 1 and 3 are unconnected in sockets, on both ends.

There are non-standard devices that do use the extra pins, though.

The three ports, roughly according to the MIDI spec

In the schematic on the right:

  • D1 is used to protect the optocouple from reverse polarity, but also from cable effects. Most any fast-switching diode will do.
it's a good idea for DIY, though could be omitted.
  • R1 is current-limiting resistor for the optocoupler's LED.
frequently 220 Ohm but this doesn't matter very precisely
  • R2 is a current limiter and pullup(verify), and is often a higher value (0.5k .. 10kOhm), maybe check your optocouple specs
they're in the original MIDI specs because, at the time, many things couldn't directly drive 5mA (and in those specs it's two triangles, because two inversions on e.g. a 74LS14 hex inverter ICs was a simple and cheap solution)
These days you're probably using a microcontroller, which tend to have buffers on each pin that can drive on the order of 30mA, so you could omit this
It's still not a bad idea (ease-of-repair-wise) to protect your IC by using a transistor, though. Same for the diode.
Then it's a good idea to use a resistor (here R4, R6) to limit the current through it.
  • cable shield should be connected only on the source side (avoids ground loops)
...within the devices, that is. The cable itself should connect it on both ends so that cable doesn't have a direction.
note that the socket on the IN end should not connect the DIN barrel/pin 2

Simplified somewhat, showing wire shield, and drawn to clarify the "you're mainly just powering that LED through a long wire" view.

Plugging around devices

MIDI is one-directional.

In a chain, earlier device can play (only) any later devices, because that's the direction messages go.

This means the order devices are hooked up in matters.

And you'ld generally put just-controllers earlier, just-synths at the end.

If more than one playable-and-controllable thing is involved (this includes PC DAWs), you have to think about it a little harder.

There are some footnotes to hardware's sockets. In particular, they may have:

  • MIDI IN - usually means it plays sounds in response to messages
  • MIDI THRU - a copy of of the IN plug (buffered but otherwise direct)
  • MIDI OUT - means it can be the origin of notes/messages

Note that THRU connections in series will slowly add timing errors (due to optocouple time), so if you have a house full of devices in a single long chain you may notice some latency from start to end. Few people will run into this, and you can reduce it by adding splitters early (building a tree instead of one long chain).

On 3.5mm TRS

Slimmer devices started using 3.5mm (and sometimes 2.5mm) TRS plugs on the device, with adapters to 5-pin DIN.

These weren't all wires the same way, so MMA decided to set a standard.


MIDI and power

MIDI does not carry power. (This also helps it avoid ground loops)

There are some devices that use pins 1 and 3 to provide power. I haven't yet found anything on conventions about polarity or voltage.

There is also the rare oddity that puts something else on pins 1 and 3. In theory that conflicts, but doing it wrong usually requires you to wire an output to an output, with a 5-wire cable, and chances are decent against you doing that.

Still, if you want this in your design, consider the slightly safer option of using a 7-pin DIN socket, because the extra two pins won't connect when inserting a standard 5-pin plug.


This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

USB-MIDI protocol is mostly modelled on serial MIDI packets, though it adds a few things, like a field called Cable Number, mostly for ease of routing(verify).

Since the transfer rate of USB is much higher (and devices are connected individually anyway), the timing pileup serial MIDI has is basically absent (though note it's not a realtime bus, so there are still some footnotes to this).

Distinct devices connected via USB-MIDI appear as distinct controllers with one MIDI device on them, so there's more focus on routing within the host (usually a PC) than before.

USB-MIDI is part of the USB standard, which means PCs support it easily, but more interestingly that relatively simple simple USB devices and hosts can speak it.

For example, an arduino with USB host shield can talk to USB-MIDI keyboards/pads with little code.

It also makes interconnecting less universal than DIN-to-DIN, as you now need a PC -- or something else designed for this interchange, like a USB midi host. There are also Raspberry Pi / Arduino style solutions. [1]


Expect between 3ms to 6ms of added latency(verify) possibly more, depending on bluetooth version and a few other practical details.

If it stays on the low end of that, that's good enough for many uses.

There are various DIY projects using Bluetooth BLE modules


This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

RTP-MIDI (a.k.a. AppleMIDI, but it's open and unlicensed) is MIDI over RTP/IP, where RTP is typically run over UDP(verify).

So this amounts to MIDI over Ethernet or WiFi.

(With some additional things like RTP doing automatic retransmission)

On LAN, latency should be about as good as serial MIDI, and it can sometimes be a practical way to link many things together, or do so over a larger distance.

On WiFi you can't really guarantee latency to always stays under an acceptable level, so

best case it just works,
worst case you can't even fix it.

On the Internet you'll have at least your broadband's latency, which is often on the order of ~7-10ms of latency, so ehhh.

Note that latency jitter doesn't directly mean inaccuracy, see e.g. https://tools.ietf.org/html/rfc4696#section-6

OSX since Tiger (10.4) has RTP-MIDI. It's that thing called "Network" in the MIDI setup. It's also in iOS since 4.2 (so ~2010, iPhones around 3G)

there's various tools, like https://www.tobias-erichsen.de/software/rtpmidi.html

Beyond that, the limited need, and the existance of things like it (like OSC), means it's not in widespread use, though there are implementations on many platforms, and a bunch of interesting DIY hardware it's being used on.


Byte protocol

Note that some of this focuses on the serial nature of the original serial implementation, and works a little differently in other variants.

Devices can ignore a messy message and focus on a new one immediately, without any state, because the highest bit is set only in the start byte of a message, and additional bytes never do. (The only sort-of-exception is SysEx, which also ends with one, but still should not contain any)

Message types are conceptually subdivided like:

  • Channel Message
    • Channel Voice messages - Note On, Note Off, and other voice triggering stuff
    • Channel Mode messages - say what the voices should do in response to voice messages (see more below)
...note that this is similar to ControlChange (which fall under Channel Voice)
  • System Message
    • System Real Time messages - meant for synchronization between MIDI devices (that support this, relatively few(verify)).
    • System Common messages - meant for all receivers, regardless of channel. Also used for some external hardware like tape (not seen very often).
    • System Exclusive (a.k.a. SysEx) messages
sent to a specific Manufacturer's ID
mostly to allow manufacturer-specific communication (though there are some predefine universal ones)
Also used to implement MIDI Machine Control
Due to variable-length behaviour, terminated with a specific package.

Channel voice

The most central in the music-making sense:

  • NoteOff
1000cccc 0nnnnnnn 0vvvvvvv
(note that NoteOn with a velocity of 0 is basically equivalent to a note off message)
  • NoteOn
1001cccc 0nnnnnnn 0vvvvvvv
where c refers to channel, n to note, and v t velocity
note is C0 to G10 (8Hz..12kHz) in semitone steps, so e.g. middle C is 60
e.g. an 88-key keyboard will use ~three quarters of the full 0..127 range
velocity of 64 is often used when there is no touch sensitivity
  • PitchBend
were V is an unsigned 14-bit integer value (0..16384) (lowest 7 bits are sent first)
the halfway value 8192 means no pitch bend.
The amount of tone range that the extremes correspond to is chosen by the listening side
apparently often either two semitones(verify)
the sending side can choose a smaller range by using less of that fairly large integer range

And perhaps

  • Aftertouch is further expression to playing notes.
Few instruments send it, few synths instruments listen to it, but it's nice to use when you have it (also, DAWs typically allow mapping it to something)
On keyboards (that have it) it is usually a force sensor that only does a thing when you lean harder into keys, and isn't particularly related to velocity. It's often also per-channel, i.e. there's just one sensor below all keys.
In some other cases (e.g. sensitive pads) it can be a more of a 'how softly you are letting go', and often also polyphonic (sent for each key, not per channel)
If sensed per key, it is sent in Polyphonic Key Pressure (1010cccc 0nnnnnnn 0vvvvvvv)
If sensed overall, it is sent in Channel Pressure (1101cccc 0vvvvvvv)

  • ControlChange is meant for when the state of a footswitch, pedal, slider, etc (a usually-physical controller) changes
1011cccc 0CCCCCCC 0vvvvvvv
where C is controller number, and v is a value
controller number....
120 through 127 have functions like reset, mute, local control, omni on/off, poly on/off - and are considered channel mode messages, see below
0 through 101ish change how a synth behaves on a specific channel
some for specific controller types controller types (breath, foot)
many to specific synth parameters (portamento, soft, volume, balance, attack, sustain, release, brightness, detune, channel volume, other effect amount)
...except for pitch bend - which has its own message (see above)
6,38, 96,97, 98,99, 100,101 are involved in a more free-form extensible thing, including the RPN and NRPN extensions (which also allow 14-bit values)

  • ProgramChange
1100cccc 0nnnnnnn
change the instrument patch. General Midi has a standard list, not all hardware need follow this.
this idea is extended by ControlChange 0, though it's less stanardized how
on some hardware (e.g. drum machines) it may have other functions


Control Change are intended as "sent when a physical knob changes".

These were intended to alter parameters of a synth on a particular channel.

Since most synths listen to relatively few,

this is great for mapping knobs to arbitrary DAW functions
you can easily get away with picking a bunch of them for custom controllers
there's a bunch of semi-standards based on CCs - some of which conflict


Channel mode

CC messages with controller numbers 120 .. 127 are interpreted as Channel Mode Messages.


120: All Sound Off
121: Reset All Controllers
122: Local Control
basically, local=off says "you, a keyboard+synth, should send notes to MIDI out instead of playing yourself (also still plays what it gets)" (verify)
123: All Notes Off - useful for sequencers, particularly in the context of omni and poly
124: Omni Off
125: Omni On
126: Mono (note: has a parameter)
127: Poly

Omni=on means messages received from all channels are played.

Mono means a new NoteOn should end the previous note

You may want this for portamento/glissando
and makes sense for some instruments, like guitar controllers

More specifically,

Mode 1 (Omni On, Poly) - from all channels
Mode 2 (Omni On, Mono) - from all channels, control one voice
Mode 3 (Omni Off, Poly) - from specific channel, to all voices
Mode 4 (Omni Off, Mono) - from specific channel, to specific voices


Some controllers and DAWs have a 'panic' button used for "argh I have no idea why you are still making sound, please stop it". This sends 123 and/or 120. And sometimes also NoteOff for all notes, in case a sound producer doesn't understand 123.

System Messages

All 1111....

Divided into

System Common Messages (1111000 through 11110111)
SysEx (11110000 (data) 11110111)
System Real-Time Messages (1111000 through 11111111)
all single-byte, no data

There's time/song/tuning stuff is in both these sections, so there's no huge distinction except some scheduling detail (e.g. real-time messages may be sent during SysEx).

SysEx is used for a lot of stuff that fits nowhere else

e.g. device-specific interaction stuff (usually in the manual) that doesn't suit CCs
some parameter upload stuff (e.g. DX7 SysEx)

MIDI monitors may report all of this as SysEx, just because most of it's special-cased control stuff.

SysEx takes the form of

0xF0 (SysEx start)
Manufacturer ID (1 or 3 bytes), helps synths decide whether it should try to read the message [2]
a variable amount of bytes
0xF7 (SysEx end)

On timing, bandwidth, latency

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

Serial MIDI is fixed at 31250 baud/second, slow by modern standards. Not too bad and was easy to implement at the time.

Sending a byte (counting start and stop bits) takes 320 microseconds, and since messages are one, two, or three bytes long, most things arrive in under 1 millisecond.

Yet wanting to send, say, 10 messages all at once means the last will by physically put on the wire ~10ms later.

There are a few tricks to alleviate this on serial MIDI, including but not limited to:

  • Running Status skips the first byte of a message if it's the same as the last.
e.g. allowing shortening of a handful of NoteOns, or a bunch of CCs,
  • Note that a running-status NoteOn with velocity 0 is one byte shorter than a NoteOff
and understood as identical same by most synths

The throughput limit rarely matters to human playing, because our timing is never robotically perfect, and saturating the bus with note messages would require playing so fast it wouldn't be musical.

It can start to matter with

MIDI sequencers, which may wish to send a bunch of things exactly on a beat
continuous change of pitch/modulation wheel, polyphonic aftertouch, or other fast CC
but an even slightly clever controller prioritizes note playing higher, so this should not matter
The strongest argument (for something faster) may be Polyphonic Expression (altering parameters per played note), as that is currently often implemented assigning notes and their alterations on channels, round-robin.
again, there are alleviations, but

In USB-MIDI, the data that is transmitted is almost entirely the same, but due to the way it is packed and the higher speeds involved, the latencies don't really add up anymore. (The latency of USB itself is still ~1ms, though, due to the way the OS handles it).

MIDI Sync and timing

Beat clock




Mackie Control Universal (MCU), and Mackie's HUI, and (also audio IO), refers to a physical controller for DAWs (just Logic at first), originally from the late ninties and originally specific to Logic.

These days there are many alternatives to such devices, often with their own (also often proprietary) protocols

MCU/HUI is for a large part just a specific convention on top of MIDI.

The point of this is mostly to have a standard for all the things it wanted, rather than telling you to manually map lots of CCs to specific controls before anything much worked.

Other DAWs and devices have chosen to support this for compatibility/feature reasons.

It's implemented mostly in SysEx. While it was kept closed for years, there's decent documentation available e.g. in logic control, MIDI Implementation section.

MMC (MIDI Machine Control)

MSC (MIDI Show Control)


MVC (MIDI Visual Control)

MIDI Visual Control Specification.pdf

Fragmented notes on mapping

MIDI files

Other stuff

Octave numbering


General MIDI


Scaled Polyphonic MIDI was targeted mainly at ringtones on simpler/earlier mobile phones.

It allows SMF files to say how they should be simplified to play on devices that make only simpler sounds.


MIDI software

MIDI hardware and DIY

More expression, and MPE

MIDI 2.0

See also

See also: