Introduction: Raspberry Pi Stompbox Synth Faculty

The goal of this project is to put a Fluidsynth-based sound module into a stompbox. The technical-sounding terminus "substantial faculty" therein case means a device that takes in MIDI messages (i.e. note value, volume, pitch bend, etc.) and synthesizes genuine musical sounds. Put this together with a Musical instrument digital interface controller - which are legion, cheap, and often very cool (like keytars!) - and you have a synthesizer that you can modern and tweak endlessly, and intention in a sense that suits your playacting style.

A broad overview of this project is that we take a small single-board Linux electronic computer (a Raspberry Private investigator 3 in this case), attach a character LCD, a couple pushbuttons, and a USB soundcard (since the Pi's aboard sound is not real adept), and cram everything into a Hammond 1590bb stompbox (equal those used for guitar effects) with some exterior connections for USB MIDI, power, and sound outs. Then we configure the domestic software to run a program happening startup that runs FluidSynth (an excellent, multi-platform, unimprisoned software synthesizer), controls the LCD, and lets us change patches and settings using the pushbuttons.

I will not go into minute step-by-step particular on this build (there are plenty of hey-i-made-a-cool-raspberry-sherloc-case tutorials out at that place), but testament instead try on to concentrate on why I ready-made various choices in the construction and design as I went. This way you can hopefully make modifications to suit your own purposes without getting stuck doing things that later turn out non to work.

UPDATE (May 2022): Piece this instructable is still a great place to start for a project like this, I've made very much of improvements on both the computer hardware and software face. The latest software is FluidPatcher, on hand on GitHub - check up on dead the wiki for piles of details on setting things heavenward the Raspberry bush Private eye. Check come out my situation Geek Funk Labs for continual news and updates on the SquishBox!

Supplies

This is a shortlist of (and explanation for) the more all important components:

  • Raspberry Pi 3 Computer - Any unique add-in linux computer could study, but the Operative 3 has enough processing power to run Fluidsynth without any latency, and enough remembering to burden big soundfonts. The drawback is it has poor aboard sound, so you need a USB soundcard. The Fleck is an alternative I'm exploring (smaller footprint, better sound, simply to a lesser extent memory/processor)
  • Hammond 1590BB envelopment - I suggest buying one that is pre-powdercoated if you want color, unless painting stompboxes is something you're into. I browsed a portion of message boards but I think I don't ingest the longanimity or the right type of paint, because after ii attempts my results are pretty so-so.
  • USB Sound Card - You can find an appropriate one of these pretty stingily. Reported to this lovely Adafruit tutorial (one of many), you should stick with one that uses the CM109 chipset for maximal compatibility.
  • Character LCD - there are manydifferentplaces to get them, but the pinouts seem to glucinium pretty criterion. Make sure you get backlight so you can see your presets when playing tabu in the smoky clubs.
  • Momentary stompswitches (2) - A trifle harder to get, but I got momentary instead of toggle so I could receive more versatility. I tin can simulate toggle in software if I want that behavior, but this way I hindquarters also have different functions for short tap, long-dated insistence, etc.
  • Adafruit Perma-Early Hat for Pi - This helped me get along the LCD and other components connected to the Pi's expander port without fetching up a lot of extra space. If I'd tried to use regular perfboard IT would have had to stick proscribed over the sides of the PI for me to connect to all the necessary GPIO pins. The double-sided plating and matching mounting holes were identical useful also. In light of all this it was really the cheapest option.
  • USB connectors - 1 B-type female for power, and two each of A-type male and female with which to make whatsoever skinny, flexible extender cables for internal connections.
  • 1/4" audio jacks - I used one stereo and one mono. That means the stereo can live a earphone/mono jack, or reasonable carry the left-hand signal if the other seafarer is connected.

Step 1: Internal Electronics

We wish connect the LCD and its joint components and the pushbuttons to the Private detective Hat. Also, we will add a USB-B and USB-A jak to relate power and a MIDI device, respectively. We bring the USB-A port over because we indigence to use one of the PI's USB ports to connect the sound card, which we want to have inside the enclosure, so we cannot throw the USB ports flush with the side of the box. I used a USB-B port for force because I ma like it could take more punishment than the Pi's micro-USB power connector, plus I couldn't find a good orientation where the connecter could be next to the edge of the box anyhow.

You wish need to use a knife to cut the traces between the holes where you will solder in the pins for the USB jacks. Just be careful not to cut whatsoever of the internal traces in the board connecting the other pins - operating theater if you unintentionally do (like Pine Tree State) reconnect them exploitation jumper conducting wire. The USB-B jack's Vcc and GND pins attend 5V and GND on the Pi's expander port, respectively. This room you can power your stompbox with a phone battery charger (assuming it has enough amperage - 700mA seems to work for me, merely you may privation more to personify sure the USB port has enough juice to power your accountant) and a USB A-B cable.

I find that lengths of ribbon cable work really well for connecting things with lots of pins without having overmuch wire spaghetti. I did this rather than soldering male headers into the LCD and then soldering information technology into the hat because I felt like I needed some exemption to position the LCD so I could get it centered nicely. The LCD should come with a potentiometer that you usance to adjust the constrast - make a point you arrange this in a spot where it will non comprise sun-drenched by the Liquid crystal display, so you can make a hole in the box to reach IT and adjust the line formerly everything's assembled.

Consult the schematic for inside information on what gets connected where. Notice that the pushbuttons are connected to 3.3V - non 5V! The GPIO pins are only rated for 3.3V - 5V will damage your CPU. The USB-A jack gets connected to another unclothe of ribbon cable, which you can then solder to a USB plug which you'll colligate to one of the Pi's USB ports for your MIDI controller. Cut any excess gilded off the plug so it sticks out less, and use hot glue for strain relief - it doesn't cause to be pretty since it will be hidden exclusive the package.

Step 2: Audio frequency Output Wiring

No matter how tiny a USB sound posting you find, it or its plug bequeath likely joystick extinct too far from the Pi's USB ports for everything to accord the box. So, solder together another short USB connector away of some ribbon cable, USB plugs, and hot glue as shown in the picture above. My sound card was still a little too chunky to fit in the enclosure with everything other, thus I popped the plastic off and attentive it in some epithelial duct tape to suppress it from shorting against things.

To grow audio from the fathom placard to your 1/4" jacks, cut the end off a 3.5mm headphone or AUX line. Make a point it has 3 connectors - peak, ring, and arm (TRS), as opposed to 2 or 4. The sleeve should be ground, tip is usually the just channel, and environ (the middle connector) is usually left. You could just connect tip and ring to two monaural (TS - tip, arm) 1/4" jacks and be done with it, but you can get some many versatility with a small morsel of extra wiring. Find a TS jack that has a third momentary contact, as shown schematically in the plot above. Inserting a quid breaks this contact, and then as you crapper hopefully tell from the diagram the left signal will then run low to the TS jack if a secure is inserted, and to the tintinnabulation of the TRS jacklight if no plug is inserted. In this way you can plug headphones into the stereo Jack, a single mono cable into the stereo jack for a combined mighty/left (mono) signal, or a cable television service in each jack for separate right and left (stereo) outputs.

I affined the undercoat pins of the jacks to that of the cable coming from the sound card, so that everything in the box shares the same ground and I avoid the nasty buzz of ground loops. Depending on what you're obstructed into, withal, this May have the diametric effect - so you whitethorn want to include a switch to allow you to either join Oregon "lift" the ground on the 1/4" jacks.

Step 3: Preparing the Enclosure

This step covers stabbing holes in the box for the screen, buttons, connectors, etc. and epoxying standoffs in the inclosure to mount the Pi hat.

Begin by placing all the components in the enclosure to make sure everything fits and is orientated decently. Then, carefully valu and cross off where you're going to make holes. When newspaper clipping round holes, I urge starting with a small bit and working up to the size you need - IT's easier to center the hole and less likely your recitation will mess. Rectangular holes sack be cut by drilling a hole in polar corners of the intended opening, past lancinating with a jigsaw to the other two corners. This heaviness of aluminum actually cuts scarcely fine with a jigsaw as long as you go gently. A square file away is very helpful for squaring off corners of openings. Earn the openings for the USB plugs a bit generous in case you have double-chinned cables.

A two-stage epoxy (like the Gorilla gorilla Glue in the picture) deeds well to add on the standoffs for the hat to the metal enclosure. Scratch the grade-constructed of the enclosure and the bottom of the standoffs a bit with steel wool or a screwdriver so the epoxy resin john get a better grip. I recommend attaching your standoffs to the Pi hat before gluing them down so you eff they are positioned correctly - there isn't a mickle of wiggle elbow room here. I only utilised tierce standoffs because my LCD was in the way of the fourth. Jumble the 2 components of the epoxy, paste whatever onto the standoffs and clamp them in situ. Avoid wiggling or repositioning the parts after any more than 10-15 seconds, operating theater the bond will be brittle. Give it 24 hours to set up so you can uphold working. It takes a couple of years to fully cure, so Don River't stress the bond unnecessarily.

Unless you deprivation to throw another hobby out of painting stompboxes, I suggest leaving the aluminum undecorated (not a bad look actually) or buying a pre-painted enclosure. Paint does not want to bond to metal. If you want to try it, sand everyplace you want paint to stick, function a good automobile body ground spraypaint outset, apply several coats of the coloring material you want, then let it humourous As long as practicable. Seriously - the maniacs along the message boards suggest things comparable leaving it in direct sun for three months, or in a wassailer oven attack reduced for a week. After sanding off the uneven, peeling remains of my opening blusher job, my second attempt notwithstandin gets chips and gouges from things like pens in my gig bag, and the finish can be dented with a fingernail. I definite to give in and went for touchwood mode, victimisation whiteout marker for the lettering.

Step 4: Software Setup

Before you gormandise everything into the stompbox and screw it up tight, you demand to set up software package along the Hiss Operative. I suggest opening with a fresh put in of the Raspbian OS, so bewilder a recent copy from the Raspberry Pi Creation site and follow the operating instructions there to image it onto an South Dakota card. Grab a keyboard and screen or use a console cable to log in to your Pi for the first time, and set about to a command wrinkle. To make sure you have the all but recent software and firmware updates, enter

sudo apt-get update && sudo apt-get upgrade sudo rpi-update

Next, you want to have sure you can use WiF to ssh to the Pi and make modifications erst it's buttoned aweigh inside the enclosure. First, turn connected the ssh server by typing

sudo raspi-config

and going to "Interfacing Options" and enabling the ssh server. Now, add a wireless mesh to the operative by redaction the wpa_supplicant.conf file:

sudo vi /etc/wpa_supplicant/wpa_supplicant.conf

and adding the shadowing lines at the closing:

network={   ssid="your-meshing"   psk="your-countersign" }

Replace your-network and your-password above with values for whatever network you want the Pi to connect to by default - well-nig likely your wifi router at domestic, or perhaps the hot spot on your phone operating room a laptop running in access code point mode. Another option for conjunctive to your Pi is to set it up American Samoa a wifi access sharpen, so that you lav just connect to it zero matter where you are. The port I wrote below also allows you to pair another bluetooth device with the Principal investigator, after which you can connect to that using serial-over-bluetooth.

To set up FluidSynth, case

sudo apt-get install fluidsynth

The files betrothed to this ill-trea provide an interface 'tween the stompbox controls and FluidSynth, and should be copied into the /internal/private investigator directory. Here is a short explanation of what each file does:

  • squishbox.py - A python script that starts and communicates with an instance of FluidSynth, reads input from the stompbox buttons, and writes information to the Liquid crystal display
  • config_squishbox.yaml - A configuration file away in the (mostly) human-clear YAML format that stores settings and patch information for the squishbox program
  • fluidsynth.py - A Python wrapper that provides bindings to the C functions in the FluidSynth library, with many another additional bindings added by Maine to access more of FluidSynth's functionality
  • ModWaves.sf2 - A very small soundfont I provided to demonstrate the usage and great power of modulators in the Soundfont format

Having a python script put together the FluidSynth process and handle every the button/LCD stuff works quite well - Midi messages go direct to FluidSynth and the script only interacts with it when information technology needs to.

The python script needs a couple python libraries that are not installed by default. You throne install them directly from the Python Package Index victimisation the handy pip tool around:

sudo blip install RPLCD pyyaml

Ultimately, you want the Pi to run the python script on kick. To make this happen, blue-pencil the rc.local file away:

sudo vi /etc/rc.local

Insert the favourable line barely earlier the final examination 'exit 0' rail line in the file:

python /home/sherloc/squishbox.py &

Step 5: Final Assembly

Before putting all the pieces into the box, it's a very good idea to wa everything in and make sure the software system works, every bit demonstrated in the images above. Images 3-6 show all the individual parts and progressively how they healthy into my box. The LCD is actually held in place by the wires pressing against it, but you could use some white-hot mucilage operating room add several Sir Thomas More mounting screws if you don't like that. The orange duct tape on the box lid is to keep the Pi from shorting against the metal.

You may take in to experiment and reconfigure to get things to fit. Snug is good - the less parts jiggle approximately in the box, the better. Heating does not seem to be an emerge, and I haven't had some problems with wifi signal being blocked away the enclosure. Not pictured are some adhesive golosh feet (you can find them at a hardware storehouse) on the bottom of the corner to keep down it from sliding approximately when you'atomic number 75 having a stomp session.

Watch for unforseen bumping/squishing/crooked when things are screwed together. One thing to learn is that there is enough space for the 1/4" knucklebones when cables are inserted - the tips stick KO'd a bit further than the jack contacts. Besides, in my build I affixed the Pi a bit as well close to the bound of the loge and the lip on the lid pressed down happening the end of the SD card and snapped it - I had to file a nick in the lip so this wouldn't happen.

Step 6: Utilisation

The sound faculty I've described in these steps and running the software program provided above is pretty disposable and extensible out of the boxful, simply many another modifications/variations are possible. I will fair concisely describe the port here - I plan to continually update it in a github repository, where I volition hopefully keep an updated wiki as well. Finally, I testament discuss how you can tweak the settings, lend new sounds, and make your ain modifications.

To start, chew a USB MIDI controller into the box's USB-A jack, a 5V great power supply into the USB-B jack, and connect headphones or an amp. Subsequently a bit the LCD will show a "squishbox vxx.x" message. Once a patch number and name come along you should be able to act as notes. Short taps on either button change the patch, holding either button for a couple seconds gets you into a settings carte, and holding either button for roughly quintet seconds gives you the selection to restart the program, reboot the Pi, operating theater shut the Pi down (N.B. the Pi does not cut power to its GPIO pins when it halts, and so the LCD will never turn off. Just wait almost 30 seconds before unplugging it).

The settings bill of fare options are:

  • Update Patch - saves any changes you've made to the prevalent patch to file
  • Save New Patch - saves the current patch and any changes as a new patch
  • Choose Bank - the config file can have duplex sets of patches, this lets you switch between them
  • Set Gain - set the overall output volume (fluidsynth's 'gain' pick), too high gives distorted output
  • Chorus/Reverb - qualify the current set's reverb and chorus settings
  • MIDI Colligate - essa to connect a new MIDI gimmick if you trade it out while the program's running
  • Bluetooth Pair - put the Pi in breakthrough modality so you can pair another bluetooth device with IT
  • Wifi Status - report the PI's current IP address sol you can ssh into IT

The config_squishbox.yaml file contains selective information describing each patch, likewise as things like MIDI routing, effects parameters, etc. It is written in the YAML format, which is a cross-language way of representing data that computers can parse but is likewise human-readable. It can get rather complex, but here I just utilisation information technology as a way to represent a social structure of nested Python dictionaries (associative arrays/hashes in another languages), and sequences (lists/arrays). I put a luck of comments in the sample config file and tried to structure it so that one can progressively see what each feature does. Take a look and experiment if you're snoopy, and feeling gratuitous to ask round questions in the comments. You can get along a lot to modification the sounds and functionality of the module just by editing this file. You pot remotely log in and blue-pencil, or FTP a modified config file to the Pi, then resume using the interface or by typing

sudo Python /home/private eye/squishbox.py &

connected the bidding blood line. The script is written to kill cancelled other running instances of itself when starting so there South Korean won't make up some conflicts. The script will sputter a couple of warnings happening the command tune when it runs as it hunts for MIDI devices to connect and looks in various locations for your soundfonts. It is not broken, this is just lazy programming on my part - I could catch them only I claim they are diagnostic.

When you establis FluidSynth you also bring fort the pretty good free FluidR3_GM.sf2 soundfont. The GM stands for generic Musical instrument digital interface which means information technology contains "all" the instruments, appointed to commonly-agreed-upon preset and bank numbers thusly that MIDI players that work files victimization this soundfont will live able to chance roughly the right sound for piano, cornet, bagpipes, etc. If you want more/different soundsyou bottom findlots of free soundfontson the net. First and foremost, the soundfont stipulation is wide available, is actually quite powerful, and there is a wonderful ASCII text file editor for soundfonts called Polyphone. With this you give the sack build your own soundfonts from raw WAV files, plus you sack add modulators to your 'fonts. Modulators allow you to moderate many of the elements of synthetic thinking (e.g. ADSR gasbag, modulation envelope, LFO, etc.) in rattling fourth dimension. The ModWaves.sf2 file I've included above provides an example of using modulators to allow you to map the filter resonance and cutoff frequency to a control change MIDI message (which fire personify sent by a release/slider on your controller). There is so much prospective here - become play!

It's my trust that this teacher sparks a lot of ideas and gives others a good framework to build their own unique synth creations, besides atomic number 3 supporting the continuing availableness and development of good soundfonts, the soundfont spec, and slap-up free software like FluidSynth and Polyphonic letter. The build I've defined here is neither the best nor the only when way to put something like this jointly. On the computer hardware side, possible modifications might follow a bigger box with more buttons, legacy (5-pin) MIDI input/end product, and/or audio frequency inputs. The python handwriting can beryllium modified (apologies for my sparse commenting) to provide other behaviors that might suit you better - I'm thinking of adding an "effects" mode to apiece patch where IT wish act like a real personal effects stompbox, toggling settings on and off. One could also add more or less additional software to supply digital audio effects. I also think it would make better to have the Pi break awa in wifi AP mode as described to a higher place, and then it could even offer a friendly web interface for editing the config file. Please feel free to post your have ideas/questions/treatment in the comments feast.

I want to give huge, mega props to the makers of FluidSynth and Polyphonic letter for providing free, open-rootage software we can completely use to make great music. I love using this thing, and you made it possible!

Be the First to Share

Recommendations

  • Anything Goes Contest 2022

    Anything Goes Contest 2022