COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### phase compensation using allpass

• Follow

```Hi all,

Is there a way to design an all-pass IIR with the exact phase response
as an known IIR, for example, a 1st-order high pass obtained using
Zolzer's formula or an biquad  high pass from RBJ's cookbook.

The purpose is to compensate the phase change caused by that IIR.

%% matlab code %%
f0 = 4000;
Fs = 48000;
c = tan(pi*f0/Fs); c = (c-1)/(c+1);
b = [c 1];
a = [1 c];
freqz(b,a,[],Fs);

b = [(1-c)/2 -1/2];
hold on;
freqz(b,a,[],Fs);

Thanks

SYL
```
 0
Reply syanli (38) 1/21/2009 8:42:53 PM

```
SYL wrote:

> Hi all,
>
> Is there a way to design an all-pass IIR with the exact phase response

There are two ways: do it yourself or hire somebody else.

> %% matlab code %%

"Matlab does all thinking for us" (TM)

DSP and Mixed Signal Design Consultant
http://www.abvolt.com
```
 0
Reply antispam_bogus (2949) 1/22/2009 12:47:20 AM

```On Jan 21, 7:47=A0pm, Vladimir Vassilevsky <antispam_bo...@hotmail.com>
wrote:
> SYL wrote:
> > Hi all,
>
> > Is there a way to design an all-pass IIR with the exact phase response
>
> There are two ways: do it yourself or hire somebody else.
>
> > %% matlab code %%
>
> "Matlab does all thinking for us" (TM)
>
> DSP and Mixed Signal Design Consultanthttp://www.abvolt.com

If you want to compensate for the phase of a known IIR, why would you
want to have an allpass with the same phase shift?

Normally "phase-compensation" means "using allpass filters to add
delay to an existing filter such that the total delay is constant with
frequency". This means the allpass delay is maximum where the filter
delay is minimum, and vice-versa. If you find a way to remove delay,
let us know.

Often by the time you add enough allpasses to approximate linear-
phase, you could have just used a linear-phase FIR to start with
(depends on the phase accuracy you are shooting for).

Bob
```
 0

```Robert Adams  <robert.adams@analog.com> wrote:

>If you want to compensate for the phase of a known IIR, why would you
>want to have an allpass with the same phase shift?

A very common reason is to try to cancel out the phase
shift in the baseband filters in a radio, such that a
rank-constrained channel equalizer has more of a chance
of working.

I am unclear on whether this ever helps in reality, but
it can look good in simulations.

Steve
```
 0
Reply spope33 (691) 1/22/2009 6:03:05 AM

```>Hi all,
>
>Is there a way to design an all-pass IIR with the exact phase response
>as an known IIR, for example, a 1st-order high pass obtained using
>Zolzer's formula or an biquad  high pass from RBJ's cookbook.
>
>The purpose is to compensate the phase change caused by that IIR.
>

Hi,
You can approximate a linear phase filter with IIRs.
There are some papers about phase equalization using allpass filters.
Try to search the net for "Markus Lang" and "allpass",

But, since I guess that you have to use some iterative optimization
method you can design an approximate linear phase filter directly.
(instead of an allpass to correct the phase for a seperately
designed IIR)

This is a nice text (with some matlab) code on the design of
filters with arbitrary magnitude and frequency response (Thanks
to Martin Eisenberg for the pointer)

I am still struggling to get some stuff from the paper to work
in gnu octave, since it requires some stuff from matlabs
optimization (LP Solvers and Quadratic Programming) toolbox
for which I couldn't find any (really working) replacement code.

In matlab take a look at the invfreqz function.  Maybe it does
what you need.

gr.
Bjoern

```
 0
Reply bantone (103) 1/22/2009 8:39:29 AM

```On Jan 22, 3:39=A0am, "banton" <bant...@web.de> wrote:
> >Hi all,
>
> >Is there a way to design an all-pass IIR with the exact phase response
> >as an known IIR, for example, a 1st-order high pass obtained using
> >Zolzer's formula or an biquad =A0high pass from RBJ's cookbook.
>
> >The purpose is to compensate the phase change caused by that IIR.
>
> Hi,
> You can approximate a linear phase filter with IIRs.
> There are some papers about phase equalization using allpass filters.
> Try to search the net for "Markus Lang" and "allpass",
>
> But, since I guess that you have to use some iterative optimization
> method you can design an approximate linear phase filter directly.
> (instead of an allpass to correct the phase for a seperately
> designed IIR)
>
> This is a nice text (with some matlab) code on the design of
> filters with arbitrary magnitude and frequency response (Thanks
> to Martin Eisenberg for the pointer)
>
>
> I am still struggling to get some stuff from the paper to work
> in gnu octave, since it requires some stuff from matlabs
> optimization (LP Solvers and Quadratic Programming) toolbox
> for which I couldn't find any (really working) replacement code.
>
> In matlab take a look at the invfreqz function. =A0Maybe it does
> what you need.
>
> gr.
> Bjoern

Hi Bjoern,
You may want to try the following optimization toolkit:
http://www2.imm.dtu.dk/~hbn/immoptibox/

I have used it with some success for my problems, and I am not
affiliated with it in any way.

Cheers,
Dave
```
 0
Reply dspguy2 (214) 1/23/2009 3:12:55 PM

```Dave wrote:
>On Jan 22, 3:39=A0am, "banton" <bant...@web.de> wrote:
>> I am still struggling to get some stuff from the paper to work
>> in gnu octave, since it requires some stuff from matlabs
>> optimization (LP Solvers and Quadratic Programming) toolbox
>> for which I couldn't find any (really working) replacement code.
>>
>> In matlab take a look at the invfreqz function. =A0Maybe it does
>> what you need.
>>
>> gr.
>> Bjoern
>
>Hi Bjoern,
>You may want to try the following optimization toolkit:
>http://www2.imm.dtu.dk/~hbn/immoptibox/
>
>I have used it with some success for my problems, and I am not
>affiliated with it in any way.
>
>Cheers,
>Dave
>

Hi Dave,
I didn't know this toolbox.  I will try if it works with octave.
From my first very short look at it, I can see that
there are no LP and QP solvers.
However, it contains some interesting stuff for me (which I

Thanks Dave,
Bjoern

```
 0
Reply bantone (103) 1/24/2009 4:01:57 AM

```On Jan 21, 11:39=A0pm, Robert Adams <robert.ad...@analog.com> wrote:
>
> If you want to compensate for the phase of a known IIR, why would you
> want to have an allpass with the same phase shift?
>
> Normally "phase-compensation" means "using allpass filters to add
> delay to an existing filter such that the total delay is constant with
> frequency". This means the allpass delay is maximum where the filter
> delay is minimum, and vice-versa.

Bob, the one and only time i ever needed to use APF to help out an IIR
was with a Butterworth where the phase or group delay was pretty
constant from DC to somewhere just below the resonant frequency.  then
there was a sharp increase in delay (a "bump" or "lip") and then
either the phase or group delay dives toward zero (because it's
approaching a constant finite phase as the frequency gets arbitrarily
large).  anyway, what i sorta wanted to match was the steepest slope
of the phase/group delay with the declining slope of the APF of about
the same magnitude (maybe just a wee bit more).

i actually had formulae, but they're from the 80s.  i dunno where it
is.  it would be painful to rederive (and i don't think i had a nice
closed-form for the Butterworth delay, you had to have a program find
the max delay slope and use that as a parameter in what i had).

> If you find a way to remove delay, let us know.

not before they patent it.

> Often by the time you add enough allpasses to approximate linear-
> phase, you could have just used a linear-phase FIR to start with
> (depends on the phase accuracy you are shooting for).

i found that to be essentially the case, too.  if you had a big
frequency knob for the filter, the 2-dim array of FIR coefs might be
big.  what's sorta cool was the impulse response of the IIR vs
"equivalent" FIR.  there were some features that looked similar, but
the weren't really similar.  the IIR was, of course, not symmetrical
as the linear-phase FIR would have to be.  but it had a big lobe (that
was at about the same time as the DC value of the IIR and APF
together) and some wiggles with sign changes before and after.

r b-j
```
 0
Reply rbj (3920) 1/24/2009 10:08:50 PM

```On Jan 24, 5:08=A0pm, robert bristow-johnson <r...@audioimagination.com>
wrote:
>
>
>
> > If you want to compensate for the phase of a known IIR, why would you
> > want to have an allpass with the same phase shift?
>
> > Normally "phase-compensation" means "using allpass filters to add
> > delay to an existing filter such that the total delay is constant with
> > frequency". This means the allpass delay is maximum where the filter
> > delay is minimum, and vice-versa.
>
> Bob, the one and only time i ever needed to use APF to help out an IIR
> was with a Butterworth where the phase or group delay was pretty
> constant from DC to somewhere just below the resonant frequency. =A0then
> there was a sharp increase in delay (a "bump" or "lip") and then
> either the phase or group delay dives toward zero (because it's
> approaching a constant finite phase as the frequency gets arbitrarily
> large). =A0anyway, what i sorta wanted to match was the steepest slope
> of the phase/group delay with the declining slope of the APF of about
> the same magnitude (maybe just a wee bit more).
>
> i actually had formulae, but they're from the 80s. =A0i dunno where it
> is. =A0it would be painful to rederive (and i don't think i had a nice
> closed-form for the Butterworth delay, you had to have a program find
> the max delay slope and use that as a parameter in what i had).
>
> > If you find a way to remove delay, let us know.
>
> not before they patent it.
>
> > Often by the time you add enough allpasses to approximate linear-
> > phase, you could have just used a linear-phase FIR to start with
> > (depends on the phase accuracy you are shooting for).
>
> i found that to be essentially the case, too. =A0if you had a big
> frequency knob for the filter, the 2-dim array of FIR coefs might be
> big. =A0what's sorta cool was the impulse response of the IIR vs
> "equivalent" FIR. =A0there were some features that looked similar, but
> the weren't really similar. =A0the IIR was, of course, not symmetrical
> as the linear-phase FIR would have to be. =A0but it had a big lobe (that
> was at about the same time as the DC value of the IIR and APF
> together) and some wiggles with sign changes before and after.
>
> r b-j

I vaugely recall hearing about filters where you say "I don't care
about the phase response in the stopband, so I'll let it roam free". I
think this allows you to get shorter group delay and still hold linear
phase over the passband.

I also think I have seen a frequency-masking approach, where the big
IIR phase "hump" before rolloff is masked out by an FIR filter whose
only purpose is to attenuate before the hump, so you can' see it.

Bob

```
 0