void fxCompressor::process(float *inputs, long frames) { double attack_coeff = exp(-1000.0 / (getParameter(fxCompressor_PRM_ATTACK) * getParameter(fxCompressor_PRM_SAMPLE_RATE))); double release_coeff = exp(-1000.0 / (getParameter(fxCompressor_PRM_RELEASE) * getParameter(fxCompressor_PRM_SAMPLE_RATE))); double keydb; double overdb; double gain; float t = getParameter(fxCompressor_PRM_THRESH); float r = getParameter(fxCompressor_PRM_RATIO); while(--frames >= 0) { keydb = lin2dB(fabs(*inputs) + DEF_DC_OFFSET); overdb = keydb - t; if(overdb < 0.0) { overdb = 0.0; } overdb += DEF_DC_OFFSET; if(m_envdb > overdb) { m_envdb = overdb + attack_coeff * (m_envdb - overdb); } else { m_envdb = overdb + release_coeff * (m_envdb - overdb); } // This is subtracted again to avoid denormalization after adding it overdb = m_envdb - DEF_DC_OFFSET; gain = overdb * (r - 1.0); gain = dB2lin(gain); *inputs++ *= gain; } }
void Compressor::process(float input, float&output) { float levelEstimate,gain; levelEstimator.process(input, levelEstimate); float logLevel = dB(levelEstimate); if (logLevel < logThreshold) { output = input; } else { float dbGain = (logLevel - logThreshold) / (1/ratio -1); output = input * dB2lin(dbGain); } }
void audio::algo::chunkware::Limiter::setThreshold(double _dB) { m_thresholddB = _dB; m_threshold = dB2lin(_dB); }
//------------------------------------------------------------- void SimpleGate::setThresh( double dB ) { threshdB_ = dB; thresh_ = dB2lin( dB ); }
//------------------------------------------------------------- void SimpleLimit::setThresh( float dB ) { threshdB_ = dB; thresh_ = dB2lin( dB ); }