![]() |
r8brain-free-src
High-quality pro audio sample rate converter library
|
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. | |
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).
Window function type.
double r8b::CDSPSincFilterGen::calcWindowBlackman | ( | ) |
double r8b::CDSPSincFilterGen::calcWindowBlackmanNuttall | ( | ) |
double r8b::CDSPSincFilterGen::calcWindowGaussian | ( | ) |
double r8b::CDSPSincFilterGen::calcWindowHamming | ( | ) |
double r8b::CDSPSincFilterGen::calcWindowHann | ( | ) |
double r8b::CDSPSincFilterGen::calcWindowKaiser | ( | ) |
double r8b::CDSPSincFilterGen::calcWindowNuttall | ( | ) |
void r8b::CDSPSincFilterGen::generateBand | ( | double * | op, |
CWindowFunc | wfunc = &CDSPSincFilterGen :: calcWindowBlackman |
||
) |
Function calculates band-limited windowed sinc function-based filter kernel.
[out] | op | Output buffer, length = KernelLen. |
wfunc | Window calculation function to use. |
void r8b::CDSPSincFilterGen::generateFrac | ( | double * | op, |
CWindowFunc | wfunc = &CDSPSincFilterGen :: calcWindowBlackman , |
||
const int | opinc = 1 |
||
) |
Function calculates windowed fractional delay filter kernel.
[out] | op | Output buffer, length = KernelLen. |
wfunc | Window calculation function to use. | |
opinc | Output buffer increment, in "op" elements. |
void r8b::CDSPSincFilterGen::generateHilbert | ( | double * | op, |
CWindowFunc | wfunc = &CDSPSincFilterGen :: calcWindowBlackman |
||
) |
Function calculates windowed Hilbert transformer filter kernel.
[out] | op | Output buffer, length = KernelLen. |
wfunc | Window calculation function to use. |
void r8b::CDSPSincFilterGen::generateWindow | ( | double * | op, |
CWindowFunc | wfunc = &CDSPSincFilterGen :: calcWindowBlackman |
||
) |
Function calculates window function only.
[out] | op | Output buffer, length = KernelLen. |
wfunc | Window calculation function to use. |
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.
WinType | Window function type. |
Params | Window 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. |
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.
WinType | Window function type. |
Params | Window 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. |
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.
WinType | Window function type. |
Params | Window 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. |
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.
WinType | Window function type. |
Params | Window 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. |