Here’s a favorite:
sample :loop_industrial
Put that into a new buffer and click Run to hear it. You can speed it up or slow it down by changing its rate. Here’s how you make it play at half its normal speed:
sample :loop_industrial, rate: 0.5
You can repeat that sample to make a continuous rhythm. Similar to composing your own music, you can use the sleep
command to put a pause between each repetition. Samples can be different lengths, however, which can make it difficult to work out how long to sleep. Luckily, Sonic Pi provides a feature in the language to stretch a sample over a certain number of beats, which solves this problem. You can use it like this:
loop do
sample :loop_industrial, beat_stretch: 2
sleep 2
end
Now the sample is stretched over 2 beats, and there is a 2-beat pause between each repetition. As a result, you can hear a continuous rhythm. As you saw when experimenting with live loops, you can change the tempo with the use_bpm
command.