I am developing a low pass biquad filer for an embedded system. Searching for examples in C, I came up to this link on Stanford University's website: https://ccrma.stanford.edu/~jos/filters/Biquad_Software_Implementations.html. After adding the code to my filter.c file in my Eclipse project, I get these build errors:
1- Syntax error on "typedef word double".
2- Type 'word' could not be resolved (for s2, s1, gain, a2, a1, b2, and b1 in "typedef struct _biquadVars").
3- Type 'dbl' could not be resolved (for "A" in "void biquad(biquadVars *a)").
4- Type 'word' could not be resolved (for "s0" in "void biquad(biquadVars *a)").
5- Symbol "NTICK" could not be resolved (in "void biquad(biquadVars *a)").
What I did:
1- Changed "typedef word double;" to "typedef double word;". This resolved the related error. 2- Changed "dbl A;" to "double A;". Obviously helpful.
Questions:
1- Should I trust the original article and search more on why "word" has been chosen over "double"? Or is "dbl" a type that I'm not aware of?
2- Any idea what NTICK might be?
Thanks.
EDIT (added the sample code):
typedef double *pp;// pointer to array of length NTICK
typedef word double; // signal and coefficient data type
typedef struct _biquadVars {
pp output;
pp input;
word s2;
word s1;
word gain;
word a2;
word a1;
word b2;
word b1;
} biquadVars;
void biquad(biquadVars *a)
{
int i;
dbl A;
word s0;
for (i=0; i<NTICK; i++) {
A = a->gain * a->input[i];
A -= a->a1 * a->s1;
A -= a->a2 * a->s2;
s0 = A;
A += a->b1 * a->s1;
a->output[i] = a->b2 * a->s2 + A;
a->s2 = a->s1;
a->s1 = s0;
}
}