mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-06-19 23:12:44 -04:00
Add an interpolate method to the Interpolator class
This commit is contained in:
parent
6707bab1a5
commit
aa45dcbd17
@ -35,6 +35,24 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// interpolation works nearly the same way
|
||||||
|
bool interpolate(Real *distance, const Complex& next, Complex* result)
|
||||||
|
{
|
||||||
|
*distance -= 1.0;
|
||||||
|
|
||||||
|
if (*distance < 1.0) // use sample
|
||||||
|
{
|
||||||
|
advanceFilter(next);
|
||||||
|
doInterpolate((int) floor(*distance * (Real)m_phaseSteps), result);
|
||||||
|
return true; // need new input sample and increment distance
|
||||||
|
}
|
||||||
|
else // use zero
|
||||||
|
{
|
||||||
|
advanceFilter();
|
||||||
|
doInterpolate((int) floor(*distance * (Real)m_phaseSteps), result);
|
||||||
|
return false; // input sample was not used and do not increment distance
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float* m_taps;
|
float* m_taps;
|
||||||
@ -56,6 +74,15 @@ private:
|
|||||||
m_samples[m_ptr] = next;
|
m_samples[m_ptr] = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void advanceFilter()
|
||||||
|
{
|
||||||
|
m_ptr--;
|
||||||
|
if(m_ptr < 0)
|
||||||
|
m_ptr = m_nTaps - 1;
|
||||||
|
m_samples[m_ptr].real(0.0);
|
||||||
|
m_samples[m_ptr].imag(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
void doInterpolate(int phase, Complex* result)
|
void doInterpolate(int phase, Complex* result)
|
||||||
{
|
{
|
||||||
if (phase < 0)
|
if (phase < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user