3
$\begingroup$

Let's say I have 3 audio filters for a realtime DSP application. For simplicity each has length $256$ (as well as the input signal). The filters should work in series. Starting with filter IR $h_{1} \left( n \right)$ and input $x \left( n \right)$, zero-padding to $512$, FFT, then multiplication and IFFT, delivers the first stage output $Y_{1} \left( n \right)$.

Since they input vector was padded to $512$ the output has $512$, too.

Second filter stage: input to this stage is $y_{1} \left( n \right)$ which has already $512$ samples, and has to be convolved with filter $h_{2} \left( L = 256 \right)$. So $y_{1}$ and $h_{2}$ have to be zero-padded to $788$, FFT, multiplication, IFFT... Output $y_{2}$ has length $768$

Third stage: will add another padding, so final output vector will have length $1024$

Since my app is realtime I would, for performance reason, like to avoid multiple FFT->iFFT for each stage. Moreover there will be a growing input length for the FFT with each filter stage. I would prefer doing FFT for each filter individually to get $H_{1}$, $H_{2}$, $H_{3}$ then do $X \cdot H_{1} \cdot H_{2} \cdot H_{3}$, then IFFT. As far as I understood from a previous post, this would work, if I would zero-pad each filter (and input) already in the beginning to length $L = N + N_{1} + N_{2} + N_{3}$. Unfortunately this I want to avoid since some filters are laying already pre-FFt´ed in big buffers already from the app start to grant fast access, and others (Equalizers e.g.) can be optionally switched on/off during runtime. So I have no way to know at program start to know how much "padded" zeros I will need to apply to those pre-FFT´ed filters.

Is there a way to get around this? Maybe zero padding those static filters in frequency domain "on the fly" if there should be added e.g. another EQ filter on runtime? If yes, how?

$\endgroup$

1 Answer 1

1
$\begingroup$

No, if you do zero-padding of $H_1$ in frequency domain.

But yes if you do zero-padding of $h_1$ in time domain. Basically you should have two FFT versions of $H_1$ ($H_{1,512}$ and $H_{1,1024}$). Because $h_1$ is static, you can precompute both, or you can compute $H_{1,1024}$ only when required.

Let $a = IFFT(FFT(x) \times H_{1,512})$ and $b = IFFT(FFT(x) \times H_{1,1024} \times H_2 \times H_3)$. Size of a is 512 and size of b is 1024. For example, using overlap add method, we can freely change fft-size between 512 and 1024, but it still process 256-input per fft.

===a====
     +
    ===a====
         +
        ===b============
             +
            ===b============
                 +
                ===a====
$\endgroup$
2
  • $\begingroup$ sounds like a good approach, but my problem is that I can have approx. 2000 filters (IRs) of type h1 preloaded. And unfortunately they are actually approx. 8192 each. If I do two versions ,loading will take forever and memory issues could start get a problem. Other ideas? $\endgroup$
    – f.f
    Aug 7, 2019 at 11:01
  • 1
    $\begingroup$ @f.f If it is the problem, you don't need to precompute 1024-version of $H_1$. Instead you may compute it when $H_2$ and $H_3$ are loaded, and precompute $H_1 \times H_2 \times H_3$. $\endgroup$
    – mfcc64
    Aug 7, 2019 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.