And how about this one, which uses pattern ‘masks’ to apply fills with variations, all of which can be edited live.
#Drumkit with mask variations
use_bpm 120
live_loop :drumtest do
cue :bar
sleep 4
end
define :r0 do
"1---2x--3---4-x-".ring.tick(:r0)=="x" and one_in(2)
end
define :r1 do
"1---2---3---4xxx".ring.tick(:r1)=="x" and one_in(2)
end
live_loop :drums do
sync :bar
#stop
a = 1.0
n = tick(:bar)
s = [:drum_bass_hard,
:drum_snare_hard,
:drum_cymbal_closed,
:ambi_swoosh]
define :p do |i|
case i
when 0
sample s[i], beat_stretch: 1.5, amp: a*0.3
when 1
sample s[i], amp: a*0.2
when 2
sample s[i], beat_stretch: 1, amp: a*0.1*[2,1,1,1].ring.tick(:hat)
when 3
sample s[i], beat_stretch: 0.5, amp: a*0.1
end
end
with_fx :echo, mix: 0.1, phase: 0.75, decay: 6 do
with_fx :lpf, cutoff: 130 do
in_thread do
16.times do
tick
p(0) if ("x-----x-x-------"[look]=="x") ^ r0 #^ one_in(24)
p(1) if ("----x-------x---"[look]=="x") ^ r1 #^ one_in(24)
p(2) if ("xxxxxxxxxxxxxxxx"[look]=="x") #^ one_in(0)
p(3) if ("-x--x--x--x-----"[look]=="x") ^ one_in(16)
sleep 1.0/4
end
end
end
end
end