#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) |
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.
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.
BandGains | Array of linear gain levels, count=BandCount specified in the init() function. | |
[out] | Filter | Output filter buffer, length = getFilterLength(). |
|
static |
Function calculates filter's length (in samples) and latency depending on the required non-truncated filter length.
aFilterLength | Required filter length in samples (non-truncated). | |
[out] | Latency | Resulting latency (group delay) of the filter, in samples (taps). |
int avir::CDSPFIREQ::getFilterLatency | ( | ) | const |
int avir::CDSPFIREQ::getFilterLength | ( | ) | const |
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.
SampleRate | Processing sample rate (use 2 for image processing). |
aFilterLength | Required filter length in samples (taps). The actual filter length is truncated to an integer value. |
aBandCount | Number of band crossover points required to control, including bands at MinFreq and MaxFreq. |
MinFreq | Minimal frequency that should be controlled. |
MaxFreq | Maximal frequency that should be controlled. |
IsLogBands | "True" if the bands should be spaced logarithmically. |
WFAlpha | Peaked Cosine window function's Alpha parameter. |