A Glimpse into Sonic Pi: “the live coding music synth for everyone”

women coding live music in a nightclub

Are you a music lover? 🎵 Do you know the coding language Ruby? Is your deepest desire to fuse coding and music together? If you answered yes to one or all, or even none of these questions, it’s about time you take a look at a live coding music app called Sonic Pi. Sonic Pi was engineered by Sam Aaron, it is a Ruby language based app that can be downloaded for free on macOS, Windows, and Raspberry Pi OS. It’s programmed to allow you to create or perform music in a major range of styles from Classical, to EDM, that’s pretty dang cool. It has even been sweeping the New York Live Music Scene.

Ok, first of all what does this Sonic Pi coding music sound like?

Check out this link to a “Live Coding Practice of Sonic Pi’s creator Sam Aaron.

https://www.youtube.com/watch?v=Xj7rGq2sd_s&ab_channel=SamAaron

Go to 19:48 minutes in for one of my favorite sections of the session.

You can use the program to easily turn text or code into music.

This is a snippet of Sonic Pi code that will continuously play a music pattern.

Why choose Ruby for this program?

It’s a powerful language that can be manipulated easily. Sam Aaron used to be a professional Ruby programmer, he wanted to “take it {Ruby} and morph it like clay and manipulate it” A major advantage to using Ruby is that the white space before the code doesn’t mean anything, unlike other coding languages. This allows for the code to get a little messy which translates perfectly to a explorative and powerful live music coding environment for a coder of any age or experience.

A run around of the basics of the program. It’s designed to be very simple to use. When you download the app to your computer, there’s an easy to follow tutorial to guide you. Effectively you will be using code to select different sounds, and you’ll be making music in no time!

‘Play’-ing sounds.

The text word ‘play’ will in fact play your notes.

‘Play 60’ , will play a singular beep tone. For all you musicians out there this ‘60’ denotation is equivalent to the middle C of the piano.

Feeling the ‘Sleep’

The keyword ‘sleep’ in the code, translates to a break in the sound, like a musical rest. Each instance of ‘sleep’ will have a duration that corresponds to it’s number. A bigger number like ‘1’ will mean a longer rest between sounds.

Creating Loops.

Coding “__”.times will create a repeated loop of whatever musical sounds/notes you select. Say you chose “8.times” like in the Sonic Pi code snippet below, whatever is inside of the “do ___ end” statement will be played [ looped] 8 times. Pretty fun right?

Making Live Music with Code.

There’s an option to make recordings of the music you code, or you could perform the coded music live, manipulating it as you go as a gigging guitar player would.

Take some time to search the library of sounds. There’s so many different sounds to make music with in the app, ranging from synths, guitar, piano, to musical effects. A person who has ever produced music with FL Studio, Ableton, or even Apple’s GarageBand might feel this program has some comparable qualities. One thing that really stands out about Sonic Pi is the magic of using CODE to create music, it has inspired the live music scene of New York, and it might just be the future of music.

Software Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store