Sonic Pi uses code to compose a dance party

No readers like this yet.
open source music with piano keys background

Sam Aaron is a live coder who considers programming a performance. He created Sonic Pi, an open source live coding synthesizer that lets people use code to compose and perform in classical and contemporary styles ranging from canons to dubstep. By day, Aaron works as a research associate at the University of Cambridge. By night, he codes music for people to dance to.

Aaron is a keynote speaker at OSCON Europe in Amsterdam this year, October 26-28. In this interview, he shares insights on the what, why, and how of Sonic Pi and its creative uses.

What is Sonic Pi? Is it a musical instrument or a programming language?

Sonic Pi is a musical instrument that happens to use code as its interface. It's also a programming environment that happens to be very capable of making sophisticated sounds. It's actually many things—a tool for learning how to program, for exploring new notations for music, for improvising electronic music, for collaborating on musical ideas via text, for researching new programming techniques related to time and liveness. Most of all, it's a lot of fun.

Why did you create Sonic Pi?

In the UK, schools have just introduced a new computing curriculum focused on teaching school children how to program and control the ever-increasing number of computers in our world.

Sonic Pi was originally created to help engage school children with this new subject. I worked very closely with teachers to develop Sonic Pi whilst creating lesson plans that taught bass lines and riffs rather than lists and functions. It just so happens that in order to make music with Sonic Pi, you have to learn to code.

Sam Aaron playing music with Sonic Pic

Photo by Sam Aaron, Copyright.

Sonic Pi's forte is live coding. What is live coding and how is it performed?

Live coding is the act of programming as a performance. Typically, this means that live coders are coding in front of an audience that is directly interested in the code the performer is writing. This might be to demo a new library, teach a new technique, or answer a business question in real time. I use it to create music for people to dance.

Sonic Pi makes it very easy for anybody to live code music. It provides a wonderful tool called the Live Loop, a new kind of loop which can be changed whilst it's running. Sonic Pi's Live Loops are inherently concurrent, which means you can have many running at once just like you might have many members of a band—one playing drums, the other bass, and another driving some ephemeral synth leads.

To perform with Sonic Pi, you just need to write one or two Live Loops and then hit the Run button to start them off. You're then free to modify one or all of them, and the next time you hit Run the changes will kick in. Write code, hit run, write code, hit run, that's all there is to it.

Who should learn Sonic Pi?

Everybody! I believe that programming is just as important as reading and writing for human creativity and expression. Sonic Pi jumps straight to that creativity in the simplest possible way—so simple that a 10-year-old can do it (and they do).

If you haven't yet learned to code, can code but haven't learned to make music, or just want to experience the amazing creative power of code, Sonic Pi is for you.

By making Sonic Pi open source, what new innovations are happening?

It's important to me that the tools I create to be as beneficial to as many people as possible. I don't see the point in making something that just benefits me (creatively or financially). By making Sonic Pi free, it opens up the audience to anyone with a computer. Also, by making Sonic Pi run on a Raspberry Pi, it opens up the audience to everyone with access to electricity and a TV.

The free open source nature of Sonic Pi has fabulous benefits in that it is the foundation for a friendly community of people sharing and contributing new ideas. Many of the new features in Sonic Pi have been contributed by other developers for free because they want to help. Sonic Pi even has a core team of volunteer developers who work together to keep the software fresh, exciting and powerful.

One last question: imagine a world without sound. Can Sonic Pi survive?

Sonic Pi's core is a live coding system that contains a strong timing model. Sound is just one of many applications of this system. For example, you can already live code Minecraft Pi Edition from Sonic Pi on your Raspberry Pi. Just think about that for a moment: modifying code that is in turn modifying the Minecraft world—live. Of course you can also combine sounds with it to make a full audio-visual experience.

It's not too hard to imagine extensions to Sonic Pi that could control DMX lighting rigs, robots, visualizations, to name a few. The exciting thing is that the readers out there will have better ideas than me, and Sonic Pi allows them to make their ideas real and share them with others.

User profile image.
Lakshman is a Senior Principal at Infosys. He nurtures the Open Source and Architects community at Infosys. He holds a Master's degree in Engineering. Software is eating the world. Do you know which software is eating the world? Open source software! Follow lakshman on Twitter @lakshmag


As a programmer, amateur musician and parent of homeschooled children, this topic, and especially the idea of 'live' coding is very interesting. There are a lot of tools that attempt to ease kids into programming (using visual buiding blocks, etc), but ultimately its the ability to see the effect of what you are writing that matters. I will definitely give this a spin. Thanks for the article and interview!

I plan to attend the Chelmsford Raspberry Pi Jam session on Sunday, 1st November. I hope to discuss sonic pi with delegates.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.