Transcript
New Tricks on the Block
Patterns
A list is a way to store a number of items in a single collection. In Sonic Pi a list consists of three main things:
[element, element2, element3]
Square brackets mark the beginning and end of the list. The items inside the list are called elements and can be for example numbers or symbols. The elements of the list are separated by a comma.
play_pattern_timed
needs two lists to make sound. First a list of notes and then a list of sleep values. These two lists need to be separated by a comma.
play_pattern_timed [:C, :D, :Eb], [0.5,1]
What will happen if the list of sleep values is shorter than the list of notes?
Staying Organised
Extra: About Note Lengths in Patterns
Copy this code to an empty buffer in Sonic Pi.
play 60, release: 0.1
sleep 0.5
play 64, release: 0.1
sleep 0.5
play 67, release: 0.1
sleep 0.5
play_pattern_timed [60, 64, 67], [0.5], release: 0.1
Did you notice that the release works differently in the pattern? You might find it strange, but actually the release time is 0.1 in both. play_pattern_timed
sets the default value for sustain:
based on the list of sleep values. Sustain sets how long the note will stay at full volume. By default, play has a sustain value of 0. Try setting the sustain:
option for play_pattern_timed
to 0 to get the same effect as with play!
play_pattern_timed [60, 64, 67], [0.5], release: 0.1, sustain: 0