From fc650c5fd1d083e0c68994ef6513f7da52e75b3b Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 4 May 2019 04:54:16 +0200 Subject: [PATCH] Method to get frequency from FLL. Fixed Channel Analyzer lock delta frequency display in case of decimation --- plugins/channelrx/chanalyzer/chanalyzer.cpp | 11 +++++++++++ plugins/channelrx/chanalyzer/chanalyzer.h | 3 ++- plugins/channelrx/chanalyzer/chanalyzergui.cpp | 3 ++- sdrbase/dsp/freqlockcomplex.h | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/channelrx/chanalyzer/chanalyzer.cpp b/plugins/channelrx/chanalyzer/chanalyzer.cpp index fa6bb59ba..5ecbdf2bb 100644 --- a/plugins/channelrx/chanalyzer/chanalyzer.cpp +++ b/plugins/channelrx/chanalyzer/chanalyzer.cpp @@ -379,3 +379,14 @@ void ChannelAnalyzer::applySettings(const ChannelAnalyzerSettings& settings, boo m_settings = settings; } + +Real ChannelAnalyzer::getPllFrequency() const +{ + if (m_settings.m_fll) { + return m_fll.getFreq(); + } else if (m_settings.m_pll) { + return m_pll.getFreq(); + } else { + return 0.0; + } +} diff --git a/plugins/channelrx/chanalyzer/chanalyzer.h b/plugins/channelrx/chanalyzer/chanalyzer.h index 94b305285..512525ec0 100644 --- a/plugins/channelrx/chanalyzer/chanalyzer.h +++ b/plugins/channelrx/chanalyzer/chanalyzer.h @@ -124,10 +124,11 @@ public: DownChannelizer *getChannelizer() { return m_channelizer; } int getInputSampleRate() const { return m_inputSampleRate; } int getChannelSampleRate() const { return m_settings.m_downSample ? m_settings.m_downSampleRate : m_inputSampleRate; } + int getDecimation() const { return 1<pll->isChecked()) { - int freq = (m_channelAnalyzer->getPllFrequency() * m_channelAnalyzer->getChannelSampleRate()) / (2.0*M_PI); + double sampleRate = ((double) m_channelAnalyzer->getChannelSampleRate()) / m_channelAnalyzer->getDecimation(); + int freq = (m_channelAnalyzer->getPllFrequency() * sampleRate) / (2.0*M_PI); ui->pll->setToolTip(tr("PLL lock. Freq = %1 Hz").arg(freq)); } } diff --git a/sdrbase/dsp/freqlockcomplex.h b/sdrbase/dsp/freqlockcomplex.h index 2408e4418..0fcbcfbf0 100644 --- a/sdrbase/dsp/freqlockcomplex.h +++ b/sdrbase/dsp/freqlockcomplex.h @@ -41,6 +41,7 @@ public: const std::complex& getComplex() const { return m_y; } float getReal() const { return m_yRe; } float getImag() const { return m_yIm; } + float getFreq() const { return m_freq; } private: /** Normalize angle in radians into the [-pi,+pi] region */