# why we do pure delay to make causal fir filter?

Sometimes, we met Non-causal FIR filter problem like this picture left is ifft of frequency response and right is time shifted fir filter to be causal filter in noise cancellation problem, delay is very annoying things.

my question is if i do filtering process in frequency domain, ideal filter (that is not delayed for making fir filter to be causal) can be used?

i can't understand why i have to do this pure delay to make causal filter.

what is the problem when i do filtering signal with frequency response of Non-causal fir filter?? i think that is just multiply process

thank you

left is ifft of frequency response and right is time shifted fir filter to be causal filter in noise cancellation problem, delay is very annoying things.

You are misinterpreting the results of the IFFT in your picture on the left side. This comes from using the IFFT where you should, properly, use the inverse DTFT.

The DFT (from whence the FFT comes), has an output domain that is both discrete and circular, where any given frequency $$\theta$$ is congruent with any other frequency $$\theta + 2\pi m$$. (As typically implemented, this means that for an $$N$$-point IFFT, any sample $$n$$ is congruent with any other sample $$n + N\ m$$).

You problem comes because you're talking about actual physical filters that operate in a time domain over all the integers. For this, the DFT (and, hence, FFT and IFFT) does not fit. Formally, you should be using the the inverse DTFT, where the domain of the output is all the integers.

Where you to do this, you would find that your filter's impulse response $$h(n)$$ has non-compnents for $$n < 0$$. This is what makes your filter non-causal. It's obvious in retrospect -- if the filter is responding before the input, then it can't exist in the physical world.

Let me reiterate this:

• Filters that start responding to an input before it happens are non-causal.
• We live in a causal universe.
• Non-causal filters are not real.

Now, someone's going to object that, no, non-causal filters are real, they apply them to recorded data all the time. OK, fine, if you're applying a filter to recorded data, then you are simulating a universe where you have prior knowledge of the 'future', and then you can, within the context of your simulation, have a "non-causal" filter.

But if you're going to apply a real filter to real-time data you can no more use a non-causal filter than you can travel faster than light*.

my question is if i do filtering process in frequency domain, ideal filter (that is not delayed for making fir filter to be causal) can be used?

In the real universe, we live in the time domain. Yes, you can take pre-recorded data, you can take it's FFT, multiply by a filter's frequency response, and then take its IFFT.

But that is not operating on data in real-time. It's operating on recorded data. And because you have recorded the data, you have, indeed, added delay.

i can't understand why i have to do this pure delay to make causal filter.

See the definition of causal filters, above. It is absolutely fundamental, by definition that a filter which responds to an input before the input happens is non-causal.

If you keep this definition in mind, then the need to add delay to make a filter causal should be obvious.

what is the problem when i do filtering signal with frequency response of Non-causal fir filter?? i think that is just multiply process

It is "just" a multiplication in the frequency domain after you record enough data that you can perform an FFT on it. Recording that data takes time, "takes time" is synonymous with "adding delay" -- so when you 'just' multiply in the frequency domain, you must first add delay in the real world.

* Apparently this is actually a result in General Relativity. I still haven't wrapped my brain around it, but -- OK, I understand the presentations when the charts are still on the screen, and I'm not a general relativist, so I'll just take that as a given.

• With all due respect I am not quite buying the IDTFT explanation (yet): Wouldn't the Inverse DTFT produce the same non-causal result? I believe the core reason is the original frequency response used was real. If we use the inverse of the DTFT we are just using a continuous frequency response instead of a discrete one, and the resulting sampled time domain extends to +/- infinity (and would be non-causal centered on t=0). Practicality dictates we would use an IFFT and then shift the second half to the beginning half rather than inserting the necessary phase delay (same outcome). Jan 26, 2022 at 6:31
• IDTFT vs IFFT is a sideshow. The core question is "can I make it all causal, without adding delay, by doing it in the frequency domain?", and the answer (which I give) is "not in the real world" because to do it in the "frequency domain" (using overlap-and-add with FFTs and IFFTs, right here in the time domain) necessarily adds delay. Jan 26, 2022 at 19:12
• I see now-- I reread the question and see your point: the core question is why we can't make zero-phase filters in the real world and why do we need to deal with that annoying delay when we can just multiply in frequency. I didn't get that from the question on my first pass, I thought the concern was with actual implementation and the resulting circularly shifted coefficients. Jan 26, 2022 at 21:27

i think that is just multiply process

Multiplying in the frequency domain implements circular convolution, not linear convolution. That's why you need to use algorithms like overlap-add or overlap-save for frequency domain filtering.

Frequency domain processing also isn't a great fit for most active noise cancellation problems since the latency is too large. In order to do an FFT of length $$N$$ you need to wait until you have accumulated $$N$$ samples. Typically the latency for an FFT based system is $$2N$$ samples.

If you only care about the magnitude of the transfer function, you can minimize the delay (and keep things causal) by using a minimum-phase instead of a zero phase.

• just to be clear may be good to add "in the discrete time domain" to your first sentence since that statement as it stands isn't generally true, right? Jan 25, 2022 at 4:59

Update: I realize now the OP is asking why we have to have any of that "annoying" delay in filter implementations given we can just multiply by a zero-phase filter in frequency. Tim answered that question while below with my prior answer, I provide the details as to why the OP's left plot is non-causal (and requires fftshift to correct), as well as reasons why simply multiplying FFT bins in the frequency domain is not a good filtering approach unless we are only interested in the FFT bins (such as OFDM).

The fundamental reason the OP has achieved a non-causal result is because the original target response in frequency had zero phase; which can't be physically implemented with an FIR filter. The FIR filter that can be implemented will have a linear phase component in frequency with a negative phase slope versus frequency that is proportional to its delay (0 to $$2\pi$$ radians from DC to the sampling rate for every unit sample delay). If the OP had started with a target response for both magnitude AND phase, with sufficient delay that is implementable, then the IFFT result on the right will be realized directly. However it is easiest to just know that but proceed with a zero phase solution in frequency when we are only concerned with magnitude and want a linear phase (fixed delay) and do the simple correction in time (Using 'ifftshift' in MATLAB, Octave and Python scipy.signal).