←back to thread

259 points zdw | 6 comments | | HN request time: 0.463s | source | bottom
Show context
thrtythreeforty ◴[] No.43635458[source]
Impulse response is sort of overkill here. If you design a filter bank in the first place, you can just implement that filter bank much cheaper than doing even an FFT-based convolution. Convolution is useful when you don't know the underlying filter transfer function.
replies(5): >>43635799 #>>43636182 #>>43636622 #>>43637141 #>>43637264 #
1. Sesse__ ◴[] No.43637264[source]
It really depends on what your filter bank looks like. If it's a 4-band parametric EQ, then sure, you can have four biquad IIR filters and that's it. But if you've measured an impulse response and want its inverse (e.g. through a Wiener filter), that's not what you have; you simply have another impulse response (effectively closer to a N-band graphical EQ where N >= 100), not a parametric EQ.

As a nitpick: You always know the filter transfer function, it's the DFT of the impulse response (and without the impulse response, you obviously cannot convolve).

replies(2): >>43638355 #>>43639539 #
2. thrtythreeforty ◴[] No.43638355[source]
Agreed - I read this bit in the article:

> generating a filter curve for a 300Hz slope, both channels were divided (A/B) against that curve

as defining a parametric EQ band. If you just generally want to invert a measured impulse response, then yeah, you don't know the underlying transfer function.

replies(1): >>43641700 #
3. patrakov ◴[] No.43639539[source]
There are a few procedures that convert an impulse response to an approximating IIR filter:

1. Hartmut Brandenstein and Rolf Unbehauen, "Weighted Least-Squares Approximation of FIR by IIR Digital Filters", IEEE TRANSACTIONS ON SIGNAL PROCESSING, VOL. 49, NO. 3, MARCH 2001

2. Hon Keung Kwan and Aimin Jiang, "Recent Advances in FIR Approximation by IIR Digital Filters", 2006 International Conference on Communications, Circuits and Systems

3. Ngai Wong and Chi-Un Lei, "FIR Filter Approximation by IIR Filters Based on Discrete-Time Vector Fitting", 2007 IEEE International Symposium on Circuits and Systems (ISCAS)

The third one is approachable by anyone who has studied linear algebra at the level usually taught for physics students and knows NumPy. No special DSP course is required. My implementation takes approximately 200 lines of Python code.

The article contains a deterministic algorithm that takes a guess on the pole positions in the complex plane and returns a better guess. The idea is to start with a random guess with the correct symmetry and apply the algorithm iteratively.

The only two tricks to be aware of are: 1) their reformulation of everything in section III.B in terms of real numbers (instead of complex numbers) is not making anything simpler and should be ignored, and 2) explicitly symmetrize matrices that are supposed to be symmetrical, it order to avoid accumulation of numerical errors.

Still, it is not something that I would be willing to fully automate: for good results, one has to add a small delay or chop off a few initial near-zero samples, and guessing the delay correctly is what separates an easy-to-approximate filter from a bad one.

4. Sesse__ ◴[] No.43641700[source]
Well, immediately after that, they say they inverted the entire curve (through a naïve 1/|X| and then un-FFT, presumably) and saved it as an impulse response. I think the 300Hz slope is to _keep_ the rolloff in that area, so that the system doesn't try to boost bass by 40 dB and just end up clipping madly.

Since these operations sort-of commute, it is easier to understand if you invert the order of operations:

1. Invert the spectrum (ideally through something less sensitive to noise than what's done here). Now you have an impulse response that will, in theory, give you a perfectly flat frequency response.

2. Apply a 300 Hz slope. Now you gave up some of that flatness, but you have something that's physically realizable without murdering your speakers.

replies(2): >>43642202 #>>43646304 #
5. manawyrm ◴[] No.43642202{3}[source]
Exactly correct, that was my thought process while doing it. I tried it without that 300 Hz slope first of course, but that did try to murder my speakers. :)
6. thrtythreeforty ◴[] No.43646304{3}[source]
Now I understand, makes sense!