【发布时间】:2020-11-19 09:13:40
【问题描述】:
我正在为嵌入式系统开发低通双二阶滤波器。在搜索 C 语言示例时,我在斯坦福大学的网站上找到了这个链接:https://ccrma.stanford.edu/~jos/filters/Biquad_Software_Implementations.html。在我的 Eclipse 项目中将代码添加到我的 filter.c 文件后,我收到以下构建错误:
1- “typedef word double”的语法错误。
2- 无法解析类型“word”(对于“typedef struct _biquadVars”中的 s2、s1、gain、a2、a1、b2 和 b1)。
3- 无法解析类型“dbl”(对于“void biquad(biquadVars *a)”中的“A”)。
4- 无法解析类型“word”(对于“void biquad(biquadVars *a)”中的“s0”)。
5- 符号“NTICK”无法解析(在“void biquad(biquadVars *a)”中)。
我做了什么:
1- 更改了“typedef word double;”为“typedef 双字;”。这解决了相关的错误。 2-更改了“dbl A;”到“双A;”。显然很有帮助。
问题:
1- 我应该相信原始文章并更多地搜索为什么选择“word”而不是“double”吗?还是“dbl”是我不知道的类型?
2- 知道 NTICK 可能是什么吗?
谢谢。
编辑(添加示例代码):
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;
}
}
【问题讨论】:
-
@ryyker 谢谢,添加了代码。
-
谢谢。请参阅下面的答案。
标签: c filter embedded signal-processing