1 #ifndef INCLUDE_HIGHPASS_H 2 #define INCLUDE_HIGHPASS_H 4 #define _USE_MATH_DEFINES 12 void create(
int nTaps,
double sampleRate,
double cutoff)
14 double wc = 2.0 *
M_PI * cutoff;
15 double Wc = wc / sampleRate;
20 qDebug(
"Highpass filter has to have an odd number of taps");
26 for(
int i = 0; i < nTaps; i++)
29 m_taps.resize(nTaps / 2 + 1);
32 for(i = 0; i < nTaps / 2 + 1; i++) {
33 if(i == (nTaps - 1) / 2)
36 m_taps[
i] = -
sin(((
double)i - ((
double)nTaps - 1.0) / 2.0) * Wc) / (((double)i - ((
double)nTaps - 1.0) / 2.0) *
M_PI);
39 m_taps[(nTaps - 1) / 2] += 1;
42 for(i = 0; i < nTaps / 2 + 1; i++)
43 m_taps[i] *= 0.54 + 0.46 *
cos((2.0 *
M_PI * ((
double)i - ((double)nTaps - 1.0) / 2.0)) / (
double)nTaps);
47 for(i = 0; i < (int)
m_taps.size() - 1; i++)
50 for(i = 0; i < (int)
m_taps.size(); i++)
69 n_taps =
m_taps.size() - 1;
71 for (i = 0; i < n_taps; i++)
106 #endif // INCLUDE_HIGHPASS_H
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
Fixed< IntType, IntBits > sin(Fixed< IntType, IntBits > const &x)
std::vector< Type > m_samples
void create(int nTaps, double sampleRate, double cutoff)
std::vector< Real > m_taps