USB MIDI Controller

I recently started learning to play the electric guitar. To be able to spend more money on the actual guitar, I forwent to buy an amp and chose instead to use Guitarix, an open source program that can do all sorts of nifty guitar effects. It also has MIDI support, meaning that you can use hardware that speaks MIDI to control it, e.g. a slider or foot pedal. The cheapest pedal I could find went for 45 EUR on eBay, so I decided to build my own.

Setup

Communication

The host device acts as a slave and has address 1, all clients are I2C masters.

A preliminary command table, with each length including the command byte. Generally, response codes are the same as the request code, but with the most significant bit set to 1.

Request Length Response Length Description
0x3F 2 0xBF 2 Initialization
0b1xxxxxxx According to MIDI spec None 0 MIDI message

In theory the same system can be used in reverse to act as a MIDI OUT device, by having the clients become I2C slaves and the host act as a master. You would only get 127 slave IDs, but there are ways around that by using the general call.

Wiring

Code

On Github. :)

Notes

At first I wanted to use an ATtiny24 as client device, since in theory it had everything I need - an ADC, I2C support, and one extra I/O pin to enable the next device. This plan failed due to my inability to make the USI work properly. It would initialize its addresses properly, but then hang during the transmission of the first control change message. I could bitbang I2C, but that would occupy the bus unnecessarily long. In the end it’s no big loss, as the ATmega8 is cheaper anyway, but it does feel like using a sledgehammer to crack a nut :)