Hi,
I'm trying to build simple compressor.
Everything is fine.I can see that compressor is working on meter with seekgain.But i can't make it work with "gain".There is no any process.
Code:
double gain = seekgain = 1;
double c = 8.65617025;
double t = 0;
double b = -exp(-62.83185307 / GetSampleRate() );
double a = 1.0 + b;
double threshDB = mThr;
double thresh = exp(threshDB/c);
double ratio = 1/20;
double attack = exp( threshDB / (10*GetSampleRate()/1000) / c);
double release = exp( threshDB / (100*GetSampleRate()/1000) / c );
seekgain = 1;
double rms = std::max( fabs(*in1) , fabs(*in2) );
rms = std::max( sqrt( (t = a*rms-b*t) ) , rms);
if (rms > thresh)
seekgain = exp((threshDB + (log(rms)*c-threshDB)*ratio) /c) / rms;
else
seekgain = 1;
if (gain > seekgain)
gain = std::max( gain*attack , seekgain );
else
gain = std::min( gain/release , seekgain );
*out1 = *in1 * gain ;
*out2 = *in2 * gain ;