This post is long overdue. Actually, it’s overdue: I released MIDI Aid for Mac and MIDI Aid for iPad, iPhone and iPod touch.

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

The MIDI Manufacturers Association has a specification for MIDI messages, but it can be a bit hard to understand at first.

In general, every message has a maximum of three bytes. There is one big exception called a “SysEx” message, but those 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 arrived. This first byte is followed by one or two data bytes.

As an example we use the “Note On” message. This is triggered when pressing a key on a MIDI controller; in the following example it will be middle C pressed with medium velocity—exactly between mezzo piano and mezzo forte.

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

Second byte: Note number from 0–127; 60 is C4 (middle C).

Third byte: 0–127: Note velocity— how hard the key was pressed.

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

  • Channel: Events that are channel-specific, like the “Note On” event above.
  • System Common: Independent of a specific channel.
  • System Exclusive: Vendor-specific messages.

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

Done for today!