Getting Started with Sonic Pi on the Raspberry Pi

By Richard Wentk

Sonic Pi is a free music synthesizer and sequencer on the Raspberry Pi. You don’t play it from a keyboard or other instrument — you play it by writing code.

If you’re not into music, it’s a cool way to make some weird sounds. And if you are into music, the only limit is your imagination!

The Sonic Pi computer language is used only by Sonic Pi. You can’t write Sonic Pi code to draw pictures, make games, or run a website. Some of the things Sonic Pi can do appear in other computer languages, too, but the code that makes them happen doesn’t look the same.

Launching Sonic Pi

If the desktop isn’t already running, launch it with the startx command.

Click the menu button at the top left and choose Programming→Sonic Pi, as shown in the following figure.

image0.jpg

Sonic Pi takes a while to load. When the splash screen with the logo and the information about Sonic Pi disappears, click the second button at the top right of the window bar to maximize the window and make it fill the screen.

You can also close the About window with the credits. You don’t need it while Sonic Pi is running.

Setting up sound on the Pi

Sound on the Pi just works — mostly. You may need to experiment with the Sonic Pi settings — called Prefs or Preferences — depending on the hardware you use to listen to the sound.

To show the Prefs, click the tiny arrows at the far right of the bar with the buttons at the top of the window. The arrows are next to the Help button.

When a button labeled Prefs appears, click it.

The following figure shows the Preferences. You can use Raspberry Pi System Volume Slider to set the volume.

image1.jpg

The sound quality of the Pi’s headphone socket isn’t brilliant. And because the Pi is a slow computer, you can’t make really big, fat, complicated sounds with it. But you can still have a lot of fun playing with note patterns, synths, samples, and FX — even if you don’t know much about music, or have never tried to play an instrument.

The Pi 2 is much better for music than the original Pi. It’s faster, so you can make bigger sounds. You can also buy external sound boards for your Pi with much better sound quality. Search online for Pi sound card for details.

If you don’t hear any sound when you use Sonic Pi, you probably need to select a different item in the Raspberry Pi Audio Output box.

If you have a TV or monitor connected but you want to listen through the Pi’s headphone socket, click the Headphones item.

If you want to listen to the sound through your TV or monitor speakers, click the HDMI button.

If you leave the setting unchanged, the Pi guesses what you want. If you have a screen connected with an HDMI lead and it doesn’t have speakers, you may not hear anything unless you change the Prefs to send the sound to the headphones.

Click the tiny cross at the top right of the Prefs when you’ve finished.

The Pi has a very basic sound chip, and the sound on the Model B+/A+ isn’t great. It’s better on the Pi 2. The easy way to hear sound is to plug some headphones or earbuds into the socket on the side of the Pi. If you have some speakers, you can plug them in to the same socket. Keep the volume down at first! Turn it up to a comfortable level using the Prefs so that you don’t deafen yourself.