1 /* 4-cascaded IIR biquad filter processing 64 points */
2 /* Modified to use arrays - SMP */
10 float output
[NPOINTS
];
11 float coefficient
[NSECTIONS
][NSECTIONS
][NSECTIONS
];
12 float internal_state
[8][NSECTIONS
][2];
14 void iir(float input
[NPOINTS
], float output
[NPOINTS
],
15 float coefficient
[NSECTIONS
][NSECTIONS
][NSECTIONS
],
16 float internal_state
[8][NSECTIONS
][2]);
22 float *pcoef
= coefficient
[0][0];
23 float *pint
= internal_state
[0][0];
25 for(i
=0;i
<NPOINTS
;i
++)
30 //input_dsp(input,NPOINTS,0);
32 iir(input
, output
, coefficient
, internal_state
);
34 //output_dsp(input,NPOINTS,0);
35 //output_dsp(coefficient,NPOINTS,0);
36 //output_dsp(internal_state,NPOINTS,0);
37 //output_dsp(output,NPOINTS,0);
40 void iir(float input
[NPOINTS
], float output
[NPOINTS
],
41 float coefficient
[NSECTIONS
][NSECTIONS
][NSECTIONS
],
42 float internal_state
[8][NSECTIONS
][2])
43 /* input: input sample array */
44 /* output: output sample array */
45 /* coefficient: coefficient array */
46 /* internal_state: internal state array */
48 int i
, imod8
, imodNSECTIONS
;
51 float state_2
, state_1
;
52 float coef_a21
, coef_a11
, coef_b21
, coef_b11
;
55 for (i
= 0; i
< NPOINTS
; ++i
) {
58 imodNSECTIONS
= i
% NSECTIONS
;
63 for (j
= 0; j
< NSECTIONS
; ++j
) {
65 state_2
= internal_state
[imod8
][j
][0];
66 state_1
= internal_state
[imod8
][j
][1];
68 sum
-= internal_state
[imod8
][j
][0] * coefficient
[imodNSECTIONS
][j
][0] +
69 internal_state
[imod8
][j
][1] * coefficient
[imodNSECTIONS
][j
][1];
71 internal_state
[imod8
][j
][0] = internal_state
[imod8
][j
][1];
72 internal_state
[imod8
][j
][1] = sum
;
74 sum
+= state_2
* coefficient
[imodNSECTIONS
][j
][2] +
75 state_1
* coefficient
[imodNSECTIONS
][j
][3];