AudiClean
|
#include <Fir1.h>
Public Member Functions | |
template<unsigned nTaps> | |
Fir1 (const double(&_coefficients)[nTaps]) | |
Fir1 (std::vector< double > _coefficients) | |
Fir1 (double *coefficients, unsigned number_of_taps) | |
Fir1 (const char *coeffFile, unsigned number_of_taps=0) | |
Fir1 (unsigned number_of_taps) | |
~Fir1 () | |
double | filter (double input) |
void | lms_update (double error) |
void | setLearningRate (double _mu) |
double | getLearningRate () |
void | reset () |
void | zeroCoeff () |
void | getCoeff (double *coeff_data, unsigned number_of_taps) const |
std::vector< double > | getCoeffVector () const |
unsigned | getTaps () |
double | getTapInputPower () |
Finite impulse response filter. The precision is double. It takes as an input a file with coefficients or an double array.
|
inline |
Coefficients as a const double array. Because the array is const the number of taps is identical to the length of the array.
_coefficients | A const double array with the impulse response. |
|
inline |
Coefficients as a C++ vector
_coefficients | is a Vector of doubles. |
Fir1::Fir1 | ( | double * | _coefficients, |
unsigned | number_of_taps | ||
) |
Coefficients as a (non-constant-) double array where the length needs to be specified.
coefficients | Coefficients as double array. |
number_of_taps | Number of taps (needs to match the number of coefficients |
Initialise the filter from coefficients, assigned as array
_coefficients | coeffs to be assigned |
number_of_taps | nr of taps (array length) |
Fir1::Fir1 | ( | const char * | coeffFile, |
unsigned | number_of_taps = 0 |
||
) |
Coefficients as a text file (for example from Python) The number of taps is automatically detected when the taps are kept zero.
coeffFile | Patht to textfile where every line contains one coefficient |
number_of_taps | Number of taps (0 = autodetect) |
Initialise the filter coefficients with a text file where each line is has one coefficient
coeffFile | text file for initialisation |
number_of_taps | nr of fiter taps (order) |
Fir1::Fir1 | ( | unsigned | number_of_taps | ) |
Inits all coefficients and the buffer to zero
This is useful for adaptive filters where we start with zero valued coefficients.
Initalise the filter with empty coefficients
number_of_taps | nr of taps (filter order) |
Fir1::~Fir1 | ( | ) |
Releases the coefficients and buffer.
Filter destructor
|
inline |
The actual filter function operation: it receives one sample and returns one sample.
input | The input sample. |
void Fir1::getCoeff | ( | double * | coeff_data, |
unsigned | number_of_taps | ||
) | const |
Copies the current filter coefficients into a provided array. Useful after an adaptive filter has been trained to query the result of its training.
coeff_data | target where coefficients are copied |
number_of_taps | number of doubles to be copied |
std::out_of_range | number_of_taps is less the actual number of taps. |
Copies a coeffs to coeff_data array
coeff_data | |
number_of_taps |
|
inline |
Returns the coefficients as a vector
|
inline |
Getting the learning rate for the adaptive filter.
|
inline |
Returns the power of the of the buffer content:
sum_k buffer[k]^2 which is needed to implement a normalised LMS algorithm.
|
inline |
Returns the number of taps.
|
inline |
LMS adaptive filter weight update:
Every filter coefficient is updated with: w_k(n+1) = w_k(n) + learning_rate * buffer_k(n) * error(n)
error | Is the term error(n), the error which adjusts the FIR conefficients. |
void Fir1::reset | ( | ) |
Resets the buffer (but not the coefficients)
sets all tap outputs to zero
|
inline |
Setting the learning rate for the adaptive filter.
_mu | The learning rate (i.e. rate of the change by the error signal) |
void Fir1::zeroCoeff | ( | ) |
Sets all coefficients to zero
Sets all coeffs to zero