📄 fir.c
字号:
#include "fir.h"
#define N 48
#define N2 24
float shifter[N]; //the shift registers
float coefficient1[] =
{0.0001454484984531, -0.001861906583965, -0.004237972639138, -0.007619623174828,
-0.01101687204104, -0.0130983131512, -0.01247543991195, -0.00829899182837,
-0.0008481734259407, 0.008172132934125, 0.01586052144191, 0.0189324366954,
0.01494241097688, 0.003527321898082, -0.0128310339597, -0.02893726515597,
-0.03804005078092, -0.03379048931743, -0.01243833306669, 0.02548243007452,
0.07462839331434, 0.1257854928957, 0.1681154506852, 0.1920693684775};
float coefficient2[] = {
0.007892214281376, 0.001700541806004,0.0007270681388075,-0.001082649543886,
-0.003583478321026,-0.006430348602174, -0.00912652004365, -0.01105549148905,
-0.01159847831035, -0.01021782078312, -0.00658544236293,-0.0006722672874986,
0.007142445809834, 0.01605787734213, 0.02492050445769, 0.03220436016868,
0.03618649333017, 0.03502915902538, 0.02676627807414, 0.00912441892671,
-0.02146971320706, -0.07340651140725, -0.1780343231821, -0.6249128084001};
float prefilter(float data, float coefficient[],int whichFilter)
{
static int pointer=-1;
int i,j,k;
float temp;
temp=0.0;
pointer=(pointer+1)%N;
shifter[pointer] = data;
if(whichFilter == 1)
{
for(i=0;i<N2;i++)
{
j=(pointer+i)%N;
k=(pointer-i-1+N)%N;
temp+=(shifter[j]+shifter[k])*coefficient[i];
}
}
else if(whichFilter == 2)
{
for(i=0;i<N2;i++)
{
j=(pointer+i)%N;
k=(pointer-i-1+N)%N;
temp+=(shifter[j]-shifter[k])*coefficient[i];
}
}
return temp;
}
void initial_filter(void)
{
int i;
for(i=0;i<N;i++)
{
shifter[i]=0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -