Skip to main content
Topic: Do Digital Equalizers Cause Phase Shifts? (Read 14941 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Do Digital Equalizers Cause Phase Shifts?

According to http://www.ethanwiner.com/EQPhase.html:
Quote
To create an equalizer from a digital delay line you tap into one of the intermediary memory addresses and feed a varying amount back to the input. Just like the feedback control on a tape recorder-based delay like an old EchoPlex. Except without all the wow and flutter. You can also reverse the polarity of the tapped signal before sending it back to the input to get either cut or boost. The bottom line is the delayed sound combines with the input - just like a flanger effect - to create peaks and dips in the frequency response. By controlling which addresses along the delay route you tap into, and how much of the tapped signal is fed back into the input and with which polarity, you create an equalizer. With an analog EQ the delays (phase shift) are created with capacitors and inductors. In a digital EQ the delays are created with a tapped shift register. But the key point is that all EQ shifts phase, unless it uses special trickery.

All equalizers, regardless of their analog/digital domain, cause phase shift.

So I ran a quick verification:
I converted 16/44.1 RMAA reference wav with Foobar2k, EQ on, and analyzed the reference wav with RMAA.


Phase did not change at all. Is my verification wrong? Do Digital Equalizers really shift phases?


Do Digital Equalizers Cause Phase Shifts?

Reply #1
Phase did not change at all. Is my verification wrong? Do Digital Equalizers really shift phases?


Ethan gave a good, simple example of two of the three general kinds of digital equalizers. Many potentially confusing details have been left out, but the first cut basics are all there. Your curiosity can be satisfied by the details that he intentionally left out.

The Executive Summary is that within broad limits, digital equalizers can give you any combination of amplitude response and phase shift that is desired.  While most analog filters are restricted to the rules of minimum phase, (amplitude and phase response connected by the Hilbert Transform) there are no such limits for digital filters. As you may have guessed, the amplitude and phase response of a digital filter are set by the coefficients that are assigned to each of taps on the delay line. The higher math part is that these coefficients may be calculated by means of the Z transform.

There is another way to make a digital filter, generally called FFT, which is to use the Discrete Fourier transform (DFT). Apply the DFT to a signal, and you obtain the amplitude and phase coefficients for that signal, arranged by hamonic frequencies. Multiply those frequency-related coefficients by the frequency-related coefficients for the filter of your dreams. The multiplcation of the coefficients is called convolution. Then take the inverse DFT of the resulting amplitude and frequency coefficients, and you get back a filtered signal.

There are three common ways to implement digital filters called IIR, FIR, and FFT.  A FIR filter is based on a tappped delay line with no feedback. An IIR adds feedback, and a FFT filter is based on the DFT.  The DFT route is the potentially most flexible, but historically its computational load has been daunting. Now that we have powerful DSP chips for $1.98 (or less), it is far more practical to use FFT filters.

Since most people only think of amplitude response (which is fine because that is what matters most to the ear) most simple implementations of digital filters only work over the amplitude coefficients.

One of the most complete implementations of digital filtering around is found in Cool Edit Pro/Adobe Audition. Their default "FFT" filter only works in the amplitude domain. But in the menus, right next to tha amplitude filter, there is a phase filter and it works. CEP/Audiion also supplies "Scientific Filters" which is their code name for filters where the phase response was derived from the frequency response by applying the Hilbert Transform. 



Do Digital Equalizers Cause Phase Shifts?

Reply #2
Oh, thank you for your insight, Arny. As far as I can comprehend, in digital domain, you may choose equalizers to cause phase shifts or not, depending on the types of digital equalizers you use.
Then, what would happen to the phase response if the FFT filter-processed digital signal gets converted into an analog signal at the audio output? Would the phase response be still identical to the original?


Do Digital Equalizers Cause Phase Shifts?

Reply #3
Then, what would happen to the phase response if the FFT filter-processed digital signal gets converted into an analog signal at the audio output? Would the phase response be still identical to the original?


Yes.
And if I am not mistaken, if you need real-time equalization, with the result playing eactly at the same time as your instrument, you have to shift phase. Respecting phase introduces a small delay.

Do Digital Equalizers Cause Phase Shifts?

Reply #4
All equalizers, regardless of their analog/digital domain, cause phase shift.

A more correct statement is that all equalizers w/o lookahead ("causal") produce phase shift. But phase shift is not the same as phase distortion. Phase shift can be linear over frequency, and this corresponds to a simple delay.

Do Digital Equalizers Cause Phase Shifts?

Reply #5
As far as I can comprehend, in digital domain, you may choose equalizers to cause phase shifts or not, depending on the types of digital equalizers you use.


Within broad limits.

Quote
Then, what would happen to the phase response if the FFT filter-processed digital signal gets converted into an analog signal at the audio output? Would the phase response be still identical to the original?


A real-world DAC would have some kind of amplitude and phase distortion of its own, no matter how small or meaningless.  The amplitude and phase variations from both sources simply add to each other.

Do Digital Equalizers Cause Phase Shifts?

Reply #6
Sorry, but I need to pedant about a bit here.

As someone said, analog filters are minimum-phase, generally, although strictly speaking, elliptic filters create an "interesting" version of minimum-phase filters.

Digitally, for IIR filters, the poles must still be minimum-phase (i.e. stable... the two go together, minimum-phase and stability) but the zeros need not be minimum phase, in real zeros or zero pairs can be more or less any value.

So, for IIR filters, it is impossible to STRICTLY create a linear-phase (i.e. constant delay) filter.  That would require unstable poles. Another way to put it is that in order to create the constant delay filter, you need a symmetric impulse response, and for an IIR that would reach to minus infinity. So it goes...

(( Aside here...  A constant delay creates a system wherein phase = 2 pi f t, where t is the delay, f is frequency, and phase is the unwrapped linear phase component...))

For FIR filters (all-zero filters) there is no such rule. If the FIR is symmetric about the middle of the filter, it WILL be constant-delay, no iffs, ands, or buts. This means, by the way, that each zero pair (or real zero) with radius over 1 has a pair with the same phase and the inverse (1/r) radius.

For an IIR filter, you get what you get. You can add pole-zero pairs to pull the phase more closely to linear phase, but that's it. You can't get there. (you use allpass filters to change phase only, this means that the zeros are the inverse of the poles in the filter, so it has a phase shift but an amplitude response of 1, or at least flat.

Interestingly, this means that if you decompose any allpass filter into second order sections (recommended), the coefficients (for a gain of 1 filter) will be  ( a z^2 + b z + 1)/(z^2 +bz +a), i.e. the coefficients of the numerator will be the reverse of the coefficients of the denominator. This actually holds true for any order, of course, for a pure allpass.

This means that you can indeed create NON-MINIMUM_PHASE filters that are IIR in a digital setting, you can simply reverse the order of the numerator coefficients, you get the same amplitude response, but more phase shift. (hence not being minimum-phase any more).  If you decompose the filter into second-order sections, you can reverse the numerator of each section individually, or of each real pole/zero pair individually, and still get the same magnitude response (but a different phase response), so it is possible to create a variety of things digitally.

FFT filtering is simply a form of FIR filtering, wherein the FFT is used as an efficient way to do it. It's not really a third way of filtering, but is often singled out as such. When using an FFT filter, one must use lots of overlap add, and be very careful not to inspire wrap-around by creating a very long impulse response due to the frequency response changes.

This is probably not the place to go into the convolution theorem right now, but that is a very handy critter, to say the least

Basically, ok, I'll say this much. If we have an impulse response h(i), and a signal s(i), and H(w) and S(w) are the fourier transforms, then s(i) * h(i) = ifft(H(w) . S(w)) where * means convolution and . means multiplication.

This means if you add a frequency shaping of H(w), you need to take its inverse transform to see how long THAT impulse response is, and then for the overlap add, use an FFT length of length(h(i))+input_block_length-1 at minimum. (because the length of any convolution of two sequences of length a and b is a+b-1.)

If you don't do that in the FFT convolution, you will get wraparound. This is most often a very unkindly effect, and not one that you want to discover.


I'll shut up now. (can you tell I just taught some people a  digital filtering tutorial?)
-----
J. D. (jj) Johnston

Do Digital Equalizers Cause Phase Shifts?

Reply #7
I think it might be useful to add that, in the context of EQ, "linear phase" isn't necessarily "good". It implies having more ringing than you'd get with minimum phase.

You don't want ringing, so if you're doing dramatic EQ, minimum phase might be audibly less ringy than linear phase, and hence preferable.


Lots of PC based EQ uses windowed FFT to generate linear phase FIR filters, and this isn't always ideal. It's usually good enough, unless you're aiming for a very steep filter response.

IMO. YMMV!

Cheers,
David.

Do Digital Equalizers Cause Phase Shifts?

Reply #8
I humbly thank all of the HA comrades who answered my question. Education never stops!

BTW, you guys might think I am extremely crazy, but I did a little fun experiment with all of the digital EQs I have:

Do Digital Equalizers Cause Phase Shifts?

Reply #9
I think it might be useful to add that, in the context of EQ, "linear phase" isn't necessarily "good". It implies having more ringing than you'd get with minimum phase.


I often thought about that. Is that a provably necessary property of any thinkable transformation of a signal's frequency composition or just the state of the art? Or could one built a perfect digital filter with flat amplitude response and both ringing and aliasing <140db with the only "flaw" being several seconds of constant delay?

Do Digital Equalizers Cause Phase Shifts?

Reply #10
That's a provably necessary property 

Do Digital Equalizers Cause Phase Shifts?

Reply #11
That's a provably necessary property 


Ok, given that minimum phase always necessarily produces less (audible) ringing than linear phase, would it still be possible to build a steep linear phase filter with both ringing and aliasing <140db with the only flaw being a vast linear delay?

Do Digital Equalizers Cause Phase Shifts?

Reply #12
BTW, you guys might think I am extremely crazy, but I did a little fun experiment with all of the digital EQs I have:


The big disappointment being that Adobe Audition does not seem to provide the claimed phase response for "scientific" filters.

Do Digital Equalizers Cause Phase Shifts?

Reply #13
That's a provably necessary property 

Ok, given that minimum phase always necessarily produces less (audible) ringing than linear phase, would it still be possible to build a steep linear phase filter with both ringing and aliasing <140db with the only flaw being a vast linear delay?


No.  Ringing isn't an artifact in this case, really,  it's the time domain manifestation of your frequency domain change.

Imagine an impulse or a step function.  Such a signal contains energy at all frequencies.  Now apply your idealized steep filter and some frequencies are eliminated. The absence of those frequencies now causes a partial failure to cancel the energy from the other remaining frequencies at locations away from the spike, so you now get the characteristic 'ringing spike' output.  There is no free lunch.

It would be possible for someone to create a linear filter which reduced the filter steepness around transients where pre-echo is mostly likely to be audible, like the block switching used in lossy transfom codecs, but I'm not aware of anyone bothering.





Do Digital Equalizers Cause Phase Shifts?

Reply #14
Ok, given that minimum phase always necessarily produces less (audible) ringing than linear phase, would it still be possible to build a steep linear phase filter with both ringing and aliasing <140db with the only flaw being a vast linear delay?

Minimum phase produces about as much audible ringing as linear phase. The least audible amount of ringing is between the two extremes. There was a test of SoX somewhere on this forum that confirms it.


The big disappointment being that Adobe Audition does not seem to provide the claimed phase response for "scientific" filters.

I think it does. It may be RMAA failing to properly align phase response on a screen (it is somewhat complex for many filters). From 2 phase displays it is hard to tell if they are the same or not, because of 2pi phase ambiguity and "linear trend = delay" ambiguity.

Do Digital Equalizers Cause Phase Shifts?

Reply #15
The big disappointment being that Adobe Audition does not seem to provide the claimed phase response for "scientific" filters.

I think it does. It may be RMAA failing to properly align phase response on a screen (it is somewhat complex for many filters). From 2 phase displays it is hard to tell if they are the same or not, because of 2pi phase ambiguity and "linear trend = delay" ambiguity.


Thanks for the quick reply, Alexy. You nailed it - when I run my own tests, it appears that CEP 2.1 "Scientific Filters" (essentially the same filters as Audition) do produce the correct phase shift results. This is at least for a few simple cases that I tried. Therefore the RMAA results may not be a true reflection of the performance of this UUT.  It might be equally true for the others.

Do Digital Equalizers Cause Phase Shifts?

Reply #16
It would be possible for someone to create a linear filter which reduced the filter steepness around transients where pre-echo is mostly likely to be audible, like the block switching used in lossy transfom codecs, but I'm not aware of anyone bothering.


Such time-variable filtering would create very interesting problems of "how do we switch" and "what are the effects of switching. Also, you'll have to deal with the fact that more imaging and aliasing implies LESS time-domain accuracy both inter-channel and intra-channel.

Alternatively to that, you would wind up suppressing even more high frequencies in the transients. I'm not sure this is going to be a simple thing to undertake.

As to minimum-phase vs. constant delay filters, each has their own artifacts. The phase shift at higher frequencies in a minimumphase filter can cause startling artifacts in things (say like percussion, bells, etc) that have partials at high frequencies, by changing the signal envelope a lot. The pre-echo in a VERY (i.e. absurdly) steep constant-delay FIR can be heard, especially if it has lots of in-band ripple (but even if it doesn't, if it's steep enough and long enough).

4 of one, substantially less than a half-dozen of the other ...
-----
J. D. (jj) Johnston

Do Digital Equalizers Cause Phase Shifts?

Reply #17
Ok, given that minimum phase always necessarily produces less (audible) ringing than linear phase, would it still be possible to build a steep linear phase filter with both ringing and aliasing <140db with the only flaw being a vast linear delay?

Minimum phase produces about as much audible ringing as linear phase. The least audible amount of ringing is between the two extremes. There was a test of SoX somewhere on this forum that confirms it.


I seem to recall that similar results were obtained with simulations that were done related to anti-aliasing filters. If memory serves, minimum phase gives maximum post-ringing and linear phase gives maximum pre-ringing.

The classical results from temporal masking studies suggest that it takes about half as much pre-ringing to give audible results as post-ringing, but that 20 KHz brick wall filters have corner frequencies so high that reasonable amounts of either pre or post ringing are pretty much benign. 

At this point it seems that brick wall filters down in the 5 KHz range and below might benefit from consideration of these results from studies of temporal masking, and that as you suggest, something between minimum phase and linear phase be used to get any possible ringing under the temporal masking curves.

While SRCs down in the 5 KHz range are not exactly hi fi, they are useful for minimizing the bandwidth requirements for coding good quality speech. I'd rather have a little muffling of the speech  instead of audible ringing and other weird-sounding effects. We don't need gobs of extenbded-rnage sibillants to articulate sppech well and identify familair voices.

Do Digital Equalizers Cause Phase Shifts?

Reply #18
I think it might be useful to add that, in the context of EQ, "linear phase" isn't necessarily "good". It implies having more ringing than you'd get with minimum phase.

You don't want ringing, so if you're doing dramatic EQ, minimum phase might be audibly less ringy than linear phase, and hence preferable.


No, not more ringing, just more PRE-ringing.

Hm, how do I post graphs here?
http://i238.photobucket.com/albums/ff228/j.../plots/impr.jpg

Two impulse responses, note same length.

http://i238.photobucket.com/albums/ff228/j...01/plots/cd.jpg
Magnitude/phase of red impulse response

http://i238.photobucket.com/albums/ff228/j...1/plots/mph.jpg
And magnitude/phase of green impulse response.

Note, magnitude response is identical to matlab ? precision.
-----
J. D. (jj) Johnston

Do Digital Equalizers Cause Phase Shifts?

Reply #19
The classical results from temporal masking studies suggest that it takes about half as much pre-ringing to give audible results as post-ringing, but that 20 KHz brick wall filters have corner frequencies so high that reasonable amounts of either pre or post ringing are pretty much benign.


Actually, with minimum-phase impulsive signals (i.e. castinettes) that result has changed, pre-echo can be audible at 1 millisecond. Post at 4-5 or so, but very frequency dependent.

Good 20kHz filters should be very close, if not ok, but for 20kHz bandwidth at 44.1 the main lobe of the filter is, still, wider than the main lobe of the narrowest critical band filter.  Well, that is, for people much younger than us , I fear.
-----
J. D. (jj) Johnston

Do Digital Equalizers Cause Phase Shifts?

Reply #20
I think it might be useful to add that, in the context of EQ, "linear phase" isn't necessarily "good". It implies having more ringing than you'd get with minimum phase.

You don't want ringing, so if you're doing dramatic EQ, minimum phase might be audibly less ringy than linear phase, and hence preferable.


No, not more ringing, just more PRE-ringing.
Yes, my mistake.

As Arny and others have said, we've been round this loop before...

http://www.hydrogenaudio.org/forums/index....st&p=604927

...and the audibly "least" ringing wasn't minimum phase (see that thread for results).

Cheers,
David.


Do Digital Equalizers Cause Phase Shifts?

Reply #21
No, not more ringing, just more PRE-ringing.

JJ, I've seen this debated many times, but nobody has ever mentioned that Parseval's Theorem covers this.  Well, strictly speaking, Parseval doesn't cover the duration of the impulse response, but it says that the energy in the impulse response is constant for a given magnitude response, regardless of the phase response.  So, minimum phase, linear phase, maximum phase; the energy in the impulse response is exactly the same.  It just gets moved around.

Greg

Do Digital Equalizers Cause Phase Shifts?

Reply #22
No, not more ringing, just more PRE-ringing.

JJ, I've seen this debated many times, but nobody has ever mentioned that Parseval's Theorem covers this.  Well, strictly speaking, Parseval doesn't cover the duration of the impulse response, but it says that the energy in the impulse response is constant for a given magnitude response, regardless of the phase response.  So, minimum phase, linear phase, maximum phase; the energy in the impulse response is exactly the same.  It just gets moved around.

Greg



Oh, absolutely.

I keep telling people (here and elsewhere) that df * dt >=1 (for unknown vs. unknown, or for filter resolution as df and dt as the main lobe of the filter for 1 sigma).

Which is just saying the same thing in another way.

There's just no way out of it, never mind what magic peopel try for. Not, at least, unless Gauss and Fourier were both dead wrong.
-----
J. D. (jj) Johnston

Do Digital Equalizers Cause Phase Shifts?

Reply #23
Interesting thread.

Did anyone cover that when "correcting" the magnitude of minimum-phase systems (such as loudspeaker elements), then using a minimum-phase equalizer will automatically give a more linear (total system) phase response as well. In that case you probably dont want linear-phase equalization.

-k

Do Digital Equalizers Cause Phase Shifts?

Reply #24
Is that true? I didn't know that, yet. Interesting!

But wouldn't a phase shift have to be applied into the opposite direction on the time axis? Or does "de-equalizing" and equalizing with two opposite minimum-phase filters* automatically restore the original phase instead of applying two (non canceling) shifts?


* For example, a Q6/+12db bell filter at 16 kHz and a Q6/-12db bell filter at 16 kHz.

 
SimplePortal 1.0.0 RC1 © 2008-2019