home/ atoms/ sonicpi-sync-blocks-until-next-cue

Sonic Pi's sync waits for the next cue from that point, so a loop with sync at the top delays its first pass by up to one cue period

sync :tag in Sonic Pi blocks the current thread until the next occurrence of a cue named :tag is broadcast. It does not catch a cue that has already fired moments before the sync was reached. This means: adding sync :beat at the top of a live_loop causes the loop to sit idle until the next :beat cue, which may take up to one full cue period — a delay that can be surprising if the cue is slow. Additionally, sync :ghost hangs forever if no other loop is running that emits :ghost. A live_loop auto-cues its own name every cycle, so sync :drums works correctly only if a live_loop named :drums is already running.

Examples

live_loop :hi do\n sync :beat\n sample :hh_open\nend — the hi-hat loop waits silently until the :beat loop fires its first cue.

Assessment

Why does sync :bass at the top of a live_loop sometimes delay the first sound by up to one bar? What guarantees sync :drums will work without hanging?

“`sync` waits for the *next* cue, discarding the current instant.”
context/ · L1-instruments/sonicpi/gotchas.md · chunk 1