I know that there has already been a lot of discussion around the cue/sync behavior and I looked at some other threads but I don’t seem to figure out what’s happening here.
As I was following the tutorial I came around to 9.3 Multiple Live Loops. There is an example that uses the implicit live_loop sync which should line up two different live_loops:
live_loop :foo do
play :e4, release: 0.5
sleep 1
end
live_loop :bar do
sync :foo
sample :bd_haus
sleep 1
end
(Note that I changed the first sleep value from 0.5 to 1 to make the issue more apparent).
When I run this snippet the sequence of events is as follows:
{run: 874, time: 0.0, thread: :live_loop_bar}
└─ sync :foo
{run: 874, time: 0.0, thread: :live_loop_foo}
└─ synth :beep, {note: 64.0, release: 0.5}
{run: 874, time: 1.0008, thread: :live_loop_foo}
└─ synth :beep, {note: 64.0, release: 0.5}
{run: 874, time: 1.0008, thread: :live_loop_bar}
├─ synced "/{cue,set,live_loop}/foo"
└─ sample "~/projects/sonic-pi/etc/samples",
"bd_haus.flac"
{run: 874, time: 2.0008, thread: :live_loop_bar}
└─ sync :foo
{run: 874, time: 2.0008, thread: :live_loop_foo}
└─ synth :beep, {note: 64.0, release: 0.5}
{run: 874, time: 3.0008, thread: :live_loop_bar}
├─ synced "/{cue,set,live_loop}/foo"
└─ sample "~/projects/sonic-pi/etc/samples",
"bd_haus.flac"
{run: 874, time: 3.0008, thread: :live_loop_foo}
└─ synth :beep, {note: 64.0, release: 0.5}
{run: 874, time: 4.0008, thread: :live_loop_bar}
└─ sync :foo
{run: 874, time: 4.0008, thread: :live_loop_foo}
└─ synth :beep, {note: 64.0, release: 0.5}
{run: 874, time: 5.0005, thread: :live_loop_bar}
├─ synced "/{cue,set,live_loop}/foo"
└─ sample "~/projects/sonic-pi/etc/samples",
"bd_haus.flac"
{run: 874, time: 5.0005, thread: :live_loop_foo}
└─ synth :beep, {note: 64.0, release: 0.5}
{run: 874, time: 6.0005, thread: :live_loop_bar}
└─ sync :foo
{run: 874, time: 6.0005, thread: :live_loop_foo}
└─ synth :beep, {note: 64.0, release: 0.5}
If you look carefully at the timings you get one bar for every two foo.
If I remove the sleep 1 from bar then they are in sync. The same happens if I just set it to 0.9, so there’s clearly some timing issue: probably bar is still sleeping and skips a cue. Similarly if I use the opt sync: :foo they are also in sync:
live_loop :bar, sync: :foo do
sample :bd_haus
sleep 1
end
(You still get one extra foo before bar starts, but I guess that’s expected.)
So my question is: is this behavior expected? Maybe using the opt sync: :foo would be better for the tutorial, otherwise the audible effect is very confusing for a beginner.
Thank you! Looking forward to discover Sonic Pi in depth!