Drum patterns, sleep, and bpm

This is an interesting one.

I am not 100% sure why there is a difference purely when changing the tempo - perhaps a rounding error in the internal code? I do know that the behaviour you’re hearing at 110 bpm is due to the :snahre loop waiting 4 beats in between triggering the snare sample, rather than every 3, due to the sync :buup making it wait an extra beat every time around.
One hacky way to make it behave the same way as this at the higher tempo is to replace the sleep 3 in the :snahre live_loop with the following:

  3.times do
    sleep 1
  end

Having said all that, using sync X inside a live_loop like you do here to act as a regular metronome between loops is often not a very workable approach, as it can lead to situations exactly like this. It is usually better to synchronise loops purely when they are first created and let them then just act independently from then on.

Here is how you could write your code using the (usually) recommended way to synchronise live_loops:

use_bpm 140

live_loop :buup do
  sleep 1
end

live_loop :seembal, sync: :buup do
  sample :drum_cymbal_closed, amp: 0.2
  sleep 1
end

live_loop :snahre, sync: :buup do
  sample :drum_snare_soft
  sleep 4
end

live_loop :keek, sync: :buup do
  sleep 1
  sample :drum_heavy_kick
  sleep 1
  sample :drum_heavy_kick
  sleep 1
  sample :drum_heavy_kick
  sleep 1
end

Notice that the snare loop clearly still triggers the snare every 4 beats, without having to rely on a confusing sync in the middle of the loop. (Incidentally, we can also do away with the unnecessary sleep before the kick drum loop, and shift it inside the loop itself. There are a bunch of other optimisations that you could also do, but the above are what I would suggest to start with).

If you are interested, threads such as this explain the various uses of sync helpfully in detail:

1 Like