DSPRelated.com
Forums

Allpass Filter Matlab Functions

Started by Luca Notini November 1, 2004
Dear group,

I am currently familiarising myself with the concept of the allpass filter.
In order to aid this process I have created two Matlab functions that allow
me to design allpass filters by directly placing poles within the unit
circle; the function calculates the position of the zero/s required in order
to generate an allpass filter for a particular configuration of poles. After
the placement of the pole/s the function then generates the bode plot of the
resulting filter.

I thought that somebody out there may find these useful also. The functions
may be found at:

http://www-staff.lboro.ac.uk/~huln/


The first function (allpass1pz.m) allows you to set the location of a pole
located within the unit circle and generates a first order allpass filter.
The second function (allpass2pz.m) allows you to set the location of two
poles within the unit circle with the restriction that the second pole is
the complex conjugate of the first, the resulting second order filter will
have real coefficients.

This functions are by no means perfect, e.g. place a pole close to an axis
or on the edge of the unit circle, so there is much scope for improvement.


Luca


On Mon, 1 Nov 2004 18:57:50 -0000, "Luca Notini"
<L.notini@lboro.ac.uk> wrote:

>Dear group, > >I am currently familiarising myself with the concept of the allpass filter. >In order to aid this process I have created two Matlab functions that allow >me to design allpass filters by directly placing poles within the unit >circle; the function calculates the position of the zero/s required in order >to generate an allpass filter for a particular configuration of poles. After >the placement of the pole/s the function then generates the bode plot of the >resulting filter. > >I thought that somebody out there may find these useful also. The functions >may be found at: > >http://www-staff.lboro.ac.uk/~huln/ > > >The first function (allpass1pz.m) allows you to set the location of a pole >located within the unit circle and generates a first order allpass filter. >The second function (allpass2pz.m) allows you to set the location of two >poles within the unit circle with the restriction that the second pole is >the complex conjugate of the first, the resulting second order filter will >have real coefficients. > >This functions are by no means perfect, e.g. place a pole close to an axis >or on the edge of the unit circle, so there is much scope for improvement. > > >Luca
Hello Luca, I'd like to run your code, but I'm not sure how to do that. Sorry for the "newbie" questions but what is the "select" in the first command of Allpass1pz.m"? Do I have to create an ".m" file for each function in the "Allpass1pz.m" routine? Thanks, [-Rick-]
Sorry, I should have stated this explicity from the outset.

You run either of the functions by typing the name of the function you wish
to run  in the command window; no arguments are required and no values are
returned. You do not have to create any additional .m files although you do
need to have the signal processing toolbox installed.When either of the
functions
are run you will be presented with two figures:one containing a plot of the
unit circle
 containing either one or two poles(depending on which function you run) and
a bode plot of the IIR filter that is described by the Z-domain transfer
function
 possessing the poles and zeros represented in figure1. Left or right click
on a pole
and drag it wheredesired within the unit circle; on release of the mouse
button the bode plot
is updated.

The figures are stacked one on top of the other so you will have to move
figure 2 out of the road to access figure 1 (see caveat at the bottom of
initial posting). Some additional information is given in the header of the
.m files.

Luca.

----- Original Message ----- 
From: "Rick Lyons" <r.lyons@_BOGUS_ieee.org>
Newsgroups: comp.dsp
Sent: Tuesday, November 02, 2004 8:12 AM
Subject: Re: Allpass Filter Matlab Functions


> On Mon, 1 Nov 2004 18:57:50 -0000, "Luca Notini" > <L.notini@lboro.ac.uk> wrote: > > >Dear group, > > > >I am currently familiarising myself with the concept of the allpass
filter.
> >In order to aid this process I have created two Matlab functions that
allow
> >me to design allpass filters by directly placing poles within the unit > >circle; the function calculates the position of the zero/s required in
order
> >to generate an allpass filter for a particular configuration of poles.
After
> >the placement of the pole/s the function then generates the bode plot of
the
> >resulting filter. > > > >I thought that somebody out there may find these useful also. The
functions
> >may be found at: > > > >http://www-staff.lboro.ac.uk/~huln/ > > > > > >The first function (allpass1pz.m) allows you to set the location of a
pole
> >located within the unit circle and generates a first order allpass
filter.
> >The second function (allpass2pz.m) allows you to set the location of two > >poles within the unit circle with the restriction that the second pole is > >the complex conjugate of the first, the resulting second order filter
will
> >have real coefficients. > > > >This functions are by no means perfect, e.g. place a pole close to an
axis
> >or on the edge of the unit circle, so there is much scope for
improvement.
> > > > > >Luca > > Hello Luca, > > I'd like to run your code, but I'm not sure > how to do that. Sorry for the "newbie" questions > but what is the "select" in the first command of > Allpass1pz.m"? Do I have to create an ".m" file for > each function in the "Allpass1pz.m" routine? > > Thanks, > [-Rick-] >
On Tue, 2 Nov 2004 09:26:58 -0000, "Luca Notini"
<L.notini@lboro.ac.uk> wrote:

>Sorry, I should have stated this explicity from the outset. > >You run either of the functions by typing the name of the function you wish >to run in the command window; no arguments are required and no values are >returned. You do not have to create any additional .m files although you do >need to have the signal processing toolbox installed.When either of the >functions >are run you will be presented with two figures:one containing a plot of the >unit circle > containing either one or two poles(depending on which function you run) and >a bode plot of the IIR filter that is described by the Z-domain transfer >function > possessing the poles and zeros represented in figure1. Left or right click >on a pole >and drag it wheredesired within the unit circle; on release of the mouse >button the bode plot >is updated. > >The figures are stacked one on top of the other so you will have to move >figure 2 out of the road to access figure 1 (see caveat at the bottom of >initial posting). Some additional information is given in the header of the >.m files. > >Luca. >
Hi Luca, Thanks for help. I think your code is terrific! The true DSP Guru Fred Harris has been "preaching the gospel" of allpass filters for many years now. In fact, he has a whole chapter in his new book ("Multirate Signal Processing") dedicated to all the many specialized filters that can be designed using allpass filters. Good work Luca, [-Rick-]
"Rick Lyons" <r.lyons@_BOGUS_ieee.org> wrote in message
news:4188a31a.53025609@news.sf.sbcglobal.net...
> On Tue, 2 Nov 2004 09:26:58 -0000, "Luca Notini" > <L.notini@lboro.ac.uk> wrote: > > > The true DSP Guru Fred Harris has been > "preaching the gospel" of allpass filters > for many years now. In fact, he has a > whole chapter in his new book ("Multirate > Signal Processing") dedicated to all the > many specialized filters that can be designed > using allpass filters.
Recently I wanted to try to make a shelving filter out of a second order AP, but couldn't figure out how. Does anyone know if that's possible?
On Wed, 3 Nov 2004 09:43:14 -0800, "Jon Harris"
<goldentully@hotmail.com> wrote:

>"Rick Lyons" <r.lyons@_BOGUS_ieee.org> wrote in message >news:4188a31a.53025609@news.sf.sbcglobal.net... >> On Tue, 2 Nov 2004 09:26:58 -0000, "Luca Notini" >> <L.notini@lboro.ac.uk> wrote: >> >> >> The true DSP Guru Fred Harris has been >> "preaching the gospel" of allpass filters >> for many years now. In fact, he has a >> whole chapter in his new book ("Multirate >> Signal Processing") dedicated to all the >> many specialized filters that can be designed >> using allpass filters. > >Recently I wanted to try to make a shelving filter out of a second order AP, but >couldn't figure out how. Does anyone know if that's possible?
Sorry Jon, but I don't know if its' possible, or not. [-Rick-]
Rick Lyons wrote:

> On Wed, 3 Nov 2004 09:43:14 -0800, "Jon Harris" > <goldentully@hotmail.com> wrote: > > >>"Rick Lyons" <r.lyons@_BOGUS_ieee.org> wrote in message >>news:4188a31a.53025609@news.sf.sbcglobal.net... >> >>>On Tue, 2 Nov 2004 09:26:58 -0000, "Luca Notini" >>><L.notini@lboro.ac.uk> wrote: >>> >>> >>>The true DSP Guru Fred Harris has been >>>"preaching the gospel" of allpass filters >>>for many years now. In fact, he has a >>>whole chapter in his new book ("Multirate >>>Signal Processing") dedicated to all the >>>many specialized filters that can be designed >>>using allpass filters. >> >>Recently I wanted to try to make a shelving filter out of a second order AP, but >>couldn't figure out how. Does anyone know if that's possible? > > > Sorry Jon, but I don't know if its' possible, > or not. > > [-Rick-]
An analog shelf requires two breaks: one up and one down. The two define the limits of the upper and lower flat asymptotes, with the amplitude changing between them. I don't see how to approximate that with a single second-order section. Since shelving involves an amplitude change, I don't think it can be done at all with all-pass sections. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Jerry Avins wrote:
> Rick Lyons wrote: > > >>On Wed, 3 Nov 2004 09:43:14 -0800, "Jon Harris" >><goldentully@hotmail.com> wrote: >> >> >> >>>"Rick Lyons" <r.lyons@_BOGUS_ieee.org> wrote in message >>>news:4188a31a.53025609@news.sf.sbcglobal.net... >>> >>> >>>>On Tue, 2 Nov 2004 09:26:58 -0000, "Luca Notini" >>>><L.notini@lboro.ac.uk> wrote: >>>> >>>> >>>>The true DSP Guru Fred Harris has been >>>>"preaching the gospel" of allpass filters >>>>for many years now. In fact, he has a >>>>whole chapter in his new book ("Multirate >>>>Signal Processing") dedicated to all the >>>>many specialized filters that can be designed >>>>using allpass filters. >>> >>>Recently I wanted to try to make a shelving filter out of a second order AP, but >>>couldn't figure out how. Does anyone know if that's possible? >> >> >>Sorry Jon, but I don't know if its' possible, >>or not. >> >>[-Rick-] > > > An analog shelf requires two breaks: one up and one down. The two define > the limits of the upper and lower flat asymptotes, with the amplitude > changing between them. I don't see how to approximate that with a single > second-order section. Since shelving involves an amplitude change, I > don't think it can be done at all with all-pass sections. > > Jerry
See P. Regalia and S. Mitra, "Tunable digital frequency response equalization filters," IEEE Trans. Acoust., Speech, Signal Processing, Vol. 35, No. 1, pp. 118-120, Jan 1987 Juha
"Jerry Avins" <jya@ieee.org> wrote in message
news:2utm9fF2b8a9nU1@uni-berlin.de...
> Rick Lyons wrote: > > > On Wed, 3 Nov 2004 09:43:14 -0800, "Jon Harris" > > <goldentully@hotmail.com> wrote: > > > > > >>"Rick Lyons" <r.lyons@_BOGUS_ieee.org> wrote in message > >>news:4188a31a.53025609@news.sf.sbcglobal.net... > >> > >>>On Tue, 2 Nov 2004 09:26:58 -0000, "Luca Notini" > >>><L.notini@lboro.ac.uk> wrote: > >>> > >>> > >>Recently I wanted to try to make a shelving filter out of a second order AP,
but
> >>couldn't figure out how. Does anyone know if that's possible? > > > > An analog shelf requires two breaks: one up and one down. The two define > the limits of the upper and lower flat asymptotes, with the amplitude > changing between them. I don't see how to approximate that with a single > second-order section. Since shelving involves an amplitude change, I > don't think it can be done at all with all-pass sections.
It seems that you are implying that you can't make amplitude changes with an AP filter. The standard technique that allows this is to combine the original unfiltered input with the AP filtered output in various proportions to achieve amplitude changes. For example, it is easy to make a peaking or notch filter with a 2nd order AP. At the center frequency, the AP output is shifted 180 degrees from the input. So adding that to the original gives you a notch and subtracting it gives you a peak. Those are the easy cases. I was wondering about other things such as shelving.
"Jerry Avins" <jya@ieee.org> wrote in message
news:2uuv3cF2fi5tlU1@uni-berlin.de...
> Juha wrote: > ... > > > See > > > > P. Regalia and S. Mitra, "Tunable digital frequency response > > equalization filters," IEEE Trans. Acoust., Speech, Signal Processing, > > Vol. 35, No. 1, pp. 118-120, Jan 1987 > > > > Juha > > I haven't seen the paper yet, but the title implies altering the > frequency response. How might that be done with all-pass filters? > > My remark about needing two breaks to create a shelf was true, but the > hunch (I knew better!) that first-order couldn't provide them was false. > http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt > and http://www.theworld.com/~cmoore/AN11.pdf show nice counterexamples.
Right. You can make a shelving filter even with a first order section. For a shelf that provides boost, the zero provides the boost and the pole flattens it back out. BTW, thanks for the second link. I hadn't seen that yet myself. I have made extensive use of RB-J's cookbook, but it is limited to second order sections, so I had been deriving the first order equations myself as needed. Interesting that the author uses the impulse invariance method rather than the more common Bi-linear transform.