Code: Select all
INLINE double CookbookFilter::getSample(double in)
{
static doubleA tmp, tmp2;
static intA i; // for the loop through the stages
tmp = in;
// calculate current output-sample (y[n]) of all the BiQuad-stages
// (the output of one stage is the input for the next stage):
for (i=0; i<numStages; i++)
{
tmp2 = tmp; //for x_1[i]
// calculate current output-sample (y[n]) of BiQuad-stage i:
tmp = b0*(tmp) + b1*x1[i] + b2*x2[i]
- a1*y1[i] - a2*y2[i];
// set x[n-1], x[n-2], y[n-1] and y[n-2] for the next call:
x2[i] = x1[i];
x1[i] = tmp2;
y2[i] = y1[i];
y1[i] = tmp;
}
return tmp;
}
INLINE double CookbookFilter::getSample2(double in)
{
static doubleA x, y, g;
static intA i; //for the loop through the stages
x = in;
// calculate current output-sample (y[n]) of all the BiQuad-stages
// (the output of one stage is the input for the next stage):
for (i=0; i<numStages; i++)
{
// calculate intermediate signal g[n] and output-signal y[n] of
// BiQuad-stage i:
g = x - a1*g1[i] - a2*g2[i];
y = b0*g + b1*g1[i] + b2*g2[i];
// set g[n-1], g[n-2] for the next call:
g2[i] = g1[i];
g1[i] = g;
x = y; // output of one stage is input to the next
}
return y;
}Code: Select all
#define INLINE __forceinline
typedef __declspec( align(8) ) double doubleA; // doubles, aligned at 64-bit
// (8 byte) boundaries
typedef __declspec( align(8) ) int intA; // integers, aligned at 64-bit
// (8 byte) boundaries

