libiir Documentation


This library allows the implementation of arbitrary IIR filters in C. It has functions for generating and manipulating filters in terms of coefficients, for chaining arbitrary filters together, and for generating coefficients for some common types of filter. See Structure of IIR filter for a definition of the IIR filter equation.

Filter creation

At a high level, filters may be specified as strings. See Describing IIR filters as strings for the required format and iir_parse() for a C function returning a filter instance from such a string.

Otherwise, the library user must first create a set of coefficients using iir_coeff_new(). Any number of filters can then be instantiated using that set of coefficients with iir_filter_new(), or the coefficients can be chained on to the end of an existing filter instance with iir_filter_chain(). See Common types of IIR filter for functions to generate coefficients.

Filter operation

The function iir_filter() will actually process an input sample through the coefficient chain and produce the output sample. Effectively it produces y(t) given x(t).

A filter may be copied, possibly including its state (for initial conditions), using the function iir_filter_copy().


In the tests directory are some simple tools for examining and experimenting with filters. run_filter takes a stream of input samples x(t) and produces the filtered output samples y(t).

Perhaps more interesting is plot_filter (requires GNUplot to be installed) which will generate a Bode plot for a given filter chain. Note the phase response can be a little rough due to the simplistic time-domain analysis of the output signal's phase.