How to change different instruments' sleep rhythms live?

This is the kind of thing, I’ve put in some percussion so you can hear what’s going on

##| ToneRhythm = [1, 1]
use_bpm 100
ToneRhythm = [1, 0.333, 0.333, 0.333, 1]
ToneRhythmLength = ToneRhythm.length

live_loop :a, sync: :metronome do
  sample :perc_snap, amp: 0.1
  in_thread do
    ToneRhythmLength.times do
      play :e2, attack: 0, release: 0.5, cutoff: 100
      sleep ToneRhythm[tick(:tone_tick) % ToneRhythmLength]
    end
  end
  sleep 4
end

live_loop :metronome do
  sample :drum_cymbal_pedal, amp: 0.1
  sleep 1
end
2 Likes