Here is an example using set and get to vary bpm according to a ring of values.
Eli.
# Eli 17/09/2018.
use_bpm 90
my_bpm = (ring 90,90,100,110,120,120,120,110,100,90,90).mirror
bg1 = (ring 0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.0).mirror
bg2 = (ring 0.6,0.5,0.4,0.3,0.2,0.1,0.0,0.0).mirror
melody_1 = [:c4,:r,:ds4,:ds4,:g4,:c4,:r,:gs4,:r,:r,:gs3,:r,:g3,:r,:r,:r].ring
live_loop :beats do
sleep 1
end
live_loop :bar do
sleep 4
end
# Initially set my_bpm, so the loop works, otherwise
# you'd just get an error message.
set :bvol1, bg1.look
set :bvol2, bg2.look
set :speed, my_bpm.look
#this loop updates the value of my_bpm, but only
#once the main loop has triggered.
live_loop :mixer do
sync :background1
tick
set :bvol1, bg1.look
set :bvol2, bg2.look
set :speed, my_bpm.look
end
with_fx :reverb, mix: 0.5, room: 0.9 do
with_fx :ixi_techno, mix: 0.75, room: 0.9 do
# the main loop making all the noise
live_loop :background1, sync: :beats do
#get the speed for this particular loop
this_speed = get :speed
#set the speed for this particular loop
use_bpm this_speed
use_synth_defaults amp: 2
use_synth (ring :supersaw, :prophet, :prophet, :tech_saws).tick
3.times do
play :C4, cutoff: rrand(60,80)
sleep 0.5
play :G3, cutoff: rrand(60,90)
sleep 0.5
play :C4, cutoff: rrand(60,70)
sleep 0.5
play :Gs3, cutoff: rrand(60,80)
sleep 0.25
play :Gs3, cutoff: rrand(70,100)
sleep 0.25
end
1.times do
play :c4, cutoff: rrand(60,80), release: 1
sleep 0.5
play :g4, cutoff: rrand(60,90), release: 1
sleep 0.5
play :c4, cutoff: rrand(60,70), release: 1
sleep 0.5
play :gs3 + 7, cutoff: rrand(80,100), release: 1
sleep 0.5
end
end
end
end