Advertisement

Single-Pole Digital Filter

Started by March 29, 2002 02:53 PM
5 comments, last by Shannon Barber 22 years, 10 months ago
Is the correct formula for sigle-pole filter: factor = e^( -2 * pi * fc * dt) or factor = e^( -2 * fc * dt) ? ifactor = 1 - factor; (where filterSample = newSample*factor + lastSample*ifactor) I wanted to verify the algorithm that our low-pass filter is using. Also, should the last sample be the last raw sample, or the last filtered sample? I also wanted to look into coding up a high-order filter, for a sharper cut-off. Could anyone recommend any books? I''ve read some of Numerical Recipes, but found the example code atrocious and the explanation of theory lacking - though it seems to be a very practical treatise on the topic. I appreciate any help, or even a link to a relavent webpage. (I''ve had amazing difficulty finding any equations on the web for simple DSP functions. There''s lots & lots talk about using filters, but not much on how to implement them.) Magmai Kai Holmlor "Oh, like you''ve never written buggy code" - Lee
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
I know this isn''t exactly the response you were waiting for, but now I''m really curious... what is a Single-Pole Filter?

--------------------
Matthew Calabrese
Realtime 3D Orchestra:
Programmer, Composer,
and 3D Artist/Animator
"I can see the music..."
Advertisement
Your filter certainly has a single pole, given that you only have one exponential term. That I know from classical control theory. But I haven''t really used digital filters so I can''t answer your full question.

You may want to look into MATLAB (www.mathworks.com) or one of the free MATLAB clones. MATLAB is *heavily* used in the engineering world for situations that require digital filtering. It could be used for example to perform simulations of a DSP chip design prior to actually manufacturing test chips. And for DSP algorithm design, which is what you want.

I did find an interesting site. Perhaps you''ve seen it too? It has tutorials (with code samples), plus links to reference material and codes.

www.dspguru.com
www.dspguru.com/sw/opendsp/mathclo.htm

This site seems to have quite a bit of information of use to you. There are a few MATLAB clones here, such as Octave for which source code is available. The source code and documentation may be useful to help you implement different types of filters. There''s a lot of stuff on Fourier Transforms (FFT, DFT, etc.) in there.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Thanks for the link grhodes, I''ll check it out.

quote:
Original post by Matt Calabrese
I know this isn''t exactly the response you were waiting for, but now I''m really curious... what is a Single-Pole Filter?


A computationally inexpensive, FIR(finite impulse response) digital filter, good for smoothing out temperature readings and frame-rates with better responsiveness than block-averaging or or even a rolling-average.

The formula I posted is for a single-pole low-pass filter, kinda like turing down the trebble on a cheap radio. It think Dolby-Noise-Reduction is a low-pass multi-tap (more than one pole) FIR. More taps/orders gives better responsiveness (important for high sampling rates, like audio) at the expense of calculation, thus latency.

And I guess, to further complicate things, all such filters can be implemented with an analog circuit (DNR most likely is), or a digital algorithm, again like the formula I posted.

Filters can be:
Analog or digital
Finite or Infinite Impulse response (FIR/IIR)
Low-Pass (DNR, trebble down), High-Pass (bass down), Band-pass, Band-stop, or notch*.
Single-Tap or Mutli-Tap


*Low pass lets lower frequencies pass unaffected, high pass lets higher frequencies pass unaffected, band-pass lets a range pass unaffected, band-stop blocks that range, and notch blocks a discrete frequency. Now in reality, none of the filters are perfect, and leak around the edges of their target frequencies, and back to normal, this is called thier responsiveness. Every aspect of filtering involves trade-offs. Digital filters are very responsive, but analog filter have tremendous dynamic range.

I''m hardly an expert on DSP, so all that information may not be entirely correct (in fact I''d wagor against it).
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
quote:
Original post by Magmai Kai Holmlor
Is the correct formula for sigle-pole filter:
factor = e^( -2 * pi * f<sub>c</sub> * dt)
or
factor = e^( -2 * f<sub>c</sub> * dt)
?
ifactor = 1 - factor;
(where filterSample = newSample*factor + lastSample*ifactor)

I wanted to verify the algorithm that our low-pass filter is using. Also, should the last sample be the last raw sample, or the last filtered sample?
I also wanted to look into coding up a high-order filter, for a sharper cut-off.




If you use the last sample you get a one-zero filter, when you use the last filtered sample (feedback) you get a one-pole filter. There is no way to control cutoff frequency this way, you can only control how strong the effect is with the factor variable.
The form ifactor = 1 - factor is what I use, and also keeps the output within bounds. This filter for instance is used in the simplest form of the Karplus-Strong plucked string algorithm.

Here is a simple two-pole filter (resonator):
y(n) = a0 * x(n) - b1 * y(n-1) - b2 * y(n-2)
where x is input, y is output.
approximate bandwith: R = e^(bandwidth in radians)
cutoff frequency: b1 = -2 * R * cos(frequency in radians)
and b2 = R * R
a0 is a scale factor to scale the output.

Hope this helps sowewhat, as I never posted here before, I hope this is readable...
approximate bandwidth should be: R = e ^ -bandwidth
Advertisement
quote:
Original post by Anonymous Poster
Hope this helps sowewhat, as I never posted here before, I hope this is readable...

It does, thanks!
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement