Re: [buildcheapeeg] Filter bank

From: Jim Peters (jim_at_uazu.net)
Date: 2002-01-21 23:16:50


Rob Sacks wrote:
> Great, congrats. I wonder if you could explain a bit
> more about the output of your filter bank? What is
> the advantage over an FFT? I know of course that
> the response is faster, but I wonder if you could go
> into a little more detail.

Well, I wanted something that had evenly spaced bins in log-frequency
space, i.e. an equal number of bins per octave. I'm using 6 at the
moment, and 10 octaves. Also, I don't want too much overlap between
bins.

I didn't like the FFT solutions, because either you have a short
window and lose all the low frequencies, or you have a long window and
have a huge delay, or you do several different FFTs with different
windows at the same time, and then you have to try and merge all of
this data, which has effectively been measured at various different
time-delays. It seemed a mess to me, and I wanted a simpler solution.

I also looked at wavelets, but they didn't seem to help in any way,
because all the frequency information is mixed up between the bands.

So my current plan is this: I amplitude modulate the signal to shift
the bin centre frequency to 0Hz, and then low-pass filter it. This is
done with a chain of IIR filters, each potentially downsampling by a
factor of two, although that is turned off at the moment for testing.
The chain is longer for lower-frequency bins. A final IIR filter gets
the bin-width exactly right.

This is all coded in integer maths, and I've tested the filter code
with impulses of various magnitudes to check the response, and it
looks good so far. Input is 16-bit data, which should be good enough
for our purposes, I hope.

For each bin, I do two complete filter chains, with the amplitude
modulation carrier offset by 90 degrees. The filter chains are
identical, and the plan is that this gives two magnitudes for the bin
output, which can be combined to give a vector (or a complex number).
This is something I picked up from Stephan M Sprenger's pages:

http://www.dspdimension.com/

However, he is using it with a short-period FFT. The idea is that if
you know the phase angle as well as the magnitude, then if you get a
wave which is slightly out of tune with the centre frequency of the
bin, then the phase will be moving instead of stationary. By seeing
how fast it is moving, you can work out the precise frequency.

This only works if there is not more than one major signal in each
bin, which is why it's important the bins don't overlap too much.

Also, for this phase measurement idea to work properly with a sweeping
tone (one changing in pitch), the phase-response of the filter has to
be fairly flat. The filters I've generated seem to be pretty good,
but I won't know until I've tested them how all of this is really
going to work.

> Is the "bin width" (or whatever corresponds to
> bin width) constant for all the frequencies? Can
> the width be adjusted at run time?

No, the bin width is different for each bin, because of the
log-frequency-scale. No, you can't change the bin width at run time,
but if there was some good reason to do this, I could maybe let you
adjust them. It's probably better to leave them alone once I've got
it all tested.

> Does the "epoch length" (or whatever corresponds
> to that) vary from one band to another?

They're based on IIR filters, so in theory the `epoch length' is
infinite (if I understand your terminology). In practice it is of
course finite, as can be seen by putting an impulse through the filter
(it goes to 0 eventually). The length for lower frequency bins is
much much longer, as you would expect.

I chose IIR filters over FIR filters because I believe they will give
faster response. They are also much closer to analogue filters in
behaviour, whereas traditional symmetric FIR filters are `perfect',
but with a definite delay, which seems unnatural to me in this
application.

The IIR filters will also give a delay, and I'm not sure exactly what
this is going to be. Perhaps I should look at this. As I'm using
quite narrow bins, it might actually be quite long. I'll have to have
a look at this.

> How do you test the output of a filter bank? Is there
> a way to set performance criteria and then
> measure to see if the filter matches?

I put a spike of 32767 in, followed by all zeros. This measures the
impulse response. I then take this impulse response, and treat it as
an FIR filter, and put it into a filter response displaying program
(the one I'm using is based on code from mkfilter, modified quite a
bit, plus a Perl-script). This shows the response of the filter at
large displacement.

http://www.cs.york.ac.uk/~fisher/mkfilter/

If instead I put in a spike of 1 followed by all zeros, I get another
impulse response. This shows how the filter responds to very small
signals. Actually, this is the smallest possible signal the filter
can ever possibly see (since it's got all zeros to infinity on either
side). If this looks good too, then everything is going pretty well.

Actually, the smallest possible impulse doesn't make it all the way
through 11 filters, but I think what I've ended up with is pretty good
nevertheless.

Also, I'm checking for problems like the IIR filter stabilising on
non-0 values and settling into small +/- oscillations instead of
silence.

Once I get this graphical displayer working, I will be able to check
that the phases are all working properly. It would be nice to tune
the bin-widths so that a tone half-way between two bins gives the same
total magnitude (more or less) as one centred on a bin. I'll have to
wait and see how this goes. This is not 100% necessary for the whole
thing to work, though.

> If these are stupid or irrelevant questions can you
> substitute better ones? :)

No, you've given me the perfect excuse to explain all the work I've
been doing !

The only possible downer now is if there is a problem with the AM, or
other problems when it is fed real signals, but I will find out pretty
soon if so. I think I also need to look at how big the IIR delay is.

Jim

-- 
Jim Peters (_)/=\~/_(_) Uazú
(_) /=\ ~/_ (_)
jim@ (_) /=\ ~/_ (_) www.
uazu.net (_) ____ /=\ ____ ~/_ ____ (_) uazu.net


This archive was generated by hypermail 2.1.4 : 2002-07-27 12:28:36 BST