Sonic Pi: Realtime music creation for the Raspberry Pi (and more)

Take a Raspberry Pi, add Sonic Pi and it's welcome digital maestro Ludwig van Raspberry!

ludwig van raspberry

Ludwig van Raspberry

Credit: Mark Gibbs

In my last post I discussed a Web-based programming environment for the Raspberry Pi. Today, for your further Raspberry Pi delectation, I have another RPi-compatible programming tool but this it’s rather more specific: It’s called Sonic Pi and it’s for programming music in real time.

Created by Sam Aaron at the University of Cambridge Computer Laboratory, Sonic Pi is a free, open source, live coding synthesizer released under the MIT License. Better still, it not only runs on the Raspberry Pi as its name suggests, it also runs on Windows, Linux, and OS X.

To use Sonic Pi you simply launch the application on whatever platform you've installed it on and start programming in Ruby; the GUI’s Help button displays a really great tutorial on how Sonic Pi works with loads of examples and there’s a free e-book to take you further. When you’ve created your opus, you can hit Play (you can pick up a conductor’s baton if you like). Want to change something? Do it on the fly; make your mods and voila! Realtime music generation! Then if you like your composition you can record it as a WAV file and or save the code in a text file.

screen shot 2016 04 09 at 12.14.28 pm

Sonic Pi user interface

Just to show what a simple Sonic Pi program can do, here’s a  one that makes the sound of the Lightcycle bikes from Tron:

screen shot 2016 04 10 at 1.06.02 pm


z bikes tron

You can hear the output from this in the Examples section of the Sonic Pi site (it’s the third example from the top).

Sonic Pi can also be driven by sending Open Sound Control, or OSC, requests over UDP to port 4557 of the device running the application and there are even plugins for Emacs and Vim that support live coding!

If you’ve had any experience with the loop-based music creation apps such as Apple’s GarageBand or Sony Acid this will seem both familiar and very different. With Sonic Pi you not only work with loops but you also use oscillators and other synthesizer components and you’re interacting with all of the resources in a far more detailed way under Sonic Pi. This detail and complexity arguably provides more control but less immediacy unless you become very fluent with the Sonic Pi language. Check out this article on programming Rimsky-Korsakoff’s “Flight of the Bumblebee” for the Sonic Pi; the author notes “it’s a 5 page score and took about 4-5 hours to program in 1268 lines of code” so we’re out of the realm of instant gratification for serious projects.

But the “heavy lifting” has a huge payoff in education to teach both programming and music and Sonic Pi has an accompanying (ha!) teaching plan for schools. There’s also an even more ambitious teaching project, Sonic Pi: Live & Coding:

… a ground breaking digital research and development project, has been working intensively with Sonic Pi and looking at how the program can be used to provide new pathways for young people into digital music. The research-centred process involved a delivery team of instrumental music teachers, school music and computing teachers, researchers, technologists and artists who worked with children at two secondary schools (KS3) and a five day summer school to explore the creative potential of Sonic Pi and test and develop resources.

This is an amazing set of resources so if you’re involved with education or just want to explore music creation, you need to check Sonic Pi out. Here’s Sam Aaron’s TED Talk, “Programming as Performance”:

Comments? Thoughts? Suggestions? Lay some feedback via email on me or comment below then follow me on Twitter and Facebook.

Must read: Hidden Cause of Slow Internet and how to fix it
View Comments
Join the discussion
Be the first to comment on this article. Our Commenting Policies