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

Use doubles for all power calculations

This commit is contained in:
f4exb 2017-05-16 23:39:49 +02:00
parent dafad384c8
commit 579c05cfe5
31 changed files with 72 additions and 72 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 == 0 ? 1e-10 : m_magsq; }
double getMagSq() const { return m_magsq; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
@ -120,7 +120,7 @@ private:
int m_undersampleCount;
fftfilt::cmplx m_sum;
bool m_usb;
Real m_magsq;
double m_magsq;
bool m_useInterpolator;
NCOF m_nco;

View File

@ -169,7 +169,7 @@ void ChannelAnalyzerNGGUI::viewChanged()
void ChannelAnalyzerNGGUI::tick()
{
Real powDb = CalcDb::dbPower(m_channelAnalyzer->getMagSq());
double powDb = CalcDb::dbPower(m_channelAnalyzer->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
// ui->channelPower->setText(QString::number(powDb, 'f', 1));

View File

@ -41,10 +41,10 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq; }
double getMagSq() const { return m_magsq; }
bool getSquelchOpen() const { return m_squelchOpen; }
void getMagSqLevels(Real& avg, Real& peak, int& nbSamples)
void getMagSqLevels(double& avg, double& peak, int& nbSamples)
{
avg = m_magsqCount == 0 ? 1e-10 : m_magsqSum / m_magsqCount;
peak = m_magsqPeak == 0.0 ? 1e-10 : m_magsqPeak;
@ -131,9 +131,9 @@ private:
Real m_squelchLevel;
int m_squelchCount;
bool m_squelchOpen;
Real m_magsq;
Real m_magsqSum;
Real m_magsqPeak;
double m_magsq;
double m_magsqSum;
double m_magsqPeak;
int m_magsqCount;
MovingAverage<double> m_movingAverage;

View File

@ -315,11 +315,11 @@ void AMDemodGUI::enterEvent(QEvent*)
void AMDemodGUI::tick()
{
Real magsqAvg, magsqPeak;
double magsqAvg, magsqPeak;
int nbMagsqSamples;
m_amDemod->getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
Real powDbAvg = CalcDb::dbPower(magsqAvg);
Real powDbPeak = CalcDb::dbPower(magsqPeak);
double powDbAvg = CalcDb::dbPower(magsqAvg);
double powDbPeak = CalcDb::dbPower(magsqPeak);
ui->channelPowerMeter->levelChanged(
(100.0f + powDbAvg) / 100.0f,

View File

@ -108,7 +108,8 @@ void BFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
Complex ci, cs, cr;
fftfilt::cmplx *rf;
int rf_out;
Real msq, demod;
double msq;
Real demod;
m_sampleBuffer.clear();

View File

@ -58,7 +58,7 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq; }
double getMagSq() const { return m_magsq; }
bool getPilotLock() const { return m_pilotPLL.locked(); }
Real getPilotLevel() const { return m_pilotPLL.get_pilot_level(); }
@ -69,7 +69,7 @@ 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)
void getMagSqLevels(double& avg, double& peak, int& nbSamples)
{
avg = m_magsqCount == 0 ? 1e-10 : m_magsqSum / m_magsqCount;
m_magsq = avg;
@ -207,11 +207,10 @@ private:
Real m_m1Arg; //!> x^-1 real sample
// MovingAverage<Real> m_movingAverage;
Real m_magsq;
Real m_magsqSum;
Real m_magsqPeak;
int m_magsqCount;
double m_magsq;
double m_magsqSum;
double m_magsqPeak;
int m_magsqCount;
AudioVector m_audioBuffer;
uint m_audioBufferFill;

View File

@ -476,7 +476,7 @@ void BFMDemodGUI::enterEvent(QEvent*)
void BFMDemodGUI::tick()
{
Real magsqAvg, magsqPeak;
double magsqAvg, magsqPeak;
int nbMagsqSamples;
m_bfmDemod->getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
Real powDbAvg = CalcDb::dbPower(magsqAvg);

View File

@ -73,7 +73,7 @@ public:
const DSDDecoder& getDecoder() const { return m_dsdDecoder; }
void getMagSqLevels(Real& avg, Real& peak, int& nbSamples)
void getMagSqLevels(double& avg, double& peak, int& nbSamples)
{
avg = m_magsqCount == 0 ? 1e-10 : m_magsqSum / m_magsqCount;
m_magsq = avg;
@ -273,9 +273,9 @@ private:
Real m_lastArgument;
MovingAverage<double> m_movingAverage;
Real m_magsq;
Real m_magsqSum;
Real m_magsqPeak;
double m_magsq;
double m_magsqSum;
double m_magsqPeak;
int m_magsqCount;
Real m_fmExcursion;

View File

@ -601,11 +601,11 @@ void DSDDemodGUI::formatStatusText()
void DSDDemodGUI::tick()
{
Real magsqAvg, magsqPeak;
double magsqAvg, magsqPeak;
int nbMagsqSamples;
m_dsdDemod->getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
Real powDbAvg = CalcDb::dbPower(magsqAvg);
Real powDbPeak = CalcDb::dbPower(magsqPeak);
double powDbAvg = CalcDb::dbPower(magsqAvg);
double powDbPeak = CalcDb::dbPower(magsqPeak);
ui->channelPowerMeter->levelChanged(
(100.0f + powDbAvg) / 100.0f,

View File

@ -72,7 +72,7 @@ public:
Real getMag() { return m_magsq; }
bool getSquelchOpen() const { return m_squelchOpen; }
void getMagSqLevels(Real& avg, Real& peak, int& nbSamples)
void getMagSqLevels(double& avg, double& peak, int& nbSamples)
{
avg = m_magsqCount == 0 ? 1e-10 : m_magsqSum / m_magsqCount;
m_magsq = avg;
@ -216,9 +216,9 @@ private:
Real m_squelchLevel;
bool m_squelchOpen;
bool m_afSquelchOpen;
Real m_magsq; //!< displayed averaged value
Real m_magsqSum;
Real m_magsqPeak;
double m_magsq; //!< displayed averaged value
double m_magsqSum;
double m_magsqPeak;
int m_magsqCount;
Real m_lastArgument;

View File

@ -419,11 +419,11 @@ void NFMDemodGUI::blockApplySettings(bool block)
void NFMDemodGUI::tick()
{
Real magsqAvg, magsqPeak;
double magsqAvg, magsqPeak;
int nbMagsqSamples;
m_nfmDemod->getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
Real powDbAvg = CalcDb::dbPower(magsqAvg);
Real powDbPeak = CalcDb::dbPower(magsqPeak);
double powDbAvg = CalcDb::dbPower(magsqAvg);
double powDbPeak = CalcDb::dbPower(magsqPeak);
ui->channelPowerMeter->levelChanged(
(100.0f + powDbAvg) / 100.0f,

View File

@ -49,9 +49,9 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq; }
double getMagSq() const { return m_magsq; }
void getMagSqLevels(Real& avg, Real& peak, int& nbSamples)
void getMagSqLevels(double& avg, double& peak, int& nbSamples)
{
avg = m_magsqCount == 0 ? 1e-10 : m_magsqSum / m_magsqCount;
m_magsq = avg;
@ -138,9 +138,9 @@ private:
bool m_usb;
bool m_dsb;
bool m_audioMute;
Real m_magsq;
Real m_magsqSum;
Real m_magsqPeak;
double m_magsq;
double m_magsqSum;
double m_magsqPeak;
int m_magsqCount;
NCOF m_nco;

View File

@ -500,11 +500,11 @@ void SSBDemodGUI::enterEvent(QEvent*)
void SSBDemodGUI::tick()
{
Real magsqAvg, magsqPeak;
double magsqAvg, magsqPeak;
int nbMagsqSamples;
m_ssbDemod->getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
Real powDbAvg = CalcDb::dbPower(magsqAvg);
Real powDbPeak = CalcDb::dbPower(magsqPeak);
double powDbAvg = CalcDb::dbPower(magsqAvg);
double powDbPeak = CalcDb::dbPower(magsqPeak);
ui->channelPowerMeter->levelChanged(
(100.0f + powDbAvg) / 100.0f,

View File

@ -50,10 +50,10 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_movingAverage.average(); }
double getMagSq() const { return m_movingAverage.average(); }
bool getSquelchOpen() const { return m_squelchOpen; }
void getMagSqLevels(Real& avg, Real& peak, int& nbSamples)
void getMagSqLevels(double& avg, double& peak, int& nbSamples)
{
avg = m_magsqCount == 0 ? 1e-10 : m_magsqSum / m_magsqCount;
m_magsq = avg;
@ -142,9 +142,9 @@ private:
Real m_squelchLevel;
int m_squelchState;
bool m_squelchOpen;
Real m_magsq; //!< displayed averaged value
Real m_magsqSum;
Real m_magsqPeak;
double m_magsq; //!< displayed averaged value
double m_magsqSum;
double m_magsqPeak;
int m_magsqCount;
Real m_lastArgument;

View File

@ -319,11 +319,11 @@ void WFMDemodGUI::tick()
// m_channelPowerDbAvg.feed(powDb);
// ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
Real magsqAvg, magsqPeak;
double magsqAvg, magsqPeak;
int nbMagsqSamples;
m_wfmDemod->getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
Real powDbAvg = CalcDb::dbPower(magsqAvg);
Real powDbPeak = CalcDb::dbPower(magsqPeak);
double powDbAvg = CalcDb::dbPower(magsqAvg);
double powDbPeak = CalcDb::dbPower(magsqPeak);
ui->channelPower->setText(QString::number(powDbAvg, 'f', 1));
ui->channelPowerMeter->levelChanged(

View File

@ -31,7 +31,7 @@ public:
void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort, int boost);
void setSpectrum(MessageQueue* messageQueue, bool enabled);
Real getMagSq() const { return m_magsq; }
double getMagSq() const { return m_magsq; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
@ -148,7 +148,7 @@ protected:
Real m_rfBandwidth;
int m_tcpPort;
int m_boost;
Real m_magsq;
double m_magsq;
Real m_scale;
Complex m_last, m_this;

View File

@ -178,7 +178,7 @@ void TCPSrcGUI::channelMarkerChanged()
void TCPSrcGUI::tick()
{
Real powDb = CalcDb::dbPower(m_tcpSrc->getMagSq());
double powDb = CalcDb::dbPower(m_tcpSrc->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
}

View File

@ -73,7 +73,7 @@ public:
int boost,
int volume);
void setSpectrum(MessageQueue* messageQueue, bool enabled);
Real getMagSq() const { return m_magsq; }
double getMagSq() const { return m_magsq; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
@ -221,7 +221,7 @@ protected:
bool m_audioStereo;
int m_volume;
int m_fmDeviation;
Real m_magsq;
double m_magsq;
Real m_scale;
Complex m_last, m_this;

View File

@ -215,7 +215,7 @@ void UDPSrcGUI::channelMarkerChanged()
void UDPSrcGUI::tick()
{
Real powDb = CalcDb::dbPower(m_udpSrc->getMagSq());
double powDb = CalcDb::dbPower(m_udpSrc->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
}

View File

@ -190,7 +190,7 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq == 0.0 ? 1e-10 : m_magsq; }
double getMagSq() const { return m_magsq; }
CWKeyer *getCWKeyer() { return &m_cwKeyer; }
@ -291,7 +291,7 @@ private:
Real m_interpolatorDistanceRemain;
bool m_interpolatorConsumed;
Real m_magsq;
double m_magsq;
MovingAverage<double> m_movingAverage;
SimpleAGC m_volumeAGC;

View File

@ -444,7 +444,7 @@ void AMModGUI::enterEvent(QEvent*)
void AMModGUI::tick()
{
Real powDb = CalcDb::dbPower(m_amMod->getMagSq());
double powDb = CalcDb::dbPower(m_amMod->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));

View File

@ -403,7 +403,7 @@ public:
virtual bool handleMessage(const Message& cmd);
int getEffectiveSampleRate() const { return m_tvSampleRate; };
Real getMagSq() const { return m_movingAverage.average(); }
double getMagSq() const { return m_movingAverage.average(); }
void getCameraNumbers(std::vector<int>& numbers);
static void getBaseValues(int outputSampleRate, int linesPerSecond, int& sampleRateUnits, uint32_t& nbPointsPerRateUnit);

View File

@ -741,7 +741,7 @@ void ATVModGUI::enterEvent(QEvent*)
void ATVModGUI::tick()
{
Real powDb = CalcDb::dbPower(m_atvMod->getMagSq());
double powDb = CalcDb::dbPower(m_atvMod->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));

View File

@ -195,7 +195,7 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq == 0 ? 1e-10 : m_magsq; }
double getMagSq() const { return m_magsq; }
CWKeyer *getCWKeyer() { return &m_cwKeyer; }
@ -339,7 +339,7 @@ private:
Lowpass<Real> m_lowpass;
Bandpass<Real> m_bandpass;
Real m_magsq;
double m_magsq;
MovingAverage<double> m_movingAverage;
SimpleAGC m_volumeAGC;

View File

@ -500,7 +500,7 @@ void NFMModGUI::enterEvent(QEvent*)
void NFMModGUI::tick()
{
Real powDb = CalcDb::dbPower(m_nfmMod->getMagSq());
double powDb = CalcDb::dbPower(m_nfmMod->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));

View File

@ -195,7 +195,7 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq == 0 ? 1e-10 : m_magsq; }
double getMagSq() const { return m_magsq; }
CWKeyer *getCWKeyer() { return &m_cwKeyer; }
@ -363,7 +363,7 @@ private:
int m_undersampleCount;
int m_sumCount;
Real m_magsq;
double m_magsq;
MovingAverage<double> m_movingAverage;
SimpleAGC m_volumeAGC;

View File

@ -638,7 +638,7 @@ void SSBModGUI::enterEvent(QEvent*)
void SSBModGUI::tick()
{
Real powDb = CalcDb::dbPower(m_ssbMod->getMagSq());
double powDb = CalcDb::dbPower(m_ssbMod->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));

View File

@ -192,7 +192,7 @@ public:
virtual void stop();
virtual bool handleMessage(const Message& cmd);
Real getMagSq() const { return m_magsq == 0 ? 1e-10 : m_magsq; }
double getMagSq() const { return m_magsq; }
CWKeyer *getCWKeyer() { return &m_cwKeyer; }
@ -323,7 +323,7 @@ private:
fftfilt::cmplx *m_rfFilterBuffer;
int m_rfFilterBufferIndex;
Real m_magsq;
double m_magsq;
MovingAverage<double> m_movingAverage;
SimpleAGC m_volumeAGC;

View File

@ -463,7 +463,7 @@ void WFMModGUI::enterEvent(QEvent*)
void WFMModGUI::tick()
{
Real powDb = CalcDb::dbPower(m_wfmMod->getMagSq());
double powDb = CalcDb::dbPower(m_wfmMod->getMagSq());
m_channelPowerDbAvg.feed(powDb);
ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));

View File

@ -17,7 +17,7 @@
#include "util/db.h"
#include <cmath>
Real CalcDb::dbPower(Real magsq, Real floordB)
double CalcDb::dbPower(double magsq, double floordB)
{
if (magsq > 0)
{

View File

@ -22,7 +22,7 @@
class CalcDb
{
public:
static Real dbPower(Real magsq, Real floordB = -100.0f);
static double dbPower(double magsq, double floordB = -100.0);
};
#endif /* INCLUDE_UTIL_DB_H_ */