WFM modulator: separate GUI and modulator phase 1

pull/85/head
f4exb 2017-10-14 05:23:45 +02:00
rodzic 2da2aaad3e
commit 9dbdeb517e
4 zmienionych plików z 71 dodań i 28 usunięć

Wyświetl plik

@ -17,15 +17,21 @@
#include <QTime>
#include <QDebug>
#include <QMutexLocker>
#include <stdio.h>
#include <complex.h>
#include <algorithm>
#include <dsp/upchannelizer.h>
#include "dsp/dspengine.h"
#include "dsp/pidcontroller.h"
#include "dsp/threadedbasebandsamplesource.h"
#include "device/devicesinkapi.h"
#include "wfmmod.h"
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureWFMMod, Message)
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureChannelizer, Message)
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureFileSourceName, Message)
MESSAGE_CLASS_DEFINITION(WFMMod::MsgConfigureFileSourceSeek, 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_rfFilterFFTLength = 1024;
WFMMod::WFMMod() :
WFMMod::WFMMod(DeviceSinkAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
m_modPhasor(0.0f),
m_movingAverage(40, 0),
m_volumeAGC(40, 0),
@ -52,14 +59,15 @@ WFMMod::WFMMod() :
{
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];
memset(m_rfFilterBuffer, 0, sizeof(Complex)*(m_rfFilterFFTLength));
m_rfFilterBufferIndex = 0;
//apply();
m_audioBuffer.resize(1<<14);
m_audioBufferFill = 0;
@ -86,6 +94,9 @@ WFMMod::~WFMMod()
delete m_rfFilter;
delete[] m_rfFilterBuffer;
DSPEngine::instance()->removeAudioSource(&m_audioFifo);
m_deviceAPI->removeThreadedSource(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
}
void WFMMod::pull(Sample& sample)
@ -291,6 +302,20 @@ bool WFMMod::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() << "WFMMod::handleMessage: MsgConfigureChannelizer:"
<< " getSampleRate: " << cfg.getSampleRate()
<< " getCenterFrequency: " << cfg.getCenterFrequency();
return true;
}
else if (MsgConfigureWFMMod::match(cmd))
{
MsgConfigureWFMMod& cfg = (MsgConfigureWFMMod&) cmd;

Wyświetl plik

@ -35,6 +35,10 @@
#include "wfmmodsettings.h"
class DeviceSinkAPI;
class ThreadedBasebandSampleSource;
class UpChannelizer;
class WFMMod : public BasebandSampleSource {
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
{
MESSAGE_CLASS_DECLARATION
@ -199,7 +226,7 @@ public:
//=================================================================
WFMMod();
WFMMod(DeviceSinkAPI *deviceAPI);
~WFMMod();
virtual void pull(Sample& sample);
@ -228,6 +255,10 @@ private:
RSRunning
};
DeviceSinkAPI* m_deviceAPI;
ThreadedBasebandSampleSource* m_threadedChannelizer;
UpChannelizer* m_channelizer;
WFMModSettings m_settings;
NCO m_carrierNco;

Wyświetl plik

@ -22,15 +22,15 @@
#include "device/devicesinkapi.h"
#include "dsp/upchannelizer.h"
#include "dsp/threadedbasebandsamplesource.h"
#include "ui_wfmmodgui.h"
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "util/db.h"
#include "gui/basicchannelsettingswidget.h"
#include "dsp/dspengine.h"
#include "mainwindow.h"
#include "ui_wfmmodgui.h"
#include "wfmmodgui.h"
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(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
m_wfmMod = new WFMMod();
m_wfmMod = new WFMMod(m_deviceAPI);
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()));
@ -318,12 +314,6 @@ WFMModGUI::WFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
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.setVisible(true);
@ -353,11 +343,7 @@ WFMModGUI::WFMModGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* pa
WFMModGUI::~WFMModGUI()
{
m_deviceAPI->removeChannelInstance(this);
m_deviceAPI->removeThreadedSource(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
delete m_wfmMod;
//delete m_channelMarker;
delete ui;
}
@ -372,9 +358,10 @@ void WFMModGUI::applySettings(bool force)
{
setTitleColor(m_channelMarker.getColor());
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
requiredBW(WFMModSettings::getRFBW(ui->rfBW->currentIndex())),
m_channelMarker.getCenterFrequency());
WFMMod::MsgConfigureChannelizer *msgChan = WFMMod::MsgConfigureChannelizer::create(
requiredBW(WFMModSettings::getRFBW(ui->rfBW->currentIndex())),
m_channelMarker.getCenterFrequency());
m_wfmMod->getInputMessageQueue()->push(msgChan);
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());

Wyświetl plik

@ -92,8 +92,8 @@ private:
bool m_basicSettingsShown;
bool m_doApplySettings;
ThreadedBasebandSampleSource* m_threadedChannelizer;
UpChannelizer* m_channelizer;
// ThreadedBasebandSampleSource* m_threadedChannelizer;
// UpChannelizer* m_channelizer;
WFMMod* m_wfmMod;
MovingAverage<double> m_channelPowerDbAvg;