21 fir_filter::fir_filter()
28 fir_filter::~fir_filter()
30 if(coef)
delete[] coef;
33 void fir_filter::set_coef(
int ord,
float *nc,
float gn)
35 if(coef)
delete[] coef;
37 coef =
new float[ord];
41 for(
int i=0;i<order;i++) coef[i] = nc[i];
47 int fir_filter::read_coef_file(std::string fname)
51 fin.open(fname.c_str());
55 if(coef)
delete[] coef;
57 coef =
new float[order];
59 for(
int i=0;i<order;i++) fin >> coef[i];
68 void fir_filter::print_filter()
70 std::cout <<
"N: " << order <<
"\n";
71 for(
int i=0;i<order;i++) std::cout << coef[i] <<
" ";
72 std::cout <<
"\nG: " << gain <<
"\n";
79 if(order == 0)
return data[len-1];
81 for(
int i = len-1, j=0; i >= 0 && j < order; i--, j++)
83 sum += coef[j]*data[i];
FIR digital filter class declarations.
float apply_filter(float *data, int len)
Apply the filter to the data fector of length len.
The namespace of VisAO software.