< Back to Sonic Pi notes


All the fun ways to directly fiddle with notes and samples

Different parameters to pass into notes and samples to better manage them.


This adjusts a sound’s rate until it plays for a specific amount of time. Great for getting sounds into specific time frames.

sample :ambi_drone, beat_stretch: 8
# This sample will slow down until it takes exactly 8 seconds to play out


Instead of making an extra 16.times block, if you’re using a sample you can instead just use the reps parameter for the same effect.

In the below example, the sound will play four times before choosing another random phase value and going again.

live_loop :break do
  p = [0.125, 0.25, 0.5].choose
  with_fx :slicer, phase: p, reps: 4 do
    sample :loop_amen, beat_stretch: 2
    sleep 2