Skip to main content

The Anatomy of a MIDI Message

·2 mins

This post is long long overdue. Actually, its overdue since I have release MIDI Aid for Mac and MIDI Aid for iPad, iPhone and iPod touch.

We have the code to receive MIDI messages (see [this post]({% post_url 2015-03-10-on-coremidi-callbacks %})), but we don’t know yet how these messages look like. Let’s figure it out in this post.

The MIDI Manufacturers Association has a specification for MIDI messages, but it is a bit weird to understand at first.

In general, every message has a maximum of three bytes. There is one big exception that is called “Sysex” message, but they are not important for now and will not be covered in detail here. The very first byte is the status byte and determines the kind of message and on which channel it came in. This first byte is being followed by one or two data bytes.

As an example we use the “Note On” message. This one will be triggered when hitting a note key on a MIDI controller, in the following example it will be the middle C being pressed down with a medium velocity, that would be exyctly between mezzo piano and mezzo forte. Is there actually a term for that?

MIDI Message Format

First byte: The first four bit indicate the type of the message and the second set of four bit tell us on which channel it has been received. Your MIDI device can have a maximum of 16 channels. In this example, we do have a Note On event (1001 -> 9) on channel 0 (0000 -> 0).

Second byte: Note number from 0 - 127, whereas 60 is C4 (middle C)

Third byte: 0 - 127: Note velocity, meaning how hard the key has been pressed.

We can also group all messages depending on their purpose. I use that in MIDI Aid for the filtering mechanism to get a better overview in the GUI.

  • Channel: Events that are channel specific. Like the “Note On” event from above for example.
  • System Common: Independent from a specific channel.
  • System Exclusive: Vendor specific messages.

When implementing MIDI Aid I was mainly referring to this overview. That one really helped me a great deal!

Done for today!