1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00

BFM and DSD Demods: added signal strength gauge. Limit height on all signal gauges

This commit is contained in:
f4exb 2016-12-06 19:06:38 +01:00
parent e6047fbdf3
commit 30de817ba6
11 changed files with 332 additions and 39 deletions

View File

@ -56,7 +56,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -199,7 +208,7 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
<height>26</height>
</size>
</property>
<property name="toolTip">
@ -378,6 +387,26 @@
</customwidgets>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -63,7 +63,11 @@ BFMDemod::BFMDemod(BasebandSampleSink* sampleSink, RDSParser *rdsParser) :
m_audioBuffer.resize(16384);
m_audioBufferFill = 0;
m_movingAverage.resize(16, 0);
// m_movingAverage.resize(16, 0);
m_magsq = 0.0f;
m_magsqSum = 0.0f;
m_magsqPeak = 0.0f;
m_magsqCount = 0;
DSPEngine::instance()->addAudioSink(&m_audioFifo);
}
@ -121,10 +125,20 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
{
msq = rf[i].real()*rf[i].real() + rf[i].imag()*rf[i].imag();
m_movingAverage.feed(msq);
m_magsqSum += msq;
if(m_movingAverage.average() >= m_squelchLevel)
if (msq > m_magsqPeak)
{
m_magsqPeak = msq;
}
m_magsqCount++;
// m_movingAverage.feed(msq);
if(m_magsq >= m_squelchLevel) {
m_squelchState = m_running.m_rfBandwidth / 20; // decay rate
}
if(m_squelchState > 0)
{

View File

@ -58,7 +58,7 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_movingAverage.average(); }
Real getMagSq() const { return m_magsq; }
bool getPilotLock() const { return m_pilotPLL.locked(); }
Real getPilotLevel() const { return m_pilotPLL.get_pilot_level(); }
@ -69,6 +69,17 @@ public:
Real getDemodQua() const { return m_rdsDemod.m_report.qua; }
Real getDemodFclk() const { return m_rdsDemod.m_report.fclk; }
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 MsgConfigureBFMDemod : public Message {
MESSAGE_CLASS_DECLARATION
@ -196,7 +207,11 @@ private:
Real m_m1Arg; //!> x^-1 real sample
MovingAverage<Real> m_movingAverage;
// MovingAverage<Real> m_movingAverage;
Real m_magsq;
Real m_magsqSum;
Real m_magsqPeak;
int m_magsqCount;
AudioVector m_audioBuffer;
uint m_audioBufferFill;

View File

@ -374,6 +374,7 @@ BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
ui->setupUi(this);
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
ui->deltaFrequency->setValueRange(7, 0U, 9999999U);
ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue);
setAttribute(Qt::WA_DeleteOnClose, true);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
@ -476,9 +477,22 @@ void BFMDemodGUI::enterEvent(QEvent*)
void BFMDemodGUI::tick()
{
Real powDb = CalcDb::dbPower(m_bfmDemod->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
Real magsqAvg, magsqPeak;
int nbMagsqSamples;
m_bfmDemod->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));
// Real powDb = CalcDb::dbPower(m_bfmDemod->getMagSq());
// m_channelPowerDbAvg.feed(powDb);
// ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
Real pilotPowDb = CalcDb::dbPower(m_bfmDemod->getPilotLevel());
QString pilotPowDbStr;

View File

@ -28,7 +28,7 @@
<x>10</x>
<y>20</y>
<width>411</width>
<height>121</height>
<height>151</height>
</rect>
</property>
<property name="windowTitle">
@ -38,7 +38,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -241,6 +250,36 @@
</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="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>26</height>
</size>
</property>
<property name="toolTip">
<string>Level meter (dB) top trace: average, bottom trace: instantaneous peak, tip: peak hold</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="rfBandwidthLayout">
<item>
@ -443,7 +482,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -465,7 +513,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>150</y>
<y>170</y>
<width>791</width>
<height>301</height>
</rect>
@ -1775,6 +1823,12 @@
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>LevelMeterSignalDB</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
@ -1790,6 +1844,26 @@
</customwidgets>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -67,7 +67,11 @@ DSDDemod::DSDDemod(BasebandSampleSink* sampleSink) :
m_sampleBuffer = new qint16[1<<17]; // 128 kS
m_sampleBufferIndex = 0;
m_movingAverage.resize(50, 0);
// m_movingAverage.resize(50, 0);
m_magsq = 0.0f;
m_magsqSum = 0.0f;
m_magsqPeak = 0.0f;
m_magsqCount = 0;
DSPEngine::instance()->addAudioSink(&m_audioFifo1);
DSPEngine::instance()->addAudioSink(&m_audioFifo2);
@ -136,8 +140,17 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
{
qint16 sample, delayedSample;
m_magsq = ((ci.real()*ci.real() + ci.imag()*ci.imag()));
m_movingAverage.feed(m_magsq);
Real magsq = ((ci.real()*ci.real() + ci.imag()*ci.imag())) / (1<<30);
// m_movingAverage.feed(m_magsq);
m_magsqSum += magsq;
if (magsq > m_magsqPeak)
{
m_magsqPeak = magsq;
}
m_magsqCount++;
Real demod = 32768.0f * m_phaseDiscri.phaseDiscriminator(ci) * ((float) m_running.m_demodGain / 100.0f);
m_sampleCount++;

View File

@ -67,11 +67,22 @@ public:
m_dsdDemodGUI = dsdDemodGUI;
}
double getMagSq() { return m_movingAverage.average() / (double) (1<<30); }
double getMagSq() { return m_magsq; }
bool getSquelchOpen() const { return m_squelchOpen; }
const DSDDecoder& getDecoder() const { return m_dsdDecoder; }
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 MsgConfigureMyPosition : public Message {
MESSAGE_CLASS_DECLARATION
@ -251,8 +262,11 @@ private:
bool m_squelchOpen;
Real m_lastArgument;
MovingAverage<double> m_movingAverage;
double m_magsq;
// MovingAverage<double> m_movingAverage;
Real m_magsq;
Real m_magsqSum;
Real m_magsqPeak;
int m_magsqCount;
Real m_fmExcursion;

View File

@ -370,6 +370,7 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue);
m_channelizer = new DownChannelizer(m_dsdDemod);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
@ -619,9 +620,22 @@ void DSDDemodGUI::formatStatusText()
void DSDDemodGUI::tick()
{
Real powDb = CalcDb::dbPower(m_dsdDemod->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
Real magsqAvg, magsqPeak;
int nbMagsqSamples;
m_dsdDemod->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));
// Real powDb = CalcDb::dbPower(m_dsdDemod->getMagSq());
// m_channelPowerDbAvg.feed(powDb);
// ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
bool squelchOpen = m_dsdDemod->getSquelchOpen();

View File

@ -370,6 +370,36 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="channelPowerMeterLayout">
<item>
<widget class="QLabel" name="channelPowerMeterUnits">
<property name="toolTip">
<string>Level meter (dB) top trace: average, bottom trace: instantaneous peak, tip: peak hold</string>
</property>
<property name="text">
<string>dB</string>
</property>
</widget>
</item>
<item>
<widget class="LevelMeterSignalDB" name="channelPowerMeter" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>26</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="rfBWLayout">
<item>
@ -908,6 +938,17 @@
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>LevelMeterSignalDB</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLScope</class>
<extends>QWidget</extends>
@ -920,11 +961,6 @@
<header>gui/glscopegui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>
@ -945,6 +981,9 @@
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -53,7 +53,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -181,7 +190,7 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
<height>26</height>
</size>
</property>
<property name="toolTip">
@ -593,6 +602,26 @@
</customwidgets>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -53,7 +53,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -239,7 +248,7 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
<height>26</height>
</size>
</property>
</widget>
@ -475,7 +484,16 @@
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
@ -513,6 +531,12 @@
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LevelMeterSignalDB</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
@ -525,15 +549,29 @@
<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"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
<include location="../../../sdrbase/resources/res.qrc"/>
</resources>
<connections/>
</ui>