Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: How to implement a FIR filter larger than 200 taps

  1. #1
    Junior Member
    Join Date
    Apr 2022
    Posts
    7

    How to implement a FIR filter larger than 200 taps

    Hi, there!

    I'm currently working on a project that involves real time audio processing and I'm using a Teensy 4.0.

    The first stage of this project aims to replicate a guitar amp's frequency response using a filter. I was interested in using FIR filters because of their linear phase perk.

    The thing is my filter needs to be around 1024 taps in order to replicate the low frequency response of the amplifier. I need to be accurate at least until it reaches 80-100 Hz.

    I came to ask you guys what is my best alternative here. Is it possible to design a cascade of 200 taps filters that would be equivalent to my 1024 taps one? Can I implement the filter in C++ and import it as an object to program the Teensy? Or should I just use a 200 tap filter and use a biquad to attenuate the low frequency response?

    My 1024 FIR filter's response is like this and it's very close to the target:

    Click image for larger version. 

Name:	1024 fir.jpg 
Views:	12 
Size:	31.8 KB 
ID:	29749

    Thanks for reading

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,772
    Quote Originally Posted by Sequoia101 View Post
    Hi, there!

    I'm currently working on a project that involves real time audio processing and I'm using a Teensy 4.0.

    The first stage of this project aims to replicate a guitar amp's frequency response using a filter. I was interested in using FIR filters because of their linear phase perk.

    The thing is my filter needs to be around 1024 taps in order to replicate the low frequency response of the amplifier. I need to be accurate at least until it reaches 80-100 Hz.

    I came to ask you guys what is my best alternative here. Is it possible to design a cascade of 200 taps filters that would be equivalent to my 1024 taps one? Can I implement the filter in C++ and import it as an object to program the Teensy? Or should I just use a 200 tap filter and use a biquad to attenuate the low frequency response?

    My 1024 FIR filter's response is like this and it's very close to the target:

    Click image for larger version. 

Name:	1024 fir.jpg 
Views:	12 
Size:	31.8 KB 
ID:	29749

    Thanks for reading
    For large FIR filters one approach is to use uniformly partitioned convolution, which allows FFT to do the heavy lifting and the partitioning allows close to real-time response, depending on the size of the partitions.

    Perhaps look at these threads: https://forum.pjrc.com/threads/43847...ft+convolution
    https://forum.pjrc.com/threads/38011...ft+convolution

    and my attempt: https://forum.pjrc.com/threads/68939...ft+convolution

    It is a complex scheme compared to using a biquad for the low frequencies...

    BTW you can't have linear phase and low latency (zero-phase), and for this application phase shift is perfectly acceptable (real acoustics involve phase shifts all over the shop!).

  3. #3
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    704
    Not sure, what you would exactly try to achieve: do you have the actual measured impulse response of your amp (and transformed into minimal phase form) OR do you have the EQ response (your picture) and would like to replicate that?

    1.) Your freq response looks like it could be replicated by a rather simple EQ with only a few bands. --> so this could be made eg. with a simple 5-band EQ with IIR filters

    2.) If you would like to do it with 1024 tap FIR filtering, you could use a Fast Convolution filter approach (not partitioned); you will save CPU cycles, if the number of filter taps exceeds about 100. The latency is the same as the number of taps, however.

    3.) If you have the exact impulse response (AND you would like low latency), you could use partitioned convolution, as MarkT said. But this only really achieves low latency, if your impulse response (your filter coefficients) are minimal phase. It does not work with the standard (linear phase) coeffs that you get from a standard FIR filter coefficient calculator. In that case the filter still works fine, but the latency is still the same as a standard FIR filter. it is quite hard and time consuming to calculate minimal phase FIR filter coeffs (MATLAB does this, but still takes half an hour of computing for a large filter size)

    Just my first thoughts on this.

    Best regards, Frank DD4WH

  4. #4
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,772
    BTW I use the Python module scipy.signal, it does a similar job to MATLAB for these filtering calculations, all open source and free. https://docs.scipy.org/doc/scipy/reference/signal.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •