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

SSB modulator: separate GUI and modulator phase 1

This commit is contained in:
f4exb 2017-10-21 16:01:16 +02:00
parent 483cdfdcea
commit 0ee4e4040a
4 changed files with 37 additions and 19 deletions

View File

@ -24,6 +24,8 @@
#include <dsp/upchannelizer.h>
#include "dsp/dspengine.h"
#include "dsp/pidcontroller.h"
#include "dsp/threadedbasebandsamplesource.h"
#include "device/devicesinkapi.h"
#include "util/db.h"
MESSAGE_CLASS_DEFINITION(SSBMod::MsgConfigureSSBMod, Message)
@ -38,7 +40,8 @@ MESSAGE_CLASS_DEFINITION(SSBMod::MsgReportFileSourceStreamTiming, Message)
const int SSBMod::m_levelNbSamples = 480; // every 10ms
const int SSBMod::m_ssbFftLen = 1024;
SSBMod::SSBMod(BasebandSampleSink* sampleSink) :
SSBMod::SSBMod(DeviceSinkAPI *deviceAPI, BasebandSampleSink* sampleSink) :
m_deviceAPI(deviceAPI),
m_SSBFilter(0),
m_DSBFilter(0),
m_SSBFilterBuffer(0),
@ -60,6 +63,10 @@ SSBMod::SSBMod(BasebandSampleSink* sampleSink) :
{
setObjectName("SSBMod");
m_channelizer = new UpChannelizer(this);
m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this);
m_deviceAPI->addThreadedSource(m_threadedChannelizer);
m_SSBFilter = new fftfilt(m_settings.m_lowCutoff / m_settings.m_audioSampleRate, m_settings.m_bandwidth / m_settings.m_audioSampleRate, m_ssbFftLen);
m_DSBFilter = new fftfilt((2.0f * m_settings.m_bandwidth) / m_settings.m_audioSampleRate, 2 * m_ssbFftLen);
m_SSBFilterBuffer = new Complex[m_ssbFftLen>>1]; // filter returns data exactly half of its size
@ -111,6 +118,10 @@ SSBMod::~SSBMod()
}
DSPEngine::instance()->removeAudioSource(&m_audioFifo);
m_deviceAPI->removeThreadedSource(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
}
void SSBMod::pull(Sample& sample)
@ -535,6 +546,19 @@ bool SSBMod::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());
qDebug() << "SSBMod::handleMessage: MsgConfigureChannelizer: sampleRate: " << cfg.getSampleRate()
<< " centerFrequency: " << cfg.getCenterFrequency();
return true;
}
else if (MsgConfigureSSBMod::match(cmd))
{
float band, lowCutoff;

View File

@ -35,6 +35,10 @@
#include "ssbmodsettings.h"
class DeviceSinkAPI;
class ThreadedBasebandSampleSource;
class UpChannelizer;
class SSBMod : public BasebandSampleSource {
Q_OBJECT
@ -222,7 +226,7 @@ public:
//=================================================================
SSBMod(BasebandSampleSink* sampleSink);
SSBMod(DeviceSinkAPI *deviceAPI, BasebandSampleSink* sampleSink);
~SSBMod();
virtual void pull(Sample& sample);
@ -251,6 +255,9 @@ private:
RSRunning
};
DeviceSinkAPI* m_deviceAPI;
ThreadedBasebandSampleSource* m_threadedChannelizer;
UpChannelizer* m_channelizer;
SSBModSettings m_settings;
NCOF m_carrierNco;

View File

@ -23,9 +23,7 @@
#include "ssbmodgui.h"
#include "device/devicesinkapi.h"
#include "dsp/upchannelizer.h"
#include "dsp/spectrumvis.h"
#include "dsp/threadedbasebandsamplesource.h"
#include "ui_ssbmodgui.h"
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
@ -457,12 +455,8 @@ SSBModGUI::SSBModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_ssbMod = new SSBMod(m_spectrumVis);
m_ssbMod = new SSBMod(m_deviceAPI, m_spectrumVis);
m_ssbMod->setMessageQueueToGUI(getInputMessageQueue());
m_channelizer = new UpChannelizer(m_ssbMod);
m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this);
//m_pluginAPI->addThreadedSink(m_threadedChannelizer);
m_deviceAPI->addThreadedSource(m_threadedChannelizer);
resetToDefaults();
@ -507,9 +501,6 @@ SSBModGUI::SSBModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
SSBModGUI::~SSBModGUI()
{
m_deviceAPI->removeChannelInstance(this);
m_deviceAPI->removeThreadedSource(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_ssbMod;
delete m_spectrumVis;
delete ui;
@ -600,9 +591,9 @@ void SSBModGUI::applySettings(bool force)
{
if (m_doApplySettings)
{
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
48000,
m_channelMarker.getCenterFrequency());
SSBMod::MsgConfigureChannelizer *msgChan = SSBMod::MsgConfigureChannelizer::create(
48000, m_settings.m_inputFrequencyOffset);
m_ssbMod->getInputMessageQueue()->push(msgChan);
SSBMod::MsgConfigureSSBMod *msg = SSBMod::MsgConfigureSSBMod::create(m_settings, force);
m_ssbMod->getInputMessageQueue()->push(msg);

View File

@ -29,8 +29,6 @@
class PluginAPI;
class DeviceSinkAPI;
class ThreadedBasebandSampleSource;
class UpChannelizer;
class SSBMod;
class SpectrumVis;
@ -102,8 +100,6 @@ private:
bool m_doApplySettings;
int m_rate;
ThreadedBasebandSampleSource* m_threadedChannelizer;
UpChannelizer* m_channelizer;
SpectrumVis* m_spectrumVis;
SSBMod* m_ssbMod;
MovingAverage<double> m_channelPowerDbAvg;