// This effect Copyright (C) 2004 and later Cockos Incorporated
// License: GPL - http://www.gnu.org/licenses/gpl.html

desc: band pass filter

slider1:800<1,20000,50>freq (Hz)
slider2:0.5<0,1,0.05>width (0=narrow, 1=wide)
slider3:0<-120,12,1>wet mix (dB)
slider4:-18<-120,12,1>dry mix (dB)
slider5:0<0,1,1{normal,notch}>mode

@slider
dampening=slider2*0.999 + 0.001;
c = ( 1 / tan( $pi*slider1 / srate ) );
a2 = 1 + c*(c+dampening);
fa1 = 2 * (1 - c*c) / a2;
fa0 = (1 + c*(c-dampening)) / a2;
fk = c*dampening / a2;
//lastdamp != dampening ? (fd1_l=fd2_l=fd1_r=fd2_r=0);

wetsign=slider5?-1:1;
dry=2 ^ (slider4/6); 
wet=2 ^ (slider3/6)*wetsign;
lastdamp=dampening;

@sample

d0_l = fk*spl0 - (fa1*fd1_l + fa0*fd2_l);
d0_r = fk*spl1 - (fa1*fd1_r + fa0*fd2_r);
spl0 = wet*(d0_l - fd2_l) + dry*spl0;
spl1 = wet*(d0_r - fd2_r) + dry*spl1;
fd2_l = fd1_l;
fd2_r = fd1_r;
fd1_l = d0_l;
fd1_r = d0_r;

