Generate sounds
Remember chord
? The chord function gives you the notes of a certain chord:
There’s also a function called scale
. Scale returns all the notes in a scale, not just the ones in a chord:
With choose
you can get a random element from a list. If you want to go through the values in a more structured manner, Sonic PI has a very powerful function called tick
:
Here, we’re just grabbing the scale E3 minor pentatonic and ticking through each element. This is done by adding .tick to the end of the scale declaration. This tick is local to the live loop, so each live loop can have its own independent tick:
You can tick through anything that is a ring (well, you can tick through lists also but it will stop when you get to the end). Ring is a special list, that starts over when you get to the end. Like in the previous example the scale started again from the beginning after reaching the last note. scale
and chord
both return a ring. Sometimes you’ll want to create a list and turn that into a ring by calling .ring
or using the ring
creator:
Here’s a bit more complex example. Here you have a list or chords that is turned into a ring and ticked through:
And then top it off with a lead ‘melody’:
Start ticking, go wild!