mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-26 19:23:51 +01:00
speed up agc (in performance, not audio levels)
This commit is contained in:
@@ -17,10 +17,8 @@ void initAGC(AGC* agc, int sampleRate, float targetLevel, float minGain, float m
|
||||
agc->rms_buffer = 0.0f;
|
||||
}
|
||||
|
||||
float process_agc_stereo(AGC* agc, float left, float right, float *right_out) {
|
||||
float sample = (left+right)/2;
|
||||
|
||||
float x2 = sample * sample;
|
||||
float process_agc(AGC* agc, float sidechain) {
|
||||
float x2 = sidechain * sidechain;
|
||||
|
||||
float rmsAlpha = expf(-1.0f / (agc->sampleRate * 0.04));
|
||||
agc->rms_buffer = rmsAlpha * agc->rms_buffer + (1.0f - rmsAlpha) * x2;
|
||||
@@ -35,6 +33,5 @@ float process_agc_stereo(AGC* agc, float left, float right, float *right_out) {
|
||||
float gainAlpha = (desiredGain > agc->currentGain) ? agc->attackCoef : agc->releaseCoef;
|
||||
agc->currentGain = gainAlpha * agc->currentGain + (1.0f - gainAlpha) * desiredGain;
|
||||
|
||||
*right_out = right * agc->currentGain;
|
||||
return left * agc->currentGain;
|
||||
return agc->currentGain;
|
||||
}
|
||||
@@ -19,4 +19,4 @@ typedef struct {
|
||||
} AGC;
|
||||
|
||||
void initAGC(AGC* agc, int sampleRate, float targetLevel, float minGain, float maxGain, float attackTime, float releaseTime);
|
||||
float process_agc_stereo(AGC* agc, float left, float right, float *right_out);
|
||||
float process_agc(AGC* agc, float sidechain);
|
||||
Reference in New Issue
Block a user