// (C) 2007, Michael Gruhn.

// NO WARRANTY IS GRANTED. THIS PLUG-IN IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
// WARRANTY OF ANY KIND. NO LIABILITY IS GRANTED, INCLUDING, BUT NOT LIMITED TO,
// ANY DIRECT OR INDIRECT,  SPECIAL,  INCIDENTAL OR CONSEQUENTIAL DAMAGE ARISING
// OUT OF  THE  USE  OR INABILITY  TO  USE  THIS PLUG-IN,  COMPUTER FAILTURE  OF
// MALFUNCTION INCLUDED.  THE USE OF THE SOURCE CODE,  EITHER  PARTIALLY  OR  IN
// TOTAL, IS ONLY GRANTED,  IF USED IN THE SENSE OF THE AUTHOR'S INTENTION,  AND
// USED WITH ACKNOWLEDGEMENT OF THE AUTHOR. FURTHERMORE IS THIS PLUG-IN A  THIRD
// PARTY CONTRIBUTION,  EVEN IF INCLUDED IN REAPER(TM),  COCKOS INCORPORATED  OR
// ITS AFFILIATES HAVE NOTHING TO DO WITH IT.  LAST BUT NOT LEAST, BY USING THIS
// PLUG-IN YOU RELINQUISH YOUR CLAIM TO SUE IT'S AUTHOR, AS WELL AS THE CLAIM TO
// ENTRUST SOMEBODY ELSE WITH DOING SO.

// Further more is this released under the GPL License:
// http://www.gnu.org/licenses/gpl.html

desc:50 Hz Kicker
desc:50 Hz Kicker (Kick Drum Enhancer) [LOSER]
//tags: processing equalizer
//author: LOSER

slider1:50<10,200,1>Freqency (Hz)
slider2:-12<-120,12,1>Wet (dB)
slider3:-3<-120,12,1>Dry (dB)

in_pin:left input
in_pin:right input
out_pin:left output
out_pin:right output

@init
b1Det = -exp(-300 / srate );
a0Det = 1.0 + b1Det;

b1Env1 = -exp(-3 / srate );
a0Env1 = 1.0 + b1Env1;
b1Env2 = -exp(-30 / srate );
a0Env2 = 1.0 + b1Env2;

@slider

adj = 2*$pi*slider1 / srate;


wet = 2^(slider2/6);
dry = 2^(slider3/6);

gain = 0;
tmpDet = 0;
tmpEnv1 = 0.1;
tmpEnv2 = 0;

@sample

det = abs(sqrt(tmpDet = a0Det*(spl0+spl1)*2 - b1Det*tmpDet));
env1 = sqrt(tmpEnv1 = a0Env1*det - b1Env1*tmpEnv1);
env2 = sqrt(tmpEnv2 = a0Env2*det - b1Env2*tmpEnv2);

gain = min(max(env2/env1,1)-1,1);

gain == 0 ? pos=0;

spl0 = sin(pos)*gain*wet + spl0*dry;
spl1 = sin(pos)*gain*wet + spl1*dry;

pos += adj;
