mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +02:00
Add EBU R128 k-weighting filter implementation to Biquad.
This commit is contained in:
parent
c3d25cfb44
commit
c002165952
@ -304,6 +304,55 @@ ArrayOf<Biquad> Biquad::CalcChebyshevType2Filter(int order, double fn, double fc
|
||||
return std::move(pBiquad);
|
||||
}
|
||||
|
||||
// fs: sample rate
|
||||
// returns array of two Biquads
|
||||
//
|
||||
// EBU R128 parameter sampling rate adaption after
|
||||
// Mansbridge, Stuart, Saoirse Finn, and Joshua D. Reiss.
|
||||
// "Implementation and Evaluation of Autonomous Multi-track Fader Control."
|
||||
// Paper presented at the 132nd Audio Engineering Society Convention,
|
||||
// Budapest, Hungary, 2012."
|
||||
ArrayOf<Biquad> Biquad::CalcEBUR128WeightingFilter(float fs)
|
||||
{
|
||||
ArrayOf<Biquad> pBiquad(size_t(2), true);
|
||||
|
||||
//
|
||||
// HSF pre filter
|
||||
//
|
||||
double db = 3.999843853973347;
|
||||
double f0 = 1681.974450955533;
|
||||
double Q = 0.7071752369554196;
|
||||
double K = tan(M_PI * f0 / fs);
|
||||
|
||||
double Vh = pow(10.0, db / 20.0);
|
||||
double Vb = pow(Vh, 0.4996667741545416);
|
||||
|
||||
double a0 = 1.0 + K / Q + K * K;
|
||||
|
||||
pBiquad[0].fNumerCoeffs[Biquad::B0] = (Vh + Vb * K / Q + K * K) / a0;
|
||||
pBiquad[0].fNumerCoeffs[Biquad::B1] = 2.0 * (K * K - Vh) / a0;
|
||||
pBiquad[0].fNumerCoeffs[Biquad::B2] = (Vh - Vb * K / Q + K * K) / a0;
|
||||
|
||||
pBiquad[0].fDenomCoeffs[Biquad::A1] = 2.0 * (K * K - 1.0) / a0;
|
||||
pBiquad[0].fDenomCoeffs[Biquad::A2] = (1.0 - K / Q + K * K) / a0;
|
||||
|
||||
//
|
||||
// HPF weighting filter
|
||||
//
|
||||
f0 = 38.13547087602444;
|
||||
Q = 0.5003270373238773;
|
||||
K = tan(M_PI * f0 / fs);
|
||||
|
||||
pBiquad[1].fNumerCoeffs[Biquad::B0] = 1.0;
|
||||
pBiquad[1].fNumerCoeffs[Biquad::B1] = -2.0;
|
||||
pBiquad[1].fNumerCoeffs[Biquad::B2] = 1.0;
|
||||
|
||||
pBiquad[1].fDenomCoeffs[Biquad::A1] = 2.0 * (K * K - 1.0) / (1.0 + K / Q + K * K);
|
||||
pBiquad[1].fDenomCoeffs[Biquad::A2] = (1.0 - K / Q + K * K) / (1.0 + K / Q + K * K);
|
||||
|
||||
return std::move(pBiquad);
|
||||
}
|
||||
|
||||
void Biquad::ComplexDiv (double fNumerR, double fNumerI, double fDenomR, double fDenomI,
|
||||
double* pfQuotientR, double* pfQuotientI)
|
||||
{
|
||||
|
@ -66,6 +66,7 @@ struct Biquad
|
||||
static ArrayOf<Biquad> CalcButterworthFilter(int order, double fn, double fc, int type);
|
||||
static ArrayOf<Biquad> CalcChebyshevType1Filter(int order, double fn, double fc, double ripple, int type);
|
||||
static ArrayOf<Biquad> CalcChebyshevType2Filter(int order, double fn, double fc, double ripple, int type);
|
||||
static ArrayOf<Biquad> CalcEBUR128WeightingFilter(float fs);
|
||||
|
||||
static void ComplexDiv (double fNumerR, double fNumerI, double fDenomR, double fDenomI,
|
||||
double* pfQuotientR, double* pfQuotientI);
|
||||
|
Loading…
x
Reference in New Issue
Block a user