Skip to content

Commit

Permalink
Added option to set all coeff to non-zero value
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernd Porr committed Apr 9, 2024
1 parent d2f1982 commit af90404
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions Fir1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ THE SOFTWARE.
*/

/* (C) 2013 Graeme Hattan & Bernd Porr */
/* (C) 2018-2021 Bernd Porr */
/* (C) 2018-2024 Bernd Porr */

#include "Fir1.h"

Expand All @@ -42,12 +42,14 @@ Fir1::Fir1(const double *_coefficients,const unsigned number_of_taps) :
}

// init all coefficients and the buffer to zero
Fir1::Fir1(unsigned number_of_taps) :
Fir1::Fir1(unsigned number_of_taps, double value) :
coefficients(new double[number_of_taps]),
buffer(new double[number_of_taps]),
taps(number_of_taps) {
zeroCoeff();
reset();
for(unsigned int i=0;i<number_of_taps;i++) {
coefficients[i] = value;
buffer[i] = 0;
}
}

void Fir1::initWithVector(std::vector<double> _coefficients) {
Expand Down
6 changes: 3 additions & 3 deletions Fir1.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ class Fir1 {
Fir1(const char* coeffFile, unsigned number_of_taps = 0);

/**
* Inits all coefficients and the buffer to zero
* Inits all coefficients and the buffer to a constant value
* This is useful for adaptive filters where we start with
* zero valued coefficients.
* zero valued coefficients or moving average filters.
**/
Fir1(unsigned number_of_taps);
Fir1(unsigned number_of_taps, double value = 0);

/**
* Releases the coefficients and buffer.
Expand Down

0 comments on commit af90404

Please sign in to comment.