1 #ifndef INCLUDE_LOWPASS_H 2 #define INCLUDE_LOWPASS_H 4 #define _USE_MATH_DEFINES 9 #define M_PI 3.14159265358979323846 15 void create(
int nTaps,
double sampleRate,
double cutoff)
17 double wc = 2.0 *
M_PI * cutoff;
18 double Wc = wc / sampleRate;
23 qDebug(
"Lowpass filter has to have an odd number of taps");
29 for(
int i = 0; i < nTaps; i++)
32 m_taps.resize(nTaps / 2 + 1);
35 for(i = 0; i < nTaps / 2 + 1; i++) {
36 if(i == (nTaps - 1) / 2)
39 m_taps[
i] =
sin(((
double)i - ((
double)nTaps - 1.0) / 2.0) * Wc) / (((double)i - ((
double)nTaps - 1.0) / 2.0) *
M_PI);
43 for(i = 0; i < nTaps / 2 + 1; i++)
44 m_taps[i] *= 0.54 + 0.46 *
cos((2.0 *
M_PI * ((
double)i - ((double)nTaps - 1.0) / 2.0)) / (
double)nTaps);
48 for(i = 0; i < (int)
m_taps.size() - 1; i++)
51 for(i = 0; i < (int)
m_taps.size(); i++)
70 n_taps =
m_taps.size() - 1;
72 for (i = 0; i < n_taps; i++)
107 #endif // INCLUDE_LOWPASS_H
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
void create(int nTaps, double sampleRate, double cutoff)
std::vector< Type > m_samples
Fixed< IntType, IntBits > sin(Fixed< IntType, IntBits > const &x)
std::vector< Real > m_taps