Hi Bryan
Nice question. I’ve had a play and come up with the following code which I think works.
#experimenting with changing cutoff using a live loop
#by Robin Newman
set :st,sample_duration(:loop_amen)
with_fx :rlpf, cutoff: 120 do |c|
set :cv,c #comment after first run from stop, before re-run
live_loop :cont do
l=60;h=100
st=get(:st)
puts "change cuttoff down to",l
control get(:cv), cutoff: l, cutoff_slide: 2*st
sleep 4*st
puts "change cuttoff up to ",h
control get(:cv),cutoff: h, cutoff_slide: 2*st
sleep 4*st
end
live_loop :loop do
st=get(:st)
sample :loop_amen
sleep st
end
end
The first time your code runs, the value of c in the live loop points correctly to the fx control and it reduces the cut off value. However you cannot change the value in the live loop and rerun, as this reruns everything, and the reference between the value of c in the live loop and with the fx call (and this has been rerun too) is not kept.
In my version I store the value c using set :cv immediately after it is created, and get it back again using the reverse get(:cv) inside the controlling live_loop :cont . However, it is important also to comment out the set :cv,c line AFTER the first run (where everything was previously stopped) but BEFORE you rerun the program to pick up the updated to a live_loop you have changed. So If you run as shown, the cutoff will go up and down between the set values l (60) and h (100). If you then comment out the set :cv,c
line, and alter either the l or h value and then rerun, it will pick up the new values on the next pass.
Of course if you don’t want it to oscillate, a simpler version is shown below. This just does a single change each time it is run, but as above remember to comment out the set:cv,c
line AFTER the first run but BEFORE subsequent ones.
#experimenting with changing cutoff using a single command line
#by Robin Newman
set :st,sample_duration(:loop_amen) #store duration of the sample
with_fx :rlpf, cutoff: 120 do |c|
set :cv,c #comment after first run from stop, before re-run
control get(:cv),cutoff: 40,cutoff_slide: 4*get(:st)
live_loop :loop do
st=get(:st)
sample :loop_amen
sleep st
end
end
Also because I liked the changes to be sychronised to the live loop I changed the delays and time slide times to be multiples of the sample duration. Again I used the set and get functions to store and recover these as required.