diff --git a/plugins/channelrx/demoddatv/datvdemod.h b/plugins/channelrx/demoddatv/datvdemod.h index 5a7095c7f..6c4bab512 100644 --- a/plugins/channelrx/demoddatv/datvdemod.h +++ b/plugins/channelrx/demoddatv/datvdemod.h @@ -100,10 +100,6 @@ public: } 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); } DATVideostream *getVideoStream() { return m_basebandSink->getVideoStream(); } DATVUDPStream *getUDPStream() { return m_basebandSink->getUDPStream(); } @@ -120,6 +116,15 @@ public: int getModcodCodeRate() const { return m_basebandSink->getModcodCodeRate(); } 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_channelId; diff --git a/plugins/channelrx/demoddatv/datvdemodbaseband.h b/plugins/channelrx/demoddatv/datvdemodbaseband.h index 522e36146..bfabc3bbd 100644 --- a/plugins/channelrx/demoddatv/datvdemodbaseband.h +++ b/plugins/channelrx/demoddatv/datvdemodbaseband.h @@ -66,10 +66,14 @@ public: int getChannelSampleRate() const; double getMagSq() const { return m_sink.getMagSq(); } void setTVScreen(TVScreen *tvScreen) { m_sink.setTVScreen(tvScreen); } - void setMERLabel(QLabel *merLabel) { m_sink.setMERLabel(merLabel); } - void setCNRLabel(QLabel *cnrLabel) { m_sink.setCNRLabel(cnrLabel); } - void setMERMeter(LevelMeterSignalDB *merMeter) { m_sink.setMERMeter(merMeter); } - void setCNRMeter(LevelMeterSignalDB *cnrMeter) { m_sink.setCNRMeter(cnrMeter); } + float getMERAvg() const { return m_sink.getMERAvg(); } + float getMERRMS() const { return m_sink.getMERRMS(); } + float getMERPeak() const { return m_sink.getMERPeak(); } + 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 setBasebandSampleRate(int sampleRate); //!< To be used when supporting thread is stopped void SetVideoRender(DATVideoRender *objScreen) { m_sink.SetVideoRender(objScreen); } diff --git a/plugins/channelrx/demoddatv/datvdemodgui.cpp b/plugins/channelrx/demoddatv/datvdemodgui.cpp index bd12e1e32..c2f6af455 100644 --- a/plugins/channelrx/demoddatv/datvdemodgui.cpp +++ b/plugins/channelrx/demoddatv/datvdemodgui.cpp @@ -213,10 +213,6 @@ DATVDemodGUI::DATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Ba m_objDATVDemod->setMessageQueueToGUI(getInputMessageQueue()); 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); if (m_settings.m_playerEnable) { @@ -233,6 +229,7 @@ DATVDemodGUI::DATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Ba m_intReadyDecodedData=0; m_objTimer.setInterval(1000); connect(&m_objTimer, SIGNAL(timeout()), this, SLOT(tick())); + connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tickMeter())); // 50 ms m_objTimer.start(); ui->fullScreen->setVisible(false); @@ -582,8 +579,14 @@ void DATVDemodGUI::tick() } else { 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) diff --git a/plugins/channelrx/demoddatv/datvdemodgui.h b/plugins/channelrx/demoddatv/datvdemodgui.h index a2f1966fd..512cc1c90 100644 --- a/plugins/channelrx/demoddatv/datvdemodgui.h +++ b/plugins/channelrx/demoddatv/datvdemodgui.h @@ -64,6 +64,7 @@ private slots: void audioSelect(); void ldpcToolSelect(); void tick(); + void tickMeter(); void on_cmbStandard_currentIndexChanged(int index); void on_cmbModulation_currentIndexChanged(const QString &arg1); diff --git a/plugins/channelrx/demoddatv/datvdemodsink.cpp b/plugins/channelrx/demoddatv/datvdemodsink.cpp index 931c70d87..1ac11b0e8 100644 --- a/plugins/channelrx/demoddatv/datvdemodsink.cpp +++ b/plugins/channelrx/demoddatv/datvdemodsink.cpp @@ -39,10 +39,6 @@ DATVDemodSink::DATVDemodSink() : m_objVideoStream(new DATVideostream()), m_udpStream(leansdr::tspacket::SIZE), m_objRenderThread(nullptr), - m_merLabel(nullptr), - m_cnrLabel(nullptr), - m_merMeter(nullptr), - m_cnrMeter(nullptr), m_audioFifo(48000), m_blnRenderingVideo(false), m_cstlnSetByModcod(false), @@ -96,22 +92,6 @@ bool DATVDemodSink::setTVScreen(TVScreen *objScreen) 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) { m_objRegisteredVideoRender = objScreen; @@ -233,8 +213,8 @@ void DATVDemodSink::CleanUpDATVFramework() if (r_cnr != nullptr) { delete r_cnr; } - if (r_cnrGauge != nullptr) { - delete r_cnrGauge; + if (r_cnrMeter != nullptr) { + delete r_cnrMeter; } //FILTERING @@ -267,8 +247,8 @@ void DATVDemodSink::CleanUpDATVFramework() if (p_mer != nullptr) { delete p_mer; } - if (r_merGauge != nullptr) { - delete r_merGauge; + if (r_merMeter != nullptr) { + delete r_merMeter; } if (p_sampled != nullptr) { delete p_sampled; @@ -460,7 +440,7 @@ void DATVDemodSink::ResetDATVFrameworkPointers() // CNR ESTIMATION p_cnr = nullptr; r_cnr = nullptr; - r_cnrGauge = nullptr; + r_cnrMeter = nullptr; //FILTERING r_resample = nullptr; @@ -477,7 +457,7 @@ void DATVDemodSink::ResetDATVFrameworkPointers() p_freq = nullptr; p_ss = nullptr; p_mer = nullptr; - r_merGauge = nullptr; + r_merMeter = nullptr; p_sampled = nullptr; //DECIMATION @@ -800,13 +780,8 @@ void DATVDemodSink::InitDATVFramework() r_scope_symbols->calculate_cstln_points(); } - if (m_merLabel && m_merMeter) { - r_merGauge = new leansdr::datvgauge(m_objScheduler, *p_mer, m_merLabel, m_merMeter); - } - - if (m_cnrLabel && m_cnrMeter) { - r_cnrGauge = new leansdr::datvgauge(m_objScheduler, *p_cnr, m_cnrLabel, m_cnrMeter); - } + r_merMeter = new leansdr::datvmeter(m_objScheduler, *p_mer); + r_cnrMeter = new leansdr::datvmeter(m_objScheduler, *p_cnr); // DECONVOLUTION AND SYNCHRONIZATION @@ -1110,13 +1085,8 @@ void DATVDemodSink::InitDATVS2Framework() r_scope_symbols_dvbs2->calculate_cstln_points(); } - if (m_merLabel && m_merMeter) { - r_merGauge = new leansdr::datvgauge(m_objScheduler, *p_mer, m_merLabel, m_merMeter); - } - - if (m_cnrLabel && m_cnrMeter) { - r_cnrGauge = new leansdr::datvgauge(m_objScheduler, *p_cnr, m_cnrLabel, m_cnrMeter); - } + r_merMeter = new leansdr::datvmeter(m_objScheduler, *p_mer); + r_cnrMeter = new leansdr::datvmeter(m_objScheduler, *p_cnr); // Bit-flipping mode. // Deinterleave into hard bits. diff --git a/plugins/channelrx/demoddatv/datvdemodsink.h b/plugins/channelrx/demoddatv/datvdemodsink.h index 331efb3e1..a6287e414 100644 --- a/plugins/channelrx/demoddatv/datvdemodsink.h +++ b/plugins/channelrx/demoddatv/datvdemodsink.h @@ -30,7 +30,7 @@ #include "leansdr/iess.h" #include "datvconstellation.h" -#include "datvgauge.h" +#include "datvmeter.h" #include "datvdvbs2constellation.h" #include "datvvideoplayer.h" #include "datvideostream.h" @@ -61,10 +61,6 @@ public: virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end); bool setTVScreen(TVScreen *objScreen); - void setMERLabel(QLabel *merLabel); - void setCNRLabel(QLabel *cnrLabel); - void setMERMeter(LevelMeterSignalDB *merMeter); - void setCNRMeter(LevelMeterSignalDB *cnrMeter); void SetVideoRender(DATVideoRender *objScreen); DATVideostream *getVideoStream() { return m_objVideoStream; } DATVUDPStream *getUDPStream() { return &m_udpStream; } @@ -85,6 +81,38 @@ public: void setMessageQueueToGUI(MessageQueue *messageQueue) { m_messageQueueToGUI = messageQueue; } 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 applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force = false); @@ -286,8 +314,8 @@ private: //CONSTELLATION leansdr::datvconstellation *r_scope_symbols; leansdr::datvdvbs2constellation *r_scope_symbols_dvbs2; - leansdr::datvgauge *r_merGauge; - leansdr::datvgauge *r_cnrGauge; + leansdr::datvmeter *r_merMeter; + leansdr::datvmeter *r_cnrMeter; //*************** DATV PARAMETERS *************** TVScreen *m_objRegisteredTVScreen; @@ -295,10 +323,6 @@ private: DATVideostream *m_objVideoStream; DATVUDPStream m_udpStream; DATVideoRenderThread *m_objRenderThread; - QLabel *m_merLabel; - QLabel *m_cnrLabel; - LevelMeterSignalDB *m_merMeter; - LevelMeterSignalDB *m_cnrMeter; // Audio AudioFifo m_audioFifo; diff --git a/plugins/channelrx/demoddatv/datvgauge.h b/plugins/channelrx/demoddatv/datvmeter.h similarity index 83% rename from plugins/channelrx/demoddatv/datvgauge.h rename to plugins/channelrx/demoddatv/datvmeter.h index 50f9cd277..65e052fc1 100644 --- a/plugins/channelrx/demoddatv/datvgauge.h +++ b/plugins/channelrx/demoddatv/datvmeter.h @@ -16,42 +16,39 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// -#ifndef DATVGAUGE_H -#define DATVGAUGE_H +#ifndef DATVMETER_H +#define DATVMETER_H -#include #include #include "leansdr/framework.h" #include "leansdr/sdr.h" -#include "gui/levelmeter.h" - namespace leansdr { -struct datvgauge: runnable +struct datvmeter: runnable { leansdr::pipereader m_in; - QLabel *m_label; - LevelMeterSignalDB *m_levelMeter; + float m_avg; + float m_rms; + float m_peak; static const int m_nbAvg = 10; leansdr::f32 m_samples[m_nbAvg]; leansdr::f32 m_sum; int m_index; - datvgauge( + datvmeter( scheduler *sch, leansdr::pipebuf &in, - QLabel *label = nullptr, - LevelMeterSignalDB *levelMeter = nullptr, const char *_name = nullptr ) : runnable(sch, _name ? _name : in.name), - m_in(in), - m_label(label), - m_levelMeter(levelMeter) + m_in(in) { 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_index = 0; } @@ -66,8 +63,9 @@ struct datvgauge: runnable oldest = *p; leansdr::f32 avg = m_sum/m_nbAvg; - m_levelMeter->levelChanged(avg/30.0, *p/30.0, m_nbAvg); - m_label->setText(QString("%1").arg(avg, 0, 'f', 1)); + m_avg = avg; + m_rms = avg/30; + m_peak = *p/30; m_in.read(1); if (m_index == m_nbAvg) {