Hi Matt
Welcome to Sonic Pi.
From your thread, I guess that you are using recordings of audio loops as samples and are trying to get them to play together. In fact Sonic Pi is incredibly accurate with timing and it matters a great deal the accuracy with which samples last if you want to be able to play them continuously and sync them together.
Lets look at three of the build-in samples
try this program
puts "bd_haus lasts ",sample_duration :bd_haus
puts"loop_amen lasts "sample_duration :loop_amen
puts loop_compus lasts ",sampleUdration :loop_compus
This produces
├─ "bd_haus lasts " 0.21993197278911564
├─ "loop_amen lasts " 1.753310657596372
└─ "loop_compus lasts " 6.486485260770975
I order to get these to play nicely together and continuously in loops we need to determine the loop duration accurately and force the samples to play for accurate times that we can handle.
If we just want a sample to repeat continously we can set the duration of the loop to be equal to that of the sample length.eg
live_loop :amen1 do
sample :loop_amen
sleep sample_duration :loop_amen
end
This works nicely, but the duration of the loop will be 1.753310657596372 beats or 1.753310657596372 seconds assuming we are using the default bpm of 60.
It is difficult to sync other looping samples to this time directly. The trick is to change the sample time to something much easer to handle by stretching the time that the sample takes to play, either by speeding it up or by slowing it down. This is done using the opt beat_stretch:
Here is a programs that plays all three samples synced together in loops
puts "bd_haus lasts ",(sample_duration :bd_haus)
puts"loop_amen lasts ",(sample_duration :loop_amen)
puts "loop_compus lasts ",(sample_duration :loop_compus)
live_loop :dr,delay: 0.001 do #see delay note at the end
sample :bd_haus #percussive sample lasts less that 1 beat
sleep 1
end
live_loop :amen,sync: :dr do
sample :loop_amen,beat_stretch: 2 #slow down to 2 beats
sleep 2
end
live_loop :compus,sync: :dr do
sample :loop_compus,beat_stretch: 8 #slow down to 8 beats
sleep 8
end
These will all play nicely together. The delay parameter in the :dr loop ensures that the two other loops are waiting to go before the :dr loop starts and sends a sync cue to start the other two loops at the same time. Without it (try missing it out) you will get a single ;bd_haus drum and then the other loops will start synced on the second pass of the :dr loop.
Hope this gives you a starting point from which to experiment. See section 3.3 of the Tutorial for more.