Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

pp::Filters::ButterworthFilter Class Template Reference

Here's a bit from an article by Arun Chandra at: http://ems.music.uiuc.edu/news/fall94/news.html. More...

#include <Filters.h>

Inheritance diagram for pp::Filters::ButterworthFilter

Inheritance graph
[legend]
Collaboration diagram for pp::Filters::ButterworthFilter:

Collaboration graph
[legend]
List of all members.

Public Methods

 ButterworthFilter (float a1=0.5f, float a2=0.5f, float a3=0.5f, float b1=0.5f, float b2=0.5f)
void SetNotchCoefficients (int fc, int sr, float r)
void SetLowPassCoefficients (int fc, int sr)
void SetBandPassCoefficients (int fc, int sr, int bw)
 But for a band-pass filter, the coefficients are:
void SetFastBandpassCoefficients (int fc, int sr, float r)
virtual const char* GetName () const
void SetCoefficients (float a1, float a2, float a3, float b1, float b2)
void GetCoefficients (float& a1, float& a2, float& a3, float& b1, float& b2) const
float GetA1 () const
float GetA2 () const
float GetA3 () const
float GetB1 () const
float GetB2 () const
void SetA1 (float a1)
void SetA2 (float a2)
void SetA3 (float a3)
void SetB1 (float b1)
void SetB2 (float b2)
operator() (const T& x)
double FrequencyResponse (float f)

Detailed Description

template<typename T = short> template class pp::Filters::ButterworthFilter

Here's a bit from an article by Arun Chandra at: http://ems.music.uiuc.edu/news/fall94/news.html.

         An intriguing aspect of Butterworth filters is that merely by 
         changing the coefficients, you can change the behavior of the 
         filter from low-pass to high-pass to band-pass to band-reject. 
         All Butterworth filters use the following algorithm: 

         y(n) = a1*x(n) + a2*x(n-1) + a3*x(n-2) - b1*y(n-1) - b2*y(n-2) 

         As you can see, this filter has two input taps x(n-1) and x(n-2), 
         and two output taps y(n-1) and y(n-2). To get a low-pass filter, 
         the coefficients a1, a2, a3, b1, b2 are calculated thusly: 

         fc = cutoff frequency 
         sr = sample rate
         C  = tan(pi*fc/sr) 
         a1 = 1 / (1 + sqrt(2)*C + C*C) 
         a2 = 2*a1 
         a3 = a1 
         b1 = 2 * (1 - C*C) * a1 
         b2 = (1 - sqrt(2)*C + C*C) * a1 


         But for a band-pass filter, the coefficients are: 

         fc = center frequency 
         sr = sample rate
         bw = band width 
         
         C = 1 / tan(pi*bw/sr)
         D = 2 * cos(2*pi*fc/sr)
         a1 = pow((1+C), -1);
         a2 = 0 
         a3 = -a1 
         b1 = -C * D * a1 
         b2 = (C - 1) * a1 
         

The frequency response is given by (a1*cos(2*pi*df)+a2*cos(2*2*df)+a3*cos(2*3*df))/(1-b1*cos(2*pi*f)-b2*cos(2*2*pi*f))


Member Function Documentation

template<typenameT = short>
void pp::Filters::ButterworthFilter<T>::SetBandPassCoefficients ( int fc,
int sr,
int bw ) [inline]
 

But for a band-pass filter, the coefficients are:

.

fc = center frequency sr = sample rate bw = band width

C = 1 / tan(pi*bw/sr) D = 2 * cos(2*pi*fc/sr) a1 = pow((1+C), -1); a2 = 0 a3 = -a1 b1 = -C * D * a1 b2 = (C - 1) * a1 \endverbatim


The documentation for this class was generated from the following file:
Generated at Mon Nov 27 01:46:39 2000 for LibPenguinPlay by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000