I am stuck on the tutorial regarding sync. For the codes below, I was expacting that the note e4 and the snare would sound the same time on every beat but instead, the snare hit comes in one beat later and only on the even beats afterwards. I can’t get my head wrapped around it. I thought the whole purpose of sync is to make sure the snare loop (contains sync command) starts the same time as the testNote loop. I am clearly missing something. Could some one enlighten me? Thank you,
live_loop :testNote do
play :e4, release: 0.5
live_loop :snare do
Thanks. your code is exactly what I was expecting would happen to my code. I still don’t understand why my code doesn’t behave this way…
I guess I just need to read on the tutorial maybe it’ll become clear later…
Thanks Ethan. Just when I thought I understood what’s happening with cue and sync, the code below confused me.
notes = scale(:a3, :aeolian).shuffle
synth :dpulse, note: notes.tick
when I hit alt+r the first time, it won’t play the live_loop met. It just plays the synth for 8 beats. But when I hit alt+r again, both blocks will play simultaneously. If now I hit alt+s to stop it and then play again, then just the synth sound again… would you mind explaining to me what’s happening…thanks.
Here, you have some code outside a live_loop, and some other code inside a live_loop.
Code in a Sonic Pi (Ruby) file is interpreted from top to bottom - in this case, this means the code not in the live_loop is interpreted first (this being the 8.times loop) and 8 times, a cue is sent, a note is played, and the script waits for a little time.
Once that has all finished, the live_loop is interpreted and immediately created by Sonic Pi. By this time, all the cues are in the past.
This means that the sync continues waiting for a cue that will never come.
Sam explains this fairly well I think in the issue I raised a few years back:
The reason it works after you re-run is because by that time, Sonic Pi has already interpreted and created the live_loop, (which it did in the first run) so it is already listening by the time the 8.times loop executes, and is able to respond.