mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-18 14:21:49 -05:00
UDPSink plugin: implemented channel power display
This commit is contained in:
parent
528e29daf0
commit
4b2dd2263e
@ -26,6 +26,8 @@ UDPSink::UDPSink(MessageQueue* uiMessageQueue, UDPSinkGUI* udpSinkGUI, BasebandS
|
|||||||
m_uiMessageQueue(uiMessageQueue),
|
m_uiMessageQueue(uiMessageQueue),
|
||||||
m_udpSinkGUI(udpSinkGUI),
|
m_udpSinkGUI(udpSinkGUI),
|
||||||
m_spectrum(spectrum),
|
m_spectrum(spectrum),
|
||||||
|
m_magsq(1e-10),
|
||||||
|
m_movingAverage(16, 0),
|
||||||
m_settingsMutex(QMutex::Recursive)
|
m_settingsMutex(QMutex::Recursive)
|
||||||
{
|
{
|
||||||
setObjectName("UDPSink");
|
setObjectName("UDPSink");
|
||||||
@ -81,6 +83,11 @@ void UDPSink::pull(Sample& sample)
|
|||||||
|
|
||||||
m_settingsMutex.unlock();
|
m_settingsMutex.unlock();
|
||||||
|
|
||||||
|
Real magsq = ci.real() * ci.real() + ci.imag() * ci.imag();
|
||||||
|
magsq /= (1<<30);
|
||||||
|
m_movingAverage.feed(magsq);
|
||||||
|
m_magsq = m_movingAverage.average();
|
||||||
|
|
||||||
sample.m_real = (FixReal) ci.real();
|
sample.m_real = (FixReal) ci.real();
|
||||||
sample.m_imag = (FixReal) ci.imag();
|
sample.m_imag = (FixReal) ci.imag();
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "dsp/basebandsamplesource.h"
|
#include "dsp/basebandsamplesource.h"
|
||||||
#include "dsp/basebandsamplesink.h"
|
#include "dsp/basebandsamplesink.h"
|
||||||
#include "dsp/interpolator.h"
|
#include "dsp/interpolator.h"
|
||||||
|
#include "dsp/movingaverage.h"
|
||||||
#include "dsp/nco.h"
|
#include "dsp/nco.h"
|
||||||
#include "util/message.h"
|
#include "util/message.h"
|
||||||
|
|
||||||
@ -51,6 +52,8 @@ public:
|
|||||||
virtual void pull(Sample& sample);
|
virtual void pull(Sample& sample);
|
||||||
virtual bool handleMessage(const Message& cmd);
|
virtual bool handleMessage(const Message& cmd);
|
||||||
|
|
||||||
|
double getMagSq() const { return m_magsq; }
|
||||||
|
|
||||||
void configure(MessageQueue* messageQueue,
|
void configure(MessageQueue* messageQueue,
|
||||||
SampleFormat sampleFormat,
|
SampleFormat sampleFormat,
|
||||||
Real inputSampleRate,
|
Real inputSampleRate,
|
||||||
@ -181,6 +184,9 @@ private:
|
|||||||
Real m_interpolatorDistanceRemain;
|
Real m_interpolatorDistanceRemain;
|
||||||
bool m_interpolatorConsumed;
|
bool m_interpolatorConsumed;
|
||||||
|
|
||||||
|
double m_magsq;
|
||||||
|
MovingAverage<double> m_movingAverage;
|
||||||
|
|
||||||
QMutex m_settingsMutex;
|
QMutex m_settingsMutex;
|
||||||
|
|
||||||
void apply(bool force);
|
void apply(bool force);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#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 "plugin/pluginapi.h"
|
#include "plugin/pluginapi.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
@ -201,6 +202,7 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget*
|
|||||||
ui(new Ui::UDPSinkGUI),
|
ui(new Ui::UDPSinkGUI),
|
||||||
m_pluginAPI(pluginAPI),
|
m_pluginAPI(pluginAPI),
|
||||||
m_deviceAPI(deviceAPI),
|
m_deviceAPI(deviceAPI),
|
||||||
|
m_channelPowerDbAvg(20,0),
|
||||||
m_channelMarker(this),
|
m_channelMarker(this),
|
||||||
m_basicSettingsShown(false),
|
m_basicSettingsShown(false),
|
||||||
m_doApplySettings(true)
|
m_doApplySettings(true)
|
||||||
@ -472,3 +474,10 @@ void UDPSinkGUI::enterEvent(QEvent*)
|
|||||||
blockApplySettings(false);
|
blockApplySettings(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UDPSinkGUI::tick()
|
||||||
|
{
|
||||||
|
double powDb = CalcDb::dbPower(m_udpSink->getMagSq());
|
||||||
|
m_channelPowerDbAvg.feed(powDb);
|
||||||
|
ui->channelPower->setText(tr("%1 dB").arg(m_channelPowerDbAvg.average(), 0, 'f', 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ private slots:
|
|||||||
void onMenuDoubleClicked();
|
void onMenuDoubleClicked();
|
||||||
void on_volume_valueChanged(int value);
|
void on_volume_valueChanged(int value);
|
||||||
void on_channelMute_toggled(bool checked);
|
void on_channelMute_toggled(bool checked);
|
||||||
|
void tick();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::UDPSinkGUI* ui;
|
Ui::UDPSinkGUI* ui;
|
||||||
@ -78,6 +79,7 @@ private:
|
|||||||
UpChannelizer* m_channelizer;
|
UpChannelizer* m_channelizer;
|
||||||
SpectrumVis* m_spectrumVis;
|
SpectrumVis* m_spectrumVis;
|
||||||
UDPSink* m_udpSink;
|
UDPSink* m_udpSink;
|
||||||
|
MovingAverage<double> m_channelPowerDbAvg;
|
||||||
ChannelMarker m_channelMarker;
|
ChannelMarker m_channelMarker;
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
|
Loading…
Reference in New Issue
Block a user