Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.

Poll

FIR or IIR? Linear phase or minimum phase?

Minimum phase IIR
[ 5 ] (45.5%)
Minimum phase FIR
[ 0 ] (0%)
Linear phase FIR
[ 5 ] (45.5%)
Other (please specify in reply)
[ 1 ] (9.1%)

Total Members Voted: 29

Topic: Best kind of digital EQ filter? (Read 41980 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Best kind of digital EQ filter?

Reply #50
Yes, linear-phase filters have to be somewhat longer than minimum-phase filters to achieve the same specification for the frequency response. However the amplitude of ringing is lower in linear-phase filters.


It's not only somewhat, but much longer if you want a clean filter. The decay of a min phase filter is faster, and the IIR will decay down to zero essentially while with a FIR you have to truncate at some point (else the filter would be extremely long) and apply a window function, which changes the frequency response.


2nd order min phase IIR, -30 dB at 60 Hz, Q=6, Fs=192k vs linear phase FIR. The plot shows 20*log10(abs(filter_output)):


Higher amplitude ringing that has the main energy concentrated near an impulse is imo quite preferable to long pre- and post-ringing in the audible range of frequencies because of masking effects.
"I hear it when I see it."

Best kind of digital EQ filter?

Reply #51
Can you post these impulses as WAV files? Looking at the pics, it's hard for me to believe that these filters have the same frequency response.

Best kind of digital EQ filter?

Reply #52
I don't see any potential to roll out the loop as there is dependency between iterations.

If loading 5 out of 8 SIMD registers is not enough for you, there are several methods to speed it up:
1. run several filters in parallel,
2. remove the dependence between iterations,
3. run Intel IPP.

And remember that float may not be enough for IIR filtering at low frequencies, you may need double.

1. Sure
2. Would it still be a biquad?
3. Are you saying that Intel IPP does a single biquad employing more than 5/8? How?

-k

Best kind of digital EQ filter?

Reply #53
2. Yes, it would be numerically identical, albeit somewhat less stable.
3. Perhaps, I haven't measured, but IPP is probably much faster than what you can hand-write.


Best kind of digital EQ filter?

Reply #55
1. Sure
2. Would it still be a biquad?
3. Are you saying that Intel IPP does a single biquad employing more than 5/8? How?


The point I was trying to make before is that one would never bother to SIMD such a low order filter for audio.  The sample rate would have to be MHz before it would be worthwhile.

Usually the filters people SIMD are of larger order and thus much easier to SIMD on very wide vector systems like SSE4+.

Best kind of digital EQ filter?

Reply #56
Can you post these impulses as WAV files? Looking at the pics, it's hard for me to believe that these filters have the same frequency response.

minvslinear.7z

The FIR doesn't match the IIR exactly but it's pretty close.
"I hear it when I see it."

Best kind of digital EQ filter?

Reply #57
Thanks. I'm wondering if this is universal or happens because you are trying to approximate IIR filter with FIR. I know that when you go the other way — convert lin-phase FIR to a min-phase FIR, — the filter length does not change (i.e. the duration of ringing remains the same).

Best kind of digital EQ filter?

Reply #58
The point I was trying to make before is that one would never bother to SIMD such a low order filter for audio.  The sample rate would have to be MHz before it would be worthwhile.

Usually the filters people SIMD are of larger order and thus much easier to SIMD on very wide vector systems like SSE4+.

I guess that is application-dependant. If you do some offline audio processing (e.g. lossy compression), you generally want it done as fast (and low power consumption) as possible. If some (granted small) sub-component can be optimised by 2:1, this might be worth it. If you do realtime processing, the penalty for high load can be high (missed deadline or increased latency to account for possible missed deadlines). In both cases, choosing filter structure based on the #mult can be a non-ideal proxy for choosing based on (realistic) complexity estimates for the given hardware/libraries.

The point that I tried to make was that the classical dsp measures of complexity (#multiplications per sample or per second) motivated by the (for the time significant) silicon area needed to implement a multiplication unit are becoming less relevant as modern architectures offers multiple cores, multiple-element vector units that does N multiplies in the same time as 1 multiply (or N additions). I believe that Intel (and even ARM) tend to spend a small fraction of the area/cost/power on floating-point multiplicators. The probably _could_ increase that count, but various issues (typical application load, typical compiler smartness etc) makes that a bad business proposition.

Thus the question is not "what filter do I choose that minimise the number of mults for a given filtering task", but "what filter do I choose that minimise total system load/cycle count/power draw/whatever performance metric for a given filtering task". Given that you have the unusual luxury of being able to write optimal code for some platform. In practice, it may boil down to "what can IPP/equivalents do for me with the least possible effort"

-k

Best kind of digital EQ filter?

Reply #59
... I know that when you go the other way — convert lin-phase FIR to a min-phase FIR, — the filter length does not change (i.e. the duration of ringing remains the same).
What is it that you convert, and how do you define "duration of ringing"?

I did a simple MATLAB test, designing some linear phase filter, inverting maximum-phase zeros to have a minimum-phase FIR filter of the same magnitude response. Total impulse response length remains equal, but how do you quantify "duration of ringing" in a way that gives a number <inf for IIR filters? Some "effective" number ala RT60?

When you "render" a filter spec into an actual filter, you loose information about the design objectives. I would assume that designing the final filter directly would come closer to the real goals of some application, rather than design a linear filter, then transform it into some other form?
http://www.dspguru.com/dsp/howtos/how-to-d...ase-fir-filters
Code: [Select]
N=11;
F = [0 0.4 0.6 1];
A = [1 1 0 0];
b = firpm(N, F, A);
a = 1;
[b,a] = eqtflength(b,a);
[z,p,k] = tf2zp(b,a);
z(abs(z)>1) = 1./z(abs(z)>1);
[b2,a2] = zp2tf(z,p,k);
b2 = b2.*(sum(b)/sum(b2));%normalize DC gain

[H,W] = freqz(b,a,512);
[H2,W2] = freqz(b2,a2,512);

figure(1)
zplane(b)

figure(2)
stem(b)

figure(3)
semilogx(W,20*log10(abs(H)))
axis tight
grid on

figure(4)
zplane(b2)

figure(5)
stem(b2)

figure(6)
semilogx(W,20*log10(abs(H2)))
axis tight
grid on

Best kind of digital EQ filter?

Reply #60
Thanks. I'm wondering if this is universal or happens because you are trying to approximate IIR filter with FIR. I know that when you go the other way — convert lin-phase FIR to a min-phase FIR, — the filter length does not change (i.e. the duration of ringing remains the same).

No that's impossible since more energy is stored right after the impulse with min phase. Maybe you're just looking at the number of taps being output by some algorithm, but that has nothing to do with the filter's performance.

I don't see a difference if going into the other direction. Well, there is one: if using the 60 Hz filter from above as prototype a simple 2nd order IIR matches the FIR better than the other way around (due to truncation... 262k taps doesn't seem enough ...).
"I hear it when I see it."

Best kind of digital EQ filter?

Reply #61
No that's impossible since more energy is stored right after the impulse with min phase. Maybe you're just looking at the number of taps being output by some algorithm...

Of course not! I'm looking at the decay rate of actual ringing, not at the number of taps. And I have already given an example of a filter that I'm talking about, see post #48. I'm attaching a pair of filters, in case you want to analyze: linminphase.zip.


Best kind of digital EQ filter?

Reply #63
Of course not! I'm looking at the decay rate of actual ringing, not at the number of taps. And I have already given an example of a filter that I'm talking about, see post #48. I'm attaching a pair of filters, in case you want to analyze: linminphase.zip.


Regardless of ringing, in the case of such a lowpass in the audio range you should choose min phase over linear phase (or at list a mix towards min) due to potentially audible pre-ringing except if you have very special requirements.

How did you design this filter? What IIR order is it, if applicable?
"I hear it when I see it."

Best kind of digital EQ filter?

Reply #64
The point I was trying to make before is that one would never bother to SIMD such a low order filter for audio.  The sample rate would have to be MHz before it would be worthwhile.

Usually the filters people SIMD are of larger order and thus much easier to SIMD on very wide vector systems like SSE4+.

I guess that is application-dependant. If you do some offline audio processing (e.g. lossy compression), you generally want it done as fast (and low power consumption) as possible. If some (granted small) sub-component can be optimised by 2:1, this might be worth it. If you do realtime processing, the penalty for high load can be high (missed deadline or increased latency to account for possible missed deadlines).


I think you're not understanding how trivial the filter you proposed is.  You're looking at << 1MHz/mbit/s output.  For a mid range Core i5 system, to run it at as fast as possible using plain scalar ops would require reading in PCM data at something like 5-10 Gbit/s.  You're need an SSD RAID array just to feed that filter!  You could process an entire CD in a fraction of a second.  On each of your cores.  SIMD would be pointless, you wouldn't be able to feed the filter fast enough to keep up

The point that I tried to make was that the classical dsp measures of complexity (#multiplications per sample or per second)


I posted actual benchmarks above for a 2 pole/zero filter on ARM above.  I'm not assuming, I'm telling you how fast these things actually run!

Best kind of digital EQ filter?

Reply #65
I did a simple MATLAB test, designing some linear phase filter, inverting maximum-phase zeros to have a minimum-phase FIR filter of the same magnitude response. Total impulse response length remains equal, but how do you quantify "duration of ringing" in a way that gives a number <inf for IIR filters? Some "effective" number ala RT60?


exp(-1) is very widely used for quantifying the decay of filters.  I'd use that unless there was a compelling reason to use something else.

Best kind of digital EQ filter?

Reply #66
How did you design this filter? What IIR order is it, if applicable?

The lin-phase FIR filter was designed from a frequency response of some analog filter with 48 dB/oct decay. If I recall correctly, it's been a Butterworth filter of order 6. The min-phase FIR filter has been designed by finding a min-phase response for the same frequency response using a Hilbert transform.

Best kind of digital EQ filter?

Reply #67
To me it's a no-brainer to never use a linear phase filter. As far as I can tell, linear phase equalizers were developed in response to the "phase shift is damaging" nonsense spewed endlessly by misinformed audio magazine writers. The myth that phase shift is a problem was repeated so many times over the years that audio gear makers came up with a way to avoid phase shift, just to use as a marketing claim. The problem is LP filters are audibly worse than minimum phase! You can't always hear the pre-ringing, but often you can depending on the frequency and other settings.


There is one real world example I occasionally encounter where a linear phase eq is useful.  An all pass filter isn't audible by itself, but if you use an all pass filter on one track and layer that track against another, then the difference is extremely audible.  A good example would be to layer kick drums ... add an all pass filter to just one kick drum and you can affect the combined sound in a very audible way.  Likewise, eq-ing the low frequencies of a single kick drum can occasionally introduce enough phase shift to be audible not in isolation, but when combined with other kick drums.  So if your 808 kick was already in phase with your other kick/bass tracks perfectly and you wanted to take out some 60 hz, a minimum phase eq would introduce phase shift and maybe some odd cancellation against another track, and you can use a linear phase eq to avoid  the problem.

This is admittedly a very rare case and I've never used it in a song, but I have used all-pass filters to get kick drums to sit against each other better.



Best kind of digital EQ filter?

Reply #68
IPP is probably much faster than what you can hand-write.

IPP is (in some ways) like a compiler: it needs to solve a (set of) generic problems that is sufficiently "wide" so as to be useful for many users, yet sufficiently "narrow" so as to allow the low-level gurus to do their thing. And AFAIK, they solve that generic problem really, really well, across a range of intel platforms. If what you need is to solve that generic problem, you probably don't want to compete with Intel.

If, however, your problem deviate from the general case in any way, there is a window of opportunity to beat IPP. For a IIR filter, this might be things like precision requirements, knowledge about coefficients, knowledge about frame sizes, targeting a single cpu architecture etc. Solving specific problems is a lot easier than solving general problems.

While software developers often fall in the trap of "over-generalization" (writing code to handle every possible future requirement), I am talking about "degeneralization" (solving what needs to be solved now and nothing else).

-k

Best kind of digital EQ filter?

Reply #69
Wheee! A chance to finally ask a question I've been wondering since forever but never knew how to phrase.

There are two functions depicted in this image (perhaps only approximately, but whatever, context). The first is sinc, which extends to infinity in both directions. The second is what? It extends to infinity only in one direction.

Best kind of digital EQ filter?

Reply #70
I don't know if any closed-form expression exists for this function. Strictly speaking, a perfect sinc does not have a min-phase variant — only an approximation. In my example, it is a minimum-phase filter which can be obtained from a linear-phase filter by either spectral factorization or complex cepstrum folding.