1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-01 12:37:11 -05:00

DATV demod: de-couple MER and CNR GUIs from core

This commit is contained in:
f4exb 2021-10-28 22:50:40 +02:00
parent ed720673f3
commit 4b1a861717
7 changed files with 85 additions and 80 deletions

View File

@ -100,10 +100,6 @@ public:
} }
void SetTVScreen(TVScreen *objScreen) { m_basebandSink->setTVScreen(objScreen); } void SetTVScreen(TVScreen *objScreen) { m_basebandSink->setTVScreen(objScreen); }
void setMERLabel(QLabel *merLabel) { m_basebandSink->setMERLabel(merLabel); }
void setCNRLabel(QLabel *cnrLabel) { m_basebandSink->setCNRLabel(cnrLabel); }
void setMERMeter(LevelMeterSignalDB *merMeter) { m_basebandSink->setMERMeter(merMeter); }
void setCNRMeter(LevelMeterSignalDB *cnrMeter) { m_basebandSink->setCNRMeter(cnrMeter); }
void SetVideoRender(DATVideoRender *objScreen) { m_basebandSink->SetVideoRender(objScreen); } void SetVideoRender(DATVideoRender *objScreen) { m_basebandSink->SetVideoRender(objScreen); }
DATVideostream *getVideoStream() { return m_basebandSink->getVideoStream(); } DATVideostream *getVideoStream() { return m_basebandSink->getVideoStream(); }
DATVUDPStream *getUDPStream() { return m_basebandSink->getUDPStream(); } DATVUDPStream *getUDPStream() { return m_basebandSink->getUDPStream(); }
@ -120,6 +116,15 @@ public:
int getModcodCodeRate() const { return m_basebandSink->getModcodCodeRate(); } int getModcodCodeRate() const { return m_basebandSink->getModcodCodeRate(); }
bool isCstlnSetByModcod() const { return m_basebandSink->isCstlnSetByModcod(); } bool isCstlnSetByModcod() const { return m_basebandSink->isCstlnSetByModcod(); }
float getMERAvg() const { return m_basebandSink->getMERAvg(); }
float getMERRMS() const { return m_basebandSink->getMERRMS(); }
float getMERPeak() const { return m_basebandSink->getMERPeak(); }
int getMERNbAvg() const { return m_basebandSink->getMERNbAvg(); }
float getCNRAvg() const { return m_basebandSink->getCNRAvg(); }
float getCNRRMS() const { return m_basebandSink->getCNRRMS(); }
float getCNRPeak() const { return m_basebandSink->getCNRPeak(); }
int getCNRNbAvg() const { return m_basebandSink->getCNRNbAvg(); }
static const char* const m_channelIdURI; static const char* const m_channelIdURI;
static const char* const m_channelId; static const char* const m_channelId;

View File

@ -66,10 +66,14 @@ public:
int getChannelSampleRate() const; int getChannelSampleRate() const;
double getMagSq() const { return m_sink.getMagSq(); } double getMagSq() const { return m_sink.getMagSq(); }
void setTVScreen(TVScreen *tvScreen) { m_sink.setTVScreen(tvScreen); } void setTVScreen(TVScreen *tvScreen) { m_sink.setTVScreen(tvScreen); }
void setMERLabel(QLabel *merLabel) { m_sink.setMERLabel(merLabel); } float getMERAvg() const { return m_sink.getMERAvg(); }
void setCNRLabel(QLabel *cnrLabel) { m_sink.setCNRLabel(cnrLabel); } float getMERRMS() const { return m_sink.getMERRMS(); }
void setMERMeter(LevelMeterSignalDB *merMeter) { m_sink.setMERMeter(merMeter); } float getMERPeak() const { return m_sink.getMERPeak(); }
void setCNRMeter(LevelMeterSignalDB *cnrMeter) { m_sink.setCNRMeter(cnrMeter); } int getMERNbAvg() const { return m_sink.getMERNbAvg(); }
float getCNRAvg() const { return m_sink.getCNRAvg(); }
float getCNRRMS() const { return m_sink.getCNRRMS(); }
float getCNRPeak() const { return m_sink.getCNRPeak(); }
int getCNRNbAvg() const { return m_sink.getCNRNbAvg(); }
void setMessageQueueToGUI(MessageQueue *messageQueue) { m_sink.setMessageQueueToGUI(messageQueue); } void setMessageQueueToGUI(MessageQueue *messageQueue) { m_sink.setMessageQueueToGUI(messageQueue); }
void setBasebandSampleRate(int sampleRate); //!< To be used when supporting thread is stopped void setBasebandSampleRate(int sampleRate); //!< To be used when supporting thread is stopped
void SetVideoRender(DATVideoRender *objScreen) { m_sink.SetVideoRender(objScreen); } void SetVideoRender(DATVideoRender *objScreen) { m_sink.SetVideoRender(objScreen); }

View File

@ -213,10 +213,6 @@ DATVDemodGUI::DATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Ba
m_objDATVDemod->setMessageQueueToGUI(getInputMessageQueue()); m_objDATVDemod->setMessageQueueToGUI(getInputMessageQueue());
m_objDATVDemod->SetTVScreen(ui->screenTV); m_objDATVDemod->SetTVScreen(ui->screenTV);
m_objDATVDemod->setMERLabel(ui->merText);
m_objDATVDemod->setCNRLabel(ui->cnrText);
m_objDATVDemod->setMERMeter(ui->merMeter);
m_objDATVDemod->setCNRMeter(ui->cnrMeter);
m_objDATVDemod->SetVideoRender(ui->screenTV_2); m_objDATVDemod->SetVideoRender(ui->screenTV_2);
if (m_settings.m_playerEnable) { if (m_settings.m_playerEnable) {
@ -233,6 +229,7 @@ DATVDemodGUI::DATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Ba
m_intReadyDecodedData=0; m_intReadyDecodedData=0;
m_objTimer.setInterval(1000); m_objTimer.setInterval(1000);
connect(&m_objTimer, SIGNAL(timeout()), this, SLOT(tick())); connect(&m_objTimer, SIGNAL(timeout()), this, SLOT(tick()));
connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tickMeter())); // 50 ms
m_objTimer.start(); m_objTimer.start();
ui->fullScreen->setVisible(false); ui->fullScreen->setVisible(false);
@ -582,8 +579,14 @@ void DATVDemodGUI::tick()
} else { } else {
ui->udpIndicator->setStyleSheet("QLabel { background-color: gray; border-radius: 8px; }"); ui->udpIndicator->setStyleSheet("QLabel { background-color: gray; border-radius: 8px; }");
} }
}
return; void DATVDemodGUI::tickMeter()
{
ui->merMeter->levelChanged(m_objDATVDemod->getMERRMS(), m_objDATVDemod->getMERPeak(), m_objDATVDemod->getMERNbAvg());
ui->cnrMeter->levelChanged(m_objDATVDemod->getCNRRMS(), m_objDATVDemod->getCNRPeak(), m_objDATVDemod->getCNRNbAvg());
ui->merText->setText(QString("%1").arg(m_objDATVDemod->getMERAvg(), 0, 'f', 1));
ui->cnrText->setText(QString("%1").arg(m_objDATVDemod->getCNRAvg(), 0, 'f', 1));
} }
void DATVDemodGUI::on_cmbStandard_currentIndexChanged(int index) void DATVDemodGUI::on_cmbStandard_currentIndexChanged(int index)

View File

@ -64,6 +64,7 @@ private slots:
void audioSelect(); void audioSelect();
void ldpcToolSelect(); void ldpcToolSelect();
void tick(); void tick();
void tickMeter();
void on_cmbStandard_currentIndexChanged(int index); void on_cmbStandard_currentIndexChanged(int index);
void on_cmbModulation_currentIndexChanged(const QString &arg1); void on_cmbModulation_currentIndexChanged(const QString &arg1);

View File

@ -39,10 +39,6 @@ DATVDemodSink::DATVDemodSink() :
m_objVideoStream(new DATVideostream()), m_objVideoStream(new DATVideostream()),
m_udpStream(leansdr::tspacket::SIZE), m_udpStream(leansdr::tspacket::SIZE),
m_objRenderThread(nullptr), m_objRenderThread(nullptr),
m_merLabel(nullptr),
m_cnrLabel(nullptr),
m_merMeter(nullptr),
m_cnrMeter(nullptr),
m_audioFifo(48000), m_audioFifo(48000),
m_blnRenderingVideo(false), m_blnRenderingVideo(false),
m_cstlnSetByModcod(false), m_cstlnSetByModcod(false),
@ -96,22 +92,6 @@ bool DATVDemodSink::setTVScreen(TVScreen *objScreen)
return true; return true;
} }
void DATVDemodSink::setMERLabel(QLabel *merLabel) {
m_merLabel = merLabel;
}
void DATVDemodSink::setCNRLabel(QLabel *cnrLabel) {
m_cnrLabel = cnrLabel;
}
void DATVDemodSink::setMERMeter(LevelMeterSignalDB *merMeter) {
m_merMeter = merMeter;
}
void DATVDemodSink::setCNRMeter(LevelMeterSignalDB *cnrMeter) {
m_cnrMeter = cnrMeter;
}
void DATVDemodSink::SetVideoRender(DATVideoRender *objScreen) void DATVDemodSink::SetVideoRender(DATVideoRender *objScreen)
{ {
m_objRegisteredVideoRender = objScreen; m_objRegisteredVideoRender = objScreen;
@ -233,8 +213,8 @@ void DATVDemodSink::CleanUpDATVFramework()
if (r_cnr != nullptr) { if (r_cnr != nullptr) {
delete r_cnr; delete r_cnr;
} }
if (r_cnrGauge != nullptr) { if (r_cnrMeter != nullptr) {
delete r_cnrGauge; delete r_cnrMeter;
} }
//FILTERING //FILTERING
@ -267,8 +247,8 @@ void DATVDemodSink::CleanUpDATVFramework()
if (p_mer != nullptr) { if (p_mer != nullptr) {
delete p_mer; delete p_mer;
} }
if (r_merGauge != nullptr) { if (r_merMeter != nullptr) {
delete r_merGauge; delete r_merMeter;
} }
if (p_sampled != nullptr) { if (p_sampled != nullptr) {
delete p_sampled; delete p_sampled;
@ -460,7 +440,7 @@ void DATVDemodSink::ResetDATVFrameworkPointers()
// CNR ESTIMATION // CNR ESTIMATION
p_cnr = nullptr; p_cnr = nullptr;
r_cnr = nullptr; r_cnr = nullptr;
r_cnrGauge = nullptr; r_cnrMeter = nullptr;
//FILTERING //FILTERING
r_resample = nullptr; r_resample = nullptr;
@ -477,7 +457,7 @@ void DATVDemodSink::ResetDATVFrameworkPointers()
p_freq = nullptr; p_freq = nullptr;
p_ss = nullptr; p_ss = nullptr;
p_mer = nullptr; p_mer = nullptr;
r_merGauge = nullptr; r_merMeter = nullptr;
p_sampled = nullptr; p_sampled = nullptr;
//DECIMATION //DECIMATION
@ -800,13 +780,8 @@ void DATVDemodSink::InitDATVFramework()
r_scope_symbols->calculate_cstln_points(); r_scope_symbols->calculate_cstln_points();
} }
if (m_merLabel && m_merMeter) { r_merMeter = new leansdr::datvmeter(m_objScheduler, *p_mer);
r_merGauge = new leansdr::datvgauge(m_objScheduler, *p_mer, m_merLabel, m_merMeter); r_cnrMeter = new leansdr::datvmeter(m_objScheduler, *p_cnr);
}
if (m_cnrLabel && m_cnrMeter) {
r_cnrGauge = new leansdr::datvgauge(m_objScheduler, *p_cnr, m_cnrLabel, m_cnrMeter);
}
// DECONVOLUTION AND SYNCHRONIZATION // DECONVOLUTION AND SYNCHRONIZATION
@ -1110,13 +1085,8 @@ void DATVDemodSink::InitDATVS2Framework()
r_scope_symbols_dvbs2->calculate_cstln_points(); r_scope_symbols_dvbs2->calculate_cstln_points();
} }
if (m_merLabel && m_merMeter) { r_merMeter = new leansdr::datvmeter(m_objScheduler, *p_mer);
r_merGauge = new leansdr::datvgauge(m_objScheduler, *p_mer, m_merLabel, m_merMeter); r_cnrMeter = new leansdr::datvmeter(m_objScheduler, *p_cnr);
}
if (m_cnrLabel && m_cnrMeter) {
r_cnrGauge = new leansdr::datvgauge(m_objScheduler, *p_cnr, m_cnrLabel, m_cnrMeter);
}
// Bit-flipping mode. // Bit-flipping mode.
// Deinterleave into hard bits. // Deinterleave into hard bits.

View File

@ -30,7 +30,7 @@
#include "leansdr/iess.h" #include "leansdr/iess.h"
#include "datvconstellation.h" #include "datvconstellation.h"
#include "datvgauge.h" #include "datvmeter.h"
#include "datvdvbs2constellation.h" #include "datvdvbs2constellation.h"
#include "datvvideoplayer.h" #include "datvvideoplayer.h"
#include "datvideostream.h" #include "datvideostream.h"
@ -61,10 +61,6 @@ public:
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
bool setTVScreen(TVScreen *objScreen); bool setTVScreen(TVScreen *objScreen);
void setMERLabel(QLabel *merLabel);
void setCNRLabel(QLabel *cnrLabel);
void setMERMeter(LevelMeterSignalDB *merMeter);
void setCNRMeter(LevelMeterSignalDB *cnrMeter);
void SetVideoRender(DATVideoRender *objScreen); void SetVideoRender(DATVideoRender *objScreen);
DATVideostream *getVideoStream() { return m_objVideoStream; } DATVideostream *getVideoStream() { return m_objVideoStream; }
DATVUDPStream *getUDPStream() { return &m_udpStream; } DATVUDPStream *getUDPStream() { return &m_udpStream; }
@ -85,6 +81,38 @@ public:
void setMessageQueueToGUI(MessageQueue *messageQueue) { m_messageQueueToGUI = messageQueue; } void setMessageQueueToGUI(MessageQueue *messageQueue) { m_messageQueueToGUI = messageQueue; }
AudioFifo *getAudioFifo() { return &m_audioFifo; } AudioFifo *getAudioFifo() { return &m_audioFifo; }
float getMERAvg() const {
return r_merMeter ? r_merMeter->m_avg : 0;
}
float getMERRMS() const {
return r_merMeter ? r_merMeter->m_rms : 0;
}
float getMERPeak() const {
return r_merMeter ? r_merMeter->m_peak : 0;
}
int getMERNbAvg() const {
return r_merMeter ? r_merMeter->m_nbAvg : 1;
}
float getCNRAvg() const {
return r_cnrMeter ? r_cnrMeter->m_avg : 0;
}
float getCNRRMS() const {
return r_cnrMeter ? r_cnrMeter->m_rms : 0;
}
float getCNRPeak() const {
return r_cnrMeter ? r_cnrMeter->m_peak : 0;
}
int getCNRNbAvg() const {
return r_cnrMeter ? r_cnrMeter->m_nbAvg : 1;
}
void applySettings(const DATVDemodSettings& settings, bool force = false); void applySettings(const DATVDemodSettings& settings, bool force = false);
void applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force = false); void applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force = false);
@ -286,8 +314,8 @@ private:
//CONSTELLATION //CONSTELLATION
leansdr::datvconstellation<leansdr::f32> *r_scope_symbols; leansdr::datvconstellation<leansdr::f32> *r_scope_symbols;
leansdr::datvdvbs2constellation<leansdr::f32> *r_scope_symbols_dvbs2; leansdr::datvdvbs2constellation<leansdr::f32> *r_scope_symbols_dvbs2;
leansdr::datvgauge *r_merGauge; leansdr::datvmeter *r_merMeter;
leansdr::datvgauge *r_cnrGauge; leansdr::datvmeter *r_cnrMeter;
//*************** DATV PARAMETERS *************** //*************** DATV PARAMETERS ***************
TVScreen *m_objRegisteredTVScreen; TVScreen *m_objRegisteredTVScreen;
@ -295,10 +323,6 @@ private:
DATVideostream *m_objVideoStream; DATVideostream *m_objVideoStream;
DATVUDPStream m_udpStream; DATVUDPStream m_udpStream;
DATVideoRenderThread *m_objRenderThread; DATVideoRenderThread *m_objRenderThread;
QLabel *m_merLabel;
QLabel *m_cnrLabel;
LevelMeterSignalDB *m_merMeter;
LevelMeterSignalDB *m_cnrMeter;
// Audio // Audio
AudioFifo m_audioFifo; AudioFifo m_audioFifo;

View File

@ -16,42 +16,39 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // // along with this program. If not, see <http://www.gnu.org/licenses/>. //
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef DATVGAUGE_H #ifndef DATVMETER_H
#define DATVGAUGE_H #define DATVMETER_H
#include <QLabel>
#include <QString> #include <QString>
#include "leansdr/framework.h" #include "leansdr/framework.h"
#include "leansdr/sdr.h" #include "leansdr/sdr.h"
#include "gui/levelmeter.h"
namespace leansdr { namespace leansdr {
struct datvgauge: runnable struct datvmeter: runnable
{ {
leansdr::pipereader<leansdr::f32> m_in; leansdr::pipereader<leansdr::f32> m_in;
QLabel *m_label; float m_avg;
LevelMeterSignalDB *m_levelMeter; float m_rms;
float m_peak;
static const int m_nbAvg = 10; static const int m_nbAvg = 10;
leansdr::f32 m_samples[m_nbAvg]; leansdr::f32 m_samples[m_nbAvg];
leansdr::f32 m_sum; leansdr::f32 m_sum;
int m_index; int m_index;
datvgauge( datvmeter(
scheduler *sch, scheduler *sch,
leansdr::pipebuf<leansdr::f32> &in, leansdr::pipebuf<leansdr::f32> &in,
QLabel *label = nullptr,
LevelMeterSignalDB *levelMeter = nullptr,
const char *_name = nullptr const char *_name = nullptr
) : ) :
runnable(sch, _name ? _name : in.name), runnable(sch, _name ? _name : in.name),
m_in(in), m_in(in)
m_label(label),
m_levelMeter(levelMeter)
{ {
std::fill(m_samples, m_samples+m_nbAvg, 0); std::fill(m_samples, m_samples+m_nbAvg, 0);
m_avg = 0.0f;
m_rms = 0.0f;
m_peak = 0.0f;
m_sum = 0; m_sum = 0;
m_index = 0; m_index = 0;
} }
@ -66,8 +63,9 @@ struct datvgauge: runnable
oldest = *p; oldest = *p;
leansdr::f32 avg = m_sum/m_nbAvg; leansdr::f32 avg = m_sum/m_nbAvg;
m_levelMeter->levelChanged(avg/30.0, *p/30.0, m_nbAvg); m_avg = avg;
m_label->setText(QString("%1").arg(avg, 0, 'f', 1)); m_rms = avg/30;
m_peak = *p/30;
m_in.read(1); m_in.read(1);
if (m_index == m_nbAvg) { if (m_index == m_nbAvg) {