1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00

SSB demod: separate GUI from demod

This commit is contained in:
f4exb 2017-10-01 22:12:10 +02:00
parent 6095cf549c
commit 06ac0d6b4d
4 changed files with 68 additions and 24 deletions

View File

@ -16,19 +16,25 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "ssbdemod.h"
#include <dsp/downchannelizer.h>
#include <QTime>
#include <QDebug>
#include <stdio.h>
#include "audio/audiooutput.h"
#include "dsp/dspengine.h"
#include <dsp/downchannelizer.h>
#include "dsp/threadedbasebandsamplesink.h"
#include "device/devicesourceapi.h"
#include "util/db.h"
MESSAGE_CLASS_DEFINITION(SSBDemod::MsgConfigureSSBDemod, Message)
#include "ssbdemod.h"
SSBDemod::SSBDemod(BasebandSampleSink* sampleSink) :
MESSAGE_CLASS_DEFINITION(SSBDemod::MsgConfigureSSBDemod, Message)
MESSAGE_CLASS_DEFINITION(SSBDemod::MsgConfigureChannelizer, Message)
SSBDemod::SSBDemod(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
m_audioBinaual(false),
m_audioFlipChannels(false),
m_dsb(false),
@ -40,7 +46,7 @@ SSBDemod::SSBDemod(BasebandSampleSink* sampleSink) :
m_agcPowerThreshold(1e-2),
m_agcThresholdGate(0),
m_audioActive(false),
m_sampleSink(sampleSink),
m_sampleSink(0),
m_audioFifo(24000),
m_settingsMutex(QMutex::Recursive)
{
@ -75,6 +81,10 @@ SSBDemod::SSBDemod(BasebandSampleSink* sampleSink) :
SSBFilter = new fftfilt(m_LowCutoff / m_audioSampleRate, m_Bandwidth / m_audioSampleRate, ssbFftLen);
DSBFilter = new fftfilt((2.0f * m_Bandwidth) / m_audioSampleRate, 2 * ssbFftLen);
m_channelizer = new DownChannelizer(this);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
DSPEngine::instance()->addAudioSink(&m_audioFifo);
}
@ -84,6 +94,10 @@ SSBDemod::~SSBDemod()
if (DSBFilter) delete DSBFilter;
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
}
void SSBDemod::configure(MessageQueue* messageQueue,
@ -284,6 +298,16 @@ bool SSBDemod::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 (MsgConfigureSSBDemod::match(cmd))
{
MsgConfigureSSBDemod& cfg = (MsgConfigureSSBDemod&) cmd;

View File

@ -31,10 +31,38 @@
#define ssbFftLen 1024
#define agcTarget 3276.8 // -10 dB amplitude => -20 dB power: center of normal signal
class DeviceSourceAPI;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class SSBDemod : public BasebandSampleSink {
public:
SSBDemod(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)
{ }
};
SSBDemod(DeviceSourceAPI *deviceAPI);
virtual ~SSBDemod();
void setSampleSink(BasebandSampleSink* sampleSink) { m_sampleSink = sampleSink; }
void configure(MessageQueue* messageQueue,
Real Bandwidth,
@ -164,6 +192,10 @@ private:
{ }
};
DeviceSourceAPI *m_deviceAPI;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
Real m_Bandwidth;
Real m_LowCutoff;
Real m_volume;

View File

@ -2,11 +2,9 @@
#include "ssbdemodgui.h"
#include <device/devicesourceapi.h>
#include <dsp/downchannelizer.h>
#include <QDockWidget>
#include <QMainWindow>
#include "dsp/threadedbasebandsamplesink.h"
#include "ui_ssbdemodgui.h"
#include "ui_ssbdemodgui.h"
#include "dsp/spectrumvis.h"
@ -373,10 +371,9 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_ssbDemod = new SSBDemod(m_spectrumVis);
m_channelizer = new DownChannelizer(m_ssbDemod);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
m_ssbDemod = new SSBDemod(m_deviceAPI);
m_ssbDemod->setMessageQueueToGUI(getInputMessageQueue());
m_ssbDemod->setSampleSink(m_spectrumVis);
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
@ -389,7 +386,6 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
//m_channelMarker = new ChannelMarker(this);
m_channelMarker.setColor(Qt::green);
m_channelMarker.setBandwidth(m_rate);
m_channelMarker.setSidebands(ChannelMarker::usb);
@ -413,12 +409,8 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
SSBDemodGUI::~SSBDemodGUI()
{
m_deviceAPI->removeChannelInstance(this);
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_ssbDemod;
delete m_spectrumVis;
//delete m_channelMarker;
delete ui;
}
@ -511,9 +503,9 @@ void SSBDemodGUI::applySettings()
setTitleColor(m_channelMarker.getColor());
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
48000,
m_channelMarker.getCenterFrequency());
SSBDemod::MsgConfigureChannelizer* channelConfigMsg = SSBDemod::MsgConfigureChannelizer::create(
48000, m_channelMarker.getCenterFrequency());
m_ssbDemod->getInputMessageQueue()->push(channelConfigMsg);
m_ssbDemod->configure(m_ssbDemod->getInputMessageQueue(),
ui->BW->value() * 100.0,

View File

@ -11,8 +11,6 @@ class PluginAPI;
class DeviceSourceAPI;
class AudioFifo;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class SSBDemod;
class SpectrumVis;
@ -76,8 +74,6 @@ private:
bool m_squelchOpen;
uint32_t m_tickCount;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
SSBDemod* m_ssbDemod;
SpectrumVis* m_spectrumVis;
MessageQueue m_inputMessageQueue;