I found it’s useful to stop a loop using a bogus sync like sync :stop below. But if comment it out, and Alt-R it doesn’t start again. It does if I issue a cue :stop somewhere. Why is that? Not academic, it’d be a useful trick for live work. The alternative being an if…then…end which is more code and easy to get wrong in the moment.
Any way to make it work? Thanks
live_loop :a do
play :c4
sleep 4
end
live_loop :b, sync: :a do
#sync :stop
3.times do
play :g4
sleep 1
end
end
I think this is because when you comment it out and rerun, then the loop is still waiting for the cue to arrive and is stuck at that point, and it is only when it receives this and goes to the end that it picks up the new version with the comment in it and starts to use that, on subsequent passes.
Correct, sync is something that makes that thread (live_loop) wait precisely for the matching external event (cue). Any changes to the live_loop’s code are not reflected until it is received and the thread ‘wakes up’ to continue execution.
Thanks. In that case, if I can rely on the original thread never running, I have a workaround of renaming the loop :b1, :b2… so it creates a new one. That’ll do
live_loop :b1, sync: :a do
#sync :stop
3.times do
play :g4
sleep 1
end
end
You have no idea how many times I have put my foot in
my mouth over simple things, like this…
I’ve come to the forums with some of the dumbest problems,
and been gently pointed at the solution, without a hint of
condescension or (heck, whats the word I’m looking for…)
judgement.
Apart from the fact I’m hooked on SP, the quality of the
SP forums is what keeps me posting.
So whilst I’m laughing at your error… I’m laughing -with-
you… not -at- you…