AVIR
High-quality pro image resizing library
 All Classes Files Functions Variables Typedefs Macros
Public Member Functions | Static Public Member Functions | List of all members
avir::CDSPFIREQ Class Reference

#include <avir.h>

Public Member Functions

void buildFilter (const double *const BandGains, double *const Filter)
 
int getFilterLatency () const
 
int getFilterLength () const
 
void init (const double SampleRate, const double aFilterLength, const int aBandCount, const double MinFreq, const double MaxFreq, const bool IsLogBands, const double WFAlpha)
 

Static Public Member Functions

static int calcFilterLength (const double aFilterLength, int &Latency)
 

Detailed Description

FIR filter-based equalizer generator.

Class implements an object used to generate symmetric-odd FIR filters with the specified frequency response (aka paragraphic equalizer). The calculated filter is windowed by the Peaked Cosine window function.

In image processing, due to short length of filters being used (6-8 taps) the resulting frequency response of the filter is approximate and may be mathematically imperfect, but still adequate to the visual requirements.

On a side note, this equalizer generator can be successfully used for audio signal equalization as well: for example, it is used in almost the same form in Voxengo Marvel GEQ equalizer plug-in.

Filter generation is based on decomposition of frequency range into spectral bands, with each band represented by linear and ramp "kernels". When the filter is built, these kernels are combined together with different weights that approximate the required frequency response.

Member Function Documentation

void avir::CDSPFIREQ::buildFilter ( const double *const  BandGains,
double *const  Filter 
)

Function creates symmetric-odd FIR filter with the specified gain levels at band crossover points.

Parameters
BandGainsArray of linear gain levels, count=BandCount specified in the init() function.
[out]FilterOutput filter buffer, length = getFilterLength().
static int avir::CDSPFIREQ::calcFilterLength ( const double  aFilterLength,
int &  Latency 
)
static

Function calculates filter's length (in samples) and latency depending on the required non-truncated filter length.

Parameters
aFilterLengthRequired filter length in samples (non-truncated).
[out]LatencyResulting latency (group delay) of the filter, in samples (taps).
Returns
Filter length in samples (taps).
int avir::CDSPFIREQ::getFilterLatency ( ) const
Returns
Filter's latency (group delay), in samples (taps).
int avir::CDSPFIREQ::getFilterLength ( ) const
Returns
Filter's length, in samples (taps).
void avir::CDSPFIREQ::init ( const double  SampleRate,
const double  aFilterLength,
const int  aBandCount,
const double  MinFreq,
const double  MaxFreq,
const bool  IsLogBands,
const double  WFAlpha 
)

Function initializes *this object with the required parameters. The gain of frequencies beyond the MinFreq..MaxFreq range are controlled by the first and the last band's gain.

Parameters
SampleRateProcessing sample rate (use 2 for image processing).
aFilterLengthRequired filter length in samples (taps). The actual filter length is truncated to an integer value.
aBandCountNumber of band crossover points required to control, including bands at MinFreq and MaxFreq.
MinFreqMinimal frequency that should be controlled.
MaxFreqMaximal frequency that should be controlled.
IsLogBands"True" if the bands should be spaced logarithmically.
WFAlphaPeaked Cosine window function's Alpha parameter.