📄 iirfilter_3.c
字号:
#include <stdlib.h>
#include <math.h>
int iirFilter_3( float *inputData, float *outputData,
float *coeff, float *state, int sampleNumber )
{
int i;
float * restrict input, * restrict output;
float temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8;
float coeff_a0, coeff_a1, coeff_a2, coeff_b1, coeff_b2;
float state_0, state_1, state_2, state_3;
input = inputData; output = outputData;
coeff_a0 = coeff[0]; coeff_a1 = coeff[1]; coeff_a2 = coeff[2];
coeff_b1 = coeff[3]; coeff_b2 = coeff[4];
state_0 = state[0]; state_1 = state[1];
state_2 = state[2]; state_3 = state[3];
for( i=0; i < sampleNumber; i++ )
{
temp1 = coeff_a0*input[i];
temp2 = coeff_a1*state_0;
temp3 = coeff_a2*state_1;
temp4 = coeff_b1*state_2;
temp5 = coeff_b2*state_3;
temp6 = temp1 + temp2; temp7 = temp3 - temp4;
temp8 = temp6 - temp5;
output[i] = temp7 + temp8;
state_1 = state_0;
state_0 = input[i];
state_3 = state_2;
state_2 = output[i];
}
state[0] = state_0; state[1] = state_1;
state[2] = state_2; state[3] = state_3;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -