r8brain-free-src
High-quality pro audio sample rate converter library
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
r8b::CDSPSincFilterGen Class Reference

Sinc function-based FIR filter generator class. More...

#include <CDSPSincFilterGen.h>

Public Types

typedef double(CDSPSincFilterGen ::* CWindowFunc) ()
 Window calculation function pointer type.
 
enum  EWindowFunctionType { wftCosine , wftKaiser , wftGaussian }
 

Public Member Functions

double calcWindowBlackman ()
 
double calcWindowBlackmanNuttall ()
 
double calcWindowGaussian ()
 
double calcWindowHamming ()
 
double calcWindowHann ()
 
double calcWindowKaiser ()
 
double calcWindowNuttall ()
 
void generateBand (double *op, CWindowFunc wfunc=&CDSPSincFilterGen ::calcWindowBlackman)
 
void generateFrac (double *op, CWindowFunc wfunc=&CDSPSincFilterGen ::calcWindowBlackman, const int opinc=1)
 
void generateHilbert (double *op, CWindowFunc wfunc=&CDSPSincFilterGen ::calcWindowBlackman)
 
void generateWindow (double *op, CWindowFunc wfunc=&CDSPSincFilterGen ::calcWindowBlackman)
 
void initBand (const EWindowFunctionType WinType=wftCosine, const double *const Params=NULL, const bool UsePower=false)
 
void initFrac (const EWindowFunctionType WinType=wftCosine, const double *const Params=NULL, const bool UsePower=false)
 
void initHilbert (const EWindowFunctionType WinType=wftCosine, const double *const Params=NULL, const bool UsePower=false)
 
void initWindow (const EWindowFunctionType WinType=wftCosine, const double *const Params=NULL, const bool UsePower=false)
 

Public Attributes

union {
   struct {
      double   Freq1
 Required corner circular frequency 1 [0; pi]. Used only in the generateBand() function.
 
      double   Freq2
 Required corner circular frequency 2 [0; pi]. Used only in the generateBand() function. The range [Freq1; Freq2] defines a pass band for the generateBand() function.
 
   } 
 
   struct {
      double   FracDelay
 Fractional delay in the range [0; 1], used only in the generateFrac() function. Note that the FracDelay parameter is actually inversed. At 0.0 value it produces 1 sample delay (with the latency equal to fl2), at 1.0 value it produces 0 sample delay (with the latency equal to fl2 - 1).
 
   } 
 
}; 
 
int fl2
 Internal "half kernel length" value. This value can be used as filter's latency in samples (taps), this variable is set after the call to one of the "init" functions.
 
int KernelLen
 Resulting length of the filter kernel, this variable is set after the call to one of the "init" functions.
 
double Len2
 Required half filter kernel's length in samples (can be a fractional value). Final physical kernel length will be provided in the KernelLen variable. Len2 should be >= 2.
 
double Len2i
 = 1.0 / Len2, initialized and used by some window functions for optimization (should not be initialized by the caller).
 
double GaussianSigmaFrac
 Equals FracDelay / GaussianSigma.
 
double GaussianSigmaI
 Gaussian window function's "Sigma" coefficient, inverse.
 
double KaiserBeta
 Kaiser window function's "Beta" coefficient.
 
double KaiserLen2Frac
 Equals FracDelay / Len2.
 
double KaiserMul
 Kaiser window function's divisor, inverse.
 

Detailed Description

Sinc function-based FIR filter generator class.

Structure that holds state used to perform generation of sinc functions of various types, windowed by the Blackman window by default (but the window function can be changed if necessary).

Member Enumeration Documentation

◆ EWindowFunctionType

Window function type.

Enumerator
wftCosine 

Generalized cosine window function. No parameters required. The "Power" parameter is optional.

wftKaiser 

Kaiser window function. Requires the "Beta" parameter. The "Power" parameter is optional.

wftGaussian 

Gaussian window function. Requires the "Sigma" parameter. The "Power" parameter is optional.

Member Function Documentation

◆ calcWindowBlackman()

double r8b::CDSPSincFilterGen::calcWindowBlackman ( )
Returns
The next "Blackman" window function coefficient.

◆ calcWindowBlackmanNuttall()

double r8b::CDSPSincFilterGen::calcWindowBlackmanNuttall ( )
Returns
The next "Blackman-Nuttall" window function coefficient.

◆ calcWindowGaussian()

double r8b::CDSPSincFilterGen::calcWindowGaussian ( )
Returns
The next "Gaussian" window function coefficient.

◆ calcWindowHamming()

double r8b::CDSPSincFilterGen::calcWindowHamming ( )
Returns
The next "Hamming" window function coefficient.

◆ calcWindowHann()

double r8b::CDSPSincFilterGen::calcWindowHann ( )
Returns
The next "Hann" window function coefficient.

◆ calcWindowKaiser()

double r8b::CDSPSincFilterGen::calcWindowKaiser ( )
Returns
The next "Kaiser" window function coefficient.

◆ calcWindowNuttall()

double r8b::CDSPSincFilterGen::calcWindowNuttall ( )
Returns
The next "Nuttall" window function coefficient.

◆ generateBand()

void r8b::CDSPSincFilterGen::generateBand ( double *  op,
CWindowFunc  wfunc = &CDSPSincFilterGen :: calcWindowBlackman 
)

Function calculates band-limited windowed sinc function-based filter kernel.

Parameters
[out]opOutput buffer, length = KernelLen.
wfuncWindow calculation function to use.

◆ generateFrac()

void r8b::CDSPSincFilterGen::generateFrac ( double *  op,
CWindowFunc  wfunc = &CDSPSincFilterGen :: calcWindowBlackman,
const int  opinc = 1 
)

Function calculates windowed fractional delay filter kernel.

Parameters
[out]opOutput buffer, length = KernelLen.
wfuncWindow calculation function to use.
opincOutput buffer increment, in "op" elements.

◆ generateHilbert()

void r8b::CDSPSincFilterGen::generateHilbert ( double *  op,
CWindowFunc  wfunc = &CDSPSincFilterGen :: calcWindowBlackman 
)

Function calculates windowed Hilbert transformer filter kernel.

Parameters
[out]opOutput buffer, length = KernelLen.
wfuncWindow calculation function to use.

◆ generateWindow()

void r8b::CDSPSincFilterGen::generateWindow ( double *  op,
CWindowFunc  wfunc = &CDSPSincFilterGen :: calcWindowBlackman 
)

Function calculates window function only.

Parameters
[out]opOutput buffer, length = KernelLen.
wfuncWindow calculation function to use.

◆ initBand()

void r8b::CDSPSincFilterGen::initBand ( const EWindowFunctionType  WinType = wftCosine,
const double *const  Params = NULL,
const bool  UsePower = false 
)

Function initializes *this structure for generation of band-limited sinc filter kernel. The generateBand() function should be used to calculate the filter.

Parameters
WinTypeWindow function type.
ParamsWindow function's parameters. If NULL, the table values may be used.
UsePower"True" if the power factor should be used to raise the window function. If "true", the power factor should be specified as the last value in the Params array. If Params is NULL, the table or default value of -1.0 (off) will be used.

◆ initFrac()

void r8b::CDSPSincFilterGen::initFrac ( const EWindowFunctionType  WinType = wftCosine,
const double *const  Params = NULL,
const bool  UsePower = false 
)

Function initializes *this structure for generation of full-bandwidth fractional delay sinc filter kernel. Freq1 and Freq2 variables are not used. The generateFrac() function should be used to calculate the filter.

Parameters
WinTypeWindow function type.
ParamsWindow function's parameters. If NULL, the table values may be used.
UsePower"True" if the power factor should be used to raise the window function. If "true", the power factor should be specified as the last value in the Params array. If Params is NULL, the table or default value of -1.0 (off) will be used.

◆ initHilbert()

void r8b::CDSPSincFilterGen::initHilbert ( const EWindowFunctionType  WinType = wftCosine,
const double *const  Params = NULL,
const bool  UsePower = false 
)

Function initializes *this structure for Hilbert transformation filter calculation. Freq1 and Freq2 variables are not used. The generateHilbert() function should be used to calculate the filter.

Parameters
WinTypeWindow function type.
ParamsWindow function's parameters. If NULL, the table values may be used.
UsePower"True" if the power factor should be used to raise the window function. If "true", the power factor should be specified as the last value in the Params array. If Params is NULL, the table or default value of -1.0 (off) will be used.

◆ initWindow()

void r8b::CDSPSincFilterGen::initWindow ( const EWindowFunctionType  WinType = wftCosine,
const double *const  Params = NULL,
const bool  UsePower = false 
)

Function initializes *this structure for generation of a window function, odd-sized.

Parameters
WinTypeWindow function type.
ParamsWindow function's parameters. If NULL, the table values may be used.
UsePower"True" if the power factor should be used to raise the window function. If "true", the power factor should be specified as the last value in the Params array. If Params is NULL, the table or default value of -1.0 (off) will be used.