1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

AM demod: removed channel power dB average engine. Use direct average from demod

This commit is contained in:
f4exb 2016-12-04 23:29:59 +01:00
parent 4d5e2f9656
commit 37f4b4e306
4 changed files with 34 additions and 6 deletions

View File

@ -30,7 +30,10 @@ MESSAGE_CLASS_DEFINITION(AMDemod::MsgConfigureAMDemod, Message)
AMDemod::AMDemod() :
m_squelchOpen(false),
m_audioFifo(4, 48000),
m_settingsMutex(QMutex::Recursive)
m_settingsMutex(QMutex::Recursive),
m_magsqSum(0.0f),
m_magsqPeak(0.0f),
m_magsqCount(0)
{
setObjectName("AMDemod");

View File

@ -43,6 +43,16 @@ public:
Real getMagSq() const { return m_magsq; }
bool getSquelchOpen() const { return m_squelchOpen; }
void getMagSqLevels(Real& avg, Real& peak, int& nbSamples)
{
avg = m_magsqSum / m_magsqCount;
peak = m_magsqPeak;
nbSamples = m_magsqCount;
m_magsqSum = 0.0f;
m_magsqPeak = 0.0f;
m_magsqCount = 0;
}
private:
class MsgConfigureAMDemod : public Message {
MESSAGE_CLASS_DECLARATION
@ -116,6 +126,9 @@ private:
int m_squelchCount;
bool m_squelchOpen;
Real m_magsq;
Real m_magsqSum;
Real m_magsqPeak;
int m_magsqCount;
MovingAverage<Real> m_movingAverage;
SimpleAGC m_volumeAGC;
@ -134,6 +147,14 @@ private:
magsq /= (1<<30);
m_movingAverage.feed(magsq);
m_magsq = m_movingAverage.average();
m_magsqSum += magsq;
if (magsq > m_magsqPeak)
{
m_magsqPeak = magsq;
}
m_magsqCount++;
if (m_magsq >= m_squelchLevel)
{

View File

@ -218,7 +218,6 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget
m_channelMarker(this),
m_basicSettingsShown(false),
m_doApplySettings(true),
m_channelPowerDbAvg(20,0),
m_squelchOpen(false)
{
ui->setupUi(this);
@ -235,6 +234,7 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
// ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenYellow);
//m_channelMarker = new ChannelMarker(this);
m_channelMarker.setColor(Qt::yellow);
@ -304,9 +304,14 @@ void AMDemodGUI::enterEvent(QEvent*)
void AMDemodGUI::tick()
{
Real powDb = CalcDb::dbPower(m_amDemod->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
Real magsqAvg, magsqPeak;
int nbMagsqSamples;
m_amDemod->getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
Real powDbAvg = CalcDb::dbPower(magsqAvg);
Real powDbPeak = CalcDb::dbPower(magsqPeak);
// ui->channelPowerMeter->levelChanged(powDbAvg, powDbPeak, nbMagsqSamples);
ui->channelPower->setText(QString::number(powDbAvg, 'f', 1));
bool squelchOpen = m_amDemod->getSquelchOpen();
if (squelchOpen != m_squelchOpen)

View File

@ -60,7 +60,6 @@ private:
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
AMDemod* m_amDemod;
MovingAverage<Real> m_channelPowerDbAvg;
bool m_squelchOpen;
explicit AMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget* parent = NULL);