0
$\begingroup$

In my application a filtering in the frequency space is desired. I designed two high-pass filters: $h_1$ Butterworth IIR filter, and $h_2$ FIR. I designed them using Python's SciPy functions. Using signal.freqz I obtained the frequency response $H_1(k)$ and $H_2(k)$.

I now want to filter signal in a real-time, buffer-wise. I read buffers of certain size, say $N=2048$, and do a DFT and obtain $F(k)$. I then want to multiply the Fourier coefficient with the two filters frequency response: $G_i(k) = F(K) H_i(k)$ for $i=1,2$. Then I do inverse DFT to get the filtered signal. (Remark: in practice I use overlap/add in the buffering, and so recovering back the filtered signal in time domain requires windowing and is more complicated.)

Now for the questions:

Multiplying $F(k)$ by $|H_1(k)|$ seems to work, even in real-time. But multiplying by the absolute value is like performing zero-phase filtering, which by theory is non-causal. However, since I apply it buffer-wise, this seems to be the loophole. Am I correct?

I also filtered using $F(k) H_2(K)$ and in Python it works just fine. However, giving the list of coefficient $\{ H_2(k) \in \mathbb{C} \mid k=0,...,N/2 \}$ for a colleague, for her to filter in another application/software, the filtering didn't seem to work. The filtered signal was a total mess (the unfiltered signal is a short speech by a woman). I verified with her that she applied the filter with the "mirror conjugate" completion so $\tilde{H}_2 = (H_2(k), \overline{H_2(N/2+1-k)}) \in \mathbb{C}^N$. Is there a theoretical reason for it not to work? (so we can narrow the reason to a bug in her code)

$\endgroup$
2
  • $\begingroup$ Are you sure that it is zero phase and not linear phase due to the delay of the buffer? $\endgroup$
    – fibonatic
    Commented Sep 2, 2020 at 16:13
  • $\begingroup$ Good question. I am not sure of the answer, but think that since we multiply in a positive real frequency response, the filtering introduces 0 phase. $\endgroup$ Commented Sep 3, 2020 at 12:05

1 Answer 1

1
$\begingroup$

It's not a loophole. A causal linear phase filter is identical to a non-causal zero phase filter in series with a delay of half the filter length. If you check the results of your filter with an impulse input, you will probably see such a delay.

So it's not really real-time if you count the delay, but is often close enough to seem real-time if the filter's impulse response and/or block size is short relative to your real-time requirements.

$\endgroup$
1
  • $\begingroup$ But why the zero-phase filtering $F(k)|H_1(k)|$ of the IIR works? $\endgroup$ Commented Sep 7, 2020 at 14:50

Your Answer

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

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