diff --git a/plugins/channelrx/demodssb/ssbdemod.cpp b/plugins/channelrx/demodssb/ssbdemod.cpp index ba8490a7c..8a2e04920 100644 --- a/plugins/channelrx/demodssb/ssbdemod.cpp +++ b/plugins/channelrx/demodssb/ssbdemod.cpp @@ -55,6 +55,10 @@ SSBDemod::SSBDemod(BasebandSampleSink* sampleSink) : m_usb = true; m_magsq = 0.0f; + m_magsqSum = 0.0f; + m_magsqPeak = 0.0f; + m_magsqCount = 0; + SSBFilter = new fftfilt(m_LowCutoff / m_audioSampleRate, m_Bandwidth / m_audioSampleRate, ssbFftLen); DSBFilter = new fftfilt((2.0f * m_Bandwidth) / m_audioSampleRate, 2 * ssbFftLen); @@ -132,6 +136,15 @@ void SSBDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto Real avgi = m_sum.imag() / decim; m_magsq = (avgr * avgr + avgi * avgi) / (1<<30); + m_magsqSum += m_magsq; + + if (m_magsq > m_magsqPeak) + { + m_magsqPeak = m_magsq; + } + + m_magsqCount++; + if (!m_dsb & !m_usb) { // invert spectrum for LSB m_sampleBuffer.push_back(Sample(avgi, avgr)); diff --git a/plugins/channelrx/demodssb/ssbdemod.h b/plugins/channelrx/demodssb/ssbdemod.h index ae81d9474..2e5c89039 100644 --- a/plugins/channelrx/demodssb/ssbdemod.h +++ b/plugins/channelrx/demodssb/ssbdemod.h @@ -51,6 +51,17 @@ public: Real getMagSq() const { return m_magsq; } + void getMagSqLevels(Real& avg, Real& peak, int& nbSamples) + { + avg = m_magsqSum / m_magsqCount; + m_magsq = avg; + peak = m_magsqPeak; + nbSamples = m_magsqCount; + m_magsqSum = 0.0f; + m_magsqPeak = 0.0f; + m_magsqCount = 0; + } + private: class MsgConfigureSSBDemod : public Message { MESSAGE_CLASS_DECLARATION @@ -127,7 +138,10 @@ private: bool m_usb; bool m_dsb; bool m_audioMute; - Real m_magsq; + Real m_magsq; + Real m_magsqSum; + Real m_magsqPeak; + int m_magsqCount; NCO m_nco; Interpolator m_interpolator; diff --git a/plugins/channelrx/demodssb/ssbdemodgui.cpp b/plugins/channelrx/demodssb/ssbdemodgui.cpp index 754b85364..e03f792df 100644 --- a/plugins/channelrx/demodssb/ssbdemodgui.cpp +++ b/plugins/channelrx/demodssb/ssbdemodgui.cpp @@ -347,6 +347,7 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg m_deviceAPI->addThreadedSink(m_threadedChannelizer); ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold)); + ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue); ui->glSpectrum->setCenterFrequency(m_rate/2); ui->glSpectrum->setSampleRate(m_rate); @@ -499,7 +500,16 @@ void SSBDemodGUI::enterEvent(QEvent*) void SSBDemodGUI::tick() { - Real powDb = CalcDb::dbPower(m_ssbDemod->getMagSq()); - m_channelPowerDbAvg.feed(powDb); - ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1)); + Real magsqAvg, magsqPeak; + int nbMagsqSamples; + m_ssbDemod->getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples); + Real powDbAvg = CalcDb::dbPower(magsqAvg); + Real powDbPeak = CalcDb::dbPower(magsqPeak); + + ui->channelPowerMeter->levelChanged( + (100.0f + powDbAvg) / 100.0f, + (100.0f + powDbPeak) / 100.0f, + nbMagsqSamples); + + ui->channelPower->setText(QString::number(powDbAvg, 'f', 1)); } diff --git a/plugins/channelrx/demodssb/ssbdemodgui.ui b/plugins/channelrx/demodssb/ssbdemodgui.ui index 7a59f30fa..a24465924 100644 --- a/plugins/channelrx/demodssb/ssbdemodgui.ui +++ b/plugins/channelrx/demodssb/ssbdemodgui.ui @@ -219,6 +219,33 @@ + + + + + + dB + + + + + + + + 0 + 0 + + + + + 0 + 30 + + + + + + @@ -498,6 +525,12 @@
gui/glspectrumgui.h
1 + + LevelMeterSignalDB + QWidget +
gui/levelmeter.h
+ 1 +
diff --git a/plugins/channelrx/demodssb/ssbplugin.cpp b/plugins/channelrx/demodssb/ssbplugin.cpp index fc6bfb2d9..fe9b12ff3 100644 --- a/plugins/channelrx/demodssb/ssbplugin.cpp +++ b/plugins/channelrx/demodssb/ssbplugin.cpp @@ -7,7 +7,7 @@ const PluginDescriptor SSBPlugin::m_pluginDescriptor = { QString("SSB Demodulator"), - QString("2.1.1"), + QString("2.4.0"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true,