Here is some code I wrote during a livestream, for patterns of bars.
Parameters:
use_bpm 100
#Some drum patterns
pattern1 = (bools 1,0,0,0)
pattern2 = (bools 0,0,1,0)
pattern3 = (bools 1,1,1,1,0,1,1,1)
pattern4 = (bools 0,0,0,0,1,0,0,0)
bars = (bools 1,1,0,0,1,1,1,0) #Pattern of bars on/off
beats_per_bar = 8 #Number of beats in a bar
One-shot version:
#One-time version
for f in bars #run through the bars
beats_per_bar.times do
tick #tick at 1/8
if f
sample :drum_bass_hard if pattern1.look
sample :drum_snare_hard if pattern2.look
sample :drum_cymbal_closed if pattern3.look
sample :drum_cymbal_open if pattern4.look
end
sleep 0.5 #1/8
end
end
Live_loop version:
#Live_loop version
live_loop :beat do
tick #tick at 1/8
tick(:bar) if (bools *(knit 1,1,0,beats_per_bar-1)).look
if bars.look(:bar)
sample :drum_bass_hard if pattern1.look
sample :drum_snare_hard if pattern2.look
sample :drum_cymbal_closed if pattern3.look
sample :drum_cymbal_open if pattern4.look
end
sleep 0.5
end
Also a link to the stream, this parts starts at 57:00