desc:Volume 0+1 vs 2+3(Trigger)
slider1:10<0,1000,1>Attack1(ms)
slider2:10<0,1000,1>Release1(ms)
slider3:10<0,1000,1>Attack2(ms)
slider4:10<0,1000,1>Release2(ms)
slider5:0<-1,1,1>Trigger(0+1 vs 2+3)
in_pin:in 1 L
in_pin:in 1 R
in_pin:in 2 L
in_pin:in 2 R
out_pin:out1 L
out_pin:out1 R
out_pin:out2 L
out_pin:out2 R
@init
function EnvFollower.SetValues(attack_ms, release_ms, samplerate)
(
this.ga = exp(-1/(samplerate*attack_ms/1000));
this.gr = exp(-1/(samplerate*release_ms/1000));
);
function EnvFollower.Apply(in)
instance(ga, gr, out)
(
in = abs(in);
out < in ? out = in + ga*(out-in) : out = in + gr*(out-in);
);
@slider
Env_01.EnvFollower.SetValues(slider1, slider2, srate);
Env_23.EnvFollower.SetValues(slider3, slider4, srate);
Trig = slider5;
@block
@sample
in_01 = (spl0 + spl1)/2;
Env_01.EnvFollower.Apply(in_01);
in_23 = (spl2 + spl3)/2;
Env_23.EnvFollower.Apply(in_23);
Env_01.EnvFollower.out > Env_23.EnvFollower.out ? (
slider5 = Trig = -1;
) :
Env_01.EnvFollower.out < Env_23.EnvFollower.out ? (
slider5 = Trig = 1;
) : (
slider5 = Trig = 0;
);
slider_automate(slider5);