1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

Channel analyzer NG: autocorrelation corrections (2): corrected FFT aliasing

This commit is contained in:
f4exb 2018-05-20 20:23:41 +02:00
parent 8050266b28
commit f2f34ad9a9
3 changed files with 6 additions and 5 deletions

View File

@ -52,8 +52,7 @@ ChannelAnalyzerNG::ChannelAnalyzerNG(DeviceSourceAPI *deviceAPI) :
m_inputFrequencyOffset = 0; m_inputFrequencyOffset = 0;
SSBFilter = new fftfilt(m_settings.m_lowCutoff / m_inputSampleRate, m_settings.m_bandwidth / m_inputSampleRate, ssbFftLen); SSBFilter = new fftfilt(m_settings.m_lowCutoff / m_inputSampleRate, m_settings.m_bandwidth / m_inputSampleRate, ssbFftLen);
DSBFilter = new fftfilt(m_settings.m_bandwidth / m_inputSampleRate, 2*ssbFftLen); DSBFilter = new fftfilt(m_settings.m_bandwidth / m_inputSampleRate, 2*ssbFftLen);
m_corr = new fftcorr(4*ssbFftLen); m_corr = new fftcorr(8*ssbFftLen); // 8k for 4k effective samples
//m_pll.computeCoefficients(0.05f, 0.707f, 1000.0f); // bandwidth, damping factor, loop gain
m_pll.computeCoefficients(0.002f, 0.5f, 10.0f); // bandwidth, damping factor, loop gain m_pll.computeCoefficients(0.002f, 0.5f, 10.0f); // bandwidth, damping factor, loop gain
applyChannelSettings(m_inputSampleRate, m_inputFrequencyOffset, true); applyChannelSettings(m_inputSampleRate, m_inputFrequencyOffset, true);

View File

@ -43,7 +43,7 @@ void fftcorr::init_fft()
outptr = 0; outptr = 0;
} }
fftcorr::fftcorr(int len) : flen(len) fftcorr::fftcorr(int len) : flen(len), flen2(len>>1)
{ {
init_fft(); init_fft();
} }
@ -66,7 +66,7 @@ int fftcorr::run(const cmplx& inA, const cmplx* inB, cmplx **out)
dataB[inptrB++] = *inB; dataB[inptrB++] = *inB;
} }
if (inptrA < flen) { if (inptrA < flen2) {
return 0; return 0;
} }
@ -83,6 +83,7 @@ int fftcorr::run(const cmplx& inA, const cmplx* inB, cmplx **out)
} }
std::transform(dataA, dataA+flen, dataBj, dataP, [](const cmplx& a, const cmplx& b) -> cmplx { return a*b; }); std::transform(dataA, dataA+flen, dataBj, dataP, [](const cmplx& a, const cmplx& b) -> cmplx { return a*b; });
fftA->InverseComplexFFT(dataP); fftA->InverseComplexFFT(dataP);
std::fill(dataA, dataA+flen, 0); std::fill(dataA, dataA+flen, 0);
@ -95,7 +96,7 @@ int fftcorr::run(const cmplx& inA, const cmplx* inB, cmplx **out)
} }
*out = dataP; *out = dataP;
return flen; return flen2;
} }
const fftcorr::cmplx& fftcorr::run(const cmplx& inA, const cmplx* inB) const fftcorr::cmplx& fftcorr::run(const cmplx& inA, const cmplx* inB)

View File

@ -41,6 +41,7 @@ public:
private: private:
void init_fft(); void init_fft();
int flen; //!< FFT length int flen; //!< FFT length
int flen2; //!< half FFT length
g_fft<float> *fftA; g_fft<float> *fftA;
g_fft<float> *fftB; g_fft<float> *fftB;
cmplx *dataA; // from A input cmplx *dataA; // from A input