Audacity  2.2.2
Biquad.cpp
Go to the documentation of this file.
1 #include "Biquad.h"
2 
3 #define square(a) ((a)*(a))
4 
5 void Biquad_Process (BiquadStruct* pBQ, int iNumSamples)
6 {
7  float* pfIn = pBQ->pfIn;
8  float* pfOut = pBQ->pfOut;
9  float fPrevIn = pBQ->fPrevIn;
10  float fPrevPrevIn = pBQ->fPrevPrevIn;
11  float fPrevOut = pBQ->fPrevOut;
12  float fPrevPrevOut = pBQ->fPrevPrevOut;
13  for (int i = 0; i < iNumSamples; i++)
14  {
15  float fIn = *pfIn++;
16  *pfOut = fIn * pBQ->fNumerCoeffs [0] +
17  fPrevIn * pBQ->fNumerCoeffs [1] +
18  fPrevPrevIn * pBQ->fNumerCoeffs [2] -
19  fPrevOut * pBQ->fDenomCoeffs [0] -
20  fPrevPrevOut * pBQ->fDenomCoeffs [1];
21  fPrevPrevIn = fPrevIn;
22  fPrevIn = fIn;
23  fPrevPrevOut = fPrevOut;
24  fPrevOut = *pfOut++;
25  }
26  pBQ->fPrevIn = fPrevIn;
27  pBQ->fPrevPrevIn = fPrevPrevIn;
28  pBQ->fPrevOut = fPrevOut;
29  pBQ->fPrevPrevOut = fPrevPrevOut;
30 }
31 
32 void ComplexDiv (float fNumerR, float fNumerI, float fDenomR, float fDenomI, float* pfQuotientR, float* pfQuotientI)
33 {
34  float fDenom = square(fDenomR) + square(fDenomI);
35  *pfQuotientR = (fNumerR * fDenomR + fNumerI * fDenomI) / fDenom;
36  *pfQuotientI = (fNumerI * fDenomR - fNumerR * fDenomI) / fDenom;
37 }
38 
39 bool BilinTransform (float fSX, float fSY, float* pfZX, float* pfZY)
40 {
41  float fDenom = square (1 - fSX) + square (fSY);
42  *pfZX = (1 - square (fSX) - square (fSY)) / fDenom;
43  *pfZY = 2 * fSY / fDenom;
44  return true;
45 }
46 
47 float Calc2D_DistSqr (float fX1, float fY1, float fX2, float fY2)
48 {
49  return square (fX1 - fX2) + square (fY1 - fY2);
50 }
51 
bool BilinTransform(float fSX, float fSY, float *pfZX, float *pfZY)
Definition: Biquad.cpp:39
float fPrevPrevOut
Definition: Biquad.h:28
float fPrevOut
Definition: Biquad.h:27
float * pfOut
Definition: Biquad.h:22
#define square(a)
Definition: Biquad.cpp:3
float fPrevPrevIn
Definition: Biquad.h:26
void Biquad_Process(BiquadStruct *pBQ, int iNumSamples)
Definition: Biquad.cpp:5
float fDenomCoeffs[2]
Definition: Biquad.h:24
float Calc2D_DistSqr(float fX1, float fY1, float fX2, float fY2)
Definition: Biquad.cpp:47
float fNumerCoeffs[3]
Definition: Biquad.h:23
float * pfIn
Definition: Biquad.h:21
void ComplexDiv(float fNumerR, float fNumerI, float fDenomR, float fDenomI, float *pfQuotientR, float *pfQuotientI)
Definition: Biquad.cpp:32
float fPrevIn
Definition: Biquad.h:25