slider1:1<1,100,1>selectivity (%)
slider2:1<1,100,1>ratio (%)
slider3:0<-30,15,0.1>bass gain (dB)
slider4:100<0,100,1>mix (%)
slider5:0<-30,15,0.1>output (dB)

in_pin:L in
in_pin:R in
out_pin:L out
out_pin:R out

@init
itm1=itm2=otm1=otm2=0;

src_selectivity = tgt_selectivity = (slider1*2)+50;
src_ratio = tgt_ratio = slider2/12.5;
src_gain = tgt_gain = 10^((slider3+6)/20);
src_gain2 = tgt_gain2 = 10^(slider5/20);

@slider
tgt_selectivity = (slider1*2)+50;
tgt_ratio = slider2/12.5;
tgt_gain = 10^((slider3+6)/20);
tgt_gain2 = 10^(slider5/20);

mixA = 1 - (slider4*0.01);
mixB = slider4*0.01;

@block
d_selectivity = (tgt_selectivity-src_selectivity)/samplesblock;
tselectivity = src_selectivity;
src_selectivity = tgt_selectivity;

d_ratio = (tgt_ratio-src_ratio)/samplesblock;
tratio = src_ratio;
src_ratio = tgt_ratio;

d_gain = (tgt_gain-src_gain)/samplesblock;
tgain = src_gain;
src_gain = tgt_gain;

d_gain2 = (tgt_gain2-src_gain2)/samplesblock;
tgain2 = src_gain2;
src_gain2 = tgt_gain2;

@sample
tselectivity += d_selectivity;
selectivity = tselectivity;

tratio += d_ratio;
ratio = tratio;

tgain += d_gain;
gain = tgain;

tgain2 += d_gain2;
gain2 = tgain2;

otm1=0.999*otm1 + spl0 - itm1; itm1=spl0; spl0=otm1;
otm2=0.999*otm2 + spl1 - itm2; itm2=spl1; spl1=otm2;

in0 = spl0;
in1 = spl1;

gain1 = 1/(selectivity + 1);

cap0 = (in0 + cap0*selectivity) * gain1;
output0 = ((in0 + cap0*ratio)*gain) * 0.5;

cap1 = (in1 + cap1*selectivity) * gain1;
output1 = ((in1 + cap1*ratio)*gain) * 0.5;

//output0 = min(max(output0,-1),1);
//output1 = min(max(output1,-1),1);

spl0 = (spl0*mixA + output0*mixB)*gain2;
spl1 = (spl1*mixA + output1*mixB)*gain2;
