With the Chinese malware gradually dying down this year and music beginning to enter back into my life, I’ve been trying to figure out how to get back into the local scene and have some fun with new musical endeavors. Part of that has been focusing on electronic music over the past year with my project, ReLiC. I’ve had a lot of fun learning how to sequence music with older technology such as the Macintosh SE I picked up earlier this year. My first instinct was to haul that puppy over to the local music hall along with as many keyboards as I could manage, hook it all up in less than a minute, and relish in the look on everyone’s faces as my 16-bit monster springs into life… My second thought was that that didn’t sound like the greatest idea.
I still want to incorporate live synths and sequencing, but in order to get the full effect of my music, I’d need to compromise and introduce just a wee bit of backing tracks into the mix. One could easily haul in a laptop and an audio interface and load up Reaper, but there are a lot of uncertainties when using a traditional device in a live performance scenario (anyone ever heard of Windows Update?). Plus, I always get a bit turned off when I see a DJ up there with their laptop. Seems like the life is getting sucked out of the music.
…So why not build my own laptop thing, but better!
My idea was simple, use a small SBC, some clean audio outputs, and midi input/output to put together a dependable one-trick pony!
I’m guessing you’ve probably already heard of the Raspberry Pi, so I won’t go into detail there. I will say that I’m using the Model A+ variant which gives this device a more slender form since all we need is one USB port, after all.
You could easily run audio out through the headphone jack built-in with the Pi, but I’m not sure how well the grounding and quality on that will play with front-of-house speakers. I chose to use the HiFiBerry DAC+ which I already had lying around. The RCA jacks would definitely be better as 1/4″ or XLR connectors, but that’s nothing that a few adapter cables can’t fix.
I’m handling MIDI over the RPi’s GPIO Serial connection using a custom board I diy’d together. It actually works really great and was a fairly simple project. The schematic for this is provided by Dr. Scott M. Baker and should be universal for most midi applications. I originally planned on using a USB midi cable, but that thing was an immediate bust. Going with the GPIO option ends up simplifying the final design, and from what I can tell, is extremely dependable.
In the end, the hardware was an easy proposition. Unfortunately, getting the darn thing doing what I wanted it to do wasn’t so easy…
It’s all in the software
It would be great if there was something like
aplaymidi that smashed the two together to synchronize Audio and Midi files… but there isn’t that I know of without loading up an unwieldy DAW (please contact me if you know otherwise). Though it might not be the best option for performance, I wrote the entire program in Python using a handful of libraries that fit the bill.
The program flow is simple:
- Read the local and user config files for settings (also a few command line options available)
- Initialize the desired audio and midi devices (serial midi over the RPi’s GPIO port is supported and encouraged)
- Search the specified folders for any audio (.wav) and midi (.mid) files. Group them together by filename (can have both audio+midi or just one or the other) and sort them alphabetically.
- There’s specific logic in there to mount and search an external drive (ie: USB thumb drive). This is the ideal way to load up files.
- When a MIDI note is received (or a keyboard number pressed) that is within the range of files collected (1-based indexing):
- Load up the audio and midi files (depending on what’s available)
- Initialize the audio device to use the specified channels/samplerate
- Begin playback of audio (by loading in buffer periods) and midi messages (based on timestamps)
- The MIDI note/keyboard number of
0is reserved as a panic button to stop playback.
So, all I’ll need now for my life performances is this little box and a small midi controller (I’ll be using the Akai MPX8, though that’s not my best recommendation) with the pads configured for the notes
1-7 (the last one can be
0 as a stop button), and I’m good to go! Much better than hauling out the Macintosh! 😛
Every good project needs a cute 3d-printed case…
The case I used is a modified version of this really cool one I found on Thingiverse created by Sean Smith. It was actually the only option I could find for the RPi Model A format with the HiFiBerry, but it was kinda perfect out of the gate. Instead of the provided HiFiBerry Digi+ sled, I found this DAC+ sled created by Ape Monkey for the same case that fit like a glove.
I’d normally provide the files for this, but I designed it specifically for the MIDI board I threw together. If you create something similar, it’d probably have a different size/shape to it. If I ever come across something like the OSA MIDI Board, I might update the design for that particular hat.