1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 04:41:55 -05:00

Websocket spectrum: adapted plugins

This commit is contained in:
f4exb 2020-04-30 09:57:05 +02:00
parent 1579e57a72
commit 9945c6a8f8
30 changed files with 219 additions and 87 deletions

View File

@ -34,6 +34,7 @@ const QString ChannelAnalyzer::m_channelId = "ChannelAnalyzer";
ChannelAnalyzer::ChannelAnalyzer(DeviceAPI *deviceAPI) :
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink),
m_deviceAPI(deviceAPI),
m_spectrumVis(SDR_RX_SCALEF),
m_basebandSampleRate(0)
{
qDebug("ChannelAnalyzer::ChannelAnalyzer");
@ -41,6 +42,7 @@ ChannelAnalyzer::ChannelAnalyzer(DeviceAPI *deviceAPI) :
m_thread = new QThread(this);
m_basebandSink = new ChannelAnalyzerBaseband();
m_basebandSink->setSampleSink(&m_spectrumVis);
m_basebandSink->moveToThread(m_thread);
applySettings(m_settings, true);

View File

@ -22,6 +22,7 @@
#include <vector>
#include "dsp/basebandsamplesink.h"
#include "dsp/spectrumvis.h"
#include "channel/channelapi.h"
#include "util/message.h"
#include "util/movingaverage.h"
@ -58,7 +59,7 @@ public:
ChannelAnalyzer(DeviceAPI *deviceAPI);
virtual ~ChannelAnalyzer();
virtual void destroy() { delete this; }
void setSampleSink(BasebandSampleSink* sampleSink) { m_basebandSink->setSampleSink(sampleSink); }
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
int getChannelSampleRate() const { return m_basebandSink->getChannelSampleRate(); }
int getDecimation() const { return 1<<m_settings.m_log2Decim; }
@ -99,6 +100,7 @@ private:
QThread *m_thread;
ChannelAnalyzerBaseband *m_basebandSink;
ChannelAnalyzerSettings m_settings;
SpectrumVis m_spectrumVis;
int m_basebandSampleRate; //!< stored from device message used when starting baseband sink
void applySettings(const ChannelAnalyzerSettings& settings, bool force = false);

View File

@ -398,11 +398,11 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
m_channelAnalyzer = (ChannelAnalyzer*) rxChannel; //new ChannelAnalyzer(m_deviceUISet->m_deviceSourceAPI);
m_spectrumVis = m_channelAnalyzer->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
m_scopeVis = new ScopeVis(ui->glScope);
m_spectrumScopeComboVis = new SpectrumScopeComboVis(m_spectrumVis, m_scopeVis);
m_channelAnalyzer = (ChannelAnalyzer*) rxChannel; //new ChannelAnalyzer(m_deviceUISet->m_deviceSourceAPI);
m_channelAnalyzer->setSampleSink(m_spectrumScopeComboVis);
m_channelAnalyzer->setMessageQueueToGUI(getInputMessageQueue());
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
@ -455,7 +455,6 @@ ChannelAnalyzerGUI::~ChannelAnalyzerGUI()
{
m_deviceUISet->removeRxChannelInstance(this);
delete m_channelAnalyzer; // TODO: check this: when the GUI closes it has to delete the demodulator
delete m_spectrumVis;
delete m_scopeVis;
delete m_spectrumScopeComboVis;
delete ui;

View File

@ -48,12 +48,14 @@ const int BFMDemod::m_udpBlockSize = 512;
BFMDemod::BFMDemod(DeviceAPI *deviceAPI) :
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink),
m_deviceAPI(deviceAPI),
m_spectrumVis(SDR_RX_SCALEF),
m_basebandSampleRate(0)
{
setObjectName(m_channelId);
m_thread = new QThread(this);
m_basebandSink = new BFMDemodBaseband();
m_basebandSink->setSpectrumSink(&m_spectrumVis);
m_basebandSink->moveToThread(m_thread);
applySettings(m_settings, true);

View File

@ -25,6 +25,7 @@
#include <QNetworkRequest>
#include "dsp/basebandsamplesink.h"
#include "dsp/spectrumvis.h"
#include "channel/channelapi.h"
#include "util/message.h"
@ -69,7 +70,7 @@ public:
BFMDemod(DeviceAPI *deviceAPI);
virtual ~BFMDemod();
virtual void destroy() { delete this; }
void setSpectrumSink(BasebandSampleSink* spectrumSink) { m_basebandSink->setSpectrumSink(spectrumSink); }
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
void setBasebandMessageQueueToGUI(MessageQueue *messageQueue) { m_basebandSink->setMessageQueueToGUI(messageQueue); }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);
@ -142,6 +143,7 @@ private:
QThread *m_thread;
BFMDemodBaseband* m_basebandSink;
BFMDemodSettings m_settings;
SpectrumVis m_spectrumVis;
int m_basebandSampleRate; //!< stored from device message used when starting baseband sink
static const int m_udpBlockSize;

View File

@ -117,6 +117,7 @@ bool BFMDemodGUI::handleMessage(const Message& message)
qDebug("BFMDemodGUI::handleMessage: BFMDemodReport::MsgReportChannelSampleRateChanged: %d S/s", m_rate);
ui->glSpectrum->setCenterFrequency(m_rate / 4);
ui->glSpectrum->setSampleRate(m_rate / 2);
m_spectrumVis->configureDSP(m_rate / 4, m_rate / 2);
return true;
}
else if (BFMDemod::MsgConfigureBFMDemod::match(message))
@ -385,11 +386,11 @@ BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
m_bfmDemod = (BFMDemod*) rxChannel; //new BFMDemod(m_deviceUISet->m_deviceSourceAPI);
m_spectrumVis = m_bfmDemod->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
m_bfmDemod->setMessageQueueToGUI(getInputMessageQueue());
m_bfmDemod->setBasebandMessageQueueToGUI(getInputMessageQueue());
m_bfmDemod->setSpectrumSink(m_spectrumVis);
ui->glSpectrum->setCenterFrequency(m_rate / 4);
ui->glSpectrum->setSampleRate(m_rate / 2);
@ -406,6 +407,7 @@ BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
SpectrumVis::AvgModeNone, // no averaging
FFTWindow::BlackmanHarris,
false); // logarithmic scale
m_spectrumVis->configureDSP(m_rate / 4, m_rate / 2);
connect(&MainWindow::getInstance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
m_channelMarker.blockSignals(true);
@ -444,7 +446,6 @@ BFMDemodGUI::~BFMDemodGUI()
{
m_deviceUISet->removeRxChannelInstance(this);
delete m_bfmDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
delete m_spectrumVis;
delete ui;
}

View File

@ -42,12 +42,14 @@ const QString FreeDVDemod::m_channelId = "FreeDVDemod";
FreeDVDemod::FreeDVDemod(DeviceAPI *deviceAPI) :
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink),
m_deviceAPI(deviceAPI)
m_deviceAPI(deviceAPI),
m_spectrumVis(SDR_RX_SCALEF)
{
setObjectName(m_channelId);
m_thread = new QThread(this);
m_basebandSink = new FreeDVDemodBaseband();
m_basebandSink->setSpectrumSink(&m_spectrumVis);
m_basebandSink->moveToThread(m_thread);
applySettings(m_settings, true);

View File

@ -23,6 +23,7 @@
#include <QNetworkRequest>
#include "dsp/basebandsamplesink.h"
#include "dsp/spectrumvis.h"
#include "channel/channelapi.h"
#include "util/message.h"
#include "util/doublebufferfifo.h"
@ -76,7 +77,7 @@ public:
FreeDVDemod(DeviceAPI *deviceAPI);
virtual ~FreeDVDemod();
virtual void destroy() { delete this; }
void setSampleSink(BasebandSampleSink* spectrumSink) { m_basebandSink->setSpectrumSink(spectrumSink); }
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
@ -145,6 +146,7 @@ private:
QThread *m_thread;
FreeDVDemodBaseband *m_basebandSink;
FreeDVDemodSettings m_settings;
SpectrumVis m_spectrumVis;
int m_basebandSampleRate; //!< stored from device message used when starting baseband sink
QNetworkAccessManager *m_networkManager;

View File

@ -275,9 +275,9 @@ FreeDVDemodGUI::FreeDVDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, B
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
m_freeDVDemod = (FreeDVDemod*) rxChannel;
m_freeDVDemod->setSampleSink(m_spectrumVis);
m_spectrumVis = m_freeDVDemod->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
m_freeDVDemod->setMessageQueueToGUI(getInputMessageQueue());
m_freeDVDemod->propagateMessageQueueToGUI();
@ -332,7 +332,6 @@ FreeDVDemodGUI::~FreeDVDemodGUI()
{
m_deviceUISet->removeRxChannelInstance(this);
delete m_freeDVDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
delete m_spectrumVis;
delete ui;
}

View File

@ -48,12 +48,14 @@ const QString SSBDemod::m_channelId = "SSBDemod";
SSBDemod::SSBDemod(DeviceAPI *deviceAPI) :
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink),
m_deviceAPI(deviceAPI),
m_spectrumVis(SDR_RX_SCALEF),
m_basebandSampleRate(0)
{
setObjectName(m_channelId);
m_thread = new QThread(this);
m_basebandSink = new SSBDemodBaseband();
m_basebandSink->setSpectrumSink(&m_spectrumVis);
m_basebandSink->moveToThread(m_thread);
applySettings(m_settings, true);

View File

@ -25,6 +25,7 @@
#include <QNetworkRequest>
#include "dsp/basebandsamplesink.h"
#include "dsp/spectrumvis.h"
#include "channel/channelapi.h"
#include "util/message.h"
@ -65,7 +66,7 @@ public:
SSBDemod(DeviceAPI *deviceAPI);
virtual ~SSBDemod();
virtual void destroy() { delete this; }
void setSpectrumSink(BasebandSampleSink* spectrumSink) { m_basebandSink->setSpectrumSink(spectrumSink); }
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
@ -130,6 +131,7 @@ private:
QThread *m_thread;
SSBDemodBaseband* m_basebandSink;
SSBDemodSettings m_settings;
SpectrumVis m_spectrumVis;
int m_basebandSampleRate; //!< stored from device message used when starting baseband sink
QNetworkAccessManager *m_networkManager;

View File

@ -307,11 +307,11 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
m_ssbDemod = (SSBDemod*) rxChannel; //new SSBDemod(m_deviceUISet->m_deviceSourceAPI);
m_spectrumVis = m_ssbDemod->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
m_ssbDemod->setMessageQueueToGUI(getInputMessageQueue());
m_ssbDemod->propagateMessageQueueToGUI();
m_ssbDemod->setSpectrumSink(m_spectrumVis);
CRightClickEnabler *audioMuteRightClickEnabler = new CRightClickEnabler(ui->audioMute);
connect(audioMuteRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(audioSelect()));
@ -366,7 +366,6 @@ SSBDemodGUI::~SSBDemodGUI()
{
m_deviceUISet->removeRxChannelInstance(this);
delete m_ssbDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
delete m_spectrumVis;
delete ui;
}

View File

@ -44,6 +44,7 @@ const QString UDPSink::m_channelId = "UDPSink";
UDPSink::UDPSink(DeviceAPI *deviceAPI) :
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink),
m_deviceAPI(deviceAPI),
m_spectrumVis(SDR_RX_SCALEF),
m_channelSampleRate(48000),
m_channelFrequencyOffset(0)
{
@ -51,6 +52,7 @@ UDPSink::UDPSink(DeviceAPI *deviceAPI) :
m_thread = new QThread(this);
m_basebandSink = new UDPSinkBaseband();
m_basebandSink->setSpectrum(&m_spectrumVis);
m_basebandSink->moveToThread(m_thread);
applySettings(m_settings, true);

View File

@ -23,6 +23,7 @@
#include <QNetworkRequest>
#include "dsp/basebandsamplesink.h"
#include "dsp/spectrumvis.h"
#include "channel/channelapi.h"
#include "util/message.h"
@ -64,7 +65,7 @@ public:
virtual ~UDPSink();
virtual void destroy() { delete this; }
void setSpectrum(BasebandSampleSink* spectrum) { m_basebandSink->setSpectrum(spectrum); }
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
void enableSpectrum(bool enable);
void setSpectrumPositiveOnly(bool positiveOnly) { m_basebandSink->setSpectrumPositiveOnly(positiveOnly); }
double getMagSq() const { return m_basebandSink->getMagSq(); }
@ -130,6 +131,7 @@ protected:
QThread *m_thread;
UDPSinkBaseband* m_basebandSink;
UDPSinkSettings m_settings;
SpectrumVis m_spectrumVis;
int m_basebandSampleRate; //!< stored from device message used when starting baseband sink
int m_channelSampleRate;

View File

@ -171,9 +171,9 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandS
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
setAttribute(Qt::WA_DeleteOnClose, true);
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
m_udpSink = (UDPSink*) rxChannel; //new UDPSrc(m_deviceUISet->m_deviceSourceAPI);
m_udpSink->setSpectrum(m_spectrumVis);
m_spectrumVis = m_udpSink->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
m_udpSink->setMessageQueueToGUI(getInputMessageQueue());
ui->fmDeviation->setEnabled(false);
@ -232,7 +232,6 @@ UDPSinkGUI::~UDPSinkGUI()
{
m_deviceUISet->removeRxChannelInstance(this);
delete m_udpSink; // TODO: check this: when the GUI closes it has to delete the demodulator
delete m_spectrumVis;
delete ui;
}

View File

@ -52,6 +52,7 @@ const QString FreeDVMod::m_channelId = "FreeDVMod";
FreeDVMod::FreeDVMod(DeviceAPI *deviceAPI) :
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSource),
m_deviceAPI(deviceAPI),
m_spectrumVis(SDR_TX_SCALEF),
m_settingsMutex(QMutex::Recursive),
m_fileSize(0),
m_recordLength(0),
@ -61,6 +62,7 @@ FreeDVMod::FreeDVMod(DeviceAPI *deviceAPI) :
m_thread = new QThread(this);
m_basebandSource = new FreeDVModBaseband();
m_basebandSource->setSpectrumSampleSink(&m_spectrumVis);
m_basebandSource->setInputFileStream(&m_ifstream);
m_basebandSource->moveToThread(m_thread);
@ -622,11 +624,6 @@ void FreeDVMod::networkManagerFinished(QNetworkReply *reply)
reply->deleteLater();
}
void FreeDVMod::setSpectrumSampleSink(BasebandSampleSink* sampleSink)
{
m_basebandSource->setSpectrumSampleSink(sampleSink);
}
uint32_t FreeDVMod::getAudioSampleRate() const
{
return m_basebandSource->getAudioSampleRate();

View File

@ -26,8 +26,9 @@
#include <QNetworkRequest>
#include "dsp/basebandsamplesource.h"
#include "channel/channelapi.h"
#include "dsp/basebandsamplesink.h"
#include "dsp/spectrumvis.h"
#include "channel/channelapi.h"
#include "util/message.h"
#include "freedvmodsettings.h"
@ -224,6 +225,7 @@ public:
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response);
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
uint32_t getAudioSampleRate() const;
uint32_t getModemSampleRate() const;
Real getLowCutoff() const;
@ -231,7 +233,6 @@ public:
double getMagSq() const;
CWKeyer *getCWKeyer();
void setLevelMeter(QObject *levelMeter);
void setSpectrumSampleSink(BasebandSampleSink* sampleSink);
uint32_t getNumberOfDeviceStreams() const;
static const QString m_channelIdURI;
@ -247,6 +248,7 @@ private:
QThread *m_thread;
FreeDVModBaseband* m_basebandSource;
FreeDVModSettings m_settings;
SpectrumVis m_spectrumVis;
SampleVector m_sampleBuffer;
QMutex m_settingsMutex;

View File

@ -369,9 +369,9 @@ FreeDVModGUI::FreeDVModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, ui->glSpectrum);
m_freeDVMod = (FreeDVMod*) channelTx;
m_freeDVMod->setSpectrumSampleSink(m_spectrumVis);
m_spectrumVis = m_freeDVMod->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
m_freeDVMod->setMessageQueueToGUI(getInputMessageQueue());
resetToDefaults();
@ -419,7 +419,6 @@ FreeDVModGUI::~FreeDVModGUI()
{
m_deviceUISet->removeTxChannelInstance(this);
delete m_freeDVMod; // TODO: check this: when the GUI closes it has to delete the modulator
delete m_spectrumVis;
delete ui;
}

View File

@ -53,6 +53,7 @@ const QString SSBMod::m_channelId = "SSBMod";
SSBMod::SSBMod(DeviceAPI *deviceAPI) :
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSource),
m_deviceAPI(deviceAPI),
m_spectrumVis(SDR_TX_SCALEF),
m_settingsMutex(QMutex::Recursive),
m_fileSize(0),
m_recordLength(0),
@ -62,6 +63,7 @@ SSBMod::SSBMod(DeviceAPI *deviceAPI) :
m_thread = new QThread(this);
m_basebandSource = new SSBModBaseband();
m_basebandSource->setSpectrumSink(&m_spectrumVis);
m_basebandSource->setInputFileStream(&m_ifstream);
m_basebandSource->moveToThread(m_thread);
@ -697,11 +699,6 @@ unsigned int SSBMod::getAudioSampleRate() const
return m_basebandSource->getAudioSampleRate();
}
void SSBMod::setSpectrumSink(BasebandSampleSink *sampleSink)
{
m_basebandSource->setSpectrumSink(sampleSink);
}
uint32_t SSBMod::getNumberOfDeviceStreams() const
{
return m_deviceAPI->getNbSinkStreams();

View File

@ -26,6 +26,7 @@
#include <QNetworkRequest>
#include "dsp/basebandsamplesource.h"
#include "dsp/spectrumvis.h"
#include "channel/channelapi.h"
#include "dsp/basebandsamplesink.h"
#include "util/message.h"
@ -222,11 +223,11 @@ public:
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response);
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
double getMagSq() const;
CWKeyer *getCWKeyer();
void setLevelMeter(QObject *levelMeter);
unsigned int getAudioSampleRate() const;
void setSpectrumSink(BasebandSampleSink *sampleSink);
uint32_t getNumberOfDeviceStreams() const;
static const QString m_channelIdURI;
@ -242,6 +243,7 @@ private:
QThread *m_thread;
SSBModBaseband* m_basebandSource;
SSBModSettings m_settings;
SpectrumVis m_spectrumVis;
SampleVector m_sampleBuffer;
QMutex m_settingsMutex;

View File

@ -419,9 +419,9 @@ SSBModGUI::SSBModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, ui->glSpectrum);
m_ssbMod = (SSBMod*) channelTx; //new SSBMod(m_deviceUISet->m_deviceSinkAPI);
m_ssbMod->setSpectrumSink(m_spectrumVis);
m_spectrumVis = m_ssbMod->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
m_ssbMod->setMessageQueueToGUI(getInputMessageQueue());
resetToDefaults();
@ -486,7 +486,6 @@ SSBModGUI::~SSBModGUI()
{
m_deviceUISet->removeTxChannelInstance(this);
delete m_ssbMod; // TODO: check this: when the GUI closes it has to delete the modulator
delete m_spectrumVis;
delete ui;
}

View File

@ -41,12 +41,14 @@ const QString UDPSource::m_channelId = "UDPSource";
UDPSource::UDPSource(DeviceAPI *deviceAPI) :
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSource),
m_deviceAPI(deviceAPI),
m_spectrumVis(SDR_TX_SCALEF),
m_settingsMutex(QMutex::Recursive)
{
setObjectName(m_channelId);
m_thread = new QThread(this);
m_basebandSource = new UDPSourceBaseband();
m_basebandSource->setSpectrumSink(&m_spectrumVis);
m_basebandSource->moveToThread(m_thread);
applySettings(m_settings, true);
@ -127,11 +129,6 @@ bool UDPSource::handleMessage(const Message& cmd)
}
}
void UDPSource::setSpectrumSink(BasebandSampleSink* spectrum)
{
m_basebandSource->setSpectrumSink(spectrum);
}
void UDPSource::setSpectrum(bool enabled)
{
Message* cmd = UDPSourceBaseband::MsgUDPSourceSpectrum::create(enabled);
@ -174,8 +171,10 @@ void UDPSource::applySettings(const UDPSourceSettings& settings, bool force)
if ((settings.m_sampleFormat != m_settings.m_sampleFormat) || force) {
reverseAPIKeys.append("sampleFormat");
}
if ((settings.m_inputSampleRate != m_settings.m_inputSampleRate) || force) {
if ((settings.m_inputSampleRate != m_settings.m_inputSampleRate) || force)
{
reverseAPIKeys.append("inputSampleRate");
m_spectrumVis.configureDSP(0, settings.m_inputSampleRate);
}
if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) {
reverseAPIKeys.append("rfBandwidth");

View File

@ -22,6 +22,7 @@
#include <QNetworkRequest>
#include "dsp/basebandsamplesource.h"
#include "dsp/spectrumvis.h"
#include "channel/channelapi.h"
#include "dsp/basebandsamplesink.h"
#include "util/message.h"
@ -141,11 +142,11 @@ public:
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response);
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
double getMagSq() const;
double getInMagSq() const;
int32_t getBufferGauge() const;
bool getSquelchOpen() const;
void setSpectrumSink(BasebandSampleSink* spectrum);
void setSpectrum(bool enabled);
void resetReadIndex();
void setLevelMeter(QObject *levelMeter);
@ -162,6 +163,7 @@ private:
QThread *m_thread;
UDPSourceBaseband* m_basebandSource;
UDPSourceSettings m_settings;
SpectrumVis m_spectrumVis;
SampleVector m_sampleBuffer;
QMutex m_settingsMutex;

View File

@ -130,9 +130,9 @@ UDPSourceGUI::UDPSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
setAttribute(Qt::WA_DeleteOnClose, true);
m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, ui->glSpectrum);
m_udpSource = (UDPSource*) channelTx;
m_udpSource->setSpectrumSink(m_spectrumVis);
m_spectrumVis = m_udpSource->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
m_udpSource->setMessageQueueToGUI(getInputMessageQueue());
ui->fmDeviation->setEnabled(false);
@ -185,7 +185,6 @@ UDPSourceGUI::~UDPSourceGUI()
{
m_deviceUISet->removeTxChannelInstance(this);
delete m_udpSource; // TODO: check this: when the GUI closes it has to delete the modulator
delete m_spectrumVis;
delete ui;
}

View File

@ -57,8 +57,8 @@ TestSinkGui::TestSinkGui(DeviceUISet *deviceUISet, QWidget* parent) :
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
ui->sampleRate->setValueRange(7, 32000U, 9000000U);
m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, ui->glSpectrum);
m_sampleSink->setSpectrumSink(m_spectrumVis);
m_spectrumVis = m_sampleSink->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
ui->glSpectrum->setCenterFrequency(m_settings.m_centerFrequency);
ui->glSpectrum->setSampleRate(m_settings.m_sampleRate*(1<<m_settings.m_log2Interp));
ui->glSpectrum->connectTimer(MainWindow::getInstance()->getMasterTimer());
@ -76,7 +76,6 @@ TestSinkGui::TestSinkGui(DeviceUISet *deviceUISet, QWidget* parent) :
TestSinkGui::~TestSinkGui()
{
delete m_spectrumVis;
delete ui;
}

View File

@ -38,10 +38,10 @@ MESSAGE_CLASS_DEFINITION(TestSinkOutput::MsgStartStop, Message)
TestSinkOutput::TestSinkOutput(DeviceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
m_settings(),
m_spectrumVis(SDR_TX_SCALEF),
m_testSinkThread(nullptr),
m_deviceDescription("TestSink"),
m_masterTimer(deviceAPI->getMasterTimer()),
m_spectrumSink(nullptr)
m_masterTimer(deviceAPI->getMasterTimer())
{
m_deviceAPI->setNbSinkStreams(1);
}
@ -67,7 +67,7 @@ bool TestSinkOutput::start()
qDebug() << "TestSinkOutput::start";
m_testSinkThread = new TestSinkThread(&m_sampleSourceFifo);
m_testSinkThread->setSpectrumSink(m_spectrumSink);
m_testSinkThread->setSpectrumSink(&m_spectrumVis);
m_testSinkThread->setSamplerate(m_settings.m_sampleRate);
m_testSinkThread->setLog2Interpolation(m_settings.m_log2Interp);
m_testSinkThread->connectTimer(m_masterTimer);

View File

@ -25,6 +25,7 @@
#include <fstream>
#include "dsp/devicesamplesink.h"
#include "dsp/spectrumvis.h"
#include "testsinksettings.h"
class TestSinkThread;
@ -104,17 +105,17 @@ public:
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage);
void setSpectrumSink(BasebandSampleSink* spectrumSink) { m_spectrumSink = spectrumSink; }
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
private:
DeviceAPI *m_deviceAPI;
QMutex m_mutex;
TestSinkSettings m_settings;
SpectrumVis m_spectrumVis;
std::ofstream m_ofstream;
TestSinkThread* m_testSinkThread;
QString m_deviceDescription;
const QTimer& m_masterTimer;
BasebandSampleSink* m_spectrumSink;
void applySettings(const TestSinkSettings& settings, bool force = false);
};

View File

@ -38,10 +38,12 @@ inline double log2f(double n)
MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureSpectrumVis, Message)
MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureDSP, Message)
MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureScalingFactor, Message)
MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureWSpectrumOpenClose, Message)
MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureWSpectrum, Message)
const Real SpectrumVis::m_mult = (10.0f / log2f(10.0f));
SpectrumVis::SpectrumVis(Real scalef, GLSpectrumInterface* glSpectrum) :
SpectrumVis::SpectrumVis(Real scalef) :
BasebandSampleSink(),
m_fft(nullptr),
m_fftEngineSequence(0),
@ -50,7 +52,7 @@ SpectrumVis::SpectrumVis(Real scalef, GLSpectrumInterface* glSpectrum) :
m_fftBufferFill(0),
m_needMoreSamples(false),
m_scalef(scalef),
m_glSpectrum(glSpectrum),
m_glSpectrum(nullptr),
m_averageNb(0),
m_avgMode(AvgModeNone),
m_linear(false),
@ -62,7 +64,7 @@ SpectrumVis::SpectrumVis(Real scalef, GLSpectrumInterface* glSpectrum) :
{
setObjectName("SpectrumVis");
handleConfigure(1024, 0, 100, 0, 0, AvgModeNone, FFTWindow::BlackmanHarris, false);
m_wsSpectrum.openSocket(); // FIXME: conditional
//m_wsSpectrum.openSocket(); // FIXME: conditional
}
SpectrumVis::~SpectrumVis()
@ -71,6 +73,18 @@ SpectrumVis::~SpectrumVis()
fftFactory->releaseEngine(m_fftSize, false, m_fftEngineSequence);
}
void SpectrumVis::openWSSpectrum()
{
MsgConfigureWSpectrumOpenClose *cmd = new MsgConfigureWSpectrumOpenClose(true);
getInputMessageQueue()->push(cmd);
}
void SpectrumVis::closeWSSpectrum()
{
MsgConfigureWSpectrumOpenClose *cmd = new MsgConfigureWSpectrumOpenClose(false);
getInputMessageQueue()->push(cmd);
}
void SpectrumVis::configure(MessageQueue* msgQueue,
int fftSize,
float refLevel,
@ -106,6 +120,12 @@ void SpectrumVis::setScalef(Real scalef)
getInputMessageQueue()->push(cmd);
}
void SpectrumVis::configureWSSpectrum(const QString& address, uint16_t port)
{
MsgConfigureWSpectrum* cmd = new MsgConfigureWSpectrum(address, port);
getInputMessageQueue()->push(cmd);
}
void SpectrumVis::feedTriggered(const SampleVector::const_iterator& triggerPoint, const SampleVector::const_iterator& end, bool positiveOnly)
{
feed(triggerPoint, end, positiveOnly); // normal feed from trigger point
@ -617,7 +637,17 @@ void SpectrumVis::stop()
bool SpectrumVis::handleMessage(const Message& message)
{
if (MsgConfigureSpectrumVis::match(message))
if (DSPSignalNotification::match(message))
{
// This is coming from device engine and will apply to main spectrum
DSPSignalNotification& notif = (DSPSignalNotification&) message;
qDebug() << "SpectrumVis::handleMessage: DSPSignalNotification:"
<< " centerFrequency: " << notif.getCenterFrequency()
<< " sampleRate: " << notif.getSampleRate();
handleConfigureDSP(notif.getCenterFrequency(), notif.getSampleRate());
return true;
}
else if (MsgConfigureSpectrumVis::match(message))
{
MsgConfigureSpectrumVis& conf = (MsgConfigureSpectrumVis&) message;
handleConfigure(conf.getFFTSize(),
@ -632,6 +662,7 @@ bool SpectrumVis::handleMessage(const Message& message)
}
else if (MsgConfigureDSP::match(message))
{
// This is coming from plugins GUI via configureDSP for auxiliary spectra
MsgConfigureDSP& conf = (MsgConfigureDSP&) message;
handleConfigureDSP(conf.getCenterFrequency(), conf.getSampleRate());
return true;
@ -641,6 +672,15 @@ bool SpectrumVis::handleMessage(const Message& message)
MsgConfigureScalingFactor& conf = (MsgConfigureScalingFactor&) message;
handleScalef(conf.getScalef());
return true;
}
else if (MsgConfigureWSpectrumOpenClose::match(message))
{
MsgConfigureWSpectrumOpenClose& conf = (MsgConfigureWSpectrumOpenClose&) message;
handleWSOpenClose(conf.getOpenClose());
}
else if (MsgConfigureWSpectrum::match(message)) {
MsgConfigureWSpectrum& conf = (MsgConfigureWSpectrum&) message;
handleConfigureWSSpectrum(conf.getAddress(), conf.getPort());
}
else
{
@ -707,4 +747,34 @@ void SpectrumVis::handleScalef(Real scalef)
{
QMutexLocker mutexLocker(&m_mutex);
m_scalef = scalef;
}
void SpectrumVis::handleWSOpenClose(bool openClose)
{
QMutexLocker mutexLocker(&m_mutex);
if (openClose) {
m_wsSpectrum.openSocket();
} else {
m_wsSpectrum.closeSocket();
}
}
void SpectrumVis::handleConfigureWSSpectrum(const QString& address, uint16_t port)
{
QMutexLocker mutexLocker(&m_mutex);
bool wsSpectrumWasOpen = false;
if (m_wsSpectrum.socketOpened())
{
m_wsSpectrum.closeSocket();
wsSpectrumWasOpen = true;
}
m_wsSpectrum.setListeningAddress(address);
m_wsSpectrum.setPort(port);
if (wsSpectrumWasOpen) {
m_wsSpectrum.openSocket();
}
}

View File

@ -47,6 +47,34 @@ public:
AvgModeMax
};
SpectrumVis(Real scalef);
virtual ~SpectrumVis();
void setGLSpectrum(GLSpectrumInterface* glSpectrum) { m_glSpectrum = glSpectrum; }
void openWSSpectrum();
void closeWSSpectrum();
void configure(MessageQueue* msgQueue,
int fftSize,
float refLevel,
float powerRange,
int overlapPercent,
unsigned int averagingNb,
AvgMode averagingMode,
FFTWindow::Function window,
bool m_linear);
void configureDSP(uint64_t centerFrequency, int sampleRate);
void setScalef(Real scalef);
void configureWSSpectrum(const QString& address, uint16_t port);
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void feed(const Complex *begin, unsigned int length); //!< direct FFT feed
void feedTriggered(const SampleVector::const_iterator& triggerPoint, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
virtual void stop();
virtual bool handleMessage(const Message& message);
private:
class MsgConfigureSpectrumVis : public Message {
MESSAGE_CLASS_DECLARATION
@ -126,29 +154,41 @@ public:
Real m_scalef;
};
SpectrumVis(Real scalef, GLSpectrumInterface* glSpectrum = nullptr);
virtual ~SpectrumVis();
class MsgConfigureWSpectrumOpenClose : public Message
{
MESSAGE_CLASS_DECLARATION
void configure(MessageQueue* msgQueue,
int fftSize,
float refLevel,
float powerRange,
int overlapPercent,
unsigned int averagingNb,
AvgMode averagingMode,
FFTWindow::Function window,
bool m_linear);
void configureDSP(uint64_t centerFrequency, int sampleRate);
void setScalef(Real scalef);
public:
MsgConfigureWSpectrumOpenClose(bool openClose) :
Message(),
m_openClose(openClose)
{}
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void feed(const Complex *begin, unsigned int length); //!< direct FFT feed
void feedTriggered(const SampleVector::const_iterator& triggerPoint, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
virtual void stop();
virtual bool handleMessage(const Message& message);
Real getOpenClose() const { return m_openClose; }
private:
bool m_openClose;
};
class MsgConfigureWSpectrum : public Message
{
MESSAGE_CLASS_DECLARATION
public:
MsgConfigureWSpectrum(const QString& address, uint16_t port) :
Message(),
m_address(address),
m_port(port)
{}
const QString& getAddress() const { return m_address; }
uint16_t getPort() const { return m_port; }
private:
QString m_address;
uint16_t m_port;
};
private:
FFTEngine* m_fft;
FFTWindow m_window;
unsigned int m_fftEngineSequence;
@ -192,9 +232,11 @@ private:
AvgMode averagingMode,
FFTWindow::Function window,
bool linear);
void handleWSOpenClose(bool openClose);
void handleConfigureDSP(uint64_t centerFrequency,
int sampleRate);
void handleScalef(Real scalef);
void handleConfigureWSSpectrum(const QString& address, uint16_t port);
};
#endif // INCLUDE_SPECTRUMVIS_H

View File

@ -37,11 +37,18 @@
DeviceUISet::DeviceUISet(int tabIndex, int deviceType, QTimer& timer)
{
m_spectrum = new GLSpectrum;
if ((deviceType == 0) || (deviceType == 2)) { // Single Rx or MIMO
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, m_spectrum);
} else if (deviceType == 1) { // Single Tx
m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, m_spectrum);
if ((deviceType == 0) || (deviceType == 2)) // Single Rx or MIMO
{
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF);
m_spectrumVis->setGLSpectrum(m_spectrum);
}
else if (deviceType == 1) // Single Tx
{
m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF);
m_spectrumVis->setGLSpectrum(m_spectrum);
}
m_spectrum->connectTimer(timer);
m_spectrumGUI = new GLSpectrumGUI;
m_spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, m_spectrum);