Live loops Sync questions :-)


#21

Exactly Martin. Trying to sync without the delay is like the conductor giving his/her initial downbeat without any warning whilst the players (the other live loops are still getting their instruments ready, so they miss the first bar and start at a later bar start from the conductor. With the delay the subsidiary live loops all start and wait the “conductor’s” cue which comes a little (0.01 beats) later.


#22

There is one (more theoretical) question concerning the technical background, which I would like to be ansered for myself. Is this the correct description in plain words:

A synced live_loop can’t just start together meaning at the same time with the cueing loop. The synced live loop notices the ‘first’ cue (which concerning the runtime of the whole script for it happened to be in the past) and then starts with the next cue. So syncing needs kind of to be announced to actually i. e. audibly to happen.


#23

Yes I think this is a fair statement that you make Martin.
Sam stated this when Ethan raised the sync issue on the Sonic Pi github site.

In v3 I made this deterministic which also meant deciding on a repeatable set of semantics. This in turn means that each cue is totally ordered across all runs and all syncs are also ordered. In v3 syncs will only catch cues after them. Which means that for threads syncing and queueing on the same logical time, their thread ID will determine whether they are before or after.

In other words for a sync to work you should make sure that the cue is sent AFTER the sync is waiting for it. For two live_loops starting at the same time, delay the one you wish to sync to slightly and they will then start together. (The second one waits for the first to send a cue as it starts).


#24

Hi,

I hope any conductor is reading your post… The conductor is the metronome and as a metronome he has to be on the beat and not 0.01 seconde after…

The conductor is of course raising its stick before the beat and not after.

And computers are used because they are kown to be very accurate. so a metronome indicates the correct beat and musicians can rely on it.

According to me there is no valable explanation of this bug, it’s not a feature it’s a sad bug and i understand why you met lot of people not understanding this. It’s not logical as a musical point of view.

So this how it works but it’s a bit sad…
So the code below may help people to clear their mind

# a signal is sent every 1 beat
live_loop :metronome do
  sleep 1
end


# this loop last 4 beats.
# metronome are accurate and that's why we can rely on them
live_loop :drums, sync: :metronome do
  
  sample :drum_bass_hard
  sleep 0.5
  sample :drum_bass_soft, compress: 0, pan: [-1,1,-0.8,0.8].ring.tick
  sleep 0.5
  sample :drum_snare_hard, compress: 1, pan: [-1,1,-0.8,0.8].ring.tick
  sleep 1
  
  sample :drum_bass_hard
  sleep 0.5
  sample :drum_bass_soft, compress: 0, pan: [-1,1,-0.8,0.8].ring.tick
  sleep 0.5
  sample :drum_snare_hard, compress: 1, pan: [-1,1,-0.8,0.8].ring.tick
  sleep 0.5
  sample :drum_snare_hard, compress: 1, pan: [-1,1,-0.8,0.8].ring.tick
  sleep 0.5
  
end

# this loop last 15 x 0.5 = 7.5 + 0.49 = 7.99 beats ! ! ! 

live_loop :hithats do
  sync :drums
  15.times do
    sample :drum_cymbal_pedal, pan: [-0.8,0.8,-0.1,0.1].ring.tick
    sleep 0.5
  end
  sample :drum_cymbal_open
  # sleep 0.50 will NOT WORK it's a bug not a feature :(
  # musicians are not accurate and it saves us :-)
  sleep 0.49
end

best regards.


#25

Hi @nlb,

try this:

live_loop :metronome do
  sleep 1
end

live_loop :drums, sync: :metronome do
  sample :drum_bass_hard
  sleep 0.5
  sample :drum_bass_soft, compress: 0, pan: [-1,1,-0.8,0.8].ring.tick
  sleep 0.5
  sample :drum_snare_hard, compress: 1, pan: [-1,1,-0.8,0.8].ring.tick
  sleep 1
  sample :drum_bass_hard
  sleep 0.5
  sample :drum_bass_soft, compress: 0, pan: [-1,1,-0.8,0.8].ring.tick
  sleep 0.5
  sample :drum_snare_hard, compress: 1, pan: [-1,1,-0.8,0.8].ring.tick
  sleep 0.5
  sample :drum_snare_hard, compress: 1, pan: [-1,1,-0.8,0.8].ring.tick
  sleep 0.5
end

live_loop :hithats, sync: :drums do
  15.times do
    sample :drum_cymbal_pedal, pan: [-0.8,0.8,-0.1,0.1].ring.tick
    sleep 0.5
  end
  sample :drum_cymbal_open
  sleep 0.5
end

Two more thoughts on this:

You are right, it is not the easiest feature to understand in Sonic Pi.

And in defendance of the conductor-metaphor: Have you ever joined a rehearsal of a Jazz band? There will most surely be someone who counts something like that (in the case of a four-four time): “One… two, you know, what to do!” and then everybody is going to start.

Before you can sync to a metronome someone has to make sure that you listen to it at all.


#26

thanks for your help @Martin
indeed your code is working but still don’t understand why mine is not working. i think i’m dumb :slight_smile:


#27

Hi @nlb,

no, if I may say so, you are not dumb at all. This thread did also help me to bring some more clarity. I have these questions during the course I give (and these are probable to pop up at any time) and now I am sure to be able to answer it.

See my grafic, which tries to explain exactly this point (as did the last part of Sam’s explanation). It is all about the fact, that your :hihats will try to sync every time the loop runs. This is a bit like, as if this loop was a musician, who after every bar needs a new start (“one… two… you know, what to do…”) In my example, it does sync one time and then goes on with its own timing. So it is actually listening to sync just once (and remember: the time rule says: a sync can only be recognised if it has happened in the past).

Hope that helps.


#28

I think you misunderstand how this works. It is EXACTLY what a conductor does. When you press RUN all the live loops start and await a sync pulse from the metronome (the conductor). At the same time the “conductor” starts waiting for 0.01 seconds to give the other loops a chance to be ready (equivalent to him/her raising the stick and checking that all the instruments (other live_loops) are ready and waiting for a cue to sync on. THEN the conductor (the metronome) starts giving the first downbeat and all the other loops start exactly in step with the metronome.
There is nothing magical about the 0.01 it could be 1 in which case there would be a slightly longer pause while the “orchestra” gets ready. However, when they start to play they would all be in perfect sync with each other and the conductor, when metronome starts after the 1 beat deal.

If the conductor started without raising his/her stick to warn the other members of the orchestra then chaos could ensue. I have played in several orchestras and this is how it works!


#29

hello everybody,
ok ok maybe sometimes “i’m lost in translation” or miss something : i’m going to read slower your correct post and start again. :smile:

thanks for your help and sorry to waste your time !


#30

No time wasted. This is an important topic. I hope that this thread will help users to get syncing right.


My year teaching Sonic Pi - Week 22