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

SSB demod: implement level meter

This commit is contained in:
f4exb 2016-12-06 01:58:23 +01:00
parent 79b4e6c945
commit 9eff950730
5 changed files with 75 additions and 5 deletions

View File

@ -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));

View File

@ -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;

View File

@ -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));
}

View File

@ -219,6 +219,33 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="channelPowerMeterLayout">
<item>
<widget class="QLabel" name="channelPowerMeterUnits">
<property name="text">
<string>dB</string>
</property>
</widget>
</item>
<item>
<widget class="LevelMeterSignalDB" name="channelPowerMeter" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="spanLayout">
<item>
@ -498,6 +525,12 @@
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LevelMeterSignalDB</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>

View File

@ -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,