Skill Builder: Midi For Makers

Craft & Design Maker News Music
Skill Builder: Midi For Makers

In 1982, Hayes released the 1200 baud modem, Microsoft released MS-DOS 1.25, and the Musical Instrument Digital Interface (MIDI) was announced in Keyboard magazine by Robert Moog with its first implementation in the Sequential Prophet-600 synthesizer.

While these days you’re unlikely to use a 1200 baud modem or early MS-DOS, you can still use MIDI to hook up the Prophet-600 to new equipment currently being sold. Even in 2020, few manufacturers would consider producing anything but a novelty synthesizer or drum machine without MIDI connectivity. Digital standards that can compare to this amazing 38 years of mainstream success are few and far between.

MIDI is a robust and easy-to-understand protocol. Simple messages are sent and received without handshakes or acknowledgments. While slow by today’s standards, for the purpose of sending musical information it still functions effectively for all but the most exotic applications. Given the speeds of modern microcontrollers, building MIDI devices is easy, cheap, and extremely satisfying. A quick perusal of the Tindie marketplace for MIDI devices underscores the creative ideas that continue to explode in the maker community.

Makers can also gain access to the universe of MIDI control surfaces. Grid controllers, slider and knob boxes, drum machines, and even wind controllers that output MIDI can become parts of projects that may have nothing to do with music. Capturing and repurposing their messages is a simple matter of programming. To understand what this would take, let’s look closer at the standard itself.

How It Works

MIDI combines a messaging standard, a digital protocol for sending those messages, and a physical scheme for how to wire systems together. This article will focus on the “classic” MIDI standard that uses 5-pin DIN plugs, and sometimes ⅛” (3.5mm) tip-ring-sleeve (TRS) plugs, with a current loop connection scheme. MIDI has also become popular over USB, but that’s an approach for another article.

Starting with the physical side of things, MIDI uses unidirectional current loop networking. This means that sending 1s and 0s is done with changes in current rather than voltage. The MIDI standard limits the current loop signals to 5mA and 5V, so realistically runs of MIDI cable can easily be 20 feet, and can more than double that with high quality cables. MIDI also uses a common current loop technique of opto-isolating the receiving system to prevent ground loops and voltage spikes. MIDI circuits are defined as MIDI IN, MIDI OUT and MIDI THRU. OUT and THRU differ only in that THRU is wired to IN and sends along whatever is received.

This ability to “chain” MIDI devices is one of the great features MIDI users enjoy.

While wiring MIDI circuits is straightforward, multiple vendors produce inexpensive MIDI shields for Arduino (usable as breakout boards for other microcontrollers). These boards typically provide standard serial I/O connections for the host controller and include the opto-isolator and DIN plugs.

Moving up from the physical, MIDI operates at 31250 baud. This value has often frustrated users since it is, to say the least, uncommon to find it implemented outside of MIDI. In actuality, its origins make perfect sense. The first MIDI implementations commonly used the outstanding Intel 8051 microcontroller. The 8051, at least in 1982, used an external XTAL oscillator with 12MHz as the fastest supported value. Internally, it divided that signal by 12 to derive a 1MHZ timer clock. If you divide 1MHz by 32 (2⁵), you get 31,250!

MIDI Messages

MIDI encodes its messages into a status byte which describes the type of message, followed by up to two data bytes. Each data frame has a start bit (value 0,) and a stop bit (value 1,) for a total length of ten bits per byte sent. Status bytes have a 1 as the most significant bit (MSB) and data bytes have a 0 as the MSB.

Messages can be channel messages which are targeted at one of the 16 channels MIDI supports (types: channel voice, channel mode) or system messages received by all devices (types: system common, system real-time, and system exclusive.) Channel messages encode the message type onto the three bits following the MSB and the target channel onto the 4 Least Significant Bits (LSB) of the status byte. Data bytes encode their payload onto the 7 bits following the MSB.

A full description of all the different MIDI messages is beyond the scope of this article, but it’s worth looking at a couple of common messages. Let’s say we want to send a message to a synthesizer on channel 4 to turn on the note C3. (Having 7 bits to encode note number means that MIDI has a range of 127 notes, from C-1 to G9.) We’d send a status byte with the channel and message type, a data byte with the note number and a second data byte with the velocity (the force with which the note is played). If we wanted to change the value of a parameter, such as the modulation wheel, then we’d send a status byte, a data byte with the controller number, and a data byte with the controller value we want to set.

Building Projects

Much like deciding to use a MIDI shield instead of wiring your own interface, using MIDI libraries like the one from FortySevenEffects makes it extremely easy to handle all the technical details of sending and receiving messages. Once messages are received, a case structure or chain of if statements selects the desired logic to implement. Sending messages requires only a single command.

Advanced MIDI messaging such as MIDI timing/clock and System Exclusive (sysex) are all supported in the FortySevenEffects library. But fantastic MIDI projects may only need to use a couple of messages like NoteOn and NoteOff or a small set of ControlChange messages. Just ignore any messages that you aren’t interested in.

Any sensor you can attach to a microcontroller can become a substitute for the keys or controls of a synth or the pads of a drum machine. Simple sketches can transpose notes, create arpeggiations, reroute messages, or any other operation you can perform on MIDI’s messages.

In 2019, MIDI 2.0 was announced, assuring the future of the standard. The new standard will be backward compatible and support existing MIDI devices, assuring the viability of maker MIDI projects for a long time to come.

Building BooshBeats

YouTube player


Who doesn’t love a grid of pads with RGB LEDs? When I needed to create an 8-channel × 8-step sequencer for my mega-flame effect BooshBeats.

An Arduino sequencer using Novation Launchpad Pro

I used MIDI to talk back and forth with a Novation Launchpad Pro. Button presses came as MIDI messages in, and I could control the colors of the pads with MIDI messages out. The Launchpad grid visually displays the pattern, and lets me edit existing and create new patterns, even while playing! I use the top, bottom, and left buttons to start, stop, retrieve, and store patterns. The right side buttons are used as displays to show the sequencer walking through the steps.

Learn more about MIDI


Discuss this article with the rest of the community on our Discord server!
Tim Deagan

Tim Deagan (@TimDeagan) likes to make things. He casts, prints, screens, welds, brazes, bends, screws, glues, nails, and dreams in his Austin, Texas, shop. He's spent decades gathering tools based on the idea that one day he will come up with a project that has a special use for each and every one of them.

Tim likes to learn and try new things. A career troubleshooter, he designs, writes, and debugs code to pay the bills. He has worked as a stagehand, meat cutter, speechwriter, programmer, sales associate at Radio Shack, VJ, sandwich maker, computer tech support specialist, car washer, desk clerk, DBA, virtual CIO, and technical writer. He's run archeology field labs, darkrooms, produce teams, video stores, ice cream shops, consulting teams, developers, and QA teams. He's written for Make: magazine, Nuts & Volts, Lotus Notes Advisor and Databased Advisor.

View more articles by Tim Deagan


Ready to dive into the realm of hands-on innovation? This collection serves as your passport to an exhilarating journey of cutting-edge tinkering and technological marvels, encompassing 15 indispensable books tailored for budding creators.