Here is a cut down of my project. The idea is that you specify 1 beat as the length for each different sample stream. Thus you can have :bd_haus say played once per cycle.
Or you could have two …elec_twips played with equal spacing in 1 beat, and so on for three, four… samples per beat. You do this simply by adjusting the sleep time and using a loop to play the sample the number of times required. eg
4.times do
sample :bd_haus
sleep 1.0/4
end
You can put this in a definition with a few more bells and whistles, and run this definition inside a live loop.
define :pl do |s,n,p=0,a=0,sp| #params samplename,beats/cycle,pan,amp,spread value
t=1.0/n
sp = [[n,sp].min,1].max #this line restricts the range of sp from 1..n
use_bpm get(:bpm) #set current bpm
n.times do #play number of samples per cycle for current element
sample s,amp: a,pan: p if spread(sp,n).tick
sleep t
end
end
I add pan and amp settings, and a spread function with range spread(1,n) up to spread(n,n) where n is the number of pulses per beat.
The whole program them becomes
set :bpm,45
define :pl do |s,n,p=0,a=0,sp| #params samplename,beats/cycle,pan,amp,spread value
t=1.0/n
sp = [[n,sp].min,1].max
use_bpm get(:bpm) #set current bpm
n.times do #play number of samples per cycle for current element
sample s,amp: a,pan: p if spread(sp,n).tick
sleep t
end
end
live_loop :metro do
use_bpm get(:bpm)
sleep 1
end
live_loop :s1,sync: :metro do
pl(:elec_twip,6,-1,1,3)
end
live_loop :s2,sync: :metro do
pl(:bd_haus,5,1,1,3)
end
live_loop :s3,sync: :metro do
pl(:drum_snare_soft,3,-0.5,1,2)
end
live_loop :s4,sync: :metro do
pl(:elec_wood,7,-0.7,0.5,3)
end
live_loop :s5,sync: :metro do
pl(:elec_flip,11,-0.5,1,8)
end
The metro loop keeps everything in sync. You can alter any of the paramters for one of the playing loops to adjust sample, number of pulses per beat, pan, amp and spread setting. When you rerun the new settings are taken up next time the live loop starts.
You could use boolean lists instead of spread, and pass in parameters if you want, and you can have further live loops to increase the number of samples used.
You can also adjust the tempo using the first line, and the new value is picked up when the next cycle starts keeping everything in sync.