icub-basic-demos
Functions
IIRFilt.h File Reference

Functions for generic, 3 tap, iir filtering. More...

Go to the source code of this file.

Functions

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 point buffers. More...
 
void iir_filt_backward (float *in, int stepin, float *out, int stepout, int length, float *coeffs, float *i0)
 
void iir_filt_forward (float *in, float *out, int length, float *coeffs, float *i0)
 
void iir_filt_backward (float *in, float *out, int length, float *coeffs, float *i0)
 
void iir_filt_forward (float *in, float *out, int stepout, int length, float *coeffs, float *i0)
 
void iir_filt_backward (float *in, float *out, int stepout, int length, float *coeffs, float *i0)
 
void iir_filt_forward (float *in, int stepin, float *out, int length, float *coeffs, float *i0)
 
void iir_filt_backward (float *in, int stepin, float *out, int length, float *coeffs, float *i0)
 

Detailed Description

Functions for generic, 3 tap, iir filtering.

Author
Alex Bernardino, ISR-IST
Date
2006-2007
Note
Release under GNU GPL v2.0
Author
Alex Bernardino, ISR-IST
Date
2006-2007
Note
Released under GNU GPL v2.0
See also
IIRFilt.h

Definition in file IIRFilt.h.

Function Documentation

◆ iir_filt_forward()

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 point buffers.

Forward filtering:

\[ y(t) = b_0 x(t) - a_1 y(t-1) - a_2 y(t-2) - a_3 y(t-3) \]

Parameters
inFloating point buffer with the input signal.
stepinSpacing between consecutive input signal samples.
outFloating point buffer to store the computation results.
stepoutSpacing between consecutive output buffer samples.
lengthNumber of samples to process (N)
coeffsFilter coefficients. A length 4 floating point array containing $(b_0, a_1, a_2, a_3)$
i0Filter boundary conditions. A length 3 floating point array containing:
  • in the forward filtering case $(y_{-1}, y_{-2}, y_{-3})$
  • in the backward filtering case $(y_{N}, y_{N+1}, y_{N+2})$
Note
Several overloads exist for the cases when stepin or stepout parameters are unitary.

Definition at line 19 of file IIRFilt.cpp.

20 {
21  int j;
22  float b0 = coeffs[0];
23  float a1 = coeffs[1];
24  float a2 = coeffs[2];
25  float a3 = coeffs[3];
26 
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];
32 }