libiir
1.0.2

Functions  
struct iir_filter_t *  iir_filter_new (const struct iir_coeff_t *coeff) 
Create IIR filter instance.  
void  iir_filter_free (struct iir_filter_t *fi) 
Free IIR filter instance.  
void  iir_filter_chain (struct iir_filter_t *fi, const struct iir_coeff_t *coeff) 
Add a further IIR filter to a filter instance.  
struct iir_filter_t *  iir_filter_copy (const struct iir_filter_t *fi, int state) 
Create a deep copy of an IIR filter instance.  
double  iir_filter (struct iir_filter_t *fi, double samp) 
Process a sample.  
int  iir_filter_coeff_sets (const struct iir_filter_t *fi) 
Count number of coefficient sets in IIR filter chain.  
struct iir_coeff_t *  iir_filter_coeff_set (const struct iir_filter_t *fi, int idx) 
Get IIR coefficient set from filter chain. 
The functions in this module present a basic interface for representing IIR filters, creating instances of (possibly chained) IIR filters, and filtering an input sample.
A general IIR filter consists of a set of coefficients, and may be created through iir_coeff_new(). The filter object (the opaque struct iir_coeff_t
) is then used to instantiate specific filters (the opaque struct iir_filter_t
) through iir_filter_new(). Each filter instance may have an arbitrary further number of IIR filters chained on to it through iir_filter_chain(). The filter processes one sample at a time through iir_filter().

read 
Create IIR filter instance.
coeff  Filter coefficients to use. 
Creates a new instance of a general IIR filter. The set of coefficients coeff is copied into the returned structure, meaning the coefficients can be freed after this function returns if they will not be needed again.
The first sample passed through iir_filter() will be used to set initial conditions (see Structure of IIR filter).
An arbitrary number of further filters may be chained on to the end of this instance through iir_filter_chain().
void iir_filter_free  (  struct iir_filter_t *  fi  ) 
Free IIR filter instance.
fi  Filter object to free. May be 0. 
Frees a previouslyallocated IIR filter instance. Can be called on a null pointer without consequences.
void iir_filter_chain  (  struct iir_filter_t *  fi, 
const struct iir_coeff_t *  coeff  
) 
Add a further IIR filter to a filter instance.
fi  Filter instance to chain onto. 
coeff  New IIR filter coefficients to add to chain. 
Extends an existing IIR filter by chaining a new set of coefficients onto the end. This can be used for >4th order Butterworth filters, for example. This copies the set of coefficients from coeff so the coefficients can be freed after this function returns if they are no longer required.

read 
Create a deep copy of an IIR filter instance.
fi  Filter instance to copy. 
state  Nonzero to copy state as well. 
Performs a deep copy of the filter instance fi. If state is nonzero, then the internal state of fi is copied as well (otherwise it is as treated as a brand new instance).
double iir_filter  (  struct iir_filter_t *  fi, 
double  samp  
) 
Process a sample.
fi  Filter object to run. 
samp  Input sample x(t) . 
y(t)
.Given the input sample x(t)
(the parameter samp), runs the filter chain in fi and produces the output sample y(t)
, which it returns.
int iir_filter_coeff_sets  (  const struct iir_filter_t *  fi  ) 
Count number of coefficient sets in IIR filter chain.
fi  Filter object. 
Returns the number of discrete IIR filter coefficient sets used in the filter object fi. There will always be at least one set.

read 
Get IIR coefficient set from filter chain.
fi  Filter object. 
idx  Index of coefficient set (0 ≤ idx < iir_filter_coeff_sets()). 
Extracts the IIR filter coefficient set for the given step (idx) in the chain of filters in fi. Returns a newlyallocated filter coefficient set object which can be freed with iir_coeff_free().