8.1 MIDI primer

Uncategorized — roguescience @ 5:13 pm

In part 5 we learned that the Arduino sends and receives data via serial - conveniently this is the same communication protocol that MIDI uses :)

MIDI Primer

I will leave learning about the details of the MIDI protocol up to you - don’t worry, there are a few million websites that cover the specification. Instead I focus only on what you NEED to know to start sending MIDI data out of your Arduino. This will enable you to connect to the 1000s of instruments and programs that support MIDI.

A MIDI message is made up of three BYTES.

BYTE 1: Status

The status BYTE is a number between 128-255 and is used to specify whether the data is Note ON, Note OFF, Polyphonic key pressure, Control change, Program change, Monophonic key (channel) pressure, Pitch bend, or System exclusive.

Each of the 8 commands has 16 channels i.e. Note ON on channel 1 = 144, Note ON on channel 2 = 145, Note ON on channel 16 = 159 etc.

LOVE THE HEX

MIDI data is often represented using the HEXIDECIMAL number system - a base-16 number system that goes 0-9 a-f i.e. 0-9 are the same as base-10 then a=11, b=12 etc. HEX isn’t used because it looks cool or because it annoys people - it is used to make your life easier. It was originally used to make binary code more readable (another story) but in the case of MIDI - using a base-16 language makes a lot of sense.

For example

Note On on channel 1 = 144, Note On on channel 2 = 145, note ON channel 16 = 159 etc. In HEX a Note On always starts with a “9″ followed by a channel e.g. Note On channel 1 = 0×90, Note On channel 2 = 0×91, Note On channel 16 = 0×9f. If you still find it easier to remember in Decimal than go ahead and use it - just be prepared to lose some nerd street cred.

BYTE 2: Value 1 (0-127)

BYTE 3: Value 2 (0-127), not all commands have a second value.

To send bytes out the D1/TX pin on theĀ  Arduino use the serial function Serial.print().

One last thing. Midi serial communication takes place at a baud rate of 31250.

Ok. Time to hook up a MIDI port.

0 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2010 Roguescience Arduino Tutorials | powered by WordPress with Barecity