Interface The Music: An Introduction to Electronic Instrument Control

An introduction to electronic instrument control

Sound System

Here, the MIDI hardware setup recommended to run the author's demo code.Vin Marshall

I'm no musician, but lately I've been experimenting with MIDI (Musical Instrument Digital Interface) in my projects. MIDI is a standard for controlling instruments that works by passing messages between pieces of connected equipment. The messages aren't actual music in the same way as, say, an MP3 is. Instead, they are commands for making music—"Play middle C on an electric piano," for example. Messages consist of a channel number (1 through 16) followed by a status byte, which indicates the type of message (such as Note On or Note Off) and, where needed, data (such as the note to be played). MIDI devices known as controllers create the messages, and MIDI synthesizers receive them, with the result usually being musical sounds (although I've also built projects that map notes to relays that control Christmas lights and fireballs).

A basic MIDI setup might include a microcontroller, such as an Arduino, along with a MIDI Shield ($20; sparkfun.com) to provide the physical interface, and the Arduino MIDI library (free; arduino.cc) to communicate using MIDI messages. The last part is the software. I've written some starter code [see link below] to demonstrate simple functions like Control Change messages, which adjust aspects of the sounds, including volume and sustain. Things get really interesting with Real Time System Exclusive messages, which go beyond music-creation projects with advanced functions like MIDI Timecode, Show Control and Machine Control. Those give MIDI the ability to synchronize whole stage acts with music and preprogrammed cues, control recording-studio equipment, and more.

For sample code and links to more information, click here.