# Serial filtering using FFT

lets say I have 3 audio filters for a realtime DSP application. For simplictity each has length 256 (as well as the input signal). The filters should work in series. Starting with filter IR h1(n) and input x(n), zeropadding to 512, FFT, then multiplication and IFFT, delivers the first stage output Y1(n).

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

Second filter stage: input to this stage is y1(n) which has already 512 samples, and has to be convolved with filter h2(L=256). So y1 and h2 have to be zeropadded to 788, FFT, Multiplication, IFFT... Output y2 has lenght 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 H1,H2,H3 then do X*H1*H2*H3, 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+N1+N2+N3. 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 arround 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?

## 1 Answer

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====

• 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? – f.f Aug 7 '19 at 11:01
• @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$. – mfcc64 Aug 7 '19 at 12:51