17#define square(a) ((a)*(a))
40 for (
int i = 0; i < iNumSamples; i++)
52 { 0, 5, 0, -20, 0, 16},
53 {-1, 0, 18, 0, -48, 0, 32},
54 { 0, -7, 0, 56, 0, -112, 0, 64},
55 { 1, 0, -32, 0, 160, 0, -256, 0, 128},
56 { 0, 9, 0, -120, 0, 432, 0, -576, 0, 256},
57 {-1, 0, 50, 0, -400, 0, 1120, 0, -1280, 0, 512}
68 double fNorm = fc /
fn;
71 double fC = tan (
PI * fNorm / 2);
72 double fDCPoleDistSqr = 1.0F;
73 double fZPoleX, fZPoleY;
78 for (
int iPair = 0; iPair < order/2; iPair++)
80 double fSPoleX = fC * cos (
PI - (iPair + 0.5) *
PI / order);
81 double fSPoleY = fC * sin (
PI - (iPair + 0.5) *
PI / order);
83 pBiquad[iPair].fNumerCoeffs [
B0] = 1;
85 pBiquad[iPair].fNumerCoeffs [
B1] = 2;
87 pBiquad[iPair].fNumerCoeffs [
B1] = -2;
88 pBiquad[iPair].fNumerCoeffs [
B2] = 1;
89 pBiquad[iPair].fDenomCoeffs [
A1] = -2 * fZPoleX;
90 pBiquad[iPair].fDenomCoeffs [
A2] =
square(fZPoleX) +
square(fZPoleY);
100 double fSPoleX = -fC;
103 pBiquad[0].fNumerCoeffs [
B0] = 1;
105 pBiquad[0].fNumerCoeffs [
B1] = 1;
107 pBiquad[0].fNumerCoeffs [
B1] = -1;
108 pBiquad[0].fNumerCoeffs [
B2] = 0;
109 pBiquad[0].fDenomCoeffs [
A1] = -fZPoleX;
110 pBiquad[0].fDenomCoeffs [
A2] = 0;
112 fDCPoleDistSqr = 1 - fZPoleX;
114 fDCPoleDistSqr = fZPoleX + 1;
115 for (
int iPair = 1; iPair <= order/2; iPair++)
117 double fSPoleX = fC * cos (
PI - iPair *
PI / order);
118 double fSPoleY = fC * sin (
PI - iPair *
PI / order);
120 pBiquad[iPair].fNumerCoeffs [
B0] = 1;
122 pBiquad[iPair].fNumerCoeffs [
B1] = 2;
124 pBiquad[iPair].fNumerCoeffs [
B1] = -2;
125 pBiquad[iPair].fNumerCoeffs [
B2] = 1;
126 pBiquad[iPair].fDenomCoeffs [
A1] = -2 * fZPoleX;
127 pBiquad[iPair].fDenomCoeffs [
A2] =
square(fZPoleX) +
square(fZPoleY);
134 pBiquad[0].fNumerCoeffs [
B0] *= fDCPoleDistSqr / (1 << order);
135 pBiquad[0].fNumerCoeffs [
B1] *= fDCPoleDistSqr / (1 << order);
136 pBiquad[0].fNumerCoeffs [
B2] *= fDCPoleDistSqr / (1 << order);
150 double fNorm = fc /
fn;
153 double fC = tan (
PI * fNorm / 2);
154 double fDCPoleDistSqr = 1.0F;
155 double fZPoleX, fZPoleY;
157 double beta = cos (fNorm*
PI);
159 double eps; eps =
sqrt (pow (10.0, wxMax(0.001, ripple) / 10.0) - 1);
160 double a; a = log (1 / eps +
sqrt(1 /
square(eps) + 1)) / order;
162 for (
int iPair = 0; iPair < order/2; iPair++)
164 double fSPoleX = -fC * sinh (a) * sin ((2*iPair + 1) *
PI / (2 * order));
165 double fSPoleY = fC * cosh (a) * cos ((2*iPair + 1) *
PI / (2 * order));
171 fDCPoleDistSqr /= 2*2;
176 ComplexDiv (beta - fZPoleX, -fZPoleY, 1 - beta * fZPoleX, -beta * fZPoleY, &fZPoleX, &fZPoleY);
179 fDCPoleDistSqr /= 2*2;
181 pBiquad[iPair].fNumerCoeffs [
B0] = fDCPoleDistSqr;
182 pBiquad[iPair].fNumerCoeffs [
B1] = -2 * fZZeroX * fDCPoleDistSqr;
183 pBiquad[iPair].fNumerCoeffs [
B2] = fDCPoleDistSqr;
184 pBiquad[iPair].fDenomCoeffs [
A1] = -2 * fZPoleX;
185 pBiquad[iPair].fDenomCoeffs [
A2] =
square(fZPoleX) +
square(fZPoleY);
187 if ((order & 1) == 0)
190 pBiquad[0].fNumerCoeffs [
B0] *= fTemp;
191 pBiquad[0].fNumerCoeffs [
B1] *= fTemp;
192 pBiquad[0].fNumerCoeffs [
B2] *= fTemp;
197 double fSPoleX = -fC * sinh (a);
209 ComplexDiv (beta - fZPoleX, -fZPoleY, 1 - beta * fZPoleX, -beta * fZPoleY, &fZPoleX, &fZPoleY);
215 pBiquad[(order-1)/2].
fNumerCoeffs [
B1] = -fZZeroX * fDCPoleDistSqr;
232 double fNorm = fc /
fn;
235 double fC = tan (
PI * fNorm / 2);
236 double fDCPoleDistSqr = 1.0F;
237 double fZPoleX, fZPoleY;
238 double fZZeroX, fZZeroY;
239 double beta = cos (fNorm*
PI);
241 double fSZeroX, fSZeroY;
242 double fSPoleX, fSPoleY;
244 double a = log (1 / eps +
sqrt(1 /
square(eps) + 1)) / order;
247 for (
int iPair = 0; iPair < order/2; iPair++)
249 ComplexDiv (fC, 0, -sinh (a) * sin ((2*iPair + 1) *
PI / (2 * order)),
250 cosh (a) * cos ((2*iPair + 1) *
PI / (2 * order)),
254 fSZeroY = fC / cos (((2 * iPair) + 1) *
PI / (2 * order));
265 ComplexDiv (beta - fZPoleX, -fZPoleY, 1 - beta * fZPoleX, -beta * fZPoleY, &fZPoleX, &fZPoleY);
266 ComplexDiv (beta - fZZeroX, -fZZeroY, 1 - beta * fZZeroX, -beta * fZZeroY, &fZZeroX, &fZZeroY);
270 pBiquad[iPair].fNumerCoeffs [
B0] = fDCPoleDistSqr;
271 pBiquad[iPair].fNumerCoeffs [
B1] = -2 * fZZeroX * fDCPoleDistSqr;
272 pBiquad[iPair].fNumerCoeffs [
B2] = (
square(fZZeroX) +
square(fZZeroY)) * fDCPoleDistSqr;
273 pBiquad[iPair].fDenomCoeffs [
A1] = -2 * fZPoleX;
274 pBiquad[iPair].fDenomCoeffs [
A2] =
square(fZPoleX) +
square(fZPoleY);
279 int iPair = (order-1)/2;
280 ComplexDiv (fC, 0, -sinh (a) * sin ((2*iPair + 1) *
PI / (2 * order)),
281 cosh (a) * cos ((2*iPair + 1) *
PI / (2 * order)),
294 ComplexDiv (beta - fZPoleX, -fZPoleY, 1 - beta * fZPoleX, -fZPoleY, &fZPoleX, &fZPoleY);
299 pBiquad[iPair].fNumerCoeffs [
B0] = fDCPoleDistSqr;
300 pBiquad[iPair].fNumerCoeffs [
B1] = -fZZeroX * fDCPoleDistSqr;
301 pBiquad[iPair].fNumerCoeffs [
B2] = 0;
302 pBiquad[iPair].fDenomCoeffs [
A1] = -fZPoleX;
303 pBiquad[iPair].fDenomCoeffs [
A2] = 0;
309 double* pfQuotientR,
double* pfQuotientI)
312 *pfQuotientR = (fNumerR * fDenomR + fNumerI * fDenomI) / fDenom;
313 *pfQuotientI = (fNumerI * fDenomR - fNumerR * fDenomI) / fDenom;
320 *pfZY = 2 * fSY / fDenom;
335 for (
int i = 0; i <= Order; i++)
__finl float_x4 __vecc sqrt(const float_x4 &a)
static ArrayOf< Biquad > CalcButterworthFilter(int order, double fn, double fc, int type)
static bool BilinTransform(double fSX, double fSY, double *pfZX, double *pfZY)
float ProcessOne(float fIn)
static ArrayOf< Biquad > CalcChebyshevType2Filter(int order, double fn, double fc, double ripple, int type)
static double ChebyPoly(int Order, double NormFreq)
static const double s_fChebyCoeffs[MAX_Order][MAX_Order+1]
@ A1
Denominator coefficient indices.
@ MIN_Order
Possible filter orders for the Calc...Filter(...) functions.
@ B0
Numerator coefficient indices.
static ArrayOf< Biquad > CalcChebyshevType1Filter(int order, double fn, double fc, double ripple, int type)
static float Calc2D_DistSqr(double fX1, double fY1, double fX2, double fY2)
static void ComplexDiv(double fNumerR, double fNumerI, double fDenomR, double fDenomI, double *pfQuotientR, double *pfQuotientI)
void Process(const float *pfIn, float *pfOut, int iNumSamples)