1 #define _USE_MATH_DEFINES 8 std::vector<Real>& taps,
13 double transitionWidthHz,
14 double oobAttenuationdB)
16 double nbTapsPerPhase = (oobAttenuationdB * sampleRateHz) / (22.0 * transitionWidthHz * phaseSteps);
22 std::vector<Real>& taps,
27 double nbTapsPerPhase)
29 int ntaps = (int)(nbTapsPerPhase * phaseSteps);
30 qDebug(
"Interpolator::createPolyphaseLowPass: ntaps: %d", ntaps);
32 if ((ntaps % 2) != 0) {
39 std::vector<float> window(ntaps);
41 for (
int n = 0; n < ntaps; n++) {
42 window[n] = 0.54 - 0.46 *
cos ((2 *
M_PI * n) / (ntaps - 1));
45 int M = (ntaps - 1) / 2;
46 double fwT0 = 2 *
M_PI * cutoffFreqHz / sampleRateHz;
48 for (
int n = -M; n <= M; n++)
51 taps[n + M] = fwT0 /
M_PI * window[n + M];
53 taps[n + M] =
sin (n * fwT0) / (n *
M_PI) * window[n + M];
57 double max = taps[0 + M];
59 for (
int n = 1; n <= M; n++) {
60 max += 2.0 * taps[n + M];
65 for (
int i = 0;
i < ntaps;
i++) {
90 std::vector<Real> taps;
96 phaseSteps * sampleRate,
102 m_nTaps = taps.size() / phaseSteps;
111 std::vector<Real> polyphase(taps.size());
113 for (
int phase = 0; phase < phaseSteps; phase++)
116 polyphase[phase * m_nTaps +
i] = taps[
i * phaseSteps + phase];
121 for (
int phase = 0; phase < phaseSteps; phase++)
125 for (
int i = phase * m_nTaps;
i < phase * m_nTaps +
m_nTaps;
i++) {
129 for (
int i = phase * m_nTaps;
i < phase * m_nTaps +
m_nTaps;
i++) {
135 m_taps =
new float[2 * taps.size() + 8];
137 for (uint
i = 0;
i < 2 * taps.size() + 8; ++
i) {
143 for (uint
i = 0;
i < taps.size(); ++
i)
149 m_taps2 =
new float[2 * taps.size() + 8];
151 for (uint
i = 0;
i < 2 * taps.size() + 8; ++
i) {
157 for (uint
i = 1;
i < taps.size(); ++
i)
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
void create(int phaseSteps, double sampleRate, double cutoff, double nbTapsPerPhase=4.5)
static void createPolyphaseLowPass(std::vector< Real > &taps, int phaseSteps, double gain, double sampleRateHz, double cutoffFreqHz, double transitionWidthHz, double oobAttenuationdB)
Fixed< IntType, IntBits > sin(Fixed< IntType, IntBits > const &x)
std::vector< Complex > m_samples
T max(const T &x, const T &y)