Skip to Main Content
University of York Library
Library Subject Guides

Coding: a Practical Guide

Sonic Pi

Sonic Pi

Want to learn how to live code music?

Sonic Pi is a coding language and code-based tool for music creation and performance that is also a useful way to learn coding concepts whilst making sounds.

What is Sonic Pi?

Sonic Pi is a coding tool and language that allows you to create music. You do this by writing your music as code and then setting it to play either a certain number of times or in a loop.

Not only can you create music quickly and "live code" your music to change when performing, but you can also use Sonic Pi as a way to learn coding in a more creative way rather than focusing on abstract concepts or working with data.

Sonic Pi is based on the coding language Ruby and any code files you save will be saved as Ruby files. However, you can learn Sonic Pi entirely separately from other coding languages and do not need any coding experience to have a go with it.

The Sonic Pi interface has a space for code that will often have live_loop written and then actions like sample or play or sleep. Buttons like run and stop allow you to control the run of the code.
A Sonic Pi screen showing some sample code.

How to get started with Sonic Pi

The first thing you need to do to use Sonic Pi is to download and install it on your device. You can do this from the Sonic Pi website. Sonic Pi is not available on University computers.

If you want to start learning Sonic Pi and the coding language it uses, there's a tutorial on the Sonic Pi website that gets you started with the basics and then goes into more depth. We have also created a Sonic Pi guidance booklet to sit alongside our Sonic Pi workshops that you can use.

The Sonic Pi website also has a range of example code that varies from simple to more complex. You might find it useful to play these examples and see what they sound like to get a sense of how the code works.

Exercises

If you'd like to have a more structured exploration of Sonic Pi, here are some exercises we've developed for our Sonic Pi session that you can use:

Feedback
X