1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-08-29 10:52:29 -04:00

AM demod: refactor demodulation

This commit is contained in:
f4exb 2017-05-12 04:25:14 +02:00
parent 225f25b9f4
commit 51d24102ed
2 changed files with 7 additions and 11 deletions

View File

@ -35,7 +35,7 @@ AMDemod::AMDemod() :
m_magsqPeak(0.0f), m_magsqPeak(0.0f),
m_magsqCount(0), m_magsqCount(0),
m_movingAverage(40, 0), m_movingAverage(40, 0),
m_volumeAGC(40, 0) m_volumeAGC(4800, 1.0)
{ {
setObjectName("AMDemod"); setObjectName("AMDemod");

View File

@ -177,21 +177,17 @@ private:
{ {
Real demod = sqrt(magsq); Real demod = sqrt(magsq);
if (demod < -1) if (demod > 1)
{
demod = -1;
}
else if (demod > 1)
{ {
demod = 1; demod = 1;
} }
m_volumeAGC.feed(demod); m_volumeAGC.feed(demod);
demod /= m_volumeAGC.getValue();
Real attack = (m_squelchCount - (m_running.m_audioSampleRate / 20)) / (Real) (m_running.m_audioSampleRate / 20); sample = (0.5 - demod) * 2048 * m_running.m_volume;
demod *= ((0.003 * attack) / m_volumeAGC.getValue()); // Real attack = (m_squelchCount - (m_running.m_audioSampleRate / 20)) / (Real) (m_running.m_audioSampleRate / 20);
demod *= m_running.m_volume; // demod *= ((0.003 * attack) / m_volumeAGC.getValue());
sample = demod * 32700 * 16; // sample = demod * 32700 * 16;
m_squelchOpen = true; m_squelchOpen = true;
} }
else else