From 8050266b2808c27da603c7253df66610b470a4f9 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 20 May 2018 19:41:36 +0200 Subject: [PATCH] Channel analyzer NG: autocorrelation corrections (1) --- debian/changelog | 2 +- .../chanalyzerng/chanalyzernggui.cpp | 1 + sdrbase/dsp/fftcorr.cpp | 24 ++++--------------- sdrbase/dsp/fftcorr.h | 3 --- 4 files changed, 7 insertions(+), 23 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3e95d948d..f5dbacd38 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,6 @@ sdrangel (3.14.7-1) unstable; urgency=medium - * ChanelAnalyzerNG: added PLL option + * ChanelAnalyzerNG: added PLL option and source selection with auto correlation * RTL-SDR: fixed inf/sup decimators * AM demod: syncrhronous AM detection option diff --git a/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp b/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp index bb7ce2a5f..4be9fb1af 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp +++ b/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp @@ -113,6 +113,7 @@ void ChannelAnalyzerNGGUI::displaySettings() ui->deltaFrequency->setValue(m_settings.m_frequency); ui->spanLog2->setCurrentIndex(m_settings.m_spanLog2); displayPLLSettings(); + ui->signalSelect->setCurrentIndex((int) m_settings.m_inputType); blockApplySettings(false); } diff --git a/sdrbase/dsp/fftcorr.cpp b/sdrbase/dsp/fftcorr.cpp index d82b5d423..5be2c3c9b 100644 --- a/sdrbase/dsp/fftcorr.cpp +++ b/sdrbase/dsp/fftcorr.cpp @@ -27,7 +27,6 @@ void fftcorr::init_fft() { - flen2 = flen >> 1; fftA = new g_fft(flen); fftB = new g_fft(flen); @@ -35,20 +34,16 @@ void fftcorr::init_fft() dataB = new cmplx[flen]; dataBj = new cmplx[flen]; dataP = new cmplx[flen]; - output = new cmplx[flen2]; - ovlbuf = new cmplx[flen2]; std::fill(dataA, dataA+flen, 0); std::fill(dataB, dataB+flen, 0); - std::fill(output, output+flen2, 0); - std::fill(ovlbuf, ovlbuf+flen2, 0); inptrA = 0; inptrB = 0; outptr = 0; } -fftcorr::fftcorr(int len) : flen(len), flen2(len>>1) +fftcorr::fftcorr(int len) : flen(len) { init_fft(); } @@ -61,8 +56,6 @@ fftcorr::~fftcorr() delete[] dataB; delete[] dataBj; delete[] dataP; - delete[] output; - delete[] ovlbuf; } int fftcorr::run(const cmplx& inA, const cmplx* inB, cmplx **out) @@ -73,7 +66,7 @@ int fftcorr::run(const cmplx& inA, const cmplx* inB, cmplx **out) dataB[inptrB++] = *inB; } - if (inptrA < flen2) { + if (inptrA < flen) { return 0; } @@ -90,15 +83,8 @@ 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; }); - fftA->InverseComplexFFT(dataP); - for (int i = 0; i < flen2; i++) - { - output[i] = ovlbuf[i] + dataP[i]; - ovlbuf[i] = dataP[flen2 + i]; - } - std::fill(dataA, dataA+flen, 0); inptrA = 0; @@ -108,8 +94,8 @@ int fftcorr::run(const cmplx& inA, const cmplx* inB, cmplx **out) inptrB = 0; } - *out = output; - return flen2; + *out = dataP; + return flen; } const fftcorr::cmplx& fftcorr::run(const cmplx& inA, const cmplx* inB) @@ -120,5 +106,5 @@ const fftcorr::cmplx& fftcorr::run(const cmplx& inA, const cmplx* inB) outptr = 0; } - return output[outptr++]; + return dataP[outptr++]; } diff --git a/sdrbase/dsp/fftcorr.h b/sdrbase/dsp/fftcorr.h index 233d4a745..9da7419e6 100644 --- a/sdrbase/dsp/fftcorr.h +++ b/sdrbase/dsp/fftcorr.h @@ -41,15 +41,12 @@ public: private: void init_fft(); int flen; //!< FFT length - int flen2; //!< half FFT length g_fft *fftA; g_fft *fftB; cmplx *dataA; // from A input cmplx *dataB; // from B input cmplx *dataBj; // conjugate of B cmplx *dataP; // product of A with conjugate of B - cmplx *ovlbuf; - cmplx *output; int inptrA; int inptrB; int outptr;