1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-18 22:31:48 -05:00

DSD demod plugin: fixed magnitude squared precision problem

This commit is contained in:
f4exb 2016-08-26 02:02:10 +02:00
parent 9d5e5c76c7
commit be4982c447
3 changed files with 7 additions and 6 deletions

View File

@ -64,7 +64,7 @@ DSDDemod::DSDDemod(SampleSink* sampleSink) :
m_sampleBuffer = new qint16[1<<17]; // 128 kS m_sampleBuffer = new qint16[1<<17]; // 128 kS
m_sampleBufferIndex = 0; m_sampleBufferIndex = 0;
m_movingAverage.resize(16, 0); m_movingAverage.resize(50, 0);
DSPEngine::instance()->addAudioSink(&m_audioFifo); DSPEngine::instance()->addAudioSink(&m_audioFifo);
} }
@ -119,7 +119,7 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
{ {
qint16 sample, delayedSample; qint16 sample, delayedSample;
m_magsq = ((ci.real()*ci.real() + ci.imag()*ci.imag())) / (Real) (1<<30); m_magsq = ((ci.real()*ci.real() + ci.imag()*ci.imag()));
m_movingAverage.feed(m_magsq); m_movingAverage.feed(m_magsq);
Real demod = 32768.0f * m_phaseDiscri.phaseDiscriminator(ci) * ((float) m_running.m_demodGain / 100.0f); Real demod = 32768.0f * m_phaseDiscri.phaseDiscriminator(ci) * ((float) m_running.m_demodGain / 100.0f);

View File

@ -61,7 +61,7 @@ public:
m_dsdDemodGUI = dsdDemodGUI; m_dsdDemodGUI = dsdDemodGUI;
} }
Real getMagSq() { return m_movingAverage.average(); } double getMagSq() { return m_movingAverage.average() / (double) (1<<30); }
bool getSquelchOpen() const { return m_squelchOpen; } bool getSquelchOpen() const { return m_squelchOpen; }
const DSDDecoder& getDecoder() const { return m_dsdDecoder; } const DSDDecoder& getDecoder() const { return m_dsdDecoder; }
@ -199,8 +199,8 @@ private:
bool m_squelchOpen; bool m_squelchOpen;
Real m_lastArgument; Real m_lastArgument;
MovingAverage<Real> m_movingAverage; MovingAverage<double> m_movingAverage;
Real m_magsq; double m_magsq;
Real m_fmExcursion; Real m_fmExcursion;

View File

@ -492,8 +492,9 @@ void DSDDemodGUI::formatStatusText()
void DSDDemodGUI::tick() void DSDDemodGUI::tick()
{ {
Real powDb = CalcDb::dbPower(m_dsdDemod->getMagSq()); Real powDb = CalcDb::dbPower(m_dsdDemod->getMagSq());
m_channelPowerDbAvg.feed(powDb); m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1)); ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
bool squelchOpen = m_dsdDemod->getSquelchOpen(); bool squelchOpen = m_dsdDemod->getSquelchOpen();
if (squelchOpen != m_squelchOpen) if (squelchOpen != m_squelchOpen)