Each note you play on a MIDI device has two primary
characteristics: pitch and velocity. Pitch is the frequency of the note,
and velocity is its volume. On a piano, each white or black key
on the keyboard delivers a different pitch. How hard and quickly
you press down on the key determines its volume, or velocity.

MIDI uses a simple numbering system to denote pitch;
these numbers (see Figure 5) match the white and black
keys on a piano. Given a standard 88 key piano keyboard,
the MIDI pitch numbers vary from 21 (low tone) to 108 (high
tone). The sequential numbering counts both the white and
black keys. Very low and very high tones are possible by
extending the pitch values through the full 0-127 range. For
reference, middle C on the piano is MIDI pitch value 60. It has a
pitch (sound frequency) of 261.6 Hz (Hertz, cycles per second).

For note velocity, the values range from 0 (silent) to
127 (full volume). There is also a separate channel volume
command (see below) that sets the overall level for the
whole channel. Values likewise range from 0 to 127 for
overall volume. The example sketches in this article
demonstrate setting both note velocity and channel volume.

An example Note On message might look like this:

0x90|1 69 100

• 0x90 is the Note On command byte; 1 is added (ORed) to
it for channel 1.

• 69 is the pitch of the note. The value 69 represents the A
above middle C.

• 100 is the note velocity. A value of 100 is about
3/4 full volume (full = 127).

Note that I’m showing only the command byte
as hexadecimal; the rest are plain ol’ decimal.

Understanding Control
Change Messages

The control change message allows for an
extended range of channel functions. These
messages use the 0xB0 command byte with a
channel number, a control byte, and a data byte to

FIGURE 7. Alternative MIDI sound modules include
these two board-level products, also from SparkFun:
a universal breakout board for use with a
microcontroller; and a combo MIDI/MP3 shield.