Hardware Reference
In-Depth Information
MIDI
The Musical Instrument Digital Interface (MIDI) protocol enables real-time communica-
tion between digital musical instruments. It's the granddaddy of digital
synthesizer protocols.
Most music synthesizers, sequencers, samplers,
keyboards, and workstations on the market today speak
MIDI. If you plan to make music using hardware,
you're going to run across it. MIDI is a comprehensive
specification covering serial communication, hardware,
and even the arrangement of banks of sounds in a syn-
thesizer's memory. Because it's so comprehensive, it's
enabled composers and musicians to work across a wide
range of MIDI synthesizers, samplers, and controllers for
decades. The full protocol is detailed on the MIDI Manufac-
turers' Association page at www.midi.org .
Microcontrollers are more frequently used as MIDI control-
lers than as MIDI input devices. There are so many good
synthesizers and samplers on the market that just need
a controller to make music, and controllers are fun and
easy to build. For the project that follows, you'll build a very
basic controller and use Spark Fun's Musical Instrument
shield as your MIDI input device, which is a general MIDI
synthesizer on a shield. The same code will work if you
want to connect the microcontroller to any general MIDI
synth, because the general MIDI specification covers not
only the messages, but how synthesizers organize their
banks of sounds.
MIDI is a music description protocol. MIDI messages don't
actually play notes—they describe what notes to play to a
synthesizer. In that sense, MIDI is to music as HTML is to
web pages. MIDI relies on a synthesizer to render music,
just as HTML relies on a browser to render your page.
MIDI messages are divided into three or more bytes. The
first byte, a command byte , is always 128 (0x80) or greater
in value. Its value depends on the command. The bytes
that follow it are called status bytes . All status bytes have
values of 127 (0x7F) or less.
MIDI devices are loosely grouped into controllers, or things
that generate MIDI messages, and playback devices, which
receive messages and do something with them. Keyboards
and other input devices fall into the first category. Syn-
thesizers, samplers, and many other devices fall into the
latter.
There are a number of different MIDI commands. The most
basic, note on and note off messages, control the playing
of notes on 16 different channels of a synthesizer. Each
note on or note off command contains two status bytes,
specifying the pitch in a range from 0-127 (a seven-bit
range) and the velocity (how hard the note should be
struck), which is also seven bits. Pitch value 0x45 is
defined as A above middle C (A-440) by the general MIDI
specification. This specification also covers the instru-
ments that you're likely to find on each channel. For a full
listing of the General MIDI instrument specification, see
www.midi.org/techspecs/gm1sound.php .
The MIDI serial protocol runs at 31,250 bps. There's a
standard MIDI connector, a DIN5, that you'll find on all
MIDI gear. All the connectors on the gear are female plugs,
and the cables all have male connectors on both ends. All
MIDI inputs to a device are supposed to be opto-isolated ,
so there is no direct electrical connection from one device
to the next. An opto-isolator is a component containing
an LED and a phototransistor. The input turns on the LED,
and the LED triggers the phototransistor, which turns on
the output. Figure 11-4 shows how to build a MIDI input
and output circuit if you plan to build your own. This circuit
would allow you to connect your microcontroller to any
MIDI synthesizer or controller. There are several MIDI
shields on the market if you don't want to build your own.
For more information on MIDI, see Paul D. Lehrman and
Tim Tully's book MIDI for the Professional (Amsco).
Search WWH ::




Custom Search