1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-24 10:50:29 -05:00

Enhancements to TCP src plugin. Effectively show channel power on TCP src GUI

This commit is contained in:
f4exb 2015-11-18 06:05:13 +01:00
parent 9b93405554
commit 0492c50e55
6 changed files with 50 additions and 19 deletions

View File

@ -49,6 +49,7 @@ TCPSrc::TCPSrc(MessageQueue* uiMessageQueue, TCPSrcGUI* tcpSrcGUI, SampleSink* s
m_this = 0;
m_scale = 0;
m_boost = 0;
m_magsq = 0;
m_sampleBufferSSB.resize(tcpFftLen);
TCPFilter = new fftfilt(0.3 / 48.0, 16.0 / 48.0, tcpFftLen);
// if (!TCPFilter) segfault;
@ -82,32 +83,43 @@ void TCPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
m_settingsMutex.lock();
// 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) {
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();
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_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);
}
for(int i = 0; i < m_s16leSockets.count(); i++)
{
m_s16leSockets[i].socket->write((const char*)&m_sampleBuffer[0], m_sampleBuffer.size() * 4);
}
if((m_sampleFormat == FormatSSB) && (m_ssbSockets.count() > 0)) {
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);
if (n_out) {
for (int i = 0; i < n_out; i+=2) {
l = (sideband[i].real() + sideband[i].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 * 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));
}
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)) {
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
int n_out = TCPFilter->runFilt(cj, &sideband);
if (n_out) {

View File

@ -31,6 +31,7 @@ public:
void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort, int boost);
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 start();
@ -128,6 +129,7 @@ protected:
Real m_rfBandwidth;
int m_tcpPort;
int m_boost;
Real m_magsq;
Real m_scale;
Complex m_last, m_this;

View File

@ -6,8 +6,10 @@
#include "dsp/spectrumvis.h"
#include "dsp/dspengine.h"
#include "util/simpleserializer.h"
#include "util/db.h"
#include "gui/basicchannelsettingswidget.h"
#include "ui_tcpsrcgui.h"
#include "mainwindow.h"
TCPSrcGUI* TCPSrcGUI::create(PluginAPI* pluginAPI)
{
@ -169,12 +171,20 @@ void TCPSrcGUI::channelMarkerChanged()
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) :
RollupWidget(parent),
ui(new Ui::TCPSrcGUI),
m_pluginAPI(pluginAPI),
m_tcpSrc(NULL),
m_tcpSrc(0),
m_channelMarker(this),
m_channelPowerDbAvg(40,0),
m_basicSettingsShown(false),
m_doApplySettings(true)
{
@ -199,6 +209,9 @@ TCPSrcGUI::TCPSrcGUI(PluginAPI* pluginAPI, QWidget* parent) :
ui->glSpectrum->setDisplayMaxHold(true);
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.setBandwidth(16000);
m_channelMarker.setCenterFrequency(0);

View File

@ -5,6 +5,7 @@
#include "gui/rollupwidget.h"
#include "plugin/plugingui.h"
#include "dsp/channelmarker.h"
#include "dsp/movingaverage.h"
#include "tcpsrc.h"
class PluginAPI;
@ -47,11 +48,14 @@ private slots:
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDoubleClicked();
void on_boost_valueChanged(int value);
void tick();
private:
Ui::TCPSrcGUI* ui;
PluginAPI* m_pluginAPI;
TCPSrc* m_tcpSrc;
ChannelMarker m_channelMarker;
MovingAverage<Real> m_channelPowerDbAvg;
// settings
TCPSrc::SampleFormat m_sampleFormat;
@ -67,7 +71,7 @@ private:
Channelizer* m_channelizer;
SpectrumVis* m_spectrumVis;
explicit TCPSrcGUI(PluginAPI* pluginAPI, QWidget* parent = NULL);
explicit TCPSrcGUI(PluginAPI* pluginAPI, QWidget* parent = 0);
virtual ~TCPSrcGUI();
void blockApplySettings(bool block);

View File

@ -6,11 +6,11 @@
const PluginDescriptor TCPSrcPlugin::m_pluginDescriptor = {
QString("TCP Channel Source"),
QString("ssb"),
QString("(c) maintech GmbH (written by Christian Daniel)"),
QString("http://www.maintech.de"),
QString("---"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
QString("github.com/hexameron/rtl-sdrangelove")
QString("https://github.com/f4exb/sdrangel")
};
TCPSrcPlugin::TCPSrcPlugin(QObject* parent) :
@ -30,14 +30,14 @@ void TCPSrcPlugin::initPlugin(PluginAPI* pluginAPI)
// register TCP Channel Source
QAction* action = new QAction(tr("&TCP Source"), this);
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)
{
if(channelName == "de.maintech.sdrangelove.channel.tcpsrc") {
if(channelName == "sdrangel.channel.tcpsrc") {
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);
return gui;
} else {
@ -48,6 +48,6 @@ PluginGUI* TCPSrcPlugin::createChannel(const QString& channelName)
void TCPSrcPlugin::createInstanceTCPSrc()
{
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);
}

View File

@ -7,7 +7,7 @@
class TCPSrcPlugin : public QObject, PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "de.maintech.sdrangelove.demod.tcpsrc")
Q_PLUGIN_METADATA(IID "sdrangel.demod.tcpsrc")
public:
explicit TCPSrcPlugin(QObject* parent = NULL);