Chapter 7. Building Beats with Sonic Pi

In this chapter, we're going to use a new application called Sonic Pi to create music using code. We will see how it's possible to create tunes and how the power of programming allows us to experiment and change things much more easily than we can with physical instruments.

This chapter is centered on sound, so you will need some speakers or headphones that can plug into the Raspberry Pi's audio port, or an HDMI monitor with built-in speakers.

Sonic Pi

Sonic Pi is a program designed specially for the Raspberry Pi. It allows us to create music by writing code. You can run Sonic Pi by choosing Sonic Pi in the Programming menu on the Raspberry Pi's desktop. Here's what you'll see:

Sonic Pi

Right at the top, there are all the buttons for controlling Sonic Pi's behavior. We can start and stop a tune playing, save our code, and record our own sounds. We can also decrease or increase the size of the text that our code is written in and neaten it up.

Below those buttons, on the left is the Code Editor, where we will type all of our code. Note that there are multiple Workspace tabs. These allow us to have multiple programs open at a time and switch between them easily. On the right is the Log. This will display information about every note that is played so that you can see what Sonic Pi is doing.

At the bottom is the Help system. This has example code and descriptions of all the sounds and programming features available.

Sonic Pi uses its own text-based programming language. It is similar to Python in some ways and different in others, but all that is important is that we will be doing the same basic operations. We will see throughout the rest of the chapter that all the languages we have seen so far share a core set of features and these features are common to almost every programming language that exists. If you can understand how these features work, all you need to do to learn a new language is learn how that language presents those features.

Note

Sonic Pi is installed as part of the default Raspbian operating system on the Raspberry Pi and is also available on Windows and Mac OS X. It can be downloaded from http://sonic-pi.net/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.104.127