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

Mods and demods: prevent returning null or infinite values for squared magnitude

This commit is contained in:
f4exb 2017-05-16 17:46:44 +02:00
parent 747f400a78
commit 416817d0b8
11 changed files with 206 additions and 205 deletions

View File

@ -43,7 +43,7 @@ public:
int getInputSampleRate() const { return m_running.m_inputSampleRate; }
int getChannelSampleRate() const { return m_running.m_channelSampleRate; }
Real getMagSq() const { return m_magsq; }
Real getMagSq() const { return m_magsq == 0 ? 1e-10 : m_magsq; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();

View File

@ -46,9 +46,9 @@ public:
void getMagSqLevels(Real& avg, Real& peak, int& nbSamples)
{
avg = m_magsqSum / m_magsqCount;
peak = m_magsqPeak;
nbSamples = m_magsqCount;
avg = m_magsqCount == 0 ? 1e-10 : m_magsqSum / m_magsqCount;
peak = m_magsqPeak == 0.0 ? 1e-10 : m_magsqPeak;
nbSamples = m_magsqCount == 0 ? 1 : m_magsqCount;
m_magsqSum = 0.0f;
m_magsqPeak = 0.0f;
m_magsqCount = 0;

View File

@ -71,10 +71,10 @@ public:
void getMagSqLevels(Real& avg, Real& peak, int& nbSamples)
{
avg = m_magsqSum / m_magsqCount;
avg = m_magsqCount == 0 ? 1e-10 : m_magsqSum / m_magsqCount;
m_magsq = avg;
peak = m_magsqPeak;
nbSamples = m_magsqCount;
peak = m_magsqPeak == 0.0 ? 1e-10 : m_magsqPeak;
nbSamples = m_magsqCount == 0 ? 1 : m_magsqCount;
m_magsqSum = 0.0f;
m_magsqPeak = 0.0f;
m_magsqCount = 0;

View File

@ -75,15 +75,16 @@ public:
void getMagSqLevels(Real& avg, Real& peak, int& nbSamples)
{
avg = m_magsqSum / m_magsqCount;
avg = m_magsqCount == 0 ? 1e-10 : m_magsqSum / m_magsqCount;
m_magsq = avg;
peak = m_magsqPeak;
nbSamples = m_magsqCount;
peak = m_magsqPeak == 0.0 ? 1e-10 : m_magsqPeak;
nbSamples = m_magsqCount == 0 ? 1 : m_magsqCount;
m_magsqSum = 0.0f;
m_magsqPeak = 0.0f;
m_magsqCount = 0;
}
private:
class MsgConfigureMyPosition : public Message {
MESSAGE_CLASS_DECLARATION

View File

@ -74,10 +74,10 @@ public:
void getMagSqLevels(Real& avg, Real& peak, int& nbSamples)
{
avg = m_magsqSum / m_magsqCount;
avg = m_magsqCount == 0 ? 1e-10 : m_magsqSum / m_magsqCount;
m_magsq = avg;
peak = m_magsqPeak;
nbSamples = m_magsqCount;
peak = m_magsqPeak == 0.0 ? 1e-10 : m_magsqPeak;
nbSamples = m_magsqCount == 0 ? 1 : m_magsqCount;
m_magsqSum = 0.0f;
m_magsqPeak = 0.0f;
m_magsqCount = 0;

View File

@ -53,10 +53,10 @@ public:
void getMagSqLevels(Real& avg, Real& peak, int& nbSamples)
{
avg = m_magsqSum / m_magsqCount;
avg = m_magsqCount == 0 ? 1e-10 : m_magsqSum / m_magsqCount;
m_magsq = avg;
peak = m_magsqPeak;
nbSamples = m_magsqCount;
peak = m_magsqPeak == 0.0 ? 1e-10 : m_magsqPeak;
nbSamples = m_magsqCount == 0 ? 1 : m_magsqCount;
m_magsqSum = 0.0f;
m_magsqPeak = 0.0f;
m_magsqCount = 0;

View File

@ -55,10 +55,10 @@ public:
void getMagSqLevels(Real& avg, Real& peak, int& nbSamples)
{
avg = m_magsqSum / m_magsqCount;
avg = m_magsqCount == 0 ? 1e-10 : m_magsqSum / m_magsqCount;
m_magsq = avg;
peak = m_magsqPeak;
nbSamples = m_magsqCount;
peak = m_magsqPeak == 0.0 ? 1e-10 : m_magsqPeak;
nbSamples = m_magsqCount == 0 ? 1 : m_magsqCount;
m_magsqSum = 0.0f;
m_magsqPeak = 0.0f;
m_magsqCount = 0;

View File

@ -190,7 +190,7 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq; }
Real getMagSq() const { return m_magsq == 0.0 ? 1e-10 : m_magsq; }
CWKeyer *getCWKeyer() { return &m_cwKeyer; }

View File

@ -195,7 +195,7 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq; }
Real getMagSq() const { return m_magsq == 0 ? 1e-10 : m_magsq; }
CWKeyer *getCWKeyer() { return &m_cwKeyer; }

View File

@ -195,7 +195,7 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq; }
Real getMagSq() const { return m_magsq == 0 ? 1e-10 : m_magsq; }
CWKeyer *getCWKeyer() { return &m_cwKeyer; }

View File

@ -192,7 +192,7 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq; }
Real getMagSq() const { return m_magsq == 0 ? 1e-10 : m_magsq; }
CWKeyer *getCWKeyer() { return &m_cwKeyer; }