Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

clFilter Class Reference

Class implementing FFT-based FIR-filter with design functions. More...

#include <Filter.hh>

Inheritance diagram for clFilter:

Inheritance graph
[legend]
Collaboration diagram for clFilter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 clFilter ()
 ~clFilter ()
bool Initialize (long, const float *, float=DSP_FILT_DEF_OVERLAPF, float=DSP_FILT_DEF_BETAF, int=FILTER_SMOOTH_DOLPH_CHEBYSHEV)
 Initialize filter.

bool Initialize (long, const double *, double=DSP_FILT_DEF_OVERLAP, double=DSP_FILT_DEF_BETA, int=FILTER_SMOOTH_DOLPH_CHEBYSHEV)
bool InitFloat (long)
bool InitDouble (long)
bool InitializeLP (float, float, float, float=DSP_FILT_DEF_OVERLAPF)
 Initialize low-pass or high-pass filter.

bool InitializeLP (double, double, double, double=DSP_FILT_DEF_OVERLAP)
bool InitializeHP (float, float, float, float=DSP_FILT_DEF_OVERLAPF)
bool InitializeHP (double, double, double, double=DSP_FILT_DEF_OVERLAP)
void Uninitialize ()
 Uninitialize filter.

void SetCoeffs (const float *)
 Set coefficients.

void SetCoeffs (const double *)
void SetCoeffs (const stpSCplx, bool=false)
void SetCoeffs (const stpDCplx, bool=false)
void GetCoeffs (float *)
 Get coefficients.

void GetCoeffs (double *)
void GetCoeffs (stpSCplx)
void GetCoeffs (stpDCplx)
long GetDelay ()
 Get filter delay in samples.

void Put (const float *, long)
 Feed data into filter.

void Put (const double *, long)
void Put (const float *, long, const stpSCplx)
 Feed data into filter using complex coefficients.

void Put (const double *, long, const stpDCplx)
bool Get (float *, long)
 Get data from filter.

bool Get (double *, long)
void DesignLP (float *, bool=false)
 Design low-pass filter.

void DesignLP (double *, bool=false)
void DesignLP (float *, float, bool=false)
void DesignLP (double *, double, bool=false)
void DesignHP (float *)
 Design high-pass filter.

void DesignHP (double *)
void DesignHP (float *, float)
void DesignHP (double *, double)
void DesignBP (float *, float *)
 Design band-pass filter.

void DesignBP (double *, double *)
void DesignBP (float *, float *, float)
void DesignBP (double *, double *, double)
void DesignBR (float *, float *)
 Design band-reject filter.

void DesignBR (double *, double *)
void DesignBR (float *, float *, float)
void DesignBR (double *, double *, double)

Private Member Functions

void InitCoeffsS ()
 Initialize complex coefficients.

void InitCoeffsD ()
void ReadyFilterS ()
 Create complex impulse response from specified frequency response.

void ReadyFilterD ()
float GetKaiserBeta (float fAlpha)
 Calculate beta value for Kaiser window.

double GetKaiserBeta (double dAlpha)

Private Attributes

bool bInitialized
long lFFTSize
long lHalfSize
long lOldSize
long lNewSize
long lSpectPoints
clDSPAlloc CoeffWin
clDSPAlloc Prev
clDSPAlloc Proc
clDSPAlloc CCoeffs
clDSPAlloc CProc
clReBuffer InBuf
clReBuffer OutBuf

Detailed Description

Class implementing FFT-based FIR-filter with design functions.

Filtering is done in complex-plane.

Definition at line 47 of file Filter.hh.


Constructor & Destructor Documentation

clFilter::clFilter  ) 
 

Definition at line 125 of file Filter.cc.

clFilter::~clFilter  ) 
 

Definition at line 131 of file Filter.cc.

References Uninitialize().


Member Function Documentation

void clFilter::InitCoeffsS  )  [private]
 

Initialize complex coefficients.

\[\left\vert\begin{array}{l}\Re_{C}(i)=1\\ \Im_{C}(i)=0\end{array}\right.\]

Definition at line 35 of file Filter.cc.

References CCoeffs, _sSCplx::I, lSpectPoints, _sSCplx::R, ReadyFilterS(), and stpSCplx.

Referenced by Initialize().

void clFilter::InitCoeffsD  )  [private]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 49 of file Filter.cc.

References CCoeffs, _sDCplx::I, lSpectPoints, _sDCplx::R, ReadyFilterD(), and stpDCplx.

Referenced by Initialize().

void clFilter::ReadyFilterS  )  [private]
 

Create complex impulse response from specified frequency response.

This is done by doing $FFT^{-1}(X)$, then multiplying it with desired window function and doing $FFT(x)$.

Definition at line 63 of file Filter.cc.

References CCoeffs, CoeffWin, clDSPOp::FFTi(), clDSPOp::IFFTo(), clDSPOp::Mul(), Proc, and stpSCplx.

Referenced by InitCoeffsS(), and SetCoeffs().

void clFilter::ReadyFilterD  )  [private]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 76 of file Filter.cc.

References CCoeffs, CoeffWin, clDSPOp::FFTi(), clDSPOp::IFFTo(), clDSPOp::Mul(), Proc, and stpDCplx.

Referenced by InitCoeffsD(), and SetCoeffs().

float clFilter::GetKaiserBeta float  fAlpha  )  [private]
 

Calculate beta value for Kaiser window.

\[\beta=\left{\begin{array}{ll}0.1102(\alpha_{s}-8.7)&, \alpha_{s}>50\\ 0.5842(\alpha_{s}-21)^{0.4}+0.07886(\alpha_{s}-21&, 21\leq\alpha_{s}\leq{50}\\ 0&, \alpha_{s}<21\end{array}\right.\]

Parameters:
Alpha Stopband rippleratio in dB
Returns:
Beta for Kaiser window

Definition at line 89 of file Filter.cc.

Referenced by InitializeHP(), and InitializeLP().

double clFilter::GetKaiserBeta double  dAlpha  )  [private]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 107 of file Filter.cc.

bool clFilter::Initialize long  ,
const float *  ,
float  = DSP_FILT_DEF_OVERLAPF,
float  = DSP_FILT_DEF_BETAF,
int  = FILTER_SMOOTH_DOLPH_CHEBYSHEV
 

Initialize filter.

Parameters:
WindowSize Number of FFT points used in filter
FiltCoeffs Optional coefficient vector, can be NULL
Overlap Normalized overlap factor
Beta Optional beta value for window
SmoothWindow Type of smoothing window to use
Returns:
Success

Definition at line 137 of file Filter.cc.

References CCoeffs, CoeffWin, clDSPOp::Convert(), clDSPOp::Copy(), CProc, clDSPOp::FFTInitialize(), FILTER_SMOOTH_DOLPH_CHEBYSHEV, FILTER_SMOOTH_KAISER, FILTER_SMOOTH_KAISER_BESSEL, FILTER_SMOOTH_NONE, InitCoeffsS(), lHalfSize, lNewSize, lOldSize, lSpectPoints, Prev, Proc, clDSPOp::Set(), SetCoeffs(), clAlloc::Size(), stSCplx, Uninitialize(), clDSPOp::WinDolphChebyshev(), clDSPOp::WinKaiser(), clDSPOp::WinKaiserBessel(), and clDSPOp::Zero().

Referenced by InitDouble(), InitFloat(), clFFTMultiRate::Initialize(), InitializeHP(), and InitializeLP().

bool clFilter::Initialize long  ,
const double *  ,
double  = DSP_FILT_DEF_OVERLAP,
double  = DSP_FILT_DEF_BETA,
int  = FILTER_SMOOTH_DOLPH_CHEBYSHEV
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 196 of file Filter.cc.

References CCoeffs, CoeffWin, clDSPOp::Copy(), CProc, clDSPOp::FFTInitialize(), FILTER_SMOOTH_DOLPH_CHEBYSHEV, FILTER_SMOOTH_KAISER, FILTER_SMOOTH_KAISER_BESSEL, FILTER_SMOOTH_NONE, InitCoeffsD(), lHalfSize, lNewSize, lOldSize, lSpectPoints, Prev, Proc, clDSPOp::Set(), SetCoeffs(), clAlloc::Size(), stDCplx, Uninitialize(), clDSPOp::WinDolphChebyshev(), clDSPOp::WinKaiser(), clDSPOp::WinKaiserBessel(), and clDSPOp::Zero().

bool clFilter::InitFloat long   ) 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 251 of file Filter.cc.

References Initialize().

bool clFilter::InitDouble long   ) 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 259 of file Filter.cc.

References Initialize().

bool clFilter::InitializeLP float  ,
float  ,
float  ,
float  = DSP_FILT_DEF_OVERLAPF
 

Initialize low-pass or high-pass filter.

\[N_{o}=\frac{\alpha_{s}-8}{2.285\delta\omega}\]

Parameters:
PassBand Normalized passband
StopBand Normalized stopband
RippleRatio Stopband ripple ratio in dB
Overlap Normalized overlap factor
Returns:
Success

Definition at line 267 of file Filter.cc.

References DesignLP(), FILTER_SMOOTH_KAISER, GetKaiserBeta(), and Initialize().

Referenced by clFFTMultiRate::Initialize().

bool clFilter::InitializeLP double  ,
double  ,
double  ,
double  = DSP_FILT_DEF_OVERLAP
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 295 of file Filter.cc.

References DesignLP(), FILTER_SMOOTH_KAISER, GetKaiserBeta(), and Initialize().

bool clFilter::InitializeHP float  ,
float  ,
float  ,
float  = DSP_FILT_DEF_OVERLAPF
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 323 of file Filter.cc.

References DesignHP(), FILTER_SMOOTH_KAISER, GetKaiserBeta(), and Initialize().

Referenced by clFFTMultiRate::Initialize().

bool clFilter::InitializeHP double  ,
double  ,
double  ,
double  = DSP_FILT_DEF_OVERLAP
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 351 of file Filter.cc.

References DesignHP(), FILTER_SMOOTH_KAISER, GetKaiserBeta(), and Initialize().

void clFilter::Uninitialize  ) 
 

Uninitialize filter.

Definition at line 379 of file Filter.cc.

References CCoeffs, clReBuffer::Clear(), CoeffWin, CProc, clDSPOp::FFTUninitialize(), clAlloc::Free(), InBuf, OutBuf, Prev, and Proc.

Referenced by Initialize(), clFFTMultiRate::Uninitialize(), and ~clFilter().

void clFilter::SetCoeffs const float *   ) 
 

Set coefficients.

You can feed the filter with desired frequency response. Length of this dataset is specified window size / 2 + 1. Filter is then created from this coefficient vector.

Parameters:
FiltCoeffs Coefficients for designing filter
Smooth Smooth filter response using smoothing window

Definition at line 392 of file Filter.cc.

References CCoeffs, _sSCplx::I, lSpectPoints, _sSCplx::R, ReadyFilterS(), and stpSCplx.

Referenced by DesignBP(), DesignBR(), DesignHP(), DesignLP(), and Initialize().

void clFilter::SetCoeffs const double *   ) 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 406 of file Filter.cc.

References CCoeffs, _sDCplx::I, lSpectPoints, _sDCplx::R, ReadyFilterD(), and stpDCplx.

void clFilter::SetCoeffs const  stpSCplx,
bool  = false
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 420 of file Filter.cc.

References CCoeffs, clDSPOp::Copy(), lSpectPoints, ReadyFilterS(), and stpSCplx.

void clFilter::SetCoeffs const  stpDCplx,
bool  = false
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 429 of file Filter.cc.

References CCoeffs, clDSPOp::Copy(), lSpectPoints, ReadyFilterD(), and stpDCplx.

void clFilter::GetCoeffs float *   ) 
 

Get coefficients.

Get filter's frequency response.

Parameters:
FiltCoeffs Filter coefficients

Definition at line 438 of file Filter.cc.

References CCoeffs, lSpectPoints, _sSCplx::R, and stpSCplx.

void clFilter::GetCoeffs double *   ) 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 450 of file Filter.cc.

References CCoeffs, lSpectPoints, _sDCplx::R, and stpDCplx.

void clFilter::GetCoeffs stpSCplx   ) 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 462 of file Filter.cc.

References CCoeffs, clDSPOp::Copy(), lSpectPoints, and stpSCplx.

void clFilter::GetCoeffs stpDCplx   ) 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 470 of file Filter.cc.

References CCoeffs, clDSPOp::Copy(), lSpectPoints, and stpDCplx.

long clFilter::GetDelay  ) 
 

Get filter delay in samples.

Delay caused by the filter in number of samples.

Returns:
Delay (in samples)

Definition at line 478 of file Filter.cc.

References lOldSize.

void clFilter::Put const float *  ,
long 
 

Feed data into filter.

Filtering is done by first doing $FFT(x)$, then doing complex multiply with complex impulse response, and finally doing $FFT^{-1}(X)$. Windows overlap with specified overlap factor and 1 - overlap factor of window length is used.

Parameters:
SrcData Source data
SrcCount Source data count

Definition at line 484 of file Filter.cc.

References CCoeffs, clDSPOp::Copy(), CProc, clDSPOp::FFTi(), clReBuffer::Get(), clDSPOp::IFFTo(), InBuf, lNewSize, lOldSize, lSpectPoints, clDSPOp::Mul(), OutBuf, Prev, Proc, clReBuffer::Put(), and stpSCplx.

Referenced by clFFTInterpolator::Put(), and clFFTDecimator::Put().

void clFilter::Put const double *  ,
long 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 506 of file Filter.cc.

References CCoeffs, clDSPOp::Copy(), CProc, clDSPOp::FFTi(), clReBuffer::Get(), clDSPOp::IFFTo(), InBuf, lNewSize, lOldSize, lSpectPoints, clDSPOp::Mul(), OutBuf, Prev, Proc, clReBuffer::Put(), and stpDCplx.

void clFilter::Put const float *  ,
long  ,
const  stpSCplx
 

Feed data into filter using complex coefficients.

Parameters:
SrcData Source data
SrcCount Source data count
Coeffs Complex coefficients

Definition at line 528 of file Filter.cc.

References clDSPOp::Copy(), CProc, clDSPOp::FFTi(), clReBuffer::Get(), clDSPOp::IFFTo(), InBuf, lNewSize, lOldSize, lSpectPoints, clDSPOp::Mul(), OutBuf, Prev, Proc, clReBuffer::Put(), and stpSCplx.

void clFilter::Put const double *  ,
long  ,
const  stpDCplx
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 550 of file Filter.cc.

References clDSPOp::Copy(), CProc, clDSPOp::FFTi(), clReBuffer::Get(), clDSPOp::IFFTo(), InBuf, lNewSize, lOldSize, lSpectPoints, clDSPOp::Mul(), OutBuf, Prev, Proc, clReBuffer::Put(), and stpDCplx.

bool clFilter::Get float *  ,
long 
 

Get data from filter.

Parameters:
DestData Destination buffer
DestCount Number of samples
Returns:
Data was available?

Definition at line 572 of file Filter.cc.

References clReBuffer::Get(), and OutBuf.

Referenced by clFFTInterpolator::Get(), and clFFTDecimator::Get().

bool clFilter::Get double *  ,
long 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 578 of file Filter.cc.

References clReBuffer::Get(), and OutBuf.

void clFilter::DesignLP float *  ,
bool  = false
 

Design low-pass filter.

Parameters:
Corner Corner frequency
SampleRate Sampling frequency
DCBlock Include DC-blocking

Definition at line 584 of file Filter.cc.

References lSpectPoints, clDSPOp::Set(), SetCoeffs(), and clDSPOp::Zero().

Referenced by DesignLP(), clFFTMultiRate::Initialize(), and InitializeLP().

void clFilter::DesignLP double *  ,
bool  = false
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 600 of file Filter.cc.

References lSpectPoints, clDSPOp::Set(), SetCoeffs(), and clDSPOp::Zero().

void clFilter::DesignLP float *  ,
float  ,
bool  = false
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 616 of file Filter.cc.

References DesignLP().

void clFilter::DesignLP double *  ,
double  ,
bool  = false
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 628 of file Filter.cc.

References DesignLP().

void clFilter::DesignHP float *   ) 
 

Design high-pass filter.

Definition at line 640 of file Filter.cc.

References lSpectPoints, clDSPOp::Set(), SetCoeffs(), and clDSPOp::Zero().

Referenced by DesignHP(), clFFTMultiRate::Initialize(), and InitializeHP().

void clFilter::DesignHP double *   ) 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 655 of file Filter.cc.

References lSpectPoints, clDSPOp::Set(), SetCoeffs(), and clDSPOp::Zero().

void clFilter::DesignHP float *  ,
float 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 670 of file Filter.cc.

References DesignHP().

void clFilter::DesignHP double *  ,
double 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 682 of file Filter.cc.

References DesignHP().

void clFilter::DesignBP float *  ,
float * 
 

Design band-pass filter.

Parameters:
LowCorner Lower corner frequency
HighCorner Higher corner frequency
SampleRate Sampling frequency

Definition at line 694 of file Filter.cc.

References lSpectPoints, clDSPOp::Set(), SetCoeffs(), and clDSPOp::Zero().

Referenced by DesignBP().

void clFilter::DesignBP double *  ,
double * 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 712 of file Filter.cc.

References lSpectPoints, clDSPOp::Set(), SetCoeffs(), and clDSPOp::Zero().

void clFilter::DesignBP float *  ,
float *  ,
float 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 730 of file Filter.cc.

References DesignBP().

void clFilter::DesignBP double *  ,
double *  ,
double 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 746 of file Filter.cc.

References DesignBP().

void clFilter::DesignBR float *  ,
float * 
 

Design band-reject filter.

Definition at line 762 of file Filter.cc.

References lSpectPoints, clDSPOp::Set(), SetCoeffs(), and clDSPOp::Zero().

Referenced by DesignBR().

void clFilter::DesignBR double *  ,
double * 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 780 of file Filter.cc.

References lSpectPoints, clDSPOp::Set(), SetCoeffs(), and clDSPOp::Zero().

void clFilter::DesignBR float *  ,
float *  ,
float 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 798 of file Filter.cc.

References DesignBR().

void clFilter::DesignBR double *  ,
double *  ,
double 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 814 of file Filter.cc.

References DesignBR().


Member Data Documentation

bool clFilter::bInitialized [private]
 

Definition at line 49 of file Filter.hh.

long clFilter::lFFTSize [private]
 

Definition at line 50 of file Filter.hh.

long clFilter::lHalfSize [private]
 

Definition at line 51 of file Filter.hh.

Referenced by Initialize().

long clFilter::lOldSize [private]
 

Definition at line 52 of file Filter.hh.

Referenced by GetDelay(), Initialize(), and Put().

long clFilter::lNewSize [private]
 

Definition at line 53 of file Filter.hh.

Referenced by Initialize(), and Put().

long clFilter::lSpectPoints [private]
 

Definition at line 54 of file Filter.hh.

Referenced by DesignBP(), DesignBR(), DesignHP(), DesignLP(), GetCoeffs(), InitCoeffsD(), InitCoeffsS(), Initialize(), Put(), and SetCoeffs().

clDSPAlloc clFilter::CoeffWin [private]
 

Definition at line 55 of file Filter.hh.

Referenced by Initialize(), ReadyFilterD(), ReadyFilterS(), and Uninitialize().

clDSPAlloc clFilter::Prev [private]
 

Definition at line 56 of file Filter.hh.

Referenced by Initialize(), Put(), and Uninitialize().

clDSPAlloc clFilter::Proc [private]
 

Definition at line 57 of file Filter.hh.

Referenced by Initialize(), Put(), ReadyFilterD(), ReadyFilterS(), and Uninitialize().

clDSPAlloc clFilter::CCoeffs [private]
 

Definition at line 58 of file Filter.hh.

Referenced by GetCoeffs(), InitCoeffsD(), InitCoeffsS(), Initialize(), Put(), ReadyFilterD(), ReadyFilterS(), SetCoeffs(), and Uninitialize().

clDSPAlloc clFilter::CProc [private]
 

Definition at line 59 of file Filter.hh.

Referenced by Initialize(), Put(), and Uninitialize().

clReBuffer clFilter::InBuf [private]
 

Definition at line 60 of file Filter.hh.

Referenced by Put(), and Uninitialize().

clReBuffer clFilter::OutBuf [private]
 

Definition at line 61 of file Filter.hh.

Referenced by Get(), Put(), and Uninitialize().


The documentation for this class was generated from the following files:
Generated on Tue Mar 2 19:47:09 2004 for libDSP by doxygen 1.3.6