mirror of https://github.com/f4exb/sdrangel.git
WFM modulator: separate GUI and modulator phase 1
This commit is contained in:
parent
2da2aaad3e
commit
9dbdeb517e
|
@ -17,15 +17,21 @@
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <complex.h>
|
#include <complex.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <dsp/upchannelizer.h>
|
#include <dsp/upchannelizer.h>
|
||||||
#include "dsp/dspengine.h"
|
#include "dsp/dspengine.h"
|
||||||
#include "dsp/pidcontroller.h"
|
#include "dsp/pidcontroller.h"
|
||||||
|
#include "dsp/threadedbasebandsamplesource.h"
|
||||||
|
#include "device/devicesinkapi.h"
|
||||||
|
|
||||||
#include "wfmmod.h"
|
#include "wfmmod.h"
|
||||||
|
|
||||||
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureWFMMod, Message)
|
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureWFMMod, Message)
|
||||||
|
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureChannelizer, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureFileSourceName, Message)
|
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureFileSourceName, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureFileSourceSeek, Message)
|
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureFileSourceSeek, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureAFInput, Message)
|
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureAFInput, Message)
|
||||||
|
@ -36,7 +42,8 @@ MESSAGE_CLASS_DEFINITION(WFMMod::MsgReportFileSourceStreamTiming, Message)
|
||||||
const int WFMMod::m_levelNbSamples = 480; // every 10ms
|
const int WFMMod::m_levelNbSamples = 480; // every 10ms
|
||||||
const int WFMMod::m_rfFilterFFTLength = 1024;
|
const int WFMMod::m_rfFilterFFTLength = 1024;
|
||||||
|
|
||||||
WFMMod::WFMMod() :
|
WFMMod::WFMMod(DeviceSinkAPI *deviceAPI) :
|
||||||
|
m_deviceAPI(deviceAPI),
|
||||||
m_modPhasor(0.0f),
|
m_modPhasor(0.0f),
|
||||||
m_movingAverage(40, 0),
|
m_movingAverage(40, 0),
|
||||||
m_volumeAGC(40, 0),
|
m_volumeAGC(40, 0),
|
||||||
|
@ -52,14 +59,15 @@ WFMMod::WFMMod() :
|
||||||
{
|
{
|
||||||
setObjectName("WFMod");
|
setObjectName("WFMod");
|
||||||
|
|
||||||
m_rfFilter = new fftfilt(-62500.0 / 384000.0, 62500.0 / 384000.0, m_rfFilterFFTLength);
|
m_channelizer = new UpChannelizer(this);
|
||||||
|
m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this);
|
||||||
|
m_deviceAPI->addThreadedSource(m_threadedChannelizer);
|
||||||
|
|
||||||
|
m_rfFilter = new fftfilt(-62500.0 / 384000.0, 62500.0 / 384000.0, m_rfFilterFFTLength);
|
||||||
m_rfFilterBuffer = new Complex[m_rfFilterFFTLength];
|
m_rfFilterBuffer = new Complex[m_rfFilterFFTLength];
|
||||||
memset(m_rfFilterBuffer, 0, sizeof(Complex)*(m_rfFilterFFTLength));
|
memset(m_rfFilterBuffer, 0, sizeof(Complex)*(m_rfFilterFFTLength));
|
||||||
m_rfFilterBufferIndex = 0;
|
m_rfFilterBufferIndex = 0;
|
||||||
|
|
||||||
//apply();
|
|
||||||
|
|
||||||
|
|
||||||
m_audioBuffer.resize(1<<14);
|
m_audioBuffer.resize(1<<14);
|
||||||
m_audioBufferFill = 0;
|
m_audioBufferFill = 0;
|
||||||
|
|
||||||
|
@ -86,6 +94,9 @@ WFMMod::~WFMMod()
|
||||||
delete m_rfFilter;
|
delete m_rfFilter;
|
||||||
delete[] m_rfFilterBuffer;
|
delete[] m_rfFilterBuffer;
|
||||||
DSPEngine::instance()->removeAudioSource(&m_audioFifo);
|
DSPEngine::instance()->removeAudioSource(&m_audioFifo);
|
||||||
|
m_deviceAPI->removeThreadedSource(m_threadedChannelizer);
|
||||||
|
delete m_threadedChannelizer;
|
||||||
|
delete m_channelizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WFMMod::pull(Sample& sample)
|
void WFMMod::pull(Sample& sample)
|
||||||
|
@ -291,6 +302,20 @@ bool WFMMod::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());
|
||||||
|
|
||||||
|
qDebug() << "WFMMod::handleMessage: MsgConfigureChannelizer:"
|
||||||
|
<< " getSampleRate: " << cfg.getSampleRate()
|
||||||
|
<< " getCenterFrequency: " << cfg.getCenterFrequency();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else if (MsgConfigureWFMMod::match(cmd))
|
else if (MsgConfigureWFMMod::match(cmd))
|
||||||
{
|
{
|
||||||
MsgConfigureWFMMod& cfg = (MsgConfigureWFMMod&) cmd;
|
MsgConfigureWFMMod& cfg = (MsgConfigureWFMMod&) cmd;
|
||||||
|
|
|
@ -35,6 +35,10 @@
|
||||||
|
|
||||||
#include "wfmmodsettings.h"
|
#include "wfmmodsettings.h"
|
||||||
|
|
||||||
|
class DeviceSinkAPI;
|
||||||
|
class ThreadedBasebandSampleSource;
|
||||||
|
class UpChannelizer;
|
||||||
|
|
||||||
class WFMMod : public BasebandSampleSource {
|
class WFMMod : public BasebandSampleSource {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -71,6 +75,29 @@ 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)
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
class MsgConfigureFileSourceName : public Message
|
class MsgConfigureFileSourceName : public Message
|
||||||
{
|
{
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
@ -199,7 +226,7 @@ public:
|
||||||
|
|
||||||
//=================================================================
|
//=================================================================
|
||||||
|
|
||||||
WFMMod();
|
WFMMod(DeviceSinkAPI *deviceAPI);
|
||||||
~WFMMod();
|
~WFMMod();
|
||||||
|
|
||||||
virtual void pull(Sample& sample);
|
virtual void pull(Sample& sample);
|
||||||
|
@ -228,6 +255,10 @@ private:
|
||||||
RSRunning
|
RSRunning
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DeviceSinkAPI* m_deviceAPI;
|
||||||
|
ThreadedBasebandSampleSource* m_threadedChannelizer;
|
||||||
|
UpChannelizer* m_channelizer;
|
||||||
|
|
||||||
WFMModSettings m_settings;
|
WFMModSettings m_settings;
|
||||||
|
|
||||||
NCO m_carrierNco;
|
NCO m_carrierNco;
|
||||||
|
|
|
@ -22,15 +22,15 @@
|
||||||
|
|
||||||
#include "device/devicesinkapi.h"
|
#include "device/devicesinkapi.h"
|
||||||
#include "dsp/upchannelizer.h"
|
#include "dsp/upchannelizer.h"
|
||||||
|
|
||||||
#include "dsp/threadedbasebandsamplesource.h"
|
#include "dsp/threadedbasebandsamplesource.h"
|
||||||
#include "ui_wfmmodgui.h"
|
|
||||||
#include "plugin/pluginapi.h"
|
#include "plugin/pluginapi.h"
|
||||||
#include "util/simpleserializer.h"
|
#include "util/simpleserializer.h"
|
||||||
#include "util/db.h"
|
#include "util/db.h"
|
||||||
#include "gui/basicchannelsettingswidget.h"
|
#include "gui/basicchannelsettingswidget.h"
|
||||||
#include "dsp/dspengine.h"
|
#include "dsp/dspengine.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include "ui_wfmmodgui.h"
|
||||||
#include "wfmmodgui.h"
|
#include "wfmmodgui.h"
|
||||||
|
|
||||||
const QString WFMModGUI::m_channelID = "sdrangel.channeltx.modwfm";
|
const QString WFMModGUI::m_channelID = "sdrangel.channeltx.modwfm";
|
||||||
|
@ -305,12 +305,8 @@ WFMModGUI::WFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
|
||||||
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
||||||
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
|
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
|
||||||
|
|
||||||
m_wfmMod = new WFMMod();
|
m_wfmMod = new WFMMod(m_deviceAPI);
|
||||||
m_wfmMod->setMessageQueueToGUI(getInputMessageQueue());
|
m_wfmMod->setMessageQueueToGUI(getInputMessageQueue());
|
||||||
m_channelizer = new UpChannelizer(m_wfmMod);
|
|
||||||
m_threadedChannelizer = new ThreadedBasebandSampleSource(m_channelizer, this);
|
|
||||||
//m_pluginAPI->addThreadedSink(m_threadedChannelizer);
|
|
||||||
m_deviceAPI->addThreadedSource(m_threadedChannelizer);
|
|
||||||
|
|
||||||
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
|
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
|
||||||
|
|
||||||
|
@ -318,12 +314,6 @@ WFMModGUI::WFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
|
||||||
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
||||||
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
||||||
|
|
||||||
//m_channelMarker = new ChannelMarker(this);
|
|
||||||
// m_channelMarker.setColor(Qt::blue);
|
|
||||||
// m_channelMarker.setBandwidth(m_rfBW[ui->rfBW->currentIndex()]);
|
|
||||||
// m_channelMarker.setCenterFrequency(0);
|
|
||||||
// m_channelMarker.setVisible(true);
|
|
||||||
|
|
||||||
m_channelMarker.setTitle("WFM Modulator");
|
m_channelMarker.setTitle("WFM Modulator");
|
||||||
m_channelMarker.setVisible(true);
|
m_channelMarker.setVisible(true);
|
||||||
|
|
||||||
|
@ -353,11 +343,7 @@ WFMModGUI::WFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
|
||||||
WFMModGUI::~WFMModGUI()
|
WFMModGUI::~WFMModGUI()
|
||||||
{
|
{
|
||||||
m_deviceAPI->removeChannelInstance(this);
|
m_deviceAPI->removeChannelInstance(this);
|
||||||
m_deviceAPI->removeThreadedSource(m_threadedChannelizer);
|
|
||||||
delete m_threadedChannelizer;
|
|
||||||
delete m_channelizer;
|
|
||||||
delete m_wfmMod;
|
delete m_wfmMod;
|
||||||
//delete m_channelMarker;
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,9 +358,10 @@ void WFMModGUI::applySettings(bool force)
|
||||||
{
|
{
|
||||||
setTitleColor(m_channelMarker.getColor());
|
setTitleColor(m_channelMarker.getColor());
|
||||||
|
|
||||||
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
|
WFMMod::MsgConfigureChannelizer *msgChan = WFMMod::MsgConfigureChannelizer::create(
|
||||||
requiredBW(WFMModSettings::getRFBW(ui->rfBW->currentIndex())),
|
requiredBW(WFMModSettings::getRFBW(ui->rfBW->currentIndex())),
|
||||||
m_channelMarker.getCenterFrequency());
|
m_channelMarker.getCenterFrequency());
|
||||||
|
m_wfmMod->getInputMessageQueue()->push(msgChan);
|
||||||
|
|
||||||
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,8 @@ private:
|
||||||
bool m_basicSettingsShown;
|
bool m_basicSettingsShown;
|
||||||
bool m_doApplySettings;
|
bool m_doApplySettings;
|
||||||
|
|
||||||
ThreadedBasebandSampleSource* m_threadedChannelizer;
|
// ThreadedBasebandSampleSource* m_threadedChannelizer;
|
||||||
UpChannelizer* m_channelizer;
|
// UpChannelizer* m_channelizer;
|
||||||
WFMMod* m_wfmMod;
|
WFMMod* m_wfmMod;
|
||||||
MovingAverage<double> m_channelPowerDbAvg;
|
MovingAverage<double> m_channelPowerDbAvg;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue