FIR filters

Re: FIR filters

I suspect the initial window might be redundant
I see a double sided time response like this:

96HFafter.jpg

If I feed it an impulse it makes a nice symmetrical arrowhead. But I better go back and take a careful look at my code to see what it's really doing.

The purpose of the initial window is just decisively to chop off the acoustic reflections to ensure an anechoic measurement. As in 2 times a 13 ft high tower minus 10 ft from speaker to mic = 16 ft. or 14 ms. But I think you're right in that any reflection should show up at its time in the TFE representation and the initial window is unnecessary. I should take a measurement holding a road case cover a few feet from the central axis and see what it looks like. I'll try turning off the initial window on the data I have and see if I can see the ground bounce out at ~15 ms.

--Frank
 
Re: FIR filters

You can see how much convolution with the window reduces the concentration for your TFR quite clearly.

Hi Mark, I don't think so. Those two examples are on different time scales and, as it turns out, from somewhat different data. The first is the average of 9 processed measurements and the second is of one raw measurement. Furthermore, the window shows up as more of a multiplication rather than a convolution in the time axis since it's applied to time domain data (the impulse response) to begin with. Below are two plots of the same (single measurement, raw) data, one with a 6 ms window and the other with 30 ms. The effect of 6ms is just to get rid of a bunch of grassy stuff beyond 6 ms. Seem right? -F

TFE6ms.jpgTFE30ms.jpg
 
Re: FIR filters

Hi Mark, I don't think so. Those two examples are on different time scales and, as it turns out, from somewhat different data. The first is the average of 9 processed measurements and the second is of one raw measurement. Furthermore, the window shows up as more of a multiplication rather than a convolution in the time axis since it's applied to time domain data (the impulse response) to begin with. Below are two plots of the same (single measurement, raw) data, one with a 6 ms window and the other with 30 ms. The effect of 6ms is just to get rid of a bunch of grassy stuff beyond 6 ms. Seem right? -F

View attachment 14053View attachment 14054

It's not the window you removed in the time domain, but the window which is the kernel of the transform. I didn't fully explain, but it looks low compared to even a Spectrogram.

The shape of the ridge, viewed looking normal to the t-f plane, strongly resembles the group delay.

The ridge should be concentrated along the instantaneous frequency, which is the first derivative of the analytic signal phase.

I too am happy for this thread, because it's making me want to play with all this stuff again! I haven't got to work with an arbitrary FIR correction filter since 2006. Now there seems to be lots of software out there and I have some DSPs which support this, that I don't have to program via JTAG.
 
Last edited:
Re: FIR filters

The ridge should be concentrated along the instantaneous frequency, which is the first derivative of the analytic signal phase.

Thank you for this. I've computed instantaneous frequency, out of curiosity, but have had a hard time understanding it or seeing what it's good for. This gives me something to go on.

Sorry I misunderstood which window you were referring to. I can vary the width of the window to trade off time and frequency resolution. What's used here is a somwhat arbitrary compromise.

Best,

--Frank

PS: Now I'm confused. The TFE ridge looks to me like a function of frequency. The instantaneous frequency is a function of time. I better just have another cup of coffee and calm down a little. -F
 
Last edited:
Re: FIR filters

Thank you for this. I've computed instantaneous frequency, out of curiosity, but have had a hard time understanding it or seeing what it's good for. This gives me something to go on.

Sorry I misunderstood which window you were referring to. I can vary the width of the window to trade off time and frequency resolution. What's used here is a somwhat arbitrary compromise.

Best,

--Frank

PS: Now I'm confused. The TFE ridge looks to me like a function of frequency. The instantaneous frequency is a function of time. I better just have another cup of coffee and calm down a little. -F

Haha, well I'm not being very clear. I'm home from work because I hurt my back lifting speakers (damn those ferrite compression drivers!!!).

Anyway, whether or not group delay exists in a global sense or not for your distribution, I believe has to do with the marginal properties holding? They do call the inverse of IF, rotation of the t-f plane basically, group delay also, as the concentration is to the FT of the analytic signal in an ideal distribution, but you're not going to find many references taking this treatment except briefly.

Concentration is always described in terms of the expansion of the phase, IF, and higher derivatives. All of these definitions come from the stationary phase (condition) holding, and I've never seen that presented in terms of group delay. And I'm not mathematician enough to know whether one implies the other holds.


The reason it's hard to make sense out of the IF is because we are looking at impulse responses. Either by statistical averaging/correlation or via dechirping/matched filtering, we've thrown out a lot of data and polluted our measurement with the effective window of the stimulus. Also, an IR typically has poor finite support in the frequency domain, and doesn't satisfy the stationary phase condition. If you simply play a stimulus with a continuous IF, like a linear chirp with low rate, you'll see much more informative results.
 
Last edited:
Re: FIR filters

The reason it's hard to make sense out of the IF is because we are looking at impulse responses. Either by statistical averaging/correlation or via dechirping/matched filtering, we've thrown out a lot of data and polluted our measurement with the effective window of the stimulus. Also, an IR typically has poor finite support in the frequency domain, and doesn't satisfy the stationary phase condition. If you simply play a stimulus with a continuous IF, like a linear chirp with low rate, you'll see much more informative results.


Indeed. Good post. We're using the tools and language of signal analysis for system analysis by treating the impulse response as a signal, but it has few of the statistical properties, such a stationarity, that make signals amenable to analysis. I've got a fat book on time-frequency analysis (Carmon, Wen-Liang, and Torresani) that is entirely concerned with signals.

The current TFE distribution has the ridge appear as a (single valued) function of frequency. One can imagine a distribution with different concentration where the ridge would be a function of time. There's likely some sort of duality there.

As for the properties of the ridge of the current TFE distribution, I can make an intuitive argument that it resembles the group delay. The group delay of a particular frequency can be thought of as the delay of the envelope of an amplitude modulated signal (with modulation frequency << carrier frequency so that the sidebands are close in) with the carrier being the frequency in question. For each frequency band the distribution passes the impulse response through a band pass filter. Converting back to the time domain we can think of the resulting signal as amplitude modulated with a carrier frequency at the filter center frequency. The carrier frequency is familiar as the ringing we hear when passing audio through a narrow band-pass, as results, for example, from a sound system on the verge of feedback. The ridge of the distribution shows us the time at which the bulk of that frequency's energy arrives.

Imagine an impulse response that has a short burst of 1 kHz at 5 ms. We can agree that this impulse response represents a group delay of 5 ms at 1 kHz. The burst will be selected by the 1 kHz filter but its place in time will be preserved (the filter bank has uniform time delay due to its symmetrical impulse response). By displaying the magnitude of the analytic signal we're essentially displaying the envelope of that 500 Hz burst which will make a bump in the TFE representation at that time and frequency. How's that for hand waving? I added a smoothed GD calculation to my TFE code and plotted the results side-by side for the same data, so the experimentalist in me thinks I'm on the right track -- for the moment.

Best,

--FrankTFE-GD.jpg
 
Re: FIR filters

OK guys, please don't shoot me for dumbing things down....you have a wonderful discussion going....

But thinking about aligning subs to mains and and FIR latency..... it seems that FIR latency has to be at least equal to the group delay of the subs at LP crossover frequency as per IIR........???


When we phase align subs to mains, I keep getting that means using a group delay implicit within the phase alignment freq range. Correct?
(BTW, on an impulse response the group delay timing looks to me to be found on the second peak, not on the first peak where all the energy and no phase lag exists, yes?) (And is there a hotkey way to toggle between phase and group delay in Smaart?

Anyway, in case I'm barking anywhere near the right tree........say I've got a sub high passed at 30hz 4th order, and LP'ed at 100hz 4th order... the filters alone give a group delay of about 7ms at 100hz, and 20ms or so at 40hz....plus there's the inherent increasing delay of the driver as it goes lower... could easily end up with 30 or more ms delay at lowest freq.

Seems like FIR has to account for this group delay however low we choose to try to flatten phase.

So if we want to flatten phase much below sub LP, doesn't latency become unacceptable for almost any app except maybe pure playback?
Do we just ignore this increasing sub lag below x-over? Whether IIR or FIR?

If we could live with the latency to get phase flat to 20-30 hz, how many dang taps would it take? THX
 
Re: FIR filters

So if we want to flatten phase much below sub LP, doesn't latency become unacceptable for almost any app except maybe pure playback?
Do we just ignore this increasing sub lag below x-over? Whether IIR or FIR?

If we could live with the latency to get phase flat to 20-30 hz, how many dang taps would it take? THX
Lots of taps...

Your guesses look about right, 10ms latency can flatten phase to 100Hz, takes around 33ms to 30 Hz, unacceptable for live use.

#544 answers some of your questions in more detail:

http://www.diyaudio.com/forums/mult...e-linearization-eq-fir-filtering-tool-55.html
 
Re: FIR filters

As for the properties of the ridge of the current TFE distribution, I can make an intuitive argument that it resembles the group delay. The group delay of a particular frequency can be thought of as the delay of the envelope of an amplitude modulated signal (with modulation frequency << carrier frequency so that the sidebands are close in) with the carrier being the frequency in question. For each frequency band the distribution passes the impulse response through a band pass filter. Converting back to the time domain we can think of the resulting signal as amplitude modulated with a carrier frequency at the filter center frequency. The carrier frequency is familiar as the ringing we hear when passing audio through a narrow band-pass, as results, for example, from a sound system on the verge of feedback. The ridge of the distribution shows us the time at which the bulk of that frequency's energy arrives.

Imagine an impulse response that has a short burst of 1 kHz at 5 ms. We can agree that this impulse response represents a group delay of 5 ms at 1 kHz. The burst will be selected by the 1 kHz filter but its place in time will be preserved (the filter bank has uniform time delay due to its symmetrical impulse response). By displaying the magnitude of the analytic signal we're essentially displaying the envelope of that 500 Hz burst which will make a bump in the TFE representation at that time and frequency. How's that for hand waving? I added a smoothed GD calculation to my TFE code and plotted the results side-by side for the same data, so the experimentalist in me thinks I'm on the right track -- for the moment.

I agree, now that I re-read your order of operations list up there, that looking at it from the group delay perspective is better. You've basically constructed a STFT with fixed lag windows starting from the frequency domain perspective.

Thus you're TFE will fail to be concentrated when the phase is too steep and fails the stationary phase condition for the FFT of the input signal. Which is what we see in the plots you provided.

I'm not exactly clear on what the rest of the operations do. If you really want that hilbert transform I would recommend building it into your filter bank as opposed to using the FFT method, if you are not already doing so. The filter method would be better, since you could construct and test the bands where they are operating.

All in all, I'm pretty impressed, looks a lot better (useful) than other peoples implementations I've seen over the years !
 
Last edited:
Re: FIR filters

I agree, now that I re-read your order of operations list up there, that looking at it from the group delay perspective is better. You've basically constructed a STFT with fixed lag windows starting from the frequency domain perspective.

That's exactly right. We might call this a "short frequency Fourier transform". The rationale being that windowing on the frequency side allows the windows to be of logarithmic width and spacing to better match perception. The Hilbert transform is implicit in the (inverse) Fourier transform back to the time domain -- we just set the negative frequencies to zero.

Dave Gunness presented a paper* describing essentially this representation. His twist was that, for computational expediency, he computed the time-domain convolution of the impulse response with an an approximate Gaussian by using multiple passes of a first order IIR filter in both directions. This converges very closely to a Gaussian after just a few passes. My implementation uses brute force in the frequency domain. It takes a few seconds to compute in R on a 10 year old desk top PC, so who cares?

Mark, I appreciate your perspective on all this, it gets me, and others I assume, thinking. I have "Signal Analysis" by Papoulis sitting on my shelf and he covers FM, the method of stationary phase, instantaneous frequency, ambiguity, etc., but some of it is tough sledding -- maybe too tough for this old dog. Thanks to computers and tools like R I can take a more empirical approach. All for now. Thanks everyone.

--Frank


*"A Spectrogram Display for Loudspeaker Transient Response"
David W. Gunness, William R. Hoy
Convention Paper 6568, AES 119th Convention, October 7-10, 2005
 
Re: FIR filters

I see a double sided time response like this:

View attachment 14051

If I feed it an impulse it makes a nice symmetrical arrowhead. But I better go back and take a careful look at my code to see what it's really doing.

The purpose of the initial window is just decisively to chop off the acoustic reflections to ensure an anechoic measurement. As in 2 times a 13 ft high tower minus 10 ft from speaker to mic = 16 ft. or 14 ms. But I think you're right in that any reflection should show up at its time in the TFE representation and the initial window is unnecessary. I should take a measurement holding a road case cover a few feet from the central axis and see what it looks like. I'll try turning off the initial window on the data I have and see if I can see the ground bounce out at ~15 ms.

--Frank

Hi Frank,

Sorry for taking a few days to reply. I'm juggling this great thread with family activities and my "day" job. Regarding the use of the Hilbert transform.... Your plot shows a gently increasing delay in it's peak toward lower frequencies and I think this might be the result of the minimum-phase behaviour in the calculation of each band.

In Matlab I simulated 5 equally wide (on a log scale) gaussian bands.

gaussianfilters_FR.jpg
I then used the Hilbert Transform, minimum phase filter design approach to create the impulse responses for each band.

gaussianfilters_IRmin.jpg
Note how the IR's of the lower frequency bands peak later in time than the higher frequency bands.

Taking the same bands (from the Frequency plot above) and just using a IDFT gives the linear phase impulse responses (shown before and after sample rotation) which all peak at the same time.

gaussianfilters_IRlin.jpggaussianfilters_IRlinrotated.jpg
I suspect using the IDFT, rather than Hilbert Transform approach, would remove the rising delay in your plot and make it symmetric about the same moment in time.

One condition for the Hilbert transform approach is that it requires a lower bound on the input magnitude response, so that the LOG() function works. For the plots above, I used a lower bound of 1e-20. Changing this lower bound causes a time shift to the minimum phase IR's (2nd plot above) of all the bands.

Also, a colleague here in Sydney showed me how using two IDFT's per gaussian band - with one as is and the other pre-multiplied by complex "i" for a 90 deg phase shift - gives two impulse responses that can be combined to create a nice envelope follower. I can email you the Matlab code.

Best,
Michael
 
Last edited:
Re: FIR filters

OK guys, please don't shoot me for dumbing things down....you have a wonderful discussion going....

But thinking about aligning subs to mains and and FIR latency..... it seems that FIR latency has to be at least equal to the group delay of the subs at LP crossover frequency as per IIR........???


When we phase align subs to mains, I keep getting that means using a group delay implicit within the phase alignment freq range. Correct?
(BTW, on an impulse response the group delay timing looks to me to be found on the second peak, not on the first peak where all the energy and no phase lag exists, yes?) (And is there a hotkey way to toggle between phase and group delay in Smaart?

Anyway, in case I'm barking anywhere near the right tree........say I've got a sub high passed at 30hz 4th order, and LP'ed at 100hz 4th order... the filters alone give a group delay of about 7ms at 100hz, and 20ms or so at 40hz....plus there's the inherent increasing delay of the driver as it goes lower... could easily end up with 30 or more ms delay at lowest freq.

Seems like FIR has to account for this group delay however low we choose to try to flatten phase.

So if we want to flatten phase much below sub LP, doesn't latency become unacceptable for almost any app except maybe pure playback?
Do we just ignore this increasing sub lag below x-over? Whether IIR or FIR?

If we could live with the latency to get phase flat to 20-30 hz, how many dang taps would it take? THX

I don’t have a background in signal processing … so this thread has made my head hurt trying to remember all my university mathematics … Hilbert transforms and all that stuff … but on the plus side it’s given me a few new ideas regarding processing the DIY's ... so thanks everyone for a great thread; can’t wait to see what Michael and Frank finally come up with.

Just to add a bit more to Arts post …. If you look at how a FIR filter is implemented using a bunch of delay taps, intuitively a crossover (FIR) will require a delay of more than the period of the crossover frequency. If you want the slope of the filter to be steep, you will require even more time.

I assume your question is to some extent relating to the DIY's you have built / processing. What I have done is use a short FIR time of 2.5ms in the Lake. This allow FIR linear phase crossovers as low as 500 Hz for the low/ mid and mid/hi.

A FIR crossover for the subs required too much time so I have used a standard IIR LR crossover. I processed the subs separately and it’s important to remember the high-pass filter protecting the excursion limit of the bass drivers as well as the crossover slope and frequency will affect the time alignment. I also used some all-pass filters to match the phase response shape / slope of the sub to the phase of the DIY at the crossover. By doing that you will get the correct LR summation at, and either side of the crossover.
 

Attachments

  • Dilbert transforms.png
    Dilbert transforms.png
    59.7 KB · Views: 5
  • FIR picture.png
    FIR picture.png
    44.1 KB · Views: 5
Last edited:
  • Like
Reactions: jami schorling
Re: FIR filters

I assume your question is to some extent referring to the DIYs. What I have done is use a short FIR time of 2.5ms in the Lake. This allow FIR linear phase crossovers as low as 500 Hz for the low/ mid and mid/hi.

I thought the Lake was doing the filtering in the FT domain so that they could keep the delay fixed? Or is that only for the PEQ overlay? Didn't they have a patent on that?
 
Re: FIR filters

.....he computed the time-domain convolution of the impulse response with an an approximate Gaussian by using multiple passes of a first order IIR filter in both directions. This converges very closely to a Gaussian after just a few passes. .....

BTW Running an IIR in both (time) directions results in a linear phase filter. Now if we could do this in realtime, it would be really efficient. ;-) :razz:
 
Re: FIR filters

I thought the Lake was doing the filtering in the FT domain so that they could keep the delay fixed? Or is that only for the PEQ overlay? Didn't they have a patent on that?

The delay is fixed, but you select what time or “alignment delay” you want e.g. 1.25, 2.5, 5, 10, 15 or 20 ms. The compromise is the lowest frequency you can achieve and the slope. You can also configure one LM26 as a mono 4 way crossover. In this case I think they combine the FIR modules and you can obtain crossover slopes that are twice as steep. E.g. (from the manual pg 94 - ish)

3 way mode
- 1.25ms = 13 dB/oct at 500Hz, up to 93dB/oct at higher frequencies
- 40ms = 14 dB/oct at 32Hz

4 way mode
- 3.15ms = 13 dB / oct at 220Hz, up to 180dB/oct at higher frequencies
- 25.17ms = 24dB /oct at 62 Hz.

http://www.reflechi-son.fr/paris/manuel-utilisateur/Dolby-Lake-Controller-Manual.pdf
 
Re: FIR filters

BTW Running an IIR in both (time) directions results in a linear phase filter. Now if we could do this in realtime, it would be really efficient. ;-) :razz:

The delay is fixed, but you select what time or “alignment delay” you want e.g. 1.25, 2.5, 5, 10, 15 or 20 ms. The compromise is the lowest frequency you can achieve and the slope. You can also configure one LM26 as a mono 4 way crossover. In this case I think they combine the FIR modules and you can obtain crossover slopes that are twice as steep. E.g. (from the manual pg 94 - ish)

Now we're really getting our terminology quacked out. Peter, I was referring to your diagram, although I really should have quoted it properly.

An impulse response is not IIR or FIR, you can design IIR coefficients which have linear phase easily via the least squares method, but the internal structure is still an IIR. (there is even a MATLAB function for this, iirgrpdelay?)

IIR and FIR normally refer to the structure of the underlying filter (the fixed structure, like Peter's diagram, which you fill coefficients into), as it is implemented in code, to do the filtering! The frequency domain method, like in the lake patent would be different. More similar to the operation of something like filtfilt (MATLAB's the forward, backwards filter), which I think you both are referring to (Michael, Frank).
 
Last edited:
Re: FIR filters

Now we're really getting our terminology quacked out. Peter, I was referring to your diagram, although I really should have quoted it properly.

Sorry Mark I misunderstood your point; I didn't give the diagram a second thought – it was the only picture I could find on the web that used simple words to describe a FIR’s structure. I was just trying to keep it simple … I should have also removed the bit about the FPGA implementation :-(
 
Last edited:
Re: FIR filters

Now we're really getting our terminology quacked out. Peter, I was referring to your diagram, although I really should have quoted it properly.

An impulse response is not IIR or FIR, you can design IIR coefficients which have linear phase easily via the least squares method, but the internal structure is still an IIR. (there is even a MATLAB function for this, iirgrpdelay?)

IIR and FIR normally refer to the structure of the underlying filter (the fixed structure, like Peter's diagram, which you fill coefficients into), as it is implemented in code, to do the filtering! The frequency domain method, like in the lake patent would be different. More similar to the operation of something like filtfilt (MATLAB's the forward, backwards filter), which I think you both are referring to (Michael, Frank).

Sorry Mark. I'm was using the terms a little loosely.

Just to clarify, I meant running an IIR filter in both directions gives the same magnitude response as having run it twice in one direction, but the filter's effective phase response is linear. It's like using a FIR filter with symmetric coefficients from -inf to +inf time but with the computational efficiency of two IIR's. Clearly not possible realtime. :)

Regarding frequency domain processing... FIR filters can be implemented directly in the time domain, which is computationally expensive, or using transforms (DFT/FFT's). The two methods are, on most processors, essentially numerically identical. Textbook transform based filtering has block latency which is a function of the transform size. Check out
https://en.wikipedia.org/wiki/Overlap–save_method
https://en.wikipedia.org/wiki/Overlap–add_method
For realtime processing of anything longer than short filters, the latency often isn't tolerable. With the Huron workstation, Lake DSP developed algorithms for very efficient, very low latency filtering using very long FIR filters.


Regarding the Lake Processor "Alignment Delay" setting, this setting locks in the bulk delay of the linear phase FIR crossover filter. It's a convenience so that the whole system doesn't have to be realigned when the crossover frequency is changed. ("Alignment Delay" only applies to linear phase FIR crossovers and is ignored for "classic" IIR crossover modules.) As the crossover frequency is varied, different FIR filters coefficients are used. The alignment delay sets the upper limit on the length of the filter. For example an alignment delay of 5ms means the linear phase FIR crossover filter can't be longer than 10ms (due to filter coefficient symmetry) or ~960 samples @ 96 kHz. This limit on the filter length then limits how sharp/steep the filter can be at low frequencies. The Lake manual has tables showing how low in frequency the different linear phase filters can go.
 
Last edited: