diff --git a/plugins/channeltx/modam/ammod.cpp b/plugins/channeltx/modam/ammod.cpp index 5cde9a0e0..7fb9cd457 100644 --- a/plugins/channeltx/modam/ammod.cpp +++ b/plugins/channeltx/modam/ammod.cpp @@ -24,6 +24,8 @@ #include #include "dsp/dspengine.h" #include "dsp/pidcontroller.h" +#include "dsp/threadedbasebandsamplesource.h" +#include "device/devicesinkapi.h" MESSAGE_CLASS_DEFINITION(AMMod::MsgConfigureAMMod, Message) MESSAGE_CLASS_DEFINITION(AMMod::MsgConfigureChannelizer, Message) @@ -36,7 +38,8 @@ MESSAGE_CLASS_DEFINITION(AMMod::MsgReportFileSourceStreamTiming, Message) const int AMMod::m_levelNbSamples = 480; // every 10ms -AMMod::AMMod() : +AMMod::AMMod(DeviceSinkAPI *deviceAPI) : + m_deviceAPI(deviceAPI), m_movingAverage(40, 0), m_volumeAGC(40, 0), m_audioFifo(4800), @@ -67,11 +70,18 @@ AMMod::AMMod() : m_cwKeyer.setMode(CWKeyer::CWNone); m_cwSmoother.setNbFadeSamples(192); // 4 ms @ 48 kHz + m_channelizer = new UpChannelizer(this); + m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this); + m_deviceAPI->addThreadedSource(m_threadedChannelizer); + applySettings(m_settings, true); } AMMod::~AMMod() { + m_deviceAPI->removeThreadedSource(m_threadedChannelizer); + delete m_threadedChannelizer; + delete m_channelizer; DSPEngine::instance()->removeAudioSource(&m_audioFifo); } diff --git a/plugins/channeltx/modam/ammod.h b/plugins/channeltx/modam/ammod.h index 7c7d363d6..346a97da7 100644 --- a/plugins/channeltx/modam/ammod.h +++ b/plugins/channeltx/modam/ammod.h @@ -34,6 +34,10 @@ #include "ammodsettings.h" +class ThreadedBasebandSampleSource; +class UpChannelizer; +class DeviceSinkAPI; + class AMMod : public BasebandSampleSource { Q_OBJECT @@ -221,7 +225,7 @@ public: //================================================================= - AMMod(); + AMMod(DeviceSinkAPI *deviceAPI); ~AMMod(); virtual void pull(Sample& sample); @@ -250,6 +254,9 @@ private: RSRunning }; + DeviceSinkAPI* m_deviceAPI; + ThreadedBasebandSampleSource* m_threadedChannelizer; + UpChannelizer* m_channelizer; AMModSettings m_settings; NCO m_carrierNco; diff --git a/plugins/channeltx/modam/ammodgui.cpp b/plugins/channeltx/modam/ammodgui.cpp index 98c51a600..7a2e34a81 100644 --- a/plugins/channeltx/modam/ammodgui.cpp +++ b/plugins/channeltx/modam/ammodgui.cpp @@ -25,7 +25,6 @@ #include "device/devicesinkapi.h" #include "dsp/upchannelizer.h" -#include "dsp/threadedbasebandsamplesource.h" #include "ui_ammodgui.h" #include "plugin/pluginapi.h" #include "util/simpleserializer.h" @@ -289,12 +288,8 @@ AMModGUI::AMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pare connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked())); - m_amMod = new AMMod(); + m_amMod = new AMMod(m_deviceAPI); m_amMod->setMessageQueueToGUI(getInputMessageQueue()); - m_channelizer = new UpChannelizer(m_amMod); - 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())); @@ -334,9 +329,6 @@ AMModGUI::AMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pare AMModGUI::~AMModGUI() { m_deviceAPI->removeChannelInstance(this); - m_deviceAPI->removeThreadedSource(m_threadedChannelizer); - delete m_threadedChannelizer; - delete m_channelizer; delete m_amMod; delete ui; } @@ -352,9 +344,10 @@ void AMModGUI::applySettings(bool force __attribute((unused))) { setTitleColor(m_channelMarker.getColor()); - m_channelizer->configure(m_channelizer->getInputMessageQueue(), - 48000, - m_channelMarker.getCenterFrequency()); + AMMod::MsgConfigureChannelizer *msgConfigure = AMMod::MsgConfigureChannelizer::create( + 48000, + m_channelMarker.getCenterFrequency()); + m_amMod->getInputMessageQueue()->push(msgConfigure); ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); diff --git a/plugins/channeltx/modam/ammodgui.h b/plugins/channeltx/modam/ammodgui.h index 547d7146d..07a4516fe 100644 --- a/plugins/channeltx/modam/ammodgui.h +++ b/plugins/channeltx/modam/ammodgui.h @@ -29,8 +29,6 @@ class PluginAPI; class DeviceSinkAPI; -class ThreadedBasebandSampleSource; -class UpChannelizer; class AMMod; namespace Ui { @@ -91,8 +89,6 @@ private: bool m_basicSettingsShown; bool m_doApplySettings; - ThreadedBasebandSampleSource* m_threadedChannelizer; - UpChannelizer* m_channelizer; AMMod* m_amMod; MovingAverage m_channelPowerDbAvg;