Does anyone know how to use all pass filters to restore the phase shift from filters.

Studiowaves
Studiowaves Member Posts: 734 Pro
edited March 18 in Building With Reaktor

Not sure if it can be done but I was hoping to re align the phase shift inherent with low pass filters. I think all pass filters have a specific phase shift but I'm not sure if they can be placed in series with low pass filters to re establish the original phase before filtering. Does anyone have any experience with this?

«1

Comments

  • Tr97
    Tr97 Member Posts: 26 Helper

    Hi, sadly this is not possible. If you look at the filter transfer function of a filter all poles have to be inside the unit circle (in the z-transform view), a single instance of an allpass filter is a pair of zero and pole in this perspective. A low pass filter has some poles inside the unit circle, to get rid of them you need an allpass with a zero at this position, this is not possible because the corresponding pole would be outside the unit circle. so the corresponding filter realization would be unstable. So the poles cannot be neutralized and so the filter stays an IIR filter which cannot be linear phase. But maybe there can be some approximations, but I would not know how to realize them.

    —————————————————————————————————————————————————————————————————-

    Also asked deepseek and got the following explanation:

    A digital lowpass filter cannot be exactly transformed into a phase-neutral filter (i.e., one with exact linear phase) through the addition of allpass filters. Here's the breakdown:

    1. IIR Filters: Most digital lowpass filters (e.g., Butterworth, Chebyshev) are IIR (Infinite Impulse Response) and inherently have non-linear phase responses. Allpass filters can adjust phase but cannot force an IIR system to have a symmetric impulse response, which is required for exact linear phase. Even after cascading with allpass filters, the system remains IIR and thus cannot achieve linear phase.
    2. FIR Filters: While FIR (Finite Impulse Response) filters can be designed for linear phase via symmetric coefficients, if the original FIR lowpass filter lacks linear phase, adding allpass filters (which are IIR) would convert the system to IIR. This still precludes exact linear phase, as IIR systems cannot have symmetric impulse responses.
    3. Phase Equalization: Allpass filters can approximate linear phase in specific frequency bands (e.g., the passband) through phase correction, but this is an approximation, not an exact transformation. This technique is used in applications like audio processing to mitigate phase distortion but does not achieve true phase neutrality.

    Conclusion: While allpass filters can improve phase linearity in practice, they cannot transform a digital lowpass filter into an exact phase-neutral (linear-phase) system. The fundamental limitation arises from the inability of IIR structures to support the symmetric impulse response required for exact linear phase.

    Answer:
    No, a digital lowpass filter cannot be transformed into an exact phase-neutral (linear-phase) filter by adding allpass filters. However, allpass filters can approximate linear phase in specific frequency bands through phase equalization.

  • Studiowaves
    Studiowaves Member Posts: 734 Pro
    edited March 28

    Well, thanks for the response, something I didn't expect. I was actually wanting to simply follow the low pass filter with a separate all pass filter network. It can be done with analog electronics but I wasn't sure if it could in the digital domain. There was an article in scientific America that showed how to do it back in the 80's or early 90's for electronic crossovers. If I remember, they started with a pair of complimentary high and low pass filters then added the all pass circuits afterwards to correct for the phase shift. It worked, the outputs of the electronic crossover were in phase all throughout the frequency spectrum. Sounds like it's a no go for digital filters then but I found a suitable workaround for this project so it's no big deal. Kind of interesting how things work though. Thanks

  • Tr97
    Tr97 Member Posts: 26 Helper

    Gave it a second thought, now I am not sure anymore if my argument with the poles holds, because I only concidered putting the filters in serial not in parallel, a moving average filter can be done with 2 IIR filters and is an FIR, also a 1 pole lowpass can be truncated by subtracting a delayed and multiplied by a factor copy.

    Most basic filters seem to delay increasing phases in the same direction, higher frequency → higher phase shift (backwards, wave shifted to the right), what can be explained by the poles inside the unit circle

    —-Think the deepseek argumentation is more reliable :D
  • colB
    colB Member Posts: 1,060 Guru

    Usually, the approach is to build an all-pass filter that has the same phase response as e.g. some low pass filter. Then you apply the all-pass to the 'through' audio, so when that is mixed with the output from the low-pass there is no phase mismatch - both have the same phase response.

    You will see this in the cross-over filters in the factory library, each one has an associated '=' macro to 'correct' the phase of a bypass signal to match that of the filtered signal.

    Here is the 3 way 2-pole Linkwitz-Riley crossover (above), and the 'corrector' (below), with the info text for the corrector.

    See how the two filters each have a respective all pass in the corrector, that takes the appropriate cutoff frequency from the main filter via the bundle ports.

    You can also use the transfer func section in the filter toolkit to build phase plots for the various filters. That helps to work out which all pass filters will have the same response as some filter you want to correct for.

  • Studiowaves
    Studiowaves Member Posts: 734 Pro

    The top is a sweep from 20 to 20k and the bottom is the filter. There is a filter cutoff and this is the LR2 lpf. There is a choice of either the filter output or a subtraction between the filter and the input to see if the phase is truly corrected. There is also a choice to use or bypass the all pass filter for easy comparison. If you use the subtraction or difference button you can see what happens between the two. It basically turns a low pass into a high pass but watch what happens when you switch the all pass section on or off. When it's off the high pass is much better so obviously the all pass here makes things worse. You can try two three or four all passes in a row and see what happens. The main thing is this makes a decent tool to see what's happening. As it stands the phase correction is all wrong with an all pass but seems better as it is. Got any ideas?

    The difference

    the difference with an all pass filter.

  • colB
    colB Member Posts: 1,060 Guru

    You should re-read my post, and the clear instructions in the info for the crossover correction macros.

    The correction '=' macros are designed to correct the pass-through signal so that it's phase will be the same as the signal through the crossover filter.

    This is wrong:

    that = input should have the 'sine' signal not the LP signal.

    Then the LP output will have the same phase resplnse as the sine signal at the output of the 'X-over LR2 =' macro.

    Here's the correct usage:

    Here, we subtract the LP output from the sine signal. This should result in a high pass filtered signal. This can be tested by nulling with the cross-over filter's HP output

    If we do it with the un-corrected sine, it doesn't null (Y output, upper scope), because the phases don't match.

    If we do it with the phase corrected sine, we get the nulled output (Y2 output, lower scope), proving that the sine signal has been properly phase corrected to match the filter.

  • Studiowaves
    Studiowaves Member Posts: 734 Pro
    edited April 2

    I tried it again, It doesn't appear to correct the phase of the low pass so it's truly in phase with the sine input though. That's what I was hoping for, but this might come in handy. Weird though, seems like adding the LP with the newly created high pass together should be flat, but they are not. I must have done something wrong.

  • Studiowaves
    Studiowaves Member Posts: 734 Pro

    Added a lissajous xy scope, might help me stumble on to something. lol

  • Studiowaves
    Studiowaves Member Posts: 734 Pro

    I found something. It seems a single all pass circuit produces an in phase sine wave that is phase coherent with the sum of the HP and LP of the LR r2 . Here's the circuit

    The lissajous pattern remains a straight line throughout the sweep The B outputs from the selectors. So summing the HP and LP goes to the X input and the Corrector (Cor) goes to the Y input. At least we know have proof the corrected sine wave is in phase with the sum of the filters. Next I verified one filter at a time and there is no phase shift between the corrected sine and either filter. HP or LP. The lissajous is a constant straight line meaning no phase shift. It's a start I guess.

    The top is the start of the LPF and the bottom is the corrected sine.

    The full sweep of the lowpass.

    Notice the Hp is also perfectly in phase as it sweeps.

  • Studiowaves
    Studiowaves Member Posts: 734 Pro

    Same results with the LR 4

    It appears the modules LR4 = or LR2 = do not interface with the wrong modules. LR2 connect to LR4= produces red modules. I'm assuming the devs tried to make this foolproof.

    Thanks Cobi, This is starting to make sense now.

  • colB
    colB Member Posts: 1,060 Guru

    I found something

    You found the thing I showed in my last post

  • Studiowaves
    Studiowaves Member Posts: 734 Pro

    Probably , I'm 73 and not too swift sometimes. lol The thing is we still haven't solved the original question. Which was to basically restore the phase to that of the original input. I haven't played with it much lately because I'm current switching to staying up all day instead of staying up all night. Man that hits you hard at my age. Do you see any way to preserve the original phase of the input signal using the LR 2 or 4; or have we solved that already? My brain is gonna be toast for a few weeks. Later. Thank for helping so far though.

  • colB
    colB Member Posts: 1,060 Guru

    The thing is we still haven't solved the original question. Which was to basically restore the phase to that of the original input.

    This is not possible. You can't 'restore' the phase.

    Think about what the phase response of a filter is in practical terms.

    The phase changes by different amounts at different frequencies.

    For that to happen, in the time domain, there must be a temporal shift. But we can't go back in time, so it must be forward in time, so that must be a form of DELAY.

    You can't undo a delay (unless you've worked out how to travel faster then the speed of light?), you would need to go back in time.

    Theoretically you can shift phase backwards, with a constant, infinite length, sine wave with constant frequency and constant amplitude, in that case, delaying by a wave cycle looks like you are back to 0 phase, but with a real life signal, that changes, it can't work, because the signal will be varying, so one cycle in the future and one cycle in the past are not guaranteed to be the same.

    The only way to phase match the original signal to the filtered one is to all pass filter the original. This applies the correct delays at the correct frequencies.

  • Tr97
    Tr97 Member Posts: 26 Helper
    edited April 4

    It could be possible to achieve linear phase what corrensponds to a fixed delay. But I am pretty sure this is not possible. An argument could be a linear phase filter has to have a symmetrical impulse response, maybe there is a possibility to cut the response of an imfinite impulse response at some point, but this would alter the frequency response as well. An added correction filter would have to catch up and match the response from some point on. This is possible for a 1 pole (exponential decay), but a 2 pole seems to be difficult.

    I am pretty sure it is impossible to achieve both: make an IIR linear phase and maintain its frequency response (without not applying the basic IIR) (of course it could be rebuild as approximated linear phase FIR), this is still the pole argument, a pole just can't be allpassed away. Argument in the frequency domain is this would need a 'bad' pole outside the unit circle created as inverse of the zero inside needed to remove the pole which makes the filter response infinite. The 'bad' zero would make the filter instable.

    The approach I know for linear phase filters is a direct one. The 'best' filter for a non-resonating response is a Gauss lowpass (can be made of multiple moving averages in series). The single moving average is an example for trimming an IIR, here it is integrate-comb (the comb cuts the infinite response of the integrator). The Gauss lowpass has an excellent rolloff but the inverse (the highpass made of 1 minus lowpassed) is not very steep (I think 6 dB per octave).

Back To Top