Music with code: Getting Started with Sonic Pi

Ibby EL-Serafy
5 min readDec 8, 2020

I’m going to introduce you to making music with code, without assuming any knowledge of either.

Sonic Pi is a great way to learn either music or code. It’s also great if you’d like to play around with music without having to spend any money.

Let’s jump right in!

Get started by downloading and installing Sonic Pi. If you are on Windows or Mac you can download the installers from the Sonic Pi website. If you are on Ubuntu a community member has created a deb file for easier installation.

Once you’re all set up, you’ll see something like this.

Sonic Pi Program

You’re now ready to make your first sounds!

Making a sound

Type the following into the text area:

play 60

Then click the run on the top left corner of the program.

Your first beep!

Try changing the number and hitting run again. Notice how the sound changes as the number goes up and down. You can even try numbers with a decimal point, like 72.5 try it out.

You can also use letter notes.

play :f

For a sharp note use an ‘s’ after the letter, for example :cs. For a flat note use a ‘b’ after the note, for example :ab. Don’t worry about it if you don’t know what those are, this is the only part of the tutorial where they’re mentioned.

By the way, rather than clicking run each time you can use a keyboard shortcut. On Windows it’s Alt-r and on Mac it’s Cmd-r.

Making several sounds

Now with those first beeps under your belt, you’re ready for your next musical masterpiece: several beeps one after the other! You can do that with this code:

--

--