Taking a Look at the Features in Sonic Pi on the Raspberry Pi

By Richard Wentk

After you’ve made some noise, take a look at the features you can see in the Sonic Pi window. You don’t need to know a lot about music to make sounds with Sonic Pi, but it helps to know what the different features do.

Looking at the code window

The code window is where you write music. The code window is an editor for Sonic Pi code.

Simple? It is, but notice the Workspace buttons under the window. You can edit up to eight projects at the same time. Click a workspace button to swap between projects.

Does that mean you can play eight projects at the same time? Yes, it does! That’s why live coding is so cool — you can make an entire band out of software and make each part start, stop, or play something different.

If you make a mistake in your code, Sonic Pi makes a special window appear under the code window, with some cryptic messages to tell you more about why your code doesn’t work. The messages aren’t easy to understand, but sometimes they give you enough of a clue to fix the problem. You can see an example in the following figure.

image0.jpg

Looking at the log window

The log window shows messages from Sonic Pi. When Sonic Pi plays a note, it adds a message to the window. When you know more about Sonic Pi, you can write your own messages to the window as reminders to yourself.

Mostly you can ignore what happens in this window. It’s not essential reading.

Understanding the Help windows

At the bottom of the screen is a Help window with two sections. The small window at the left is a list of all the features in Sonic Pi, collected into groups. When you click a feature in the left window, the bigger window at the right shows more information about it.

Here’s a list of groups:

  • Tutorial: Step-by-step lessons you can try.

  • Examples: Ready-made projects.

  • Synths: Ready-made electronic sounds to make bass notes, bells, whooshes, beeps, growls, and other noises.

  • FX: Ready-made electronic sound changers that process the sound and make it more interesting. (Or turn it into a grungey distorted mess. But sometimes you want that, so it’s cool.)

  • Samples: A different collection of ready-made sounds. Unlike synths, which make sounds by doing lots of scary math, samples are recordings of drum sounds, looped rhythms, ambient sounds for atmosphere, and the like.

  • Lang: Short for Language — this section lists all the commands and special words you can use in Sonic Pi code.

On a small screen, you can see only some of the groups. If you move the mouse to the top of the Help bar, the cursor changes into a double arrow. Now you can drag the top of the Help window up and down to show more of the help topics and less of the code window.

The following figure shows a much bigger Help window.

image1.jpg

You can listen to the Tutorial and Example code. Click-drag the mouse to highlight the code — it’s red in the tutorials, blue in the examples. Right-click and choose Copy. Select a blank workspace, right-click, and choose paste. Then click Run. To clear a workspace, right-click, choose Clear All, and press Delete.

Understanding the Tools

The Tools along the top of the window control the main features of Sonic Pi. Most tools do more or less what you expect. A few have some not-so-obvious gotcha features:

  • Run: Play the code in the current workspace.

  • Stop: Stop all sound in all workspaces.

  • Save: Save the code in the current workspace. Unfortunately, there’s no Load option yet, although it’s planned for a future version. So ignore this button for now.

  • Rec: Record the sound. When you click Stop, Sonic Pi asks for a filename so that you can save the file.

  • Size + and Size -: Make the code in the window bigger or smaller. This doesn’t change the sound; it just makes it easier/harder to see/edit the code.

  • Align: Apply some magic to make code in the workspace line up the way it should.

  • Info: Shows an info window about Sonic Pi. You won’t need to click this more than once.

  • Help: Shows/hides the Help area.

  • Prefs: Set up sound on the Pi. If you use the Pi with a small screen, you can see this button only if you click the double arrows at the far right of the Tools area.

If you’re not careful, you can make the Tools disappear. To make them reappear, click on the bar to the right of Log in the Log window and choose Tools in the menu that appears.

As of version 2.4 of Sonic Pi, you can’t save and load code. This is a big problem! Supposedly, this feature will appear in version 3. In the meantime, there is a workaround. You can copy and paste code to and from the Leaf editor to save it and reload it. It’s not a convenient fix, but it does the job.

Understanding code completion

When you type a command into the code window, Sonic Pi tries to guess the rest of it. It doesn’t make very smart guesses — it shows possible code alphabetically in a floating menu next to the code.

You can either scroll through the menu with the mouse to pick a command, or you can keep typing to narrow down the options. When the menu highlights the command you want, press Enter, and Sonic Pi types the rest of it for you. The following figure shows the floating menu.

image2.jpg

This feature is called code completion. Many of the code editors used by professional developers include it. It can be a real timesaver, so it’s a good idea to get used to working with it.