From 3a32d5aec3a8b67be63af9cd26409cddc8ba9bd2 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 28 Feb 2017 23:12:14 +0100 Subject: [PATCH] Channel Analyzer NG: put spanLog2 and ssb indicator in config structure --- .../channelrx/chanalyzerng/chanalyzerng.cpp | 29 +++++++++---------- plugins/channelrx/chanalyzerng/chanalyzerng.h | 10 ++++--- .../chanalyzerng/chanalyzernggui.cpp | 6 ++-- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/plugins/channelrx/chanalyzerng/chanalyzerng.cpp b/plugins/channelrx/chanalyzerng/chanalyzerng.cpp index 4f87542b4..6e3ee3d7c 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzerng.cpp +++ b/plugins/channelrx/chanalyzerng/chanalyzerng.cpp @@ -29,11 +29,9 @@ ChannelAnalyzerNG::ChannelAnalyzerNG(BasebandSampleSink* sampleSink) : m_sampleSink(sampleSink), m_settingsMutex(QMutex::Recursive) { - m_spanLog2 = 3; m_undersampleCount = 0; m_sum = 0; m_usb = true; - m_ssb = true; m_magsq = 0; m_interpolatorDistance = 1.0f; m_interpolatorDistanceRemain = 0.0f; @@ -63,7 +61,7 @@ void ChannelAnalyzerNG::feed(const SampleVector::const_iterator& begin, const Sa { fftfilt::cmplx *sideband; int n_out; - int decim = 1<real(), it->imag()); c *= m_nco.nextIQ(); - if (m_ssb) + if (m_running.m_ssb) { n_out = SSBFilter->runSSB(c, &sideband, m_usb); } @@ -95,7 +93,7 @@ void ChannelAnalyzerNG::feed(const SampleVector::const_iterator& begin, const Sa m_sum /= decim; m_magsq = (m_sum.real() * m_sum.real() + m_sum.imag() * m_sum.imag())/ (1<<30); - if (m_ssb & !m_usb) + if (m_running.m_ssb & !m_usb) { // invert spectrum for LSB //m_sampleBuffer.push_back(Sample(m_sum.imag() * 32768.0, m_sum.real() * 32768.0)); m_sampleBuffer.push_back(Sample(m_sum.imag(), m_sum.real())); @@ -113,7 +111,7 @@ void ChannelAnalyzerNG::feed(const SampleVector::const_iterator& begin, const Sa if(m_sampleSink != NULL) { - m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), m_ssb); // m_ssb = positive only + m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), m_running.m_ssb); // m_ssb = positive only } m_sampleBuffer.clear(); @@ -156,23 +154,17 @@ bool ChannelAnalyzerNG::handleMessage(const Message& cmd) m_config.m_channelSampleRate = cfg.getChannelSampleRate(); m_config.m_Bandwidth = cfg.getBandwidth(); m_config.m_LowCutoff = cfg.getLoCutoff(); + m_config.m_spanLog2 = cfg.getSpanLog2(); + m_config.m_ssb = cfg.getSSB(); qDebug() << "ChannelAnalyzerNG::handleMessage: MsgConfigureChannelAnalyzer:" << " m_channelSampleRate: " << m_config.m_channelSampleRate << " m_Bandwidth: " << m_config.m_Bandwidth << " m_LowCutoff: " << m_config.m_LowCutoff - << " m_spanLog2: " << m_spanLog2 - << " m_ssb: " << m_ssb; + << " m_spanLog2: " << m_config.m_spanLog2 + << " m_ssb: " << m_config.m_ssb; apply(); - - //m_settingsMutex.lock(); - - m_spanLog2 = cfg.getSpanLog2(); - m_ssb = cfg.getSSB(); - - //m_settingsMutex.unlock(); - return true; } else @@ -246,4 +238,9 @@ void ChannelAnalyzerNG::apply(bool force) m_running.m_inputSampleRate = m_config.m_inputSampleRate; m_running.m_Bandwidth = m_config.m_Bandwidth; m_running.m_LowCutoff = m_config.m_LowCutoff; + + //m_settingsMutex.lock(); + m_running.m_spanLog2 = m_config.m_spanLog2; + m_running.m_ssb = m_config.m_ssb; + //m_settingsMutex.unlock(); } diff --git a/plugins/channelrx/chanalyzerng/chanalyzerng.h b/plugins/channelrx/chanalyzerng/chanalyzerng.h index f5120cc44..bdaa84d21 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzerng.h +++ b/plugins/channelrx/chanalyzerng/chanalyzerng.h @@ -41,7 +41,7 @@ public: int spanLog2, bool ssb); - int getSampleRate() const { return m_running.m_inputSampleRate; } + int getInputSampleRate() const { return m_running.m_inputSampleRate; } Real getMagSq() const { return m_magsq; } virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); @@ -99,24 +99,26 @@ private: int m_channelSampleRate; Real m_Bandwidth; Real m_LowCutoff; + int m_spanLog2; + bool m_ssb; Config() : m_frequency(0), m_inputSampleRate(96000), m_channelSampleRate(96000), m_Bandwidth(5000), - m_LowCutoff(300) + m_LowCutoff(300), + m_spanLog2(3), + m_ssb(false) {} }; Config m_config; Config m_running; - int m_spanLog2; int m_undersampleCount; fftfilt::cmplx m_sum; bool m_usb; - bool m_ssb; Real m_magsq; NCOF m_nco; diff --git a/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp b/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp index b12ee3507..25b88d628 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp +++ b/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp @@ -392,8 +392,8 @@ bool ChannelAnalyzerNGGUI::setNewRate(int spanLog2) { qDebug("ChannelAnalyzerNGGUI::setNewRate"); - ui->channelSampleRate->setValueRange(7, 0, m_channelAnalyzer->getSampleRate()); - ui->channelSampleRate->setValue(m_channelAnalyzer->getSampleRate()); + ui->channelSampleRate->setValueRange(7, 0, m_channelAnalyzer->getInputSampleRate()); + ui->channelSampleRate->setValue(m_channelAnalyzer->getInputSampleRate()); if ((spanLog2 < 0) || (spanLog2 > 6)) { return false; @@ -401,7 +401,7 @@ bool ChannelAnalyzerNGGUI::setNewRate(int spanLog2) m_spanLog2 = spanLog2; //m_rate = 48000 / (1<getSampleRate() / (1<getInputSampleRate() / (1<