All Pass filters for phase correction

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi,

I'm building a three band system in which some bands use IIR filters. This means that the phase response of one band differs from others which can cause frequency cancellations, etc (especially around the cross over's splitting points).

Reading about this issue I found that one can use 1 pole AP (all pass) or 2 pole AP on some specific bands. The logic is to fit the phase response of one band with the other.
However, 1 Pole AP and 2 pole AP are very crude tools for this mission. 1 pole AP has a 180 [deg] phase response with 90 [deg] around the cut-off.

What if I need, as an example, a 45 [deg] phase shift? How about more complex phase curves?

I'm looking for a tool (Python? MATLAB? other ?) to design a complex phase response system which doesn't effect the magnitude (frequency response).
Any ideas ?

Post

I can't answer your question, but off the top of my head I would consider redesigning the bands so that only filters with responses of the form H^2 (where H is some other filter's response) would be used in each of the bands, including the splitting filters (kinda Linkwitz-Riley style). In that case off the top of my head I'd guess that their phase responses can be exactly compensated with allpasses. But maybe I'm mistaken... Also don't know how far are you with your design and whether that's an option for you at all.

Post

I built a 4-band Compressor several years ago using IIR filters combined with all-pass filters for "phase compensation".

All the math worked on paper but in actual practice I found it an audible mess. What you have to keep in mind are the transient responses. Even though phase compensation works in the math it is really only true for steady-state situations. You could still hear phasey interactions when band gains were changed (i.e., the transient response was not good).

Long story short, I ended up using linear phase FIRs instead. No phase shifts, period. All bands stayed time and phase-aligned regardless of gain. Sounded much more solid.

Post

Ross21 wrote: Mon Apr 15, 2019 8:53 am Hi,

I'm building a three band system in which some bands use IIR filters.
Is the problem the crossovers themselves, or that you are applying IIRs to the bands after they've been split?

Post

Yep, that's going to be a problem. The phase response of the "series" filter in one band would be required in all the other bands. This isn't a rule or anything, it's possible if there's harmonic distortion or other decorrelating elements in the one band, it would be possible to filter that band in series without the same cancellations.

Post

Fender19 wrote: Mon Apr 15, 2019 10:18 pm I built a 4-band Compressor several years ago using IIR filters combined with all-pass filters for "phase compensation".
...
Long story short, I ended up using linear phase FIRs instead. No phase shifts, period. All bands stayed time and phase-aligned regardless of gain. Sounded much more solid.
What should be the minimum FIR length (in samples) to build a decent 3 band cross-over (say 12/18/24 db per octave) ?
I guess it is a few thousands of samples at least ??

Post

Ross21 wrote: Tue Apr 16, 2019 12:40 pm
Fender19 wrote: Mon Apr 15, 2019 10:18 pm I built a 4-band Compressor several years ago using IIR filters combined with all-pass filters for "phase compensation".
...
Long story short, I ended up using linear phase FIRs instead. No phase shifts, period. All bands stayed time and phase-aligned regardless of gain. Sounded much more solid.
What should be the minimum FIR length (in samples) to build a decent 3 band cross-over (say 12/18/24 db per octave) ?
I guess it is a few thousands of samples at least ??
It depends on the frequency. A crossover point at 4k doesn't require too many samples but at 200Hz it can require a hundred or more. It depends on how steep you want the roll off and how much stop band attenuation you want.

Also, if you are using a "sinc" filter kernel the rolloff is not in dB/oct. It's basically "brick wall" where the actual slope and attenuation depends on number of sample points, filter kernel and window function. There are other filter kernels you can use for different slopes but it's not "cookbook" AFAIK.

Selecting all those options is where the "art" of plugin design comes in. 8)

BTW - a "trick" you can use with IIR filters is "subtractive" filtering. For example, instead of trying to match a low pass to a high pass to create a smooth crossover you simply subtract one or the other from the input signal. For example, High pass = Input - Low pass. This guarantees the (unaltered) signal will recombine to unity and the phase shifts line up. The slopes of the two filters will not be the same but that usually doesn't matter. Sometimes this is all you need for something like a compressor.

Post

Ross21 wrote: Tue Apr 16, 2019 12:40 pm
Fender19 wrote: Mon Apr 15, 2019 10:18 pm I built a 4-band Compressor several years ago using IIR filters combined with all-pass filters for "phase compensation".
...
Long story short, I ended up using linear phase FIRs instead. No phase shifts, period. All bands stayed time and phase-aligned regardless of gain. Sounded much more solid.
What should be the minimum FIR length (in samples) to build a decent 3 band cross-over (say 12/18/24 db per octave) ?
I guess it is a few thousands of samples at least ??
FIR filters are usually not designed for db/octave, but in general, you should usually think of the length of the FIR filter in terms of wavelength at cutoff (or equivalently "zero crossings") rather than samples. Longer filters give you a steeper transition from passband to stopband, but in order to get the same shape (at least to a good approximation) at half the cutoff, you need to make the filter twice as long in terms of samples (which keeps it same length in terms of wavelength at cutoff). For windowed designs, you can in fact simply stretch the whole filter in time.

Post

Fender19 wrote: Tue Apr 16, 2019 4:05 pm BTW - a "trick" you can use with IIR filters is "subtractive" filtering. For example, instead of trying to match a low pass to a high pass to create a smooth crossover you simply subtract one or the other from the input signal. For example, High pass = Input - Low pass. This guarantees the (unaltered) signal will recombine to unity and the phase shifts line up. The slopes of the two filters will not be the same but that usually doesn't matter. Sometimes this is all you need for something like a compressor.
This works if all you want to do is split the signal and then recombine. Unfortunately, as soon as you do any processing with the individual bands (ie. even change the gain of one of them) it's no longer quite sufficient and you start to get "phasing" problems.

What you really need is a cross-over design that (1) sums back to all-pass and (2) keeps all individual bands in phase-alignment. It's the second property that allows you to manipulate the bands (at least with linear-phase processing, such as gain adjustments) without causing phase problems. Note that it's impossible to design a (causal, at least) IIR cross-over network that is phase-coherent and sums back to the original signal without phase-shifts (ie. you will always have to accept all-pass response or use a linear-phase filter instead).

The classic design that satisfies both properties is Linkwitz-Riley. In The Art of VA Filter Design, Vadim (Z1202) describes some elliptic filters (or at least filters based on elliptic filters; see the book) that supposedly work as well if you don't mind some ripple (although I haven't personally looked at those, other than observing that they are mentioned in the book).

Post

mystran wrote: Tue Apr 16, 2019 9:43 pmThe classic design that satisfies both properties is Linkwitz-Riley. In The Art of VA Filter Design, Vadim (Z1202) describes some elliptic filters (or at least filters based on elliptic filters; see the book) that supposedly work as well if you don't mind some ripple (although I haven't personally looked at those, other than observing that they are mentioned in the book).
Actually the book has a description of a general framework for the filters which sum up to an allpass. "Elliptic Linkwitz-Riley" are just a particular case of that. This was developed based on our discussion here at KVR including you and Max M.

However when we're talking about simply phase-compensating a filter, such as e.g. a low-shelving filter which could be used as a part of the band's processing (rather than a part of the crossover), we need an allpass whose phase response matches the one of a filter in question. In that case, given the filter has a response of the form (H1(s)/H2(s))^2 we could compensate the phase shift using an allpass H1(s)*H2(-s)/H1(-s)*H2(s) (up to the sign, which I ignore for simplicity of argument). Now that I explicitly wrote this formula out, I notice that the original filter must be maximum phase, so we either can convert it to maximum phase, or (probably a better idea) convert it to "zero-phase numerator": H1(s)H1(-s)/H2^2(s) in which case the compensating allpass simply becomes H2(-s)/H2(s). Notice the obvious similarity to the generalized Linkwitz-Riley. Disclaimer: all of that written off the top of my head, mistakes are possible.

Post

Z1202 wrote: Wed Apr 17, 2019 7:44 amthe original filter must be maximum phase, so we either can convert it to maximum phase, or (probably a better idea) convert it to "zero-phase numerator":
This is rather off-topic, but I just can't resist: (causal, stable) maximum-phase filters are also handy when you want to replace the (scalar) feedback coefficient of an all-pass filter with an IIR filter. This would obviously be a rather silly thing to do with all-pass filters based on unit-delays, but it makes it possible to build all-pass comb filters that have frequency dependent decay times, while still keeping the unitary frequency response and efficient delay-based implementation.

Post

mystran wrote: Tue Apr 16, 2019 9:43 pm The classic design that satisfies both properties is Linkwitz-Riley.
Actually, LwR doesn't work well either (I've tried it) and the reason is the transient response. Run a square wave through a Linkwitz-Riley crossover and see what happens to the edges of the re-combined signal - especially when you start manipulating band gains.

IMO, the best crossover filter for multi-band processors is linear phase FIR. HOWEVER, some people complain about the "pre-ringing" of FIRs - so it's all a matter of taste in practical application, i.e., the art of audio design.

Post

Fender19 wrote: Wed Apr 17, 2019 3:54 pm
mystran wrote: Tue Apr 16, 2019 9:43 pm The classic design that satisfies both properties is Linkwitz-Riley.
Actually, LwR doesn't work well either (I've tried it) and the reason is the transient response. Run a square wave through a Linkwitz-Riley crossover and see what happens to the edges of the re-combined signal - especially when you start manipulating band gains.
The all-pass phase-shift will distort the time-domain waveform and transient response. This certainly tends to be audible (for better or worse) especially at low cross-over frequencies and more so with increasing filter orders. Whether you prefer this phase-shift or FIR pre-ringing (and latency) in any given situation is obviously largely a matter of taste.

However, the phase-coherence (ie. all bands have the same phase-shift) of Linkwitz-Riley filters means that the overall magnitude response is still a simple sum of the magnitude responses of the individual bands and the phase-shift (undesirable as it may be) is independent of the band gains. In other words, the result is essentially equivalent to first applying single-band all-pass filter and then using a linear-phase cross-over to do the multi-band processing.

Post Reply

Return to “DSP and Plugin Development”