Hi,
I’ve been trying to find a comparably easy solution (‘easy’ meaning: memorable, on a medium abstraction level, not to much code, possibly staying within the SP language range) to handle fading and other dynamic parameter operations within a live_loop
without being entirely dependant on the runtime of a live_loop
(this is to say: if you don’t work with control
you will have to wait until the live_loop
starts again until some change is going to happen); here is so far my solution using a function fade
to provide an appropriate ring of values which will be used in connection with a double tick
– in this case to fade amplitude.
type = (ring :up, :down, :wave)
define :fade do |min, max, len, type|
case type
when :up
b = (line min, max, steps: len, inclusive: true).stretch(2).drop(1).butlast.ramp
when :down
b = (line min, max, steps: len, inclusive: true).stretch(2).drop(1).butlast.reverse.ramp
when :wave
b = (line min, max, steps: len, inclusive: true).stretch(2).drop(1).butlast.mirror
end
end
live_loop :fade_amen1 do
stop
l = fade(0, 1, 5, :down)
s = sample :loop_amen, beat_stretch: 2, amp: l.tick(:v)
puts "From #{l.look(:v)} ..."
control s, amp: l.tick(:v), amp_slide: 2
puts "... to #{l.look(:v)}."
sleep 2
end
live_loop :fade_amen2 do
stop
l = fade(0, 1, 5, :wave)
puts ""
puts l
with_fx :level, amp: l.tick(:v) do |lev|
puts "From #{l.look(:v)} ..."
control lev, amp: l.tick(:v), amp_slide: 2
puts "... to #{l.look(:v)}."
sample :loop_amen, beat_stretch: 2
end
sleep 2
end
The problem with this solution is I can’t change the fade type e. g. from fading in to fading out (from up
to down
) without 1st: setting amp
to the last reached value and 2nd: reset the tick. Maybe my solution is concpetionally flawed… In an ideal world I would imagine to have a funciton such as my :fade
, which would receive a starting and end value (for amp
or cutoff
or any other parameter I’d like to change over time), a step value to control the speed and the type or direction of fading which would also make sure that a call to the fading function would handle any change in direction (from up to down, in or out aso.) on its own in the propper way.
Hope I could make myself clear (happy to go into detail if not). I’d be grateful for any hints or thoughts about that.