This is my second instructable on using the Raspberry Pi for digital audio, check out my first instructable for how to set up and control custom audio effects on a Raspberry Pi. If you like them, please vote for me!!
If you like messing with audio effects or making digital music, you might have heard of MIDI. For the rest of you savages, MIDI (Musical Instrument Digital Interface) is a standard method for communicating musical information between two or more electronics. I first heard of MIDI in the early 90s as a kid, thinking “What is this awful music playing on geocities webpages?” Synthesized music has improved a lot since then, with various controllers, synths and MIDI interfaces available to dubstep and warble to your heart’s content.
Enter the PiMiDi: A MIDI interface built on a Raspberry Pi. There are a few commercial USB MIDI interfaces on the market that would work with the Raspberry Pi, but since the Pi has built in UART (a serial hardware platform used by MIDI), I decided to make my own MIDI interface. If you’re interested in learning how to make your own, grab your materials and let’s get started!
Step 1: Materials Needed
You’ll need a few things to get started:
- Raspberry Pi (any model should work, I used Model B)
- Hammond 1590BB alumin(i)um enclosure (or similar)
Electronic Components for wiring up MIDI to the Raspberry Pi:
- Prototyping PCB board (2.54mm/.1″ spacing, double-sided is best)
- PCB connector pins (26 for the Raspberry Pi GPIO)
- 7414 Hex Schmitt-Trigger Inverter (or equivalent: SN7414, 74HC14, etc.)
- An Opto-coupler (I used 6n138, others: 6n137,6n139,PC900*)
- A diode (like 1N4148, 1N914, or similar)
- A 470 Ohm and 1k Ohm resistor
- Five 220 Ohm resistors (1 for MIDI input, 2 for each MIDI output)
- One MIDI plug for each input/thru/output
- Wires to connect it all up
- (optional) 26-pin GPIO ribbon connector to connect Pi to the PCB
- (optional) LED with ~330 Ohm resistor
- (optional) a pushbutton switch
Tools you will need to get the job done
- Soldering iron and solder
- A drill with different bit sizes (1/8″, 1/4″, 5/8″)
- Some free MIDI music to keep you motivated
Step 2: From Schematic to PCB
After searching on the web for MIDI to Raspberry Pi schematics, I got a good start from siliconstuff.com and modified it to include a MIDI thru port and an LED with a controllable switch. (*note: if you only have a PC900 opto-coupler, you need to modify its pinout slightly according to the 2nd schematic).
Now, it’s time to start placing parts on the PCB board. I’ve included a layout of two PCB designs, depending on whether you want to use a ribbon cable (like I did) or connect it directly to the Raspberry Pi header. If you don’t have a double-sided protoboard, use the left schematic and ribbon cable. If you’re concerned about fitting it in a 1590BB box, use the layout on the right. Both layouts use the same connections, however the connector pins are reversed.
Since things aren’t very clear on the layout, you can hover over components in the photo to see their values and other important details. MIDI connectors don’t need to be directly soldered to the board if you have connector pins and 6 female-adapter wires.
Step 3: Drilling Holes in Alumin(i)um
Once you’ve got your electronics soldered properly onto the PCB, it’s a good time to give your eyes a rest and work on the case for your PiMiDi. Start by laying your Raspberry Pi on the bottom lid of your stomp box. It should be placed with the USB jack, audio and RCA video connector closer to the sides. The Pi’s SD card should just barely touch the other side of the box without going over the lid’s inner edge. Using a sharpie marker, make a small mark on the lid where the two screw holes will hold it in place.
Next remove the Raspberry Pi and drill two 1/8″ holes in the lid where you marked it. If you did it right, the holes should line up perfectly and you can mount your Pi onto the lid with two screws (and standoffs if you have them). I made a mistake drilling at an off angle and just drilled a second hole to line up better. Don’t worry no one will see it when it’s on the floor/table.
Check to see that your Pi fits nicely in the box with the lid almost completely closed, and take note of where the power cable comes into the side of the box. Drill a small hole (about 1/4″) to allow your power cable to connect inside the box while it’s closed. Drill 3 holes (about 5/8″) on the side opposite to the audio connectors for the MIDI jacks. Also drill any holes you want for the audio, video, USB and ethernet ports.
Because I wanted to use both the USB and the ethernet port, I drilled a roughly square shape into one side of the box and then slowly filed it out with a hand file. I would recommend using a dremel tool or CNC machine if you have one, otherwise it’ll look as “pretty” as mine does.
Test fit your MIDI jacks and all wiring before connecting the PCB board, allowing for extra room for each plug. Once you’re satisfied connect the PCB to the Pi and wire up the MIDI jacks. The backs of the MIDI jacks should have #’s 1-5 on them, but if not the schematic shows the jack from the back side where you connect the PCB wires, not the face where you plug in a MIDI cable.
Current Project / Post can also be found using:
- 1590Bb raspberry pi
- raspberry pi midi box