We have already seen how we can playback music using a Raspberry Pi and Balena Sound, but with this project, we will be able to create our own music. And you won’t need an external musical keyboard or another instrument, or even a MIDI controller, as we can make our music using nothing but code!
Sonic Pi is described as “a code-based music creation and performance tool”, and that pretty well says it all. By using a coding language similar to Ruby, you can create complex musical compositions in just about any musical style.
Installing Sonic Pi
Although Sonic Pi can be installed directly from the Preferred Software menu on the Raspberry Pi, you are better off installing it from the website, as the version on the Pi repository is not the most current one.
It can also be installed on a Windows or macOS workstation, but in our case, we will be using a Raspberry Pi.
The only required part you’ll need is a Raspberry Pi. Of course, you’ll also need to have some sort of an audio device, such as speakers or headphones, connected to your Pi.
While Sonic Pi can technically run on just about any Raspberry Pi, this product benefits from extra memory, so I recommend a Raspberry Pi 4 or Raspberry Pi 400.
Also, as of this writing, the most recent version of Sonic Pi fails to install on the h64-bit version of the Raspberry Pi OS, so you’ll want to format your MicroSD card with the 32-bit version instead.
Sonic Pi Software Installation
To obtain the installation file for Sonic Pi, you just need to open the Chromium browser on your Raspberry Pi and visit the Sonic Pi website.
Scroll down until you see the Raspberry Pi button. Click it, and you’ll be scrolled down even further, to the Raspberry Pi OS section. The big Download button is all you need to click to download the DEB file you’ll require to install Sonic Pi.
Chromium will give you some warning messages as you’re downloading an executable file, you may safely ignore these messages and save the file in your Downloads folder.
Once you have downloaded the file, close Chromium and open up the File Manager. Navigate to the Downloads folder, where you will see the DEB file you just downloaded.
Double-click the file in order to launch the installation program. Follow the onscreen instructions and Sonic Pi will be installed on your Raspberry Pi.
Running Sonic Pi
You might expect to see Sonic Pi in the Sound & Video section of the Raspberry Pi menu, but it’s actually in the Programming section. This speaks to its use as a coding language for music.
When you launch Sonic Pi you’ll get a splash-screen, as is common with many software applications. The splash-screen will display until you click it.
You will then be taken to the Sonic Pi editor. You can do all of your work here, including playing back compositions.
The top left part of the editor is where you compose your code. There are a series of buttons above the editor area which you use to run your composition, save it, load a new one, or even record it.
The right side of the editor displays waveforms while you run your composition.
The bottom section has the documentation, which includes a number of lessons and some sample code that you can try out. I would encourage you to do this so that you can learn more about working with Sonic Pi.
Sonic Pi is a unique product that is both educational and fun. It can ve used by serious musicians, by coders, or just by folks who want to learn more about coding and music and who want to make some great sounds.
So go ahead and expose your creative side by giving Sonic Pi a try. Who knows, you may discover a talent you never knew you possessed!
This article is part of a series of 10 Projects for the Raspberry Pi. Check out the other articles in this series.