Book Image

Raspberry Pi Projects for Kids (Second Edition)

By : Daniel Leonard Bates
Book Image

Raspberry Pi Projects for Kids (Second Edition)

By: Daniel Leonard Bates

Overview of this book

Table of Contents (14 chapters)

Getting started with Sonic Pi

Getting Sonic Pi to create a sound is very simple. Type the following code in the Code Editor and click on Run:

play 60

You should hear a tone.


If you do not hear anything, verify that your speakers are switched on and that the sound is not muted.

Here, we represent different notes as numbers; this is a convenient representation that the Raspberry Pi understands. A higher number represents a higher note. Try it for yourself; change the number and click on Run.

If you know a little about music, you might be familiar with the letter names of notes. Sonic Pi knows these too! Try this code:

play :C

This is the same note as before, but now it has a name. Any note from A to G will work, and you can also place a b or s after the name to make the note flat (lower) or sharp (higher).

Finally, we can put a number at the end of the note name to say which octave the note is in. Again, a higher number will give a higher pitched sound. Here's an example note that combines all...