// 4 pole Karlsen Fast Ladder emulation.

slider1:1000<50,5000,1>Frequency (Hz)
slider2:0<0,4,0.001>Resonance
slider3:0<-24,24,0.1>Output (dB)

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

@slider
slider1 = min(slider1,5000);
slider2 = min(slider2,4);

cut = (2*$pi*slider1/srate);
res = slider2;
output = 10^(slider3/20);

@sample
inA = spl0;
inB = spl1;

resoclipA=min(max(buf4A,-1),1);
inA = inA - (resoclipA * res);
buf1A = ((inA - buf1A) * cut) + buf1A;
buf2A = ((buf1A - buf2A) * cut) + buf2A;
buf3A = ((buf2A - buf3A) * cut) + buf3A;
buf4A = ((buf3A - buf4A) * cut) + buf4A;
lpoutA = buf4A;

resoclipB=min(max(buf4B,-1),1);
inB = inB - (resoclipB * res);
buf1B = ((inB - buf1B) * cut) + buf1B;
buf2B = ((buf1B - buf2B) * cut) + buf2B;
buf3B = ((buf2B - buf3B) * cut) + buf3B;
buf4B = ((buf3B - buf4B) * cut) + buf4B;
lpoutB = buf4B;

spl0 = lpoutA*output;
spl1 = lpoutB*output;
