Arduino-Filters icon indicating copy to clipboard operation
Arduino-Filters copied to clipboard

FIRFilter initialization

Open m0rphex opened this issue 4 years ago • 2 comments

Hi thanks for the library. Testing the Butterworth worked great with i2s audio and the ESP32. I would like to test coefficients with the FIRFilter, but having trouble initiating the filter and there isn't an example for it currently, at least I haven't found one. Something like auto filter = FIRFilter<TAP_COUNT, uint16_t>(&filter_taps) doesn't work. I'm aware that the notch filter makes use of the FIRFilter, but I can't wrap my head around how to get a simple FIR filter object initialized. An example would be great!

m0rphex avatar May 01 '21 11:05 m0rphex

What is the type of filter_taps? The FIRFilter class expects the argument to be of type Array<uint16_t, TAP_COUNT>.

Apart from the documentation, you can always have a look at the tests to learn how to initialize the different classes: https://github.com/tttapa/Arduino-Filters/blob/4b4cc094bf0f93bd21f47f2915a98c85dc207366/test/Filters/test-FIRFilter.cpp#L31

The current implementation of FIRFilter uses the same type for the accumulator as for the inputs and the coefficients. If you're working with integers, it might be better to use a larger type for the accumulator, especially with high tap counts. I might add this option to the library in a future release.

tttapa avatar May 01 '21 13:05 tttapa

Thank you for the prompt response and pointing out the example, I got my test application working. I had the type wrong, used int finally for a low pass filter. I'm making a sdr receiver with the ESP32-A1S kit (hopefully module later) and would like to implement a FIR low pass filter with a +-45 degree Hilbert transform but I have still a lot to learn. Your Butterworth filter sounds great and I'm able to sample at 192000 Hz with dma buffers. I will also experiment with applying a phase shift to the i q channels after the Butterworth filtering and before summing them. DSP is fun but the learning curve is quite steep :) Thank you again!

m0rphex avatar May 01 '21 19:05 m0rphex