Crash Course to Midi with Teensyduino: Part 1

In order to design a midi controller with Teensyduino, it’s best to understand a little about how midi messages are used and formatted, what commands Teensyduino requires to create these messages (and receive messages), the settings you switch to turn your Teensy device to midi controller mode (and back again for programming). I’ll try to keep it brief, including just what you need to know to get started.

What is midi?

MIDI (Musical Instrument Digital Interface) is a standard which lays out how to send and receive messages between musical instruments, computers, and other devices, such as lighting, and even rides in theme parks. It lays out exactly how a message should look and what cables should be used, although USB is becoming the more common connector of choice for devices to computers.

Midi is not audio messages. Sound created using messages is produced by the equipment reading and interpreting midi messages, not by playing back an audio file. For this reason, midi messages are very small (a few bytes) and fast.

How are midi messages sent?

Midi messages are sent normally over a wired connection between devices. For the purposes of our project, we will be sending messages from our foot pedal midi controller over USB to a computer running a program (FL Studio) that will read the messages and interpret them to carry out tasks.

Midi messages are sent in bytes (groups of eight zeros or ones, like this: [11101001]). The first byte of the message is the status byte. This status byte stores the type of message that is being sent, as well as the channel (more about this in a moment). The following bytes hold values that that type of message were to use. For example, if the type of message is a “Note On” message, the second byte to follow the status byte would hold the note number, or note pitch, and the third would hold the velocity of the note (usually determines how loud the note it played).

The status byte stores the channel of the message. Channels allow you to use up to 16 different devices at once over the same midi cables. By having messages sent over different channMidiels when using a keyboard and an electric drum kit, a synthesizer can play back the keyboard notes when the keys are played, and play drum sounds when the drums are played, even if the type of message is the same.

What types of messages can be sent?

There are many different types of messages that can be sent over midi connections. Some take additional data bytes, which will be between < > symbols. Some common message types are as follows:

Note On – Turns on a specific <note number> at a given “velocity”. There are 128 different notes available (0-127), with Middle C as number 60. A velocity of 0 is equivalent to turning the note off.

Note Off – Turns off a specific <note number>. If a note is not turned off, it will be on indefinitely.

Polyphonic Aftertouch – Sends amount of <pressure> placed on a specific key of a <note number>. Many midi controls do not have pressure sensitivity. This is important for dynamic keyboards or drum pads.

Control Change РChanges a <control> on the device, such as a pedal, switch, or wheel to a given <value>. This could be in response to a knob, wheel, switch or pedal.

Program Change – Changes between <patches or presets> in a device. This can allow you the change an instrument’s sound at the push of a button. Useful for changing presets set for a specific song.

Pitch Bend – Pitch wheels have a specific message just for pitch bending. These messages use <two values> to create a smooth pitch bend up and down from the default center value.

System Messages – These include system controls such as timing messages and start and stop. Useful for playback or recorded midi notes, but probably not useful for our project.

 

That’s about all we need to know (and a little more) to understand what some of the Teensyduino commands mean when sending midi messages on our Teensy device. We will cover that in part two of this post series.

For additional reading, check out the MIDI Manufacturers Association, which has beginner lessons and copies of the MIDI specifications, and this document from NYU, which makes the midi message format easy to understand (great resource!).

Leave a Message!

Your email address will not be published. Required fields are marked *