DSPRelated.com
Forums

Time Delay of a FIR filter

Started by adnanyusuf May 14, 2015
I came across this online :

"2.1.4 What is the delay of a linear-phase FIR?
The formula is simple: given a FIR filter which has N taps, the delay is:
(N - 1) / (2 * Fs), where Fs is the sampling frequency. So, for example, a
21 tap linear-phase FIR filter operating at a 1 kHz rate has delay: (21 -
1) / (2 * 1 kHz)=10 milliseconds."

I think the formula should be (N-1)/(Fs). For example assuming, its an 8
tap filter. So, if 8 samples arrive only after that, the first output is
generated. So 7*(time_between_samples).

Please help.





---------------------------------------
Posted through http://www.DSPRelated.com
On 14.05.15 16.22, adnanyusuf wrote:
> I came across this online : > > "2.1.4 What is the delay of a linear-phase FIR?
It depends on the filter kernel.
> The formula is simple: given a FIR filter which has N taps, the delay is: > (N - 1) / (2 * Fs), where Fs is the sampling frequency.
If and only if your filter kernel is symmetric. Otherwise the group delay is frequency dependent.
> So, for example, a > 21 tap linear-phase FIR filter operating at a 1 kHz rate has delay: (21 - > 1) / (2 * 1 kHz)=10 milliseconds."
> I think the formula should be (N-1)/(Fs). For example assuming, its an 8 > tap filter. So, if 8 samples arrive only after that, the first output is > generated. So 7*(time_between_samples).
The filter delay is not the latency. The latency is usually even larger, because short FIR filters are uncommon and long FIR kernels are likely implemented using FFT convolution which has significantly higher latency. Marcel
On 14.05.2015 17:22, adnanyusuf wrote:
> I came across this online : > > "2.1.4 What is the delay of a linear-phase FIR? > The formula is simple: given a FIR filter which has N taps, the delay is: > (N - 1) / (2 * Fs), where Fs is the sampling frequency. So, for example, a > 21 tap linear-phase FIR filter operating at a 1 kHz rate has delay: (21 - > 1) / (2 * 1 kHz)=10 milliseconds." > > I think the formula should be (N-1)/(Fs). For example assuming, its an 8 > tap filter. So, if 8 samples arrive only after that, the first output is > generated. So 7*(time_between_samples). > > Please help. > > > --------------------------------------- > Posted through http://www.DSPRelated.com >
Hi. Consider an ideal non-casual N-tap FIR filter. In order to produce a sample of output, it needs a current input sample, (N - 1)/2 input samples from the past and (N - 1)/2 input samples from the future. And it has zero delay. But since you are processing a a continuous stream of data, such non-casual filter cannot be realized. In order to make it casual, you shift its impulse response by (N - 1) / 2 taps, so it takes (N - 1) input samples from the past and takes no samples from the future. Comparing it to the non-casual filter, you can now say that the casual FIR filter has a delay of (N - 1)/2 taps. HTH, Evgeny.
On Thu, 14 May 2015 09:22:14 -0500, "adnanyusuf" <105792@DSPRelated>
wrote:

>I came across this online : > >"2.1.4 What is the delay of a linear-phase FIR? >The formula is simple: given a FIR filter which has N taps, the delay is: >(N - 1) / (2 * Fs), where Fs is the sampling frequency. So, for example, a >21 tap linear-phase FIR filter operating at a 1 kHz rate has delay: (21 - >1) / (2 * 1 kHz)=10 milliseconds." > >I think the formula should be (N-1)/(Fs). For example assuming, its an 8 >tap filter. So, if 8 samples arrive only after that, the first output is >generated. So 7*(time_between_samples). > >Please help.
A linear-phase filter has coefficients that are symmetric about the center of the impulse response. A typical filter has a main lobe at the center and much smaller sidelobes on either side of it. The "delay" of the filter is the delay of a signal from the input to the output, and if you put an impulse into the filter, the appearance of the main lobe is considered the representation of the output time of the "impulse". The delay to the main lobe of a linear-phase filter is therefore always N/2, not N, since the "impulse" output appears halfway through the impulse response. So the original formula is correct. Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
Marcel Mueller wrote:
> On 14.05.15 16.22, adnanyusuf wrote: >> I came across this online : >> >> "2.1.4 What is the delay of a linear-phase FIR? > > It depends on the filter kernel. > >> The formula is simple: given a FIR filter which has N taps, the delay is: >> (N - 1) / (2 * Fs), where Fs is the sampling frequency. > > If and only if your filter kernel is symmetric. Otherwise the group > delay is frequency dependent. > >> So, for example, a >> 21 tap linear-phase FIR filter operating at a 1 kHz rate has delay: (21 - >> 1) / (2 * 1 kHz)=10 milliseconds." > >> I think the formula should be (N-1)/(Fs). For example assuming, its an 8 >> tap filter. So, if 8 samples arrive only after that, the first output is >> generated. So 7*(time_between_samples). > > The filter delay is not the latency. The latency is usually even larger, > because short FIR filters are uncommon and long FIR kernels are likely > implemented using FFT convolution which has significantly higher latency. > > > Marcel
FFT convolution need have no latency: http://www.cs.ust.hk/mjg_lib/bibs/DPSu/DPSu.Files/Ga95.PDF -- Les Cargill
On 5/14/15 7:07 PM, Les Cargill wrote:
> Marcel Mueller wrote:
...
>> >> The filter delay is not the latency.
oh, but they are soooo intimately related.
>> The latency is usually even larger, >> because short FIR filters are uncommon and long FIR kernels are likely >> implemented using FFT convolution which has significantly higher latency. >> > > FFT convolution need have no latency: > > http://www.cs.ust.hk/mjg_lib/bibs/DPSu/DPSu.Files/Ga95.PDF
in section 2.1 the author (Bill Gardner now of WaveArts) states that "The first block, h0, is N points long, and its result, y0, is computed by direct-form filtering without delay." all of the FFT blocks *must* have delay (or "latency", whatever word you wanna use) because double-buffering is necessary. the minimum delay must be twice the length of the FIR block. in fact, i couldn't get the scheduling thing that Bill describes here to work in my brain and have, just last week, been discussing this with Bill. this paper has, as best that i can tell, the least amount of "latency" between the time it was first presented at an AES Convention (Nov 1994) and when published in the Journal (Mar 1995). like 4 friggin' months! that's pretty impressive. i've never seen nor heard of any other convention paper go from initial presentation to journal publication in that short period of time. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On 15.05.15 01.50, robert bristow-johnson wrote:
> all of the FFT blocks *must* have delay (or "latency", whatever word you > wanna use) because double-buffering is necessary. the minimum delay > must be twice the length of the FIR block.
AFAIK that's not true. You could choose an FFT size that hes less than twice of the filter kernel length. You simply get less output samples with each transformation in this case. Of course, it makes no sense to have only a few samples more. But 167% of the FIR length works quite well, e.g. FIR kernel of 6144 and FFT of 8192. Marcel
robert bristow-johnson wrote:
> On 5/14/15 7:07 PM, Les Cargill wrote: >> Marcel Mueller wrote: > ... >>> >>> The filter delay is not the latency. > > oh, but they are soooo intimately related. > >>> The latency is usually even larger, >>> because short FIR filters are uncommon and long FIR kernels are likely >>> implemented using FFT convolution which has significantly higher >>> latency. >>> >> >> FFT convolution need have no latency: >> >> http://www.cs.ust.hk/mjg_lib/bibs/DPSu/DPSu.Files/Ga95.PDF > > in section 2.1 the author (Bill Gardner now of WaveArts) states that > "The first block, h0, is N points long, and its result, y0, is computed > by direct-form filtering without delay." > > all of the FFT blocks *must* have delay (or "latency", whatever word you > wanna use) because double-buffering is necessary.
Indeed; an identity transform on a real-world DAW (for example) must have some latency. It'll be more than two samples in most cases. I used the term latency as I thought it fit - no additional latency from the signals processing algorithm itself, which is only partially true of the entire system. I took as the context that there was already digital processing in play; so those latencies are hardware and not software driven.
> the minimum delay > must be twice the length of the FIR block.
Mmmm... I believe you can simply copy the first block without modification for most cases. Er, I've never found a case where you could not. I am sure they exist, but I don't know what they are because I'm biased towards certain types of applications.
> in fact, i couldn't get the > scheduling thing that Bill describes here to work in my brain and have, > just last week, been discussing this with Bill. >
*Kewl*. I have gotten to where I either understand it or am deluded into thinking I do. I will say - "zero latency convolution reverbs" are claimed to exist and I'm gonna write one one day. Then and only then will I know.
> this paper has, as best that i can tell, the least amount of "latency" > between the time it was first presented at an AES Convention (Nov 1994) > and when published in the Journal (Mar 1995). like 4 friggin' months!
FLAM! ;)
> that's pretty impressive. i've never seen nor heard of any other > convention paper go from initial presentation to journal publication in > that short period of time. > >
It's one of the coolest algorithms I have ever read. -- Les Cargill
On Thu, 14 May 2015 09:22:14 -0500, "adnanyusuf" <105792@DSPRelated>
wrote:

>I came across this online : > >"2.1.4 What is the delay of a linear-phase FIR? >The formula is simple: given a FIR filter which has N taps, the delay is: >(N - 1) / (2 * Fs), where Fs is the sampling frequency. So, for example, a >21 tap linear-phase FIR filter operating at a 1 kHz rate has delay: (21 - >1) / (2 * 1 kHz)=10 milliseconds." > >I think the formula should be (N-1)/(Fs). For example assuming, its an 8 >tap filter. So, if 8 samples arrive only after that, the first output is >generated. So 7*(time_between_samples). > >Please help.
Hi adnanyusuf, I think you are confusing two different time-related characteristics of FIR filters. I call those two characteristics (1) the "time delay", and (2) the "transient response". [1] The "time delay" (also called "group delay") of an FIR filter is the time difference between an input sine wave applied to the filter and the output sine wave generated by the filter. For an N-tap FIR filter that "time delay" is (N-1)/2 and is measured in "samples". Your expression (N-1)/(2*Fs) is the "time delay" measured in seconds. That "time delay" will always be an integer multiple of one half of a sample, or an integer multiple of 1/(2*Fs) seconds. [2] The "transient response" of an FIR filter is the time from when the first input sample is applied to the filter to the time instant when the filter's delay line becomes completely filled with input samples. For example, for an N = 9 tap FIR filter if you apply a sine wave sequence to the filter's input the filter's output will be a sine wave (of the same frequency as the input) delayed by (N-1)/2 = 4 samples. But the first eight (N-1 = 8) filter output samples will not be "valid" (not be correct) samples of a sine wave sequence. The first eight filter output samples were computed when the filter's delay line was not completely filled with valid input samples. It's only when the ninth (N = 9) input sample is applied to the filter that the delay line is filled with data and the filter's ninth output sample becomes a "valid" sample of a sine wave sequence You can prove this to your self by modeling this "sine wave input" scenario using some signal processing software and plotting the FIR filter's output sequence. You'll see that the first eight output samples do not look like the samples of a sine wave sequence. Thinking more about this, I guess we could argue about the exact definition of the "transient response" of a FIR filter. But regardless of our agreed-upon definition, the "transient response of an N = 9 tap FIR filter will either be eight samples or nine samples. Hope this helped. [-Rick-]
Hi adnanyusuf,
   Oops.  I forgot to mention something in my 
previous post.

In that post, discussing the "time delay" of 
an FIR filter, I forgot to say that my description 
of "time delay" only applies to FIR filters whose 
coefficients are symmetrical.

[-Rick-]