So far we’ve had quite a lot of fun making beeps. However, you’re probably starting to get bored of the basic beep noise. Is that all Sonic Pi has to offer? Surely there’s more to live coding than just playing beeps? Yes there is, and in this section we’ll explore some of the exciting range of sounds that Sonic Pi has to offer.
Sonic Pi has a number of different instruments it calls synths (which is short for synthesisers). Whereas samples represent pre-recorded sounds, synths are capable of generating new sounds depending on how you control them (which we’ll explore later in this tutorial). Sonic Pi’s synths are very powerful and expressive and you’ll have a lot of fun exploring and playing with them. First, let’s learn how to select the current synth to use.
A fun sound is the saw wave - let’s give it a try:
use_synth :saw
play 38
sleep 0.25
play 50
sleep 0.25
play 62
Let’s try another sound - the prophet:
use_synth :prophet
play 38
sleep 0.25
play 50
sleep 0.25
play 62
How about combining two sounds. First one after another:
use_synth :saw
play 38
sleep 0.25
play 50
sleep 0.25
use_synth :prophet
play 57
Now multiple sounds at the same time (by not sleeping between successive calls to play
):
use_synth :tb303
play 38
use_synth :dsaw
play 50
use_synth :prophet
play 57
Notice that the use_synth
command only affects the following calls to play
. Think of it like a big switch - new calls to play
will play whatever synth it’s currently pointing to. You can move the switch to a new synth with use_synth
.
För att se vilka syntar Sonic Pi har tillgängliga för dig, ta en titt på Syntar-tabben längst ned under menyn till det här hjälpfönstret (mellan Exempel och Fx). Där finns mer än 20 stycken att välja från. Här är några av mina favoriter:
:prophet
:dsaw
:fm
:tb303
:pulse
Now play around with switching synths during your music. Have fun combining synths to make new sounds as well as using different synths for different sections of your music.