diff --git a/plugins/channelrx/chanalyzerng/chanalyzerng.cpp b/plugins/channelrx/chanalyzerng/chanalyzerng.cpp index 0cb8a928e..9c562703c 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzerng.cpp +++ b/plugins/channelrx/chanalyzerng/chanalyzerng.cpp @@ -52,6 +52,7 @@ ChannelAnalyzerNG::ChannelAnalyzerNG(DeviceSourceAPI *deviceAPI) : m_inputFrequencyOffset = 0; 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); + m_corr = new fftcorr(4*ssbFftLen); //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 @@ -145,8 +146,8 @@ void ChannelAnalyzerNG::processOneSample(Complex& c, fftfilt::cmplx *sideband) if (!(m_undersampleCount++ & (decim - 1))) // counter LSB bit mask for decimation by 2^(m_scaleLog2 - 1) { m_sum /= decim; - Real re = m_sum.real() / SDR_RX_SCALED; - Real im = m_sum.imag() / SDR_RX_SCALED; + Real re = m_sum.real() / SDR_RX_SCALEF; + Real im = m_sum.imag() / SDR_RX_SCALEF; m_magsq = re*re + im*im; std::complex mix; @@ -306,7 +307,8 @@ void ChannelAnalyzerNG::applySettings(const ChannelAnalyzerNGSettings& settings, << " m_ssb: " << settings.m_ssb << " m_pll: " << settings.m_pll << " m_fll: " << settings.m_fll - << " m_pllPskOrder: " << settings.m_pllPskOrder; + << " m_pllPskOrder: " << settings.m_pllPskOrder + << " m_inputType: " << (int) settings.m_inputType; if ((settings.m_downSampleRate != m_settings.m_downSampleRate) || force) { diff --git a/plugins/channelrx/chanalyzerng/chanalyzerng.h b/plugins/channelrx/chanalyzerng/chanalyzerng.h index f4afa6bda..24ac8204c 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzerng.h +++ b/plugins/channelrx/chanalyzerng/chanalyzerng.h @@ -24,6 +24,7 @@ #include "channel/channelsinkapi.h" #include "dsp/interpolator.h" #include "dsp/ncof.h" +#include "dsp/fftcorr.h" #include "dsp/fftfilt.h" #include "dsp/phaselockcomplex.h" #include "dsp/freqlockcomplex.h" @@ -230,6 +231,7 @@ private: fftfilt* SSBFilter; fftfilt* DSBFilter; + fftcorr* m_corr; BasebandSampleSink* m_sampleSink; SampleVector m_sampleBuffer; @@ -248,12 +250,23 @@ private: case ChannelAnalyzerNGSettings::InputPLL: { if (m_settings.m_ssb & !m_usb) { // invert spectrum for LSB - m_sampleBuffer.push_back(Sample(pll.imag(), pll.real())); + m_sampleBuffer.push_back(Sample(pll.imag()*SDR_RX_SCALEF, pll.real()*SDR_RX_SCALEF)); } else { - m_sampleBuffer.push_back(Sample(pll.real(), pll.imag())); + m_sampleBuffer.push_back(Sample(pll.real()*SDR_RX_SCALEF, pll.imag()*SDR_RX_SCALEF)); } } break; + case ChannelAnalyzerNGSettings::InputAutoCorr: + { + std::complex a = m_corr->run(s/(SDR_RX_SCALEF/1024.0f), 0); + + if (m_settings.m_ssb & !m_usb) { // invert spectrum for LSB + m_sampleBuffer.push_back(Sample(a.imag(), a.real())); + } else { + m_sampleBuffer.push_back(Sample(a.real(), a.imag())); + } + } + break; case ChannelAnalyzerNGSettings::InputSignal: default: { diff --git a/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp b/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp index 2e6149092..bb7ce2a5f 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp +++ b/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp @@ -277,6 +277,12 @@ int ChannelAnalyzerNGGUI::getRequestedChannelSampleRate() } } +void ChannelAnalyzerNGGUI::on_signalSelect_currentIndexChanged(int index) +{ + m_settings.m_inputType = (ChannelAnalyzerNGSettings::InputType) index; + applySettings(); +} + void ChannelAnalyzerNGGUI::on_deltaFrequency_changed(qint64 value) { m_channelMarker.setCenterFrequency(value); diff --git a/plugins/channelrx/chanalyzerng/chanalyzernggui.h b/plugins/channelrx/chanalyzerng/chanalyzernggui.h index 79d031fdd..fb68d20eb 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzernggui.h +++ b/plugins/channelrx/chanalyzerng/chanalyzernggui.h @@ -98,6 +98,7 @@ private slots: void on_pll_toggled(bool checked); void on_pllPskOrder_currentIndexChanged(int index); void on_useRationalDownsampler_toggled(bool checked); + void on_signalSelect_currentIndexChanged(int index); void on_BW_valueChanged(int value); void on_lowCut_valueChanged(int value); void on_spanLog2_currentIndexChanged(int index); diff --git a/plugins/channelrx/chanalyzerng/chanalyzernggui.ui b/plugins/channelrx/chanalyzerng/chanalyzernggui.ui index f9c740101..ecee494a2 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzernggui.ui +++ b/plugins/channelrx/chanalyzerng/chanalyzernggui.ui @@ -356,6 +356,28 @@ + + + + Select input signal + + + + Sig + + + + + Lock + + + + + ACorr + + + + diff --git a/sdrbase/dsp/fftcorr.cpp b/sdrbase/dsp/fftcorr.cpp index 22fa00ba4..d82b5d423 100644 --- a/sdrbase/dsp/fftcorr.cpp +++ b/sdrbase/dsp/fftcorr.cpp @@ -45,6 +45,7 @@ void fftcorr::init_fft() inptrA = 0; inptrB = 0; + outptr = 0; } fftcorr::fftcorr(int len) : flen(len), flen2(len>>1) @@ -110,3 +111,14 @@ int fftcorr::run(const cmplx& inA, const cmplx* inB, cmplx **out) *out = output; return flen2; } + +const fftcorr::cmplx& fftcorr::run(const cmplx& inA, const cmplx* inB) +{ + cmplx *dummy; + + if (run(inA, inB, &dummy)) { + outptr = 0; + } + + return output[outptr++]; +} diff --git a/sdrbase/dsp/fftcorr.h b/sdrbase/dsp/fftcorr.h index cd7777340..233d4a745 100644 --- a/sdrbase/dsp/fftcorr.h +++ b/sdrbase/dsp/fftcorr.h @@ -36,6 +36,7 @@ public: ~fftcorr(); int run(const cmplx& inA, const cmplx* inB, cmplx **out); //!< if inB = 0 then run auto-correlation + const cmplx& run(const cmplx& inA, const cmplx* inB); private: void init_fft(); @@ -51,6 +52,7 @@ private: cmplx *output; int inptrA; int inptrB; + int outptr; };