From 76bdd497a7bd623c98fc9d41f47c6cd7de588c81 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 12 Oct 2017 21:51:25 +0200 Subject: [PATCH] NFM modulator: GUI and modulator separation phase 1 (3) --- plugins/channeltx/modnfm/nfmmod.cpp | 14 +++++++++++--- plugins/channeltx/modnfm/nfmmodgui.cpp | 19 +++++-------------- plugins/channeltx/modnfm/nfmmodgui.h | 5 ----- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/plugins/channeltx/modnfm/nfmmod.cpp b/plugins/channeltx/modnfm/nfmmod.cpp index 6dadb7a8e..3f5c31918 100644 --- a/plugins/channeltx/modnfm/nfmmod.cpp +++ b/plugins/channeltx/modnfm/nfmmod.cpp @@ -26,6 +26,7 @@ #include "dsp/dspengine.h" #include "dsp/pidcontroller.h" #include "device/devicesinkapi.h" +#include "dsp/threadedbasebandsamplesource.h" #include "nfmmod.h" @@ -74,12 +75,19 @@ NFMMod::NFMMod(DeviceSinkAPI *deviceAPI) : m_cwKeyer.setMode(CWKeyer::CWNone); m_cwSmoother.setNbFadeSamples(192); // 2 ms @ 48 kHz + m_channelizer = new UpChannelizer(this); + m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this); + m_deviceAPI->addThreadedSource(m_threadedChannelizer); + applySettings(m_settings, true); } NFMMod::~NFMMod() { DSPEngine::instance()->removeAudioSource(&m_audioFifo); + m_deviceAPI->removeThreadedSource(m_threadedChannelizer); + delete m_threadedChannelizer; + delete m_channelizer; } void NFMMod::pull(Sample& sample) @@ -285,9 +293,9 @@ bool NFMMod::handleMessage(const Message& cmd) { MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd; -// m_channelizer->configure(m_channelizer->getInputMessageQueue(), -// cfg.getSampleRate(), -// cfg.getCenterFrequency()); + m_channelizer->configure(m_channelizer->getInputMessageQueue(), + cfg.getSampleRate(), + cfg.getCenterFrequency()); qDebug() << "NFMMod::handleMessage: MsgConfigureChannelizer:" << " getSampleRate: " << cfg.getSampleRate() diff --git a/plugins/channeltx/modnfm/nfmmodgui.cpp b/plugins/channeltx/modnfm/nfmmodgui.cpp index 7946692ce..401750937 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.cpp +++ b/plugins/channeltx/modnfm/nfmmodgui.cpp @@ -21,16 +21,14 @@ #include #include "device/devicesinkapi.h" -#include "dsp/upchannelizer.h" - -#include "dsp/threadedbasebandsamplesource.h" -#include "ui_nfmmodgui.h" #include "plugin/pluginapi.h" #include "util/simpleserializer.h" #include "util/db.h" #include "gui/basicchannelsettingswidget.h" #include "dsp/dspengine.h" #include "mainwindow.h" + +#include "ui_nfmmodgui.h" #include "nfmmodgui.h" const QString NFMModGUI::m_channelID = "sdrangel.channeltx.modnfm"; @@ -321,10 +319,6 @@ NFMModGUI::NFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa m_nfmMod = new NFMMod(m_deviceAPI); m_nfmMod->setMessageQueueToGUI(getInputMessageQueue()); - m_channelizer = new UpChannelizer(m_nfmMod); - m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this); - //m_pluginAPI->addThreadedSink(m_threadedChannelizer); - m_deviceAPI->addThreadedSource(m_threadedChannelizer); connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); @@ -366,9 +360,6 @@ NFMModGUI::NFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa NFMModGUI::~NFMModGUI() { m_deviceAPI->removeChannelInstance(this); - m_deviceAPI->removeThreadedSource(m_threadedChannelizer); - delete m_threadedChannelizer; - delete m_channelizer; delete m_nfmMod; delete ui; } @@ -384,9 +375,9 @@ void NFMModGUI::applySettings(bool force) { setTitleColor(m_channelMarker.getColor()); - m_channelizer->configure(m_channelizer->getInputMessageQueue(), - 48000, - m_channelMarker.getCenterFrequency()); + NFMMod::MsgConfigureChannelizer *msgChan = NFMMod::MsgConfigureChannelizer::create( + 48000, m_channelMarker.getCenterFrequency()); + m_nfmMod->getInputMessageQueue()->push(msgChan); ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); diff --git a/plugins/channeltx/modnfm/nfmmodgui.h b/plugins/channeltx/modnfm/nfmmodgui.h index 8bf08d003..47df2b4b8 100644 --- a/plugins/channeltx/modnfm/nfmmodgui.h +++ b/plugins/channeltx/modnfm/nfmmodgui.h @@ -28,9 +28,6 @@ class PluginAPI; class DeviceSinkAPI; - -class ThreadedBasebandSampleSource; -class UpChannelizer; class NFMMod; namespace Ui { @@ -95,8 +92,6 @@ private: bool m_basicSettingsShown; bool m_doApplySettings; - ThreadedBasebandSampleSource* m_threadedChannelizer; - UpChannelizer* m_channelizer; NFMMod* m_nfmMod; MovingAverage m_channelPowerDbAvg;