Live_loop sync forces triple time?


#1

Hi
I’m learning about live_loops and sync. When I run two live_loops without using sync, they are in time, and can be forced out of phase by editing and running again. However, when I sync loop2 to loop1, loop2 falls into triple time; the code below demonstrates the issue:

use_synth :tb303
use_bpm 60
live_loop :foo do
play 42, release: 0.2, amp: 0.3
sleep 0.5
end

live_loop :bar do
/run both loops; uncomment line below then run again/
/#sync :foo/
sample :bd_haus
sleep 1
end

/
expected behaviour:
:kick will sync to :foo,
:kick every second, :foo every half second

actual behaviour:
:kick cycles every 1.5 seconds

/

I cannot find any ‘time-sgnature’ setting. I fear that this behaviour might not be replicated on your machine though (OSX Sierra here)

Thanks


#2

Hi there. I think what you may want is this:

use_synth :tb303
use_bpm 60
live_loop :foo,delay: 0.0001 do
  play 42, release: 0.2, amp: 0.3
  sleep 0.5
end

live_loop :bar,sync: :foo do  
  sample :bd_haus
  sleep 1
end

Using the sync: setting in the live_loop header like this ensures that the second loop starts synced to the start of the first loop. If you subseqeuntly change the second loop, eg chnage the sample played and rerun, it will switch over in sync with the first loop.
Using the delay: 0.001 in the sfirst loop, ensures that the second loop has started and is waiting sync before the first loop starts the first time. The timing of the two lopps is not altgerted, but the whole thing is delayed 0.001 from when you push the start button. Seing as you already have a built in delay 0f 0…2 ecs on a mac or 0.5 on a RPi this is neither here nor there.

Using sync like this only applies any adjustment each time the loop is altered. If you put the sync inside the loop then it tries to resync EVERY time that line is reached, causing the loop to pause until the first loop starts another cycle.

There is no concept of time signature in Sonic Pi, but you can change the beat tempo using the use_bpm setting. The default is 60 beats per minute, in shwihc case a sleep of 1 lasts for 1 beat or 1 second. If you alter the bpm to 120 using use_bpm 120 then sleep 1 actually lasts for 0.5 seconds.

btw when you post code use three back ticks ``` before and after the code to format it nicely on this site. Makes it easier for folk to copy.

EDIT ONE FURTHER POINT. I notice that you have use_bpm 60 INSIDE one of the live_loops This restricts its scope to apply just to that live loop. A use_bpm placed in the main body applies to ALL live loops when they first start. You can have different live loops running with different bpm if you want, specifying them separately inside the live loop. This would override any setting in the main body of the program. The default value for bpm is 60.


#3

Thanks for the detail!

I have watched several demos by Sam, and he uses sync: inside the body of his live_loop, and it seems to work as expected. But declaring the sync: in the loop header makes more sense (and now works for me)

Brendan


#4

[note to self: remember to do a forum search first!!]