Hi
I need some help on following code.
Doing some metering stuff with a own envelope follower code doesn't work correctly.
Getting my values like this:
Code:
//--processReplacing
//--MAX PEAKS CALC METER
peakL = MAX(peakL, fabs(*in1));
peakR = MAX(peakR, fabs(*in2));
//--PHASE CORRELATION METER
CorrLR = outputCorr;
Then I have my envelopes and the calculations for the metering:
Code:
double atCorr = exp(log(0.01)/( 10.0 * SR * 0.001));
double relCorr = exp(log(0.01)/( 50 * SR * 0.001));
double at2 = exp(log(0.01)/( 0.1 * SR * 0.001));
double rel2 = exp(log(0.01)/( 50 * SR * 0.001));
double envelope = 0.0;
double envelope1 = 0.0;
double envelope2 = 0.0;
//--CORR ENVELOPE
double tmpCorr = fabs(CorrLR);
if(tmpCorr > envelope){
envelope = atCorr * (envelope - tmpCorr) + tmpCorr;
} else {
envelope = relCorr * (envelope - tmpCorr) + tmpCorr;
}
//--LEFT ENVELOPE
double tmpLeft = fabs(peakL);
if(tmpLeft > envelope1){
envelope1 = at2 * (envelope1 - tmpLeft) + tmpLeft;
} else {
envelope1 = rel2 * (envelope1 - tmpLeft) + tmpLeft;
}
//--LEFT ENVELOPE
double tmpRight = fabs(peakR);
if(tmpRight > envelope2){
envelope2 = at2 * (envelope2 - tmpRight) + tmpRight;
} else {
envelope2 = rel2 * (envelope2 - tmpRight) + tmpRight;
}
CorrLR = CorrLR * envelope + mPrevCorr * (1.0 - envelope);
peakL = peakL * envelope1 + mPrevL * (1.0 - envelope1);
peakR = peakR * envelope2 + mPrevR * (1.0 - envelope2);
mPrevL = peakL;
mPrevR = peakR;
mPrevCorr = CorrLR;
if (GetGUI())
{
GetGUI()->SetControlFromPlug(mMeterIdx_L, peakL);
GetGUI()->SetControlFromPlug(mMeterIdx_R, peakR);
GetGUI()->SetControlFromPlug(mCorrIdx, CorrLR);
}
So the thing is, that the metering for Correlation works perfectly.
The meters for Left and Right stock in last position when I stop the playback.
What's wrong in the LEFT & RIGHT envelopes?
Any help would be fine
Thanks!