1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-04 16:01:14 -05:00

DSD demod: separate GUI from demod

This commit is contained in:
f4exb 2017-10-02 13:56:40 +02:00
parent 610333a883
commit 918aff8b8f
8 changed files with 158 additions and 73 deletions

View File

@ -4,6 +4,7 @@ set(dsddemod_SOURCES
dsddemod.cpp dsddemod.cpp
dsddemodgui.cpp dsddemodgui.cpp
dsddemodplugin.cpp dsddemodplugin.cpp
dsddemodbaudrates.cpp
dsddecoder.cpp dsddecoder.cpp
) )
@ -11,6 +12,7 @@ set(dsddemod_HEADERS
dsddemod.h dsddemod.h
dsddemodgui.h dsddemodgui.h
dsddemodplugin.h dsddemodplugin.h
dsddemodbaudrates.h
dsddecoder.h dsddecoder.h
) )

View File

@ -40,12 +40,14 @@ CONFIG(Debug):build_subdir = debug
SOURCES = dsddecoder.cpp\ SOURCES = dsddecoder.cpp\
dsddemod.cpp\ dsddemod.cpp\
dsddemodgui.cpp\ dsddemodgui.cpp\
dsddemodplugin.cpp dsddemodplugin.cpp\
dsddemodbaudrates.cpp
HEADERS = dsddecoder.h\ HEADERS = dsddecoder.h\
dsddemod.h\ dsddemod.h\
dsddemodgui.h\ dsddemodgui.h\
dsddemodplugin.h dsddemodplugin.h\
dsddemodbaudrates.h
FORMS = dsddemodgui.ui FORMS = dsddemodgui.ui

View File

@ -15,24 +15,30 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // // along with this program. If not, see <http://www.gnu.org/licenses/>. //
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include "../../channelrx/demoddsd/dsddemod.h"
#include <QTime> #include <QTime>
#include <QDebug> #include <QDebug>
#include <stdio.h> #include <stdio.h>
#include <complex.h> #include <complex.h>
#include <dsp/downchannelizer.h> #include <dsp/downchannelizer.h>
#include "audio/audiooutput.h" #include "audio/audiooutput.h"
#include "dsp/pidcontroller.h" #include "dsp/pidcontroller.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsddemodgui.h" #include "dsp/threadedbasebandsamplesink.h"
#include <dsp/downchannelizer.h>
#include <device/devicesourceapi.h>
#include "dsddemod.h"
MESSAGE_CLASS_DEFINITION(DSDDemod::MsgConfigureChannelizer, Message)
MESSAGE_CLASS_DEFINITION(DSDDemod::MsgConfigureDSDDemod, Message) MESSAGE_CLASS_DEFINITION(DSDDemod::MsgConfigureDSDDemod, Message)
MESSAGE_CLASS_DEFINITION(DSDDemod::MsgConfigureMyPosition, Message) MESSAGE_CLASS_DEFINITION(DSDDemod::MsgConfigureMyPosition, Message)
const int DSDDemod::m_udpBlockSize = 512; const int DSDDemod::m_udpBlockSize = 512;
DSDDemod::DSDDemod(BasebandSampleSink* sampleSink) : DSDDemod::DSDDemod(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
m_sampleCount(0), m_sampleCount(0),
m_squelchCount(0), m_squelchCount(0),
m_squelchOpen(false), m_squelchOpen(false),
@ -40,7 +46,7 @@ DSDDemod::DSDDemod(BasebandSampleSink* sampleSink) :
m_fmExcursion(24), m_fmExcursion(24),
m_audioFifo1(48000), m_audioFifo1(48000),
m_audioFifo2(48000), m_audioFifo2(48000),
m_scope(sampleSink), m_scope(0),
m_scopeEnabled(true), m_scopeEnabled(true),
m_dsdDecoder(), m_dsdDecoder(),
m_settingsMutex(QMutex::Recursive) m_settingsMutex(QMutex::Recursive)
@ -79,6 +85,10 @@ DSDDemod::DSDDemod(BasebandSampleSink* sampleSink) :
m_audioFifo1.setUDPSink(m_udpBufferAudio); m_audioFifo1.setUDPSink(m_udpBufferAudio);
m_audioFifo2.setUDPSink(m_udpBufferAudio); m_audioFifo2.setUDPSink(m_udpBufferAudio);
m_channelizer = new DownChannelizer(this);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
apply(true); apply(true);
} }
@ -88,6 +98,10 @@ DSDDemod::~DSDDemod()
DSPEngine::instance()->removeAudioSink(&m_audioFifo1); DSPEngine::instance()->removeAudioSink(&m_audioFifo1);
DSPEngine::instance()->removeAudioSink(&m_audioFifo2); DSPEngine::instance()->removeAudioSink(&m_audioFifo2);
delete m_udpBufferAudio; delete m_udpBufferAudio;
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
} }
void DSDDemod::configure(MessageQueue* messageQueue, void DSDDemod::configure(MessageQueue* messageQueue,
@ -364,6 +378,16 @@ bool DSDDemod::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 (MsgConfigureDSDDemod::match(cmd)) else if (MsgConfigureDSDDemod::match(cmd))
{ {
MsgConfigureDSDDemod& cfg = (MsgConfigureDSDDemod&) cmd; MsgConfigureDSDDemod& cfg = (MsgConfigureDSDDemod&) cmd;

View File

@ -35,12 +35,38 @@
#include "dsddecoder.h" #include "dsddecoder.h"
class DSDDemodGUI; class DeviceSourceAPI;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class DSDDemod : public BasebandSampleSink { class DSDDemod : public BasebandSampleSink {
public: public:
DSDDemod(BasebandSampleSink* sampleSink); 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)
{ }
};
DSDDemod(DeviceSourceAPI *deviceAPI);
~DSDDemod(); ~DSDDemod();
void setScopeSink(BasebandSampleSink* sampleSink) { m_scope = sampleSink; }
void configure(MessageQueue* messageQueue, void configure(MessageQueue* messageQueue,
int rfBandwidth, int rfBandwidth,
@ -69,10 +95,6 @@ public:
virtual void stop(); virtual void stop();
virtual bool handleMessage(const Message& cmd); virtual bool handleMessage(const Message& cmd);
void registerGUI(DSDDemodGUI *dsdDemodGUI) {
m_dsdDemodGUI = dsdDemodGUI;
}
double getMagSq() { return m_magsq; } double getMagSq() { return m_magsq; }
bool getSquelchOpen() const { return m_squelchOpen; } bool getSquelchOpen() const { return m_squelchOpen; }
@ -288,6 +310,10 @@ private:
Config m_config; Config m_config;
Config m_running; Config m_running;
DeviceSourceAPI *m_deviceAPI;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
NCO m_nco; NCO m_nco;
Interpolator m_interpolator; Interpolator m_interpolator;
Real m_interpolatorDistance; Real m_interpolatorDistance;
@ -320,7 +346,6 @@ private:
bool m_scopeEnabled; bool m_scopeEnabled;
DSDDecoder m_dsdDecoder; DSDDecoder m_dsdDecoder;
DSDDemodGUI *m_dsdDemodGUI;
QMutex m_settingsMutex; QMutex m_settingsMutex;
PhaseDiscriminators m_phaseDiscri; PhaseDiscriminators m_phaseDiscri;

View File

@ -0,0 +1,50 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 F4EXB //
// written by Edouard Griffiths //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "dsddemodbaudrates.h"
unsigned int DSDDemodBaudRates::m_rates[] = {2400, 4800};
unsigned int DSDDemodBaudRates::m_nb_rates = 2;
unsigned int DSDDemodBaudRates::m_defaultRateIndex = 1; // 4800 bauds
unsigned int DSDDemodBaudRates::getRate(unsigned int rate_index)
{
if (rate_index < m_nb_rates)
{
return m_rates[rate_index];
}
else
{
return m_rates[m_defaultRateIndex];
}
}
unsigned int DSDDemodBaudRates::getRateIndex(unsigned int rate)
{
for (unsigned int i=0; i < m_nb_rates; i++)
{
if (rate == m_rates[i])
{
return i;
}
}
return m_defaultRateIndex;
}

View File

@ -0,0 +1,35 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 F4EXB //
// written by Edouard Griffiths //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHANNELRX_DEMODDSD_DSDDEMODBAUDRATES_H_
#define PLUGINS_CHANNELRX_DEMODDSD_DSDDEMODBAUDRATES_H_
class DSDDemodBaudRates
{
public:
static unsigned int getRate(unsigned int rate_index);
static unsigned int getRateIndex(unsigned int rate);
static unsigned int getDefaultRate() { return m_rates[m_defaultRateIndex]; }
static unsigned int getDefaultRateIndex() { return m_defaultRateIndex; }
static unsigned int getNbRates() { return m_nb_rates; }
private:
static unsigned int m_nb_rates;
static unsigned int m_rates[2];
static unsigned int m_defaultRateIndex;
};
#endif /* PLUGINS_CHANNELRX_DEMODDSD_DSDDEMODBAUDRATES_H_ */

View File

@ -34,14 +34,11 @@
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "dsddemodbaudrates.h"
#include "dsddemod.h" #include "dsddemod.h"
const QString DSDDemodGUI::m_channelID = "sdrangel.channel.dsddemod"; const QString DSDDemodGUI::m_channelID = "sdrangel.channel.dsddemod";
unsigned int DSDDemodBaudRates::m_rates[] = {2400, 4800};
unsigned int DSDDemodBaudRates::m_nb_rates = 2;
unsigned int DSDDemodBaudRates::m_defaultRateIndex = 1; // 4800 bauds
DSDDemodGUI* DSDDemodGUI::create(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI) DSDDemodGUI* DSDDemodGUI::create(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI)
{ {
DSDDemodGUI* gui = new DSDDemodGUI(pluginAPI, deviceAPI); DSDDemodGUI* gui = new DSDDemodGUI(pluginAPI, deviceAPI);
@ -322,8 +319,9 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &))); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_scopeVis = new ScopeVis(ui->glScope); m_scopeVis = new ScopeVis(ui->glScope);
m_dsdDemod = new DSDDemod(m_scopeVis); m_dsdDemod = new DSDDemod(m_deviceAPI);
m_dsdDemod->registerGUI(this); m_dsdDemod->setScopeSink(m_scopeVis);
m_dsdDemod->setMessageQueueToGUI(getInputMessageQueue());
ui->glScope->setSampleRate(48000); ui->glScope->setSampleRate(48000);
m_scopeVis->setSampleRate(48000); m_scopeVis->setSampleRate(48000);
@ -339,11 +337,7 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999); ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue); ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue);
m_channelizer = new DownChannelizer(m_dsdDemod);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
//m_channelMarker = new ChannelMarker(this);
m_channelMarker.setTitle(windowTitle()); m_channelMarker.setTitle(windowTitle());
m_channelMarker.setColor(Qt::cyan); m_channelMarker.setColor(Qt::cyan);
m_channelMarker.setBandwidth(10000); m_channelMarker.setBandwidth(10000);
@ -366,11 +360,7 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
DSDDemodGUI::~DSDDemodGUI() DSDDemodGUI::~DSDDemodGUI()
{ {
m_deviceAPI->removeChannelInstance(this); m_deviceAPI->removeChannelInstance(this);
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_dsdDemod; delete m_dsdDemod;
//delete m_channelMarker;
delete ui; delete ui;
} }
@ -400,9 +390,9 @@ void DSDDemodGUI::applySettings(bool force)
setTitleColor(m_channelMarker.getColor()); setTitleColor(m_channelMarker.getColor());
m_channelizer->configure(m_channelizer->getInputMessageQueue(), DSDDemod::MsgConfigureChannelizer* channelConfigMsg = DSDDemod::MsgConfigureChannelizer::create(
48000, 48000, m_channelMarker.getCenterFrequency());
m_channelMarker.getCenterFrequency()); m_dsdDemod->getInputMessageQueue()->push(channelConfigMsg);
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
ui->rfBWText->setText(QString("%1k").arg(ui->rfBW->value() / 10.0, 0, 'f', 1)); ui->rfBWText->setText(QString("%1k").arg(ui->rfBW->value() / 10.0, 0, 'f', 1));
@ -683,28 +673,3 @@ void DSDDemodGUI::tick()
m_tickCount++; m_tickCount++;
} }
unsigned int DSDDemodBaudRates::getRate(unsigned int rate_index)
{
if (rate_index < m_nb_rates)
{
return m_rates[rate_index];
}
else
{
return m_rates[m_defaultRateIndex];
}
}
unsigned int DSDDemodBaudRates::getRateIndex(unsigned int rate)
{
for (unsigned int i=0; i < m_nb_rates; i++)
{
if (rate == m_rates[i])
{
return i;
}
}
return m_defaultRateIndex;
}

View File

@ -30,8 +30,6 @@
class PluginAPI; class PluginAPI;
class DeviceSourceAPI; class DeviceSourceAPI;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class ScopeVis; class ScopeVis;
class DSDDemod; class DSDDemod;
@ -100,8 +98,6 @@ private:
char m_formatStatusText[82+1]; //!< Fixed signal format dependent status text char m_formatStatusText[82+1]; //!< Fixed signal format dependent status text
SignalFormat m_signalFormat; SignalFormat m_signalFormat;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
ScopeVis* m_scopeVis; ScopeVis* m_scopeVis;
DSDDemod* m_dsdDemod; DSDDemod* m_dsdDemod;
@ -131,18 +127,4 @@ private:
void enterEvent(QEvent*); void enterEvent(QEvent*);
}; };
class DSDDemodBaudRates
{
public:
static unsigned int getRate(unsigned int rate_index);
static unsigned int getRateIndex(unsigned int rate);
static unsigned int getDefaultRate() { return m_rates[m_defaultRateIndex]; }
static unsigned int getDefaultRateIndex() { return m_defaultRateIndex; }
static unsigned int getNbRates();
private:
static unsigned int m_nb_rates;
static unsigned int m_rates[2];
static unsigned int m_defaultRateIndex;
};
#endif // INCLUDE_DSDDEMODGUI_H #endif // INCLUDE_DSDDEMODGUI_H