Intro to Sonic Pi and Coding Sound

From The Museum of Human Achievement


By Diane Sung CATS+ Spring 2025 Resident ShowcasePublished: June 25, 2025

This is an artist page by Diane Sung. Diane was a resident during the CATS+ Spring 2025 cohort.

Introduction

I started using Sonic Pi because I wanted to make my sound effects for animations. Personally, I wanted to have more control and rely less on searching through endless royalty-free sites. I wasn’t trying to make music or a song, so much as a soundscape to complement the rest of my work.

I think Sonic Pi is a great resource to dabble in sound-making, especially if you don’t have a musical background or have ready access to instruments, mics, expensive equipment, etc. Once you get into it, it’s a pretty powerful tool. You can make and record your own soundtracks or even perform live coding sessions for an audience.

Getting Started

You can download Sonic Pi for free here!

When you first open it up, there should be a window at the bottom that is full of extensive tutorials and lists of different synths and samples you can code with. At the top, there are buttons to run, stop, and record what you’ve coded.
Screenshot of the opening dashboard of Sonic Pi software when first opened

Coding Sounds

Basic Functions

Sonic Pi uses numbers that coordinate to regular music notes and octaves like E flat or middle C. For example, 60 corresponds to middle C. Here’s a chart that shows all the octaves in detail.
Screenshot of Sonic Pi showing coding examples of individual notes

If you type

play 60

A default synth will play middle C for a beat.

If you want multiple notes, you need to code for the silences in between sounds, just like rest symbols in sheet music. In Sonic Pi, it’s called sleep, and the default value for a beat is 1. That lets you start piecing notes together like this!
<bbr> play 60
sleep 1
play 62
sleep 1
play 74

Screenshot of Sonic Pi showing a coding example of multiple notes

You need all these spaces in your code too, otherwise it won’t be readable by the software. You’ll usually know if you typed something right if it lights up in a specific color.

Varying the Sounds

You can vary the notes you’ve coded by adding functions. Attack is how long it takes for your note to reach its default volume. Sustain is how long it plays at that default volume. And release is how long it takes for the note to fade out. Add any number to these functions, and that effect will be applied for that many seconds.

For example:

attack:2
sustain:0.8
release:6

Screenshot of Sonic Pi showing a coding example of how to modify notes with a diagram explaining how the sound is affected

Next you can change the synths from the default sound to a lot of other fun options. There’s an extensive list in the tutorial window under the tab labeled ‘synths.’ I’ve used a fun beepy one called tb303 in the example picture below. There’s also samples available that will play a snippet of a soundtrack. Think of samples as playing a pre-recorded audio clip, and synths as options for changing the sound of your electric keyboard.

use_synth: tb303
sample: ambi_lunar_land

Screenshot of Sonic Pi showing a coding example of synths and samples

Making a Loop!

simultaneously. You simply have to give the loop a name so that the program can tell which live loop is which. The name can be literally anything. Then you make sure to put ‘do’ and ‘end’ around your code to show where you want stuff to repeat.

live_loop: mohacats do

end

Screenshot of Sonic Pi showing a coding example of a live loop

Using the live loop function, you can make as many different tracks play simultaneously as you want! As long as they have different names!

Screenshot of Sonic Pi showing a coding example of multiple loops with different names

My Projects and Code

I’ve found Sonic Pi to be a very user-friendly and accessible way to make specific sounds and try out creative coding. This one’s a personal project, it’s a stopmotion short called ‘scribe’. It’s my first go at making and editing my own sounds, and all the synth noises (especially in the second half) were made using Sonic Pi.

Additional Resources

There’s an online forum for Sonic Pi called in_thread where you can find lots of other people sharing ideas, projects, and troubleshooting the software together. I like to look at other peoples’ coding and try to deconstruct it for myself. I find that I learn a lot of new things through that the most.

There’s also this Youtube playlist with some really short but solid tutorials on all sorts of fun code that expands upon what’s in this wiki page.