Of Instruments, Banks,
and Channels
The most basic MIDI module is programmed to
reproduce the sound of at least one instrument, but many
are capable of synthesizing numerous instruments: acoustic
and electric piano; guitars; various woodwind and brass
instruments; drums; bongos; cymbals; and much more.
Sound modules have built-in defaults, and for instruments
the default is usually an acoustic grand piano. To change
the instrument so the module plays something else, you
send the “change instrument command,” 0xC0, followed by
the number of the instrument you want to use. Instrument
numbers span from 0 to 127, with 0 being the default.
For instance, to change to instrument #12 – whatever
it might be – you simply transmit a couple of bytes from
the controller to the MIDI sound module:
www.servomagazine.com/index.php?/magazine/article/april2012_McComb
FIGURE 2. MIDI messages are composed of just a few
bytes, an eight-bit command byte (it always has its eighth
bit set to 1), and one or more seven-bit data bytes.
0xC0 12
and so on. To combine a command byte with a channel
number, simply add them together. Popular programming
practice performs this function using binary OR, which on
the Arduino is done using the | (pipe) operator:
(Before going further, take note that the documentation
for the sound module probably lists the instruments starting
at 1, but programmatically you specify them beginning with
0xC0|3
// Bits: 11000011
Note: As with instruments, channel numbers in MIDI
are typically noted as 1-16, but programmatically are
referred to as 0-15. So in the list above, Channel_0 is
actually MIDI channel 1, Channel_1 is MIDI channel 2, and
so on. This difference really only matters if you’re
interfacing with other MIDI equipment — like a MIDI
keyboard — where channels are numbered 1 through 16.
For programming using an Arduino and a MIDI breakout
board like the one in Tunebot, the channel offset numbers
make little or no difference.
Understanding Channel
Voice Messages
Switching instruments to play something else is an
example of modifying the channel voice. Channel voice
messages are those that alter the sound on a specific
channel, rather than for the entire sound module. There are
seven channel message commands in common use:
FIGURE 4. Channel voice bytes are constructed by adding
or ORing the four most significant bits (MSB) of a
command byte with the four least significant bits
(LSB) of the channel number.
For example, the command byte for switching
instruments (0xC0) begins with the binary bits 1100. Channel_0
is binary 0000, making the whole command byte:
1100 0000
Other variations are:
11000001
11000010
11000011
Channel_1
Channel_2
Channel_3
FIGURE 3. MIDI devices synthesize one or
more instruments that are kept in a
repository called a bank. Instruments are
played through any of 16 channels.
SERVO 04.2012 55