mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-05 22:57:47 -04:00
Enhancements to TCP src plugin. Effectively show channel power on TCP src GUI
This commit is contained in:
parent
9b93405554
commit
0492c50e55
@ -49,6 +49,7 @@ TCPSrc::TCPSrc(MessageQueue* uiMessageQueue, TCPSrcGUI* tcpSrcGUI, SampleSink* s
|
|||||||
m_this = 0;
|
m_this = 0;
|
||||||
m_scale = 0;
|
m_scale = 0;
|
||||||
m_boost = 0;
|
m_boost = 0;
|
||||||
|
m_magsq = 0;
|
||||||
m_sampleBufferSSB.resize(tcpFftLen);
|
m_sampleBufferSSB.resize(tcpFftLen);
|
||||||
TCPFilter = new fftfilt(0.3 / 48.0, 16.0 / 48.0, tcpFftLen);
|
TCPFilter = new fftfilt(0.3 / 48.0, 16.0 / 48.0, tcpFftLen);
|
||||||
// if (!TCPFilter) segfault;
|
// if (!TCPFilter) segfault;
|
||||||
@ -82,32 +83,43 @@ void TCPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
|
|||||||
m_settingsMutex.lock();
|
m_settingsMutex.lock();
|
||||||
|
|
||||||
// Rtl-Sdr uses full 16-bit scale; FCDPP does not
|
// Rtl-Sdr uses full 16-bit scale; FCDPP does not
|
||||||
int rescale = 30000 * (1 << m_boost);
|
//int rescale = 32768 * (1 << m_boost);
|
||||||
|
int rescale = (1 << m_boost);
|
||||||
|
|
||||||
for(SampleVector::const_iterator it = begin; it < end; ++it) {
|
for(SampleVector::const_iterator it = begin; it < end; ++it) {
|
||||||
Complex c(it->real() / 32768.0f, it->imag() / 32768.0f);
|
//Complex c(it->real() / 32768.0f, it->imag() / 32768.0f);
|
||||||
|
Complex c(it->real(), it->imag());
|
||||||
c *= m_nco.nextIQ();
|
c *= m_nco.nextIQ();
|
||||||
|
|
||||||
if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &ci)) {
|
if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &ci))
|
||||||
|
{
|
||||||
|
m_magsq = ((ci.real()*ci.real() + ci.imag()*ci.imag())*rescale*rescale) / (1<<30);
|
||||||
m_sampleBuffer.push_back(Sample(ci.real() * rescale, ci.imag() * rescale));
|
m_sampleBuffer.push_back(Sample(ci.real() * rescale, ci.imag() * rescale));
|
||||||
m_sampleDistanceRemain += m_inputSampleRate / m_outputSampleRate;
|
m_sampleDistanceRemain += m_inputSampleRate / m_outputSampleRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((m_spectrum != NULL) && (m_spectrumEnabled))
|
if((m_spectrum != 0) && (m_spectrumEnabled))
|
||||||
|
{
|
||||||
m_spectrum->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), positiveOnly);
|
m_spectrum->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), positiveOnly);
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < m_s16leSockets.count(); i++)
|
for(int i = 0; i < m_s16leSockets.count(); i++)
|
||||||
|
{
|
||||||
m_s16leSockets[i].socket->write((const char*)&m_sampleBuffer[0], m_sampleBuffer.size() * 4);
|
m_s16leSockets[i].socket->write((const char*)&m_sampleBuffer[0], m_sampleBuffer.size() * 4);
|
||||||
|
}
|
||||||
|
|
||||||
if((m_sampleFormat == FormatSSB) && (m_ssbSockets.count() > 0)) {
|
if((m_sampleFormat == FormatSSB) && (m_ssbSockets.count() > 0)) {
|
||||||
for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) {
|
for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) {
|
||||||
Complex cj(it->real() / 30000.0, it->imag() / 30000.0);
|
//Complex cj(it->real() / 30000.0, it->imag() / 30000.0);
|
||||||
|
Complex cj(it->real(), it->imag());
|
||||||
int n_out = TCPFilter->runSSB(cj, &sideband, true);
|
int n_out = TCPFilter->runSSB(cj, &sideband, true);
|
||||||
if (n_out) {
|
if (n_out) {
|
||||||
for (int i = 0; i < n_out; i+=2) {
|
for (int i = 0; i < n_out; i+=2) {
|
||||||
l = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32000.0;
|
//l = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32000.0;
|
||||||
r = (sideband[i+1].real() + sideband[i+1].imag()) * 0.7 * 32000.0;
|
//r = (sideband[i+1].real() + sideband[i+1].imag()) * 0.7 * 32000.0;
|
||||||
|
l = (sideband[i].real() + sideband[i].imag()) * 0.7;
|
||||||
|
r = (sideband[i+1].real() + sideband[i+1].imag()) * 0.7;
|
||||||
m_sampleBufferSSB.push_back(Sample(l, r));
|
m_sampleBufferSSB.push_back(Sample(l, r));
|
||||||
}
|
}
|
||||||
for(int i = 0; i < m_ssbSockets.count(); i++)
|
for(int i = 0; i < m_ssbSockets.count(); i++)
|
||||||
@ -119,7 +131,7 @@ void TCPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
|
|||||||
|
|
||||||
if((m_sampleFormat == FormatNFM) && (m_ssbSockets.count() > 0)) {
|
if((m_sampleFormat == FormatNFM) && (m_ssbSockets.count() > 0)) {
|
||||||
for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) {
|
for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) {
|
||||||
Complex cj(it->real() / 30000.0, it->imag() / 30000.0);
|
Complex cj(it->real() / 32768.0f, it->imag() / 32768.0f);
|
||||||
// An FFT filter here is overkill, but was already set up for SSB
|
// An FFT filter here is overkill, but was already set up for SSB
|
||||||
int n_out = TCPFilter->runFilt(cj, &sideband);
|
int n_out = TCPFilter->runFilt(cj, &sideband);
|
||||||
if (n_out) {
|
if (n_out) {
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
|
|
||||||
void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort, int boost);
|
void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort, int boost);
|
||||||
void setSpectrum(MessageQueue* messageQueue, bool enabled);
|
void setSpectrum(MessageQueue* messageQueue, bool enabled);
|
||||||
|
Real getMagSq() const { return m_magsq; }
|
||||||
|
|
||||||
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
||||||
virtual void start();
|
virtual void start();
|
||||||
@ -128,6 +129,7 @@ protected:
|
|||||||
Real m_rfBandwidth;
|
Real m_rfBandwidth;
|
||||||
int m_tcpPort;
|
int m_tcpPort;
|
||||||
int m_boost;
|
int m_boost;
|
||||||
|
Real m_magsq;
|
||||||
|
|
||||||
Real m_scale;
|
Real m_scale;
|
||||||
Complex m_last, m_this;
|
Complex m_last, m_this;
|
||||||
|
@ -6,8 +6,10 @@
|
|||||||
#include "dsp/spectrumvis.h"
|
#include "dsp/spectrumvis.h"
|
||||||
#include "dsp/dspengine.h"
|
#include "dsp/dspengine.h"
|
||||||
#include "util/simpleserializer.h"
|
#include "util/simpleserializer.h"
|
||||||
|
#include "util/db.h"
|
||||||
#include "gui/basicchannelsettingswidget.h"
|
#include "gui/basicchannelsettingswidget.h"
|
||||||
#include "ui_tcpsrcgui.h"
|
#include "ui_tcpsrcgui.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
TCPSrcGUI* TCPSrcGUI::create(PluginAPI* pluginAPI)
|
TCPSrcGUI* TCPSrcGUI::create(PluginAPI* pluginAPI)
|
||||||
{
|
{
|
||||||
@ -169,12 +171,20 @@ void TCPSrcGUI::channelMarkerChanged()
|
|||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TCPSrcGUI::tick()
|
||||||
|
{
|
||||||
|
Real powDb = CalcDb::dbPower(m_tcpSrc->getMagSq());
|
||||||
|
m_channelPowerDbAvg.feed(powDb);
|
||||||
|
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
|
||||||
|
}
|
||||||
|
|
||||||
TCPSrcGUI::TCPSrcGUI(PluginAPI* pluginAPI, QWidget* parent) :
|
TCPSrcGUI::TCPSrcGUI(PluginAPI* pluginAPI, QWidget* parent) :
|
||||||
RollupWidget(parent),
|
RollupWidget(parent),
|
||||||
ui(new Ui::TCPSrcGUI),
|
ui(new Ui::TCPSrcGUI),
|
||||||
m_pluginAPI(pluginAPI),
|
m_pluginAPI(pluginAPI),
|
||||||
m_tcpSrc(NULL),
|
m_tcpSrc(0),
|
||||||
m_channelMarker(this),
|
m_channelMarker(this),
|
||||||
|
m_channelPowerDbAvg(40,0),
|
||||||
m_basicSettingsShown(false),
|
m_basicSettingsShown(false),
|
||||||
m_doApplySettings(true)
|
m_doApplySettings(true)
|
||||||
{
|
{
|
||||||
@ -199,6 +209,9 @@ TCPSrcGUI::TCPSrcGUI(PluginAPI* pluginAPI, QWidget* parent) :
|
|||||||
ui->glSpectrum->setDisplayMaxHold(true);
|
ui->glSpectrum->setDisplayMaxHold(true);
|
||||||
m_spectrumVis->configure(m_spectrumVis->getInputMessageQueue(), 64, 10, FFTWindow::BlackmanHarris);
|
m_spectrumVis->configure(m_spectrumVis->getInputMessageQueue(), 64, 10, FFTWindow::BlackmanHarris);
|
||||||
|
|
||||||
|
ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
|
||||||
|
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
|
||||||
|
|
||||||
//m_channelMarker = new ChannelMarker(this);
|
//m_channelMarker = new ChannelMarker(this);
|
||||||
m_channelMarker.setBandwidth(16000);
|
m_channelMarker.setBandwidth(16000);
|
||||||
m_channelMarker.setCenterFrequency(0);
|
m_channelMarker.setCenterFrequency(0);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "gui/rollupwidget.h"
|
#include "gui/rollupwidget.h"
|
||||||
#include "plugin/plugingui.h"
|
#include "plugin/plugingui.h"
|
||||||
#include "dsp/channelmarker.h"
|
#include "dsp/channelmarker.h"
|
||||||
|
#include "dsp/movingaverage.h"
|
||||||
#include "tcpsrc.h"
|
#include "tcpsrc.h"
|
||||||
|
|
||||||
class PluginAPI;
|
class PluginAPI;
|
||||||
@ -47,11 +48,14 @@ private slots:
|
|||||||
void onWidgetRolled(QWidget* widget, bool rollDown);
|
void onWidgetRolled(QWidget* widget, bool rollDown);
|
||||||
void onMenuDoubleClicked();
|
void onMenuDoubleClicked();
|
||||||
void on_boost_valueChanged(int value);
|
void on_boost_valueChanged(int value);
|
||||||
|
void tick();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::TCPSrcGUI* ui;
|
Ui::TCPSrcGUI* ui;
|
||||||
PluginAPI* m_pluginAPI;
|
PluginAPI* m_pluginAPI;
|
||||||
TCPSrc* m_tcpSrc;
|
TCPSrc* m_tcpSrc;
|
||||||
ChannelMarker m_channelMarker;
|
ChannelMarker m_channelMarker;
|
||||||
|
MovingAverage<Real> m_channelPowerDbAvg;
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
TCPSrc::SampleFormat m_sampleFormat;
|
TCPSrc::SampleFormat m_sampleFormat;
|
||||||
@ -67,7 +71,7 @@ private:
|
|||||||
Channelizer* m_channelizer;
|
Channelizer* m_channelizer;
|
||||||
SpectrumVis* m_spectrumVis;
|
SpectrumVis* m_spectrumVis;
|
||||||
|
|
||||||
explicit TCPSrcGUI(PluginAPI* pluginAPI, QWidget* parent = NULL);
|
explicit TCPSrcGUI(PluginAPI* pluginAPI, QWidget* parent = 0);
|
||||||
virtual ~TCPSrcGUI();
|
virtual ~TCPSrcGUI();
|
||||||
|
|
||||||
void blockApplySettings(bool block);
|
void blockApplySettings(bool block);
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
const PluginDescriptor TCPSrcPlugin::m_pluginDescriptor = {
|
const PluginDescriptor TCPSrcPlugin::m_pluginDescriptor = {
|
||||||
QString("TCP Channel Source"),
|
QString("TCP Channel Source"),
|
||||||
QString("ssb"),
|
QString("---"),
|
||||||
QString("(c) maintech GmbH (written by Christian Daniel)"),
|
QString("(c) Edouard Griffiths, F4EXB"),
|
||||||
QString("http://www.maintech.de"),
|
QString("https://github.com/f4exb/sdrangel"),
|
||||||
true,
|
true,
|
||||||
QString("github.com/hexameron/rtl-sdrangelove")
|
QString("https://github.com/f4exb/sdrangel")
|
||||||
};
|
};
|
||||||
|
|
||||||
TCPSrcPlugin::TCPSrcPlugin(QObject* parent) :
|
TCPSrcPlugin::TCPSrcPlugin(QObject* parent) :
|
||||||
@ -30,14 +30,14 @@ void TCPSrcPlugin::initPlugin(PluginAPI* pluginAPI)
|
|||||||
// register TCP Channel Source
|
// register TCP Channel Source
|
||||||
QAction* action = new QAction(tr("&TCP Source"), this);
|
QAction* action = new QAction(tr("&TCP Source"), this);
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(createInstanceTCPSrc()));
|
connect(action, SIGNAL(triggered()), this, SLOT(createInstanceTCPSrc()));
|
||||||
m_pluginAPI->registerChannel("de.maintech.sdrangelove.channel.tcpsrc", this, action);
|
m_pluginAPI->registerChannel("sdrangel.channel.tcpsrc", this, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginGUI* TCPSrcPlugin::createChannel(const QString& channelName)
|
PluginGUI* TCPSrcPlugin::createChannel(const QString& channelName)
|
||||||
{
|
{
|
||||||
if(channelName == "de.maintech.sdrangelove.channel.tcpsrc") {
|
if(channelName == "sdrangel.channel.tcpsrc") {
|
||||||
TCPSrcGUI* gui = TCPSrcGUI::create(m_pluginAPI);
|
TCPSrcGUI* gui = TCPSrcGUI::create(m_pluginAPI);
|
||||||
m_pluginAPI->registerChannelInstance("de.maintech.sdrangelove.channel.tcpsrc", gui);
|
m_pluginAPI->registerChannelInstance("sdrangel.channel.tcpsrc", gui);
|
||||||
m_pluginAPI->addChannelRollup(gui);
|
m_pluginAPI->addChannelRollup(gui);
|
||||||
return gui;
|
return gui;
|
||||||
} else {
|
} else {
|
||||||
@ -48,6 +48,6 @@ PluginGUI* TCPSrcPlugin::createChannel(const QString& channelName)
|
|||||||
void TCPSrcPlugin::createInstanceTCPSrc()
|
void TCPSrcPlugin::createInstanceTCPSrc()
|
||||||
{
|
{
|
||||||
TCPSrcGUI* gui = TCPSrcGUI::create(m_pluginAPI);
|
TCPSrcGUI* gui = TCPSrcGUI::create(m_pluginAPI);
|
||||||
m_pluginAPI->registerChannelInstance("de.maintech.sdrangelove.channel.tcpsrc", gui);
|
m_pluginAPI->registerChannelInstance("sdrangel.channel.tcpsrc", gui);
|
||||||
m_pluginAPI->addChannelRollup(gui);
|
m_pluginAPI->addChannelRollup(gui);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
class TCPSrcPlugin : public QObject, PluginInterface {
|
class TCPSrcPlugin : public QObject, PluginInterface {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(PluginInterface)
|
Q_INTERFACES(PluginInterface)
|
||||||
Q_PLUGIN_METADATA(IID "de.maintech.sdrangelove.demod.tcpsrc")
|
Q_PLUGIN_METADATA(IID "sdrangel.demod.tcpsrc")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TCPSrcPlugin(QObject* parent = NULL);
|
explicit TCPSrcPlugin(QObject* parent = NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user