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.

Note

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 the previously shown features:

play :Fs4

Note

An octave is a range of sounds where the lowest pitch is exactly half that of the highest pitch. The repeating sequence of keys on a piano represents different octaves. An octave covers the notes A, B, C, D, E, F, and G; as well as A# (or Bb), C# (or Db), D# (or Eb), F# (or Gb), and G# (or Ab). Two notes that are an octave apart tend to sound good when played together.

Part of the beauty of representing notes as numbers in Sonic Pi is that we do not have to stick to whole numbers, as we do with many physical instruments. We can play note 60.5 or 71.419, or any other number we like.

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

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