skip navigational linksPJRC
Shopping Cart Download Website
Home Products Teensy Blog Forum
You are here: MIDI Drum Machine MIDI Protocol Details

MIDI Drum Machine
Main Page
Circuit Board Layout
selected MIDI Protocol Details

About MIDI and the MIDI Specification

MIDI stands for Musical Instrument Digital Interface. It is a protocol which allows devices to communicate with each other. Harmony Central has a excellent group of free web resources regarding MIDI. The actual MIDI Specification is not available for free download. It is sold for approx $50 (US) by the MIDI Manufacturers Association. When I designed the MIDI drum machine, I obtained the MIDI 1.0 Specification from appendix A of "The MIDI Manual", by David Miles Huber, SAMS 1991, ISBN 0-672-22757-6, which Rod checked out from the Oregon State University Library. Several years later I purchased a used copy of this book at Powells for $16.

Hardware Details

MIDI communication is async serial, 8-N-1 format at 31250 baud, using a opto-isolated current loop circuit. The optical isolation prevents the interconnection of digital grounds between devices, which (usually) have their analog circuit grounds connected together at an audio signal mixer. Each MIDI cable carries communication in only a single direction. Devices need separate ports for input and output, and a "Thru" is usually provided which is an exact copy of the input, so that multiple devices can be easily connected to receive the same messages.


MIDI communication consists of messages, which are usually short groups of bytes, where the first byte has its Most Significant Bit (MSB) set (128 to 255) and the following bytes of the message have their MSB clear (0 to 127). Having the MSB dedicated to marking the beginning of a message means that every byte can only carry 7 bits of data. The MIDI Spec defines a number of different messages, but the MIDI Drum Machine only uses a small subset of all the possible messages.

The MIDI Drum Machine transmits these five messages:

  • Note On
  • Note Off
  • Program Change
  • Bank Select
  • All Notes Off
The following sections document the actual bytes sent in each message by this drum machine. These descriptions are not intended to serve as a replacement for the MIDI Specification.

Note On

The Note On message is sent when the drum machine detects that the drummer has struck a pad. The message is always transmitted as 3 bytes. MIDI's running status feature (allowing 2 bytes instead of 3) is not used.

Byte #BitsFunction
11001CCCCC = Channel
30VVVVVVVV = Velocity

The Channel and Note bits in the first two bytes are copied directly from the user's configuration for the pad that was struck. The velocity bits are copied from the upper 7 bits of the code from the A/D converter. The MIDI Spec suggests a log scale for velocity, but the linear code is copied. Perhaps a conversion implemented as a 256 byte lookup table would be an improvement?

Note Off

When the Note On message is sent, a software timer that corresponds to the pad struck is started. The length of time set is controlled by the pad's "sustain" parameter. Later, when the timer expires, this Note Off code is sent.

Byte #BitsFunction
11000CCCCC = Channel
30VVVVVVVV = Velocity

The Channel and Note bits in the first two bytes are copied directly from the user's configuration. The user's configued "release" parameter is copied into the Note Off velocity bits. With Rod's equipment, this Note Off velocity didn't have any noticable effect.

When a pad is struck, the firmware had ought to check corresponging timer and if it is currently running, a Note Off message should be sent before another Note On is sent. This simple check was not implemented in the code, but it could easily be added.

Program Change

When the user assigns a particular sound to a pad, by changing the Voice parameter on the front panel, the Program Change message is sent.

Byte #BitsFunction
11001CCCCC = Channel
20PPPPPPPP = Program (voice #)

Bank Select

When the user select a particular bank of voices for a pad, by changing the Bank parameter on the front panel, the Bank Select message is sent. This is actually a vendor specific system exclusive message.

Byte #BitsFunction
111110000Begin System Exclusive Message
30001CCCCC = Channel
600000BBBB = Bank

All Notes Off

If the All Notes Off button is pressed, these two bytes are sent. Many MIDI devices immediately turn off all notes when they receive these bytes. While developing, this can be useful feature if a Note On message is sent and no Note Off message turns it off.

Byte #BitsFunction
111110000Begin System Exclusive Message

The MIDI Drum Machine, Paul Stoffregen and Rod Seely.
Designed and constructed Fall, 1991. Project status: Complete.
Last updated: February 24, 2005
-- These drum-machine web pages are still under construction --
Questions, Comments?? <>