1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 18:15:45 -05:00

NFM demod: GUI and demod separation phase1 (1)

This commit is contained in:
f4exb 2017-10-08 14:06:48 +02:00
parent 88a10f9a7e
commit 094f10fe5a
4 changed files with 33 additions and 19 deletions

View File

@ -25,6 +25,8 @@
#include "audio/audiooutput.h"
#include "dsp/pidcontroller.h"
#include "dsp/dspengine.h"
#include "dsp/threadedbasebandsamplesink.h"
#include <device/devicesourceapi.h>
#include "nfmdemodgui.h"
#include "nfmdemod.h"
@ -35,7 +37,8 @@ MESSAGE_CLASS_DEFINITION(NFMDemod::MsgConfigureChannelizer, Message)
static const double afSqTones[2] = {1000.0, 6000.0}; // {1200.0, 8000.0};
const int NFMDemod::m_udpBlockSize = 512;
NFMDemod::NFMDemod() :
NFMDemod::NFMDemod(DeviceSourceAPI *devieAPI) :
m_deviceAPI(devieAPI),
m_ctcssIndex(0),
m_sampleCount(0),
m_squelchCount(0),
@ -55,6 +58,10 @@ NFMDemod::NFMDemod() :
{
setObjectName("NFMDemod");
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;
@ -74,6 +81,9 @@ NFMDemod::~NFMDemod()
{
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
delete m_udpBufferAudio;
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
}
float arctan2(Real y, Real x)
@ -338,6 +348,16 @@ bool NFMDemod::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 (MsgConfigureNFMDemod::match(cmd))
{
MsgConfigureNFMDemod& cfg = (MsgConfigureNFMDemod&) cmd;

View File

@ -35,6 +35,9 @@
#include "nfmdemodsettings.h"
class DeviceSourceAPI;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class NFMDemodGUI;
class NFMDemod : public BasebandSampleSink {
@ -85,7 +88,7 @@ public:
{ }
};
NFMDemod();
NFMDemod(DeviceSourceAPI *deviceAPI);
~NFMDemod();
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);
@ -126,6 +129,10 @@ private:
RSRunning
};
DeviceSourceAPI* m_deviceAPI;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
NFMDemodSettings m_settings;
NCO m_nco;

View File

@ -1,12 +1,10 @@
#include "nfmdemodgui.h"
#include <device/devicesourceapi.h>
#include <dsp/downchannelizer.h>
#include <QDockWidget>
#include <QMainWindow>
#include <QDebug>
#include "dsp/threadedbasebandsamplesink.h"
#include "ui_nfmdemodgui.h"
#include "dsp/nullsink.h"
#include "plugin/pluginapi.h"
@ -304,7 +302,7 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_nfmDemod = new NFMDemod();
m_nfmDemod = new NFMDemod(m_deviceAPI);
m_nfmDemod->registerGUI(this);
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
@ -336,10 +334,6 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue);
m_channelizer = new DownChannelizer(m_nfmDemod);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
//m_channelMarker = new ChannelMarker(this);
m_channelMarker.setColor(Qt::red);
m_channelMarker.setBandwidth(12500);
@ -366,9 +360,6 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
NFMDemodGUI::~NFMDemodGUI()
{
m_deviceAPI->removeChannelInstance(this);
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_nfmDemod;
//delete m_channelMarker;
delete ui;
@ -382,9 +373,9 @@ void NFMDemodGUI::applySettings(bool force)
setTitleColor(m_channelMarker.getColor());
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
48000,
m_channelMarker.getCenterFrequency());
NFMDemod::MsgConfigureChannelizer* channelConfigMsg = NFMDemod::MsgConfigureChannelizer::create(
48000, m_channelMarker.getCenterFrequency());
m_nfmDemod->getInputMessageQueue()->push(channelConfigMsg);
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());

View File

@ -13,8 +13,6 @@
class PluginAPI;
class DeviceSourceAPI;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class NFMDemod;
namespace Ui {
@ -68,8 +66,6 @@ private:
bool m_basicSettingsShown;
bool m_doApplySettings;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
NFMDemod* m_nfmDemod;
bool m_squelchOpen;
uint32_t m_tickCount;