1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

AM demod: move channelizer and threaded channelizer from GUI to demod

This commit is contained in:
f4exb 2017-09-28 00:24:03 +02:00
parent 95891164d5
commit ff5e233eb0
4 changed files with 57 additions and 15 deletions

View File

@ -26,12 +26,16 @@
#include "audio/audiooutput.h"
#include "dsp/dspengine.h"
#include "dsp/pidcontroller.h"
#include "dsp/threadedbasebandsamplesink.h"
#include "device/devicesourceapi.h"
MESSAGE_CLASS_DEFINITION(AMDemod::MsgConfigureAMDemod, Message)
MESSAGE_CLASS_DEFINITION(AMDemod::MsgConfigureChannelizer, Message)
const int AMDemod::m_udpBlockSize = 512;
AMDemod::AMDemod() :
AMDemod::AMDemod(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
m_squelchOpen(false),
m_magsqSum(0.0f),
m_magsqPeak(0.0f),
@ -43,6 +47,10 @@ AMDemod::AMDemod() :
{
setObjectName("AMDemod");
m_channelizer = new DownChannelizer(this);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
m_audioBuffer.resize(1<<14);
m_audioBufferFill = 0;
@ -144,6 +152,16 @@ bool AMDemod::handleMessage(const Message& cmd)
return true;
}
else if (MsgConfigureChannelizer::match(cmd))
{
MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
cfg.getSampleRate(),
cfg.getCenterFrequency());
return true;
}
else if (MsgConfigureAMDemod::match(cmd))
{
MsgConfigureAMDemod& cfg = (MsgConfigureAMDemod&) cmd;

View File

@ -29,6 +29,10 @@
#include "util/message.h"
#include "amdemodsettings.h"
class DeviceSourceAPI;
class DownChannelizer;
class ThreadedBasebandSampleSink;
class AMDemod : public BasebandSampleSink {
Q_OBJECT
public:
@ -55,7 +59,30 @@ public:
{ }
};
AMDemod();
class MsgConfigureChannelizer : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getSampleRate() const { return m_sampleRate; }
int getCenterFrequency() const { return m_centerFrequency; }
static MsgConfigureChannelizer* create(int sampleRate, int centerFrequency)
{
return new MsgConfigureChannelizer(sampleRate, centerFrequency);
}
private:
int m_sampleRate;
int m_centerFrequency;
MsgConfigureChannelizer(int sampleRate, int centerFrequency) :
Message(),
m_sampleRate(sampleRate),
m_centerFrequency(centerFrequency)
{ }
};
AMDemod(DeviceSourceAPI *deviceAPI);
~AMDemod();
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);
@ -82,6 +109,10 @@ private:
RSRunning
};
DeviceSourceAPI *m_deviceAPI;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
AMDemodSettings m_settings;
NCO m_nco;

View File

@ -185,11 +185,7 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_amDemod = new AMDemod();
m_channelizer = new DownChannelizer(m_amDemod);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
//m_pluginAPI->addThreadedSink(m_threadedChannelizer);
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
m_amDemod = new AMDemod(m_deviceAPI);
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms
@ -220,9 +216,6 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget
AMDemodGUI::~AMDemodGUI()
{
m_deviceAPI->removeChannelInstance(this);
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_amDemod;
delete ui;
}
@ -238,9 +231,9 @@ void AMDemodGUI::applySettings(bool force)
{
setTitleColor(m_channelMarker.getColor());
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
48000,
m_channelMarker.getCenterFrequency());
AMDemod::MsgConfigureChannelizer* channelConfigMsg = AMDemod::MsgConfigureChannelizer::create(
48000, m_channelMarker.getCenterFrequency());
m_amDemod->getInputMessageQueue()->push(channelConfigMsg);
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());

View File

@ -60,8 +60,8 @@ private:
AMDemodSettings m_settings;
bool m_doApplySettings;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
// ThreadedBasebandSampleSink* m_threadedChannelizer;
// DownChannelizer* m_channelizer;
AMDemod* m_amDemod;
bool m_squelchOpen;
uint32_t m_tickCount;