Progressing drum beats

I’ve been working on a drum machine that changes beats during a song/track.

It’s almost there… the pattern does change, and you can choose the beats by
careful selection of your patterns beforehand.

But somethings not quite right in the durations, which I can’t put my hand to…

use_bpm 120

drum_pattern = (ring 234, 1293, 33536, 3453, 234, 3763, 1293, 3872, 1293, 234)
drum_duration = (ring 4,4,8,4,4,8,16,16,16,16)

set :pattern, drum_pattern.look
set :duration, drum_duration.look

live_loop :drums do
  
  this_pattern = get :pattern
  this_duration = get :duration
  
  use_random_seed this_pattern
  
  puts this_pattern
  puts this_duration
  
  this_duration.times do
    
    sample :bd_haus if one_in(3)
    sample :sn_dolf if one_in(5)
    sample :drum_cymbal_closed if one_in(2)
    sleep 0.5
  end
end

live_loop :controller do
  this_duration = get :duration
  sleep this_duration-1
  set :pattern, drum_pattern.tick
  set :duration, drum_duration.tick
  sleep 1
end

Eli…

Added a simple ’ ride ’ and all seems on time ?
‘’
use_bpm 120
drum_pattern = (ring 234, 1293, 33536, 3453, 234, 3763, 1293, 3872, 1293, 234)
drum_duration = (ring 4,4,8,4,4,8,16,16,16,16)
set :pattern, drum_pattern.look
set :duration, drum_duration.look
live_loop :drums do
this_pattern = get :pattern
this_duration = get :duration
use_random_seed this_pattern
puts this_pattern
puts this_duration
this_duration.times do
sample :bd_haus if one_in(3)
sample :sn_dolf if one_in(5)
sample :drum_cymbal_closed if one_in(2)
sleep 0.5
end
end
live_loop :controller do
this_duration = get :duration
sleep this_duration-1
set :pattern, drum_pattern.tick
set :duration, drum_duration.tick
sleep 1
end

live_loop :ride do
synth :dull_bell, note: 93, release: 0.3, amp: 0.3
sleep 0.5
end

``

I could have only suggested that you might want an explicit sync to make the drums and controller thread guaranteed to execute in a certain order. Though on first glance it does not look like it should matter.

You have two ticks in the controller loop, that might be it.

Does it sound as if with a problem to you ?

Hi David.

Looks like you got it. :slight_smile:
Thats what I get for writing code at 3
a.m. after a few Bacardi’s.

EDIT: And I also missed a tick higher up.

sample :drum_cymbal_closed if spread(3,16).tick

Ah well.

Eli…