19 void iir_filt_forward(
float *in,
int stepin,
float *out,
int stepout,
int length,
float *coeffs,
float *i0)
27 out[0] = b0*in[0] - a1*i0[0] - a2*i0[1] - a3*i0[2];
28 out[1*stepout] = b0*in[stepin] - a1*out[0] - a2*i0[0] - a3*i0[1];
29 out[2*stepout] = b0*in[2*stepin] - a1*out[stepout] - a2*out[0] - a3*i0[0];
30 for(j = 3; j < length; j++)
31 out[j*stepout] = b0*in[j*stepin] - a1*out[(j-1)*stepout] - a2*out[(j-2)*stepout] - a3*out[(j-3)*stepout];
35 void iir_filt_backward(
float *in,
int stepin,
float *out,
int stepout,
int length,
float *coeffs,
float *i0)
43 out[(length-1)*stepout] = b0*in[(length-1)*stepin] - a1*i0[0] - a2*i0[1] - a3*i0[2];
44 out[(length-2)*stepout] = b0*in[(length-2)*stepin] - a1*out[(length-1)*stepout] - a2*i0[0] - a3*i0[1];
45 out[(length-3)*stepout] = b0*in[(length-3)*stepin] - a1*out[(length-2)*stepout] - a2*out[(length-1)*stepout] - a3*i0[0];
46 for(j = length-4; j >= 0; j--)
47 out[j*stepout] = b0*in[j*stepin] - a1*out[(j+1)*stepout] - a2*out[(j+2)*stepout] - a3*out[(j+3)*stepout];
50 void iir_filt_forward(
float *in,
float *out,
int length,
float *coeffs,
float *i0)
58 out[0] = b0*in[0] - a1*i0[0] - a2*i0[1] - a3*i0[2];
59 out[1] = b0*in[1] - a1*out[0] - a2*i0[0] - a3*i0[1];
60 out[2] = b0*in[2] - a1*out[1] - a2*out[0] - a3*i0[0];
61 for(j = 3; j < length; j++)
62 out[j] = b0*in[j] - a1*out[j-1] - a2*out[j-2] - a3*out[j-3];
66 void iir_filt_backward(
float *in,
float *out,
int length,
float *coeffs,
float *i0)
74 out[length-1] = b0*in[length-1] - a1*i0[0] - a2*i0[1] - a3*i0[2];
75 out[length-2] = b0*in[length-2] - a1*out[length-1] - a2*i0[0] - a3*i0[1];
76 out[length-3] = b0*in[length-3] - a1*out[length-2] - a2*out[length-1] - a3*i0[0];
77 for(j = length-4; j >= 0; j--)
78 out[j] = b0*in[j] - a1*out[j+1] - a2*out[j+2] - a3*out[j+3];
81 void iir_filt_forward(
float *in,
float *out,
int stepout,
int length,
float *coeffs,
float *i0)
89 out[0] = b0*in[0] - a1*i0[0] - a2*i0[1] - a3*i0[2];
90 out[1*stepout] = b0*in[1] - a1*out[0] - a2*i0[0] - a3*i0[1];
91 out[2*stepout] = b0*in[2] - a1*out[stepout] - a2*out[0] - a3*i0[0];
92 for(j = 3; j < length; j++)
93 out[j*stepout] = b0*in[j] - a1*out[(j-1)*stepout] - a2*out[(j-2)*stepout] - a3*out[(j-3)*stepout];
97 void iir_filt_backward(
float *in,
float *out,
int stepout,
int length,
float *coeffs,
float *i0)
100 float b0 = coeffs[0];
101 float a1 = coeffs[1];
102 float a2 = coeffs[2];
103 float a3 = coeffs[3];
105 out[(length-1)*stepout] = b0*in[length-1] - a1*i0[0] - a2*i0[1] - a3*i0[2];
106 out[(length-2)*stepout] = b0*in[length-2] - a1*out[(length-1)*stepout] - a2*i0[0] - a3*i0[1];
107 out[(length-3)*stepout] = b0*in[length-3] - a1*out[(length-2)*stepout] - a2*out[(length-1)*stepout] - a3*i0[0];
108 for(j = length-4; j >= 0; j--)
109 out[j*stepout] = b0*in[j] - a1*out[(j+1)*stepout] - a2*out[(j+2)*stepout] - a3*out[(j+3)*stepout];
112 void iir_filt_forward(
float *in,
int stepin,
float *out,
int length,
float *coeffs,
float *i0)
115 float b0 = coeffs[0];
116 float a1 = coeffs[1];
117 float a2 = coeffs[2];
118 float a3 = coeffs[3];
120 out[0] = b0*in[0] - a1*i0[0] - a2*i0[1] - a3*i0[2];
121 out[1] = b0*in[stepin] - a1*out[0] - a2*i0[0] - a3*i0[1];
122 out[2] = b0*in[2*stepin] - a1*out[1] - a2*out[0] - a3*i0[0];
123 for(j = 3; j < length; j++)
124 out[j] = b0*in[j*stepin] - a1*out[j-1] - a2*out[j-2] - a3*out[j-3];
128 void iir_filt_backward(
float *in,
int stepin,
float *out,
int length,
float *coeffs,
float *i0)
131 float b0 = coeffs[0];
132 float a1 = coeffs[1];
133 float a2 = coeffs[2];
134 float a3 = coeffs[3];
136 out[length-1] = b0*in[(length-1)*stepin] - a1*i0[0] - a2*i0[1] - a3*i0[2];
137 out[length-2] = b0*in[(length-2)*stepin] - a1*out[length-1] - a2*i0[0] - a3*i0[1];
138 out[length-3] = b0*in[(length-3)*stepin] - a1*out[length-2] - a2*out[length-1] - a3*i0[0];
139 for(j = length-4; j >= 0; j--)
140 out[j] = b0*in[j*stepin] - a1*out[j+1] - a2*out[j+2] - a3*out[j+3];
Functions for generic, 3 tap, iir filtering.
void iir_filt_forward(float *in, int stepin, float *out, int stepout, int length, float *coeffs, float *i0)
Functions iir_filt_forward and iir_filt_backward do a 3 tap recursive filtering operation on floating...