Do you know of some C++ library that implements IIR fi开发者_运维百科lters? I need something similar to Matlab's filter(B,A,X) function. Although it is not necessary, I would prefer an implementation of the IIR direct form 2.
There's octave, an open-source MatLab clone, you could use its implementation (but it will likely require you use use its special matrix type).
Searching for "C++ IIR filter" finds a bunch of other projects, such as:
- Signal Processing using C++
- dspfilterscpp
There are also a variety of books on the subject, for example:
- C++ algorithms for digital signal processing
In general, implementation of an IIR filter is very easy. Numerical robustness and efficient use of your computer hardware are more difficult, but they require knowledge of your specific application (e.g. resampling, etc) so aren't really suited for library implementations.
You could also try GNURadio (gnuradio.org), which contains all sorts of components for software defined radio (including iir filters). It was originally all C++, now it is a bunch of modules written in C++ with python bindings, but you should still be able to use the C++ code directly.
You can try the SPUC project on sourceforge. They do have some DSP functions but there is little documentation.
gtkIOStream has IIR and IIRCascade classes in C++. It is pretty easy to use. For example first you instantiate the IIR class and then load in your A and B vectors (note if you load in A and B matrices then you are specifying a bank of filters to apply in parallel) :
IIR iir;
iir.reset(B, A);
Then you filter the input (x) to the output (y) :
iir.process(x, y);
A full example using the IIR class is available here.
If you want cascaded IIR filters, then you can use the IIRCascade class. First you instantiate the class and reset the filter coefficients using the Matrices B and A which specify many filters to be applied one after the other to the same input signal :
IIRCascade iir;
iir.reset(B, A);
Again processing is simply :
iir.process(x, y);
A full example using the IIRCascade class is available here.
精彩评论