1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-18 06:11:46 -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 <QHostAddress>
#include "dsp/downchannelizer.h"
#include "dsp/dspengine.h"
#include "util/db.h"
#include "dsp/downchannelizer.h"
#include "dsp/threadedbasebandsamplesink.h"
#include "device/devicesourceapi.h"
#include "udpsrcgui.h"
#include "udpsrc.h"
const Real UDPSrc::m_agcTarget = 16384.0f;
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgConfigureChannelizer, Message)
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcConfigure, Message)
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcConfigureImmediate, Message)
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcSpectrum, Message)
@ -68,6 +71,11 @@ UDPSrc::UDPSrc(DeviceSourceAPI *deviceAPI) :
m_scale = 0;
m_magsq = 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);
m_phaseDiscri.setFMScaling((float) m_config. m_outputSampleRate / (2.0f * m_config.m_fmDeviation));
@ -96,6 +104,9 @@ UDPSrc::~UDPSrc()
delete[] m_udpAudioBuf;
if (UDPFilter) delete UDPFilter;
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 */
@ -363,6 +374,16 @@ bool UDPSrc::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 (MsgUDPSrcConfigureImmediate::match(cmd))
{
MsgUDPSrcConfigureImmediate& cfg = (MsgUDPSrcConfigureImmediate&) cmd;

View File

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

View File

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

View File

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