Re: [slightly OT] Re: Calculation of filter coefficients given characteristic

From: Dana Massie (dana@beadgame.com)
Date: Mon Nov 22 1999 - 13:36:26 EST


Hi Everybody!
I have wanted to jump in and discuss some of these filter calculation
issues, but I have been so busy that I was unable to write any code to help
demonstrate what I would say.

Rather than say nothing, i thought I would just mention a few ideas about
filter calculations.

1. Arbitrary Filter Calculations
2. Table lookup
3. Table lookup with interpolation of coefficients
4. Variable Filters

1. Arbitrary Filter Calculations

Today, it is more realistic than ever to simply have full on complex filter
calculations, such as bilinear transform of analog designed elliptic filter
coefficients, but it still is a waste of computer time, when we still are in
need of as many CPU cycles as we can get.

It takes a lot of CPU cycles to perform the typical filter design
calculation. Many transcendental computations are usually needed, such as
trig, log, etc., not to mention square roots and divides, all of which chew
up a lot of CPU time. Even at the K-rate, you can be looking at a lot of
cycles, if you are trying to run something in real time.

Of course, i suspect that Eric's original request was for convenience, and
he may not have been concerned about real-time performance, but even in this
case, I would argue that table lookup with interpolation is a strong
candidate.

2. Table Lookup

Throughout history, table lookup of filter coefficients has been by far the
fastest method for filter coefficient calculation. Pre compute the filter
coefs, and then store them in a table.

The problem is of course that the table can get big. Also, you need tons of
tables to cover all of the cases that you might want.

So, lots of people have gone to

3. Table lookup with Interpolation

This idea dates back to before the Beatles, I think. What is new, perhaps,
is that some filters (at least) interpolate incredibly well.

For example, and I strongly suggest that people take out their Matlab and
try this out at home, look at a parametric equalizer.

There are several popular design methods to generate coefficients for a
5-multiply biquad that satisfy the parametric equalizer design constraints.
Pick one, and generate 2 sets of coefficients. One set could have one
setting of user parameters (frequency, bandwidth, and boost/cut amount).
The other set of 5 filter coefs should have a different set of user
parameters.

Now write a simple routine that generates say 16 intermediate sets of 5
filter coefficients (call these frames - these are the a[] and b[] vectors
that are the actual multipliers in the filter implementation, of course).

Now plot the frequency responses of the resulting 16 frames, overlaid with
the original and the target user parameter sets.

You will discover that all of the intermediate interpolated frames are all
legal parametric equalizer shapes.

This actually is a miracle. If you look a little bit at the algebra, it
starts to make more sense.

The result is that for a parametric equalizer, it is only necessary to store
8 initial frames, one for each corner of a cube, where the axes are the
three user parameters of a traditional parametric equalizer.

All intermediate setting for the PEQ can then be generated by simple
bi-linear interpolation from these corner sets.

I have not tried other filter designs in a lot of detail, but this trick
will work with a wide variety of filters. I strongly suspect that elliptic
filters for example, will work just fine. The algorithm is to pick 1, 2 or
3 parameters of the ellip() filter that you want to expose to the user as
parameters, and then generate 2, 4 or 8 sets of filter a[], and b[]
coefficients to load into a table. Then test to see if the interpolated
filter frames, when plotted against the original, follow the desired
constraints.

This may seem like an ad hoc method, but it is quite effective. It is
possible to set up algebra to prove that this interpolation method does or
does not work properly, but if you just need a decent variable filter, and
want to be able to calculate the coefficients in real time with minimal
processor load, this method works great.

4. Variable Filters

There have been a number of articles in the DSP literature on variable
filters. Constandinides, Mitra, Regalia, and others have published about
this. There are a few articles in AES, but frankly, I have never seen
anybody analyze simple linear interpolation of filter coefficients. I know
people who used simple linear interpolation of coefficients, and they have
always asked me what possible advantage could there be in using any more
complex scheme. Linear interpolation of the filter coefficients has been
used by many implementers with great results. I wonder why nobody has
looked at this analytically. The idea would be to work the design equations
backwards, starting with a substitution of the interpolated coefficients,
and seeing what happens to the user parameters when the interpolation is
brought all the way back out through the design equations.

When i started to do this, I quickly got in over my head with algebra, but I
am not the best person with hairy algebra. Using Mathematica or Maple might
help.

This would be a great thing for a grad student to look into, as the
literature on variable filters seems to have overlooked this simple but most
powerful technique of all.

---------------

I would enjoy discussing this scheme further, if there is any interest.
Hopefully, I will have time to write something up in more detail, but
perhaps this vague description is enough to get somebody else started.

Cheers!

-dana massie

Nicola Bernardini wrote:

> Nov 12, John Lazzaro mi scrisse cio` che segue:
>
> > > You might be able to start with the Matlab code for ellip() or
> > > one of those and simplify and translate it to SAOL.
> >
> > Alternatively, you might want to look at the code for x-pole:
> >
> > ftp://ptolemy.eecs.berkeley.edu/pub/misc/
> >
> > which seems to have an IIR filter design engine that would seem
> > to do everything Eric needs ...
>
> I tried hard to compile this one under linux 2.0 and 2.2 libc5 and
> glibc. It seems un-maintained since a long time and had no luck with it.
>
> Somebody had better luck and is willing to share tips?
>
> ciao
>
> Nicola
> ------------------------------------------------------------------------
> Nicola Bernardini
> E-mail: nicb@axnet.it
>
> Re graphics: A picture is worth 10K words -- but only those to describe
> the picture. Hardly any sets of 10K words can be adequately described
> with pictures.

--
Dana Massie
dana@beadgame.com
102 Bradley Drive
Santa Cruz, CA 95060



This archive was generated by hypermail 2b29 : Mon Jan 28 2002 - 11:46:36 EST