📄 iirfilter_7.c
字号:
#include <stdlib.h>
#include <math.h>
#include <ops/custom_defs.h>
#define SHIFT 3 /* see case study on IIR filter in Cookbook */
int iirFilter_7( int *inputData, int *outputData,
int *coeff, int *state, int sampleNumber )
{
int i;
int * restrict input, * restrict output;
int temp1, temp2, temp3, temp4, temp5;
int coeff_a0, coeff_a1, coeff_a2, coeff_b1, coeff_b2;
int 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 = IMULM( coeff_a0, input[i] );
temp2 = IMULM( coeff_a1, state_0 );
temp3 = IMULM( coeff_a2, state_1 );
temp4 = IMULM( coeff_b1, state_2 );
temp5 = IMULM( coeff_b2, state_3 );
output[i] = ( temp1 + temp2 + temp3 - temp4 - temp5 ) << SHIFT;
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 + -