1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-16 13:21:50 -05:00

UDP source: separate demod and GUI phase 1

This commit is contained in:
f4exb 2017-10-04 22:41:58 +02:00
parent a1afc0ebe6
commit d0943b384f
4 changed files with 52 additions and 18 deletions

View File

@ -18,15 +18,18 @@
#include <QUdpSocket> #include <QUdpSocket>
#include <QHostAddress> #include <QHostAddress>
#include "dsp/downchannelizer.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "util/db.h" #include "util/db.h"
#include "dsp/downchannelizer.h"
#include "dsp/threadedbasebandsamplesink.h"
#include "device/devicesourceapi.h"
#include "udpsrcgui.h" #include "udpsrcgui.h"
#include "udpsrc.h" #include "udpsrc.h"
const Real UDPSrc::m_agcTarget = 16384.0f; const Real UDPSrc::m_agcTarget = 16384.0f;
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgConfigureChannelizer, Message)
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcConfigure, Message) MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcConfigure, Message)
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcConfigureImmediate, Message) MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcConfigureImmediate, Message)
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcSpectrum, Message) MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcSpectrum, Message)
@ -68,6 +71,11 @@ UDPSrc::UDPSrc(DeviceSourceAPI *deviceAPI) :
m_scale = 0; m_scale = 0;
m_magsq = 0; m_magsq = 0;
m_inMagsq = 0; m_inMagsq = 0;
m_channelizer = new DownChannelizer(this);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
UDPFilter = new fftfilt(0.0, (m_config.m_rfBandwidth / 2.0) / m_config.m_outputSampleRate, udpBlockSize); UDPFilter = new fftfilt(0.0, (m_config.m_rfBandwidth / 2.0) / m_config.m_outputSampleRate, udpBlockSize);
m_phaseDiscri.setFMScaling((float) m_config. m_outputSampleRate / (2.0f * m_config.m_fmDeviation)); m_phaseDiscri.setFMScaling((float) m_config. m_outputSampleRate / (2.0f * m_config.m_fmDeviation));
@ -96,6 +104,9 @@ UDPSrc::~UDPSrc()
delete[] m_udpAudioBuf; delete[] m_udpAudioBuf;
if (UDPFilter) delete UDPFilter; if (UDPFilter) delete UDPFilter;
if (m_running.m_audioActive) DSPEngine::instance()->removeAudioSink(&m_audioFifo); if (m_running.m_audioActive) DSPEngine::instance()->removeAudioSink(&m_audioFifo);
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
} }
/** what needs the "apply" button validation */ /** what needs the "apply" button validation */
@ -363,6 +374,16 @@ bool UDPSrc::handleMessage(const Message& cmd)
return true; 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 (MsgUDPSrcConfigureImmediate::match(cmd)) else if (MsgUDPSrcConfigureImmediate::match(cmd))
{ {
MsgUDPSrcConfigureImmediate& cfg = (MsgUDPSrcConfigureImmediate&) cmd; MsgUDPSrcConfigureImmediate& cfg = (MsgUDPSrcConfigureImmediate&) cmd;

View File

@ -35,11 +35,36 @@
class QUdpSocket; class QUdpSocket;
class DeviceSourceAPI; class DeviceSourceAPI;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class UDPSrc : public BasebandSampleSink { class UDPSrc : public BasebandSampleSink {
Q_OBJECT Q_OBJECT
public: public:
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)
{ }
};
enum SampleFormat { enum SampleFormat {
FormatS16LE, FormatS16LE,
FormatNFM, FormatNFM,
@ -294,6 +319,8 @@ protected:
Config m_running; Config m_running;
DeviceSourceAPI *m_deviceAPI; DeviceSourceAPI *m_deviceAPI;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
QUdpSocket *m_audioSocket; QUdpSocket *m_audioSocket;

View File

@ -18,8 +18,6 @@
#include "udpsrcgui.h" #include "udpsrcgui.h"
#include "device/devicesourceapi.h" #include "device/devicesourceapi.h"
#include "dsp/downchannelizer.h"
#include "dsp/threadedbasebandsamplesink.h"
#include "plugin/pluginapi.h" #include "plugin/pluginapi.h"
#include "dsp/spectrumvis.h" #include "dsp/spectrumvis.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
@ -273,9 +271,6 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget*
m_spectrumVis = new SpectrumVis(ui->glSpectrum); m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_udpSrc = new UDPSrc(m_deviceAPI); m_udpSrc = new UDPSrc(m_deviceAPI);
m_udpSrc->setSpectrum(m_spectrumVis); m_udpSrc->setSpectrum(m_spectrumVis);
m_channelizer = new DownChannelizer(m_udpSrc);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
ui->fmDeviation->setEnabled(false); ui->fmDeviation->setEnabled(false);
@ -293,7 +288,6 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget*
ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer()); ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
//m_channelMarker = new ChannelMarker(this);
m_channelMarker.setBandwidth(16000); m_channelMarker.setBandwidth(16000);
m_channelMarker.setCenterFrequency(0); m_channelMarker.setCenterFrequency(0);
m_channelMarker.setTitle("UDP Sample Source"); m_channelMarker.setTitle("UDP Sample Source");
@ -319,12 +313,8 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget*
UDPSrcGUI::~UDPSrcGUI() UDPSrcGUI::~UDPSrcGUI()
{ {
m_deviceAPI->removeChannelInstance(this); m_deviceAPI->removeChannelInstance(this);
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_udpSrc; delete m_udpSrc;
delete m_spectrumVis; delete m_spectrumVis;
//delete m_channelMarker;
delete ui; delete ui;
} }
@ -402,9 +392,9 @@ void UDPSrcGUI::applySettings(bool force)
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged())); connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
ui->glSpectrum->setSampleRate(outputSampleRate); ui->glSpectrum->setSampleRate(outputSampleRate);
m_channelizer->configure(m_channelizer->getInputMessageQueue(), UDPSrc::MsgConfigureChannelizer* channelConfigMsg = UDPSrc::MsgConfigureChannelizer::create(
outputSampleRate, outputSampleRate, m_channelMarker.getCenterFrequency());
m_channelMarker.getCenterFrequency()); m_udpSrc->getInputMessageQueue()->push(channelConfigMsg);
UDPSrc::SampleFormat sampleFormat; UDPSrc::SampleFormat sampleFormat;

View File

@ -29,8 +29,6 @@
class PluginAPI; class PluginAPI;
class DeviceSourceAPI; class DeviceSourceAPI;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class UDPSrc; class UDPSrc;
class SpectrumVis; class SpectrumVis;
@ -103,8 +101,6 @@ private:
MessageQueue m_inputMessageQueue; MessageQueue m_inputMessageQueue;
// RF path // RF path
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
SpectrumVis* m_spectrumVis; SpectrumVis* m_spectrumVis;
explicit UDPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget* parent = 0); explicit UDPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget* parent = 0);