18 #ifndef INCLUDE_INTERPOLATOR_H 19 #define INCLUDE_INTERPOLATOR_H 22 #include <emmintrin.h> 33 void create(
int phaseSteps,
double sampleRate,
double cutoff,
double nbTapsPerPhase = 4.5);
43 if (*distance >= 1.0) {
47 doInterpolate((
int)
floor(*distance * (
Real)m_phaseSteps), result);
55 bool consumed =
false;
64 doInterpolate((
int)
floor(*distance * (
Real)m_phaseSteps), result);
73 while (*distance >= 1.0)
87 doInterpolate((
int)
floor(*distance * (
Real)m_phaseSteps), result);
102 static void createPolyphaseLowPass(
103 std::vector<Real>& taps,
108 double transitionWidthHz,
109 double oobAttenuationdB);
111 static void createPolyphaseLowPass(
112 std::vector<Real>& taps,
117 double nbTapsPerPhase);
119 void createTaps(
int nTaps,
double sampleRate,
double cutoff, std::vector<Real>* taps);
129 m_samples[m_ptr] = next;
140 m_samples[m_ptr].real(0.0);
141 m_samples[m_ptr].imag(0.0);
153 const float* src = (
const float*)&m_samples[0];
154 const __m128* filter = (
const __m128*)&m_alignedTaps[phase * m_nTaps * 2];
155 __m128 sum = _mm_setzero_ps();
156 int todo = m_nTaps / 2;
158 for(
int i = 0;
i < todo;
i++) {
159 sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(src), *filter));
165 _mm_storel_pi((__m64*)result, _mm_add_ps(sum, _mm_shuffle_ps(sum, _mm_setzero_ps(), _MM_SHUFFLE(1, 0, 3, 2))));
168 const float* src = (
const float*)&m_samples[m_ptr];
169 const __m128* filter = (
const __m128*)&m_alignedTaps[phase * m_nTaps * 2];
170 __m128 sum = _mm_setzero_ps();
173 int block = m_nTaps - m_ptr;
174 int todo = block / 2;
177 for(
int i = 0;
i < todo;
i++) {
178 sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(src), *filter));
184 filter = (
const __m128*)&m_alignedTaps2[phase * m_nTaps * 2 + todo * 4 - 4];
187 src = (
const float*)&m_samples[0];
190 for(
int i = 0;
i < todo;
i++) {
191 sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(src), *filter));
197 sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadl_pi(_mm_setzero_ps(), (
const __m64*)src), filter[0]));
201 _mm_storel_pi((__m64*)result, _mm_add_ps(sum, _mm_shuffle_ps(sum, _mm_setzero_ps(), _MM_SHUFFLE(1, 0, 3, 2))));
205 const Real* coeff = &m_alignedTaps[phase * m_nTaps * 2];
209 for (
int i = 0;
i < m_nTaps;
i++) {
210 rAcc += *coeff * m_samples[sample].real();
211 iAcc += *coeff * m_samples[sample].imag();
212 sample = (sample + 1) % m_nTaps;
222 #endif // INCLUDE_INTERPOLATOR_H bool resample(Real *distance, const Complex &next, bool *consumed, Complex *result)
bool decimate(Real *distance, const Complex &next, Complex *result)
bool interpolate(Real *distance, const Complex &next, Complex *result)
void advanceFilter(const Complex &next)
Fixed< IntType, IntBits > floor(Fixed< IntType, IntBits > const &x)
void * create(QString type)
std::vector< Complex > m_samples
void doInterpolate(int phase, Complex *result)
std::complex< Real > Complex