[sdiy] Looking for cheap lowpass filter algorithm

Seb Francis seb at burnit.co.uk
Fri Aug 18 13:12:44 CEST 2006


Eric Brombaugh wrote:
> Seb Francis wrote:
>> A couple of people have mentioned Matlab, but this isn't exactly a 
>> free download.  Eric suggested octave and octave-forge function 
>> library, but this looks like a lot of work to learn to use, and even 
>> then I'm not sure I'd know the names of the right mathematical 
>> algorithms to use.
>
> I've just built a new computer and part of the process was to do a 
> Cygwin install. I can confirm that if you do a full install of Cygwin 
> you'll get an up-to-date and fully usable copy of octave/octave-forge.
>

Well I have Cygwin, but I chose the packages and didn't choose octave.  
Would be easy to add it though.

> With that out of the way, the following code will design a 33-tap FIR 
> filter for you, dump the tap values and plot the response in dB:
>
> --------snip----------
> b = remez(32, [0 .20 .30 1], [1 1 0 0])
> plot(20*log10(abs(freqz(b))));
> --------snip----------
>
> use 'help remez' to learn what the parameters mean.
>

Thanks, this will certainly cut out some of the learning curve :)

For my current project I ended up using a program called ScopeFIR which 
is quite comprehensive and easy to use with a nice GUI.  It's shareware 
but has a 60 day trial period.
http://www.iowegian.com/scopefir.htm

> Note that 33 taps is fairly restricted and gives only about 32dB of 
> stop band rejection. Not surprisingly, more taps give better results.
>

With the Parks-McClellan Equiripple (aka Remez) algorithm it's possible 
to get more stop band rejection at the expense of increased ripple.  It 
seems the big disadvantage with the results this algorithm gives is that 
the phase response within the passband is always oscillating between 
-180 and 180 deg with every 'ripple' in the amplitude response.  This is 
the case regardless of how many taps you use.

I tried quite a few different combinations of taps, ripple, stop band 
rejection and listened to them as well as looking at the graphs.  In the 
end I settled on one with 9 taps that sounded really nice to my ears.  
Why it sounded nice was probably something to do with the fact that it 
had a gentle amplitude rolloff, but I think more so that in the passband 
there is only 1 'ripple' which means the phase response changes very 
gradually, rather than switching back from -180 to 180 deg 20 or so 
times like it does with higher order filters designed with this algorithm.

The stopband reject I obtained with this 9 tap filter is at least 72dB 
throughout the whole stopband which is more than enough.  This is at the 
expense of having a not very flat passband which is a gently curve 
throughout.  Now this isn't super hi-fi in statistical terms, but it 
actually sounds very nice, and if people want hi-fi flat response they 
can stick to delay times that fit into the available SRAM at 48kHz 
(which is 4 channels of 670ms each).

Here's a pic of the graphs for the filter I ended up using:
http://burnit.co.uk/sdiy/stuff/FIR.gif

Seb





More information about the Synth-diy mailing list