mirror of https://github.com/f4exb/sdrangel.git
Removed MagSquaredAGC class and added use squared value (power) as an option to MagAGC because apart from that the code was entirely the same
This commit is contained in:
parent
86e52928d9
commit
ca8cad26c5
|
@ -40,101 +40,6 @@ Real AGC::getAverage()
|
||||||
return m_moving_average.average();
|
return m_moving_average.average();
|
||||||
}
|
}
|
||||||
|
|
||||||
//MagSquaredAGC::MagSquaredAGC() :
|
|
||||||
// AGC(),
|
|
||||||
// m_magsq(0.0)
|
|
||||||
//{}
|
|
||||||
|
|
||||||
MagSquaredAGC::MagSquaredAGC(int historySize, double R, double threshold) :
|
|
||||||
AGC(historySize, R),
|
|
||||||
m_magsq(0.0),
|
|
||||||
m_threshold(threshold),
|
|
||||||
m_thresholdEnable(true),
|
|
||||||
m_gate(0),
|
|
||||||
m_stepLength(std::min(StepLengthMax, historySize/2)),
|
|
||||||
m_stepDelta(1.0/m_stepLength),
|
|
||||||
m_stepUpCounter(0),
|
|
||||||
m_stepDownCounter(m_stepLength),
|
|
||||||
m_gateCounter(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
MagSquaredAGC::~MagSquaredAGC()
|
|
||||||
{}
|
|
||||||
|
|
||||||
void MagSquaredAGC::resize(int historySize, Real R)
|
|
||||||
{
|
|
||||||
m_stepLength = std::min(StepLengthMax, historySize/2);
|
|
||||||
m_stepDelta = 1.0 / m_stepLength;
|
|
||||||
m_stepUpCounter = 0;
|
|
||||||
m_stepDownCounter = m_stepLength;
|
|
||||||
AGC::resize(historySize, R);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MagSquaredAGC::feed(Complex& ci)
|
|
||||||
{
|
|
||||||
ci *= feedAndGetValue(ci);
|
|
||||||
}
|
|
||||||
|
|
||||||
double MagSquaredAGC::feedAndGetValue(const Complex& ci)
|
|
||||||
{
|
|
||||||
m_magsq = ci.real()*ci.real() + ci.imag()*ci.imag();
|
|
||||||
m_moving_average.feed(m_magsq);
|
|
||||||
m_u0 = m_R / m_moving_average.average();
|
|
||||||
|
|
||||||
if (m_magsq > m_threshold)
|
|
||||||
{
|
|
||||||
if (m_gateCounter < m_gate)
|
|
||||||
{
|
|
||||||
m_gateCounter++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_count = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (m_count < m_moving_average.historySize()) {
|
|
||||||
m_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_gateCounter = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_count < m_moving_average.historySize())
|
|
||||||
{
|
|
||||||
m_stepDownCounter = m_stepUpCounter;
|
|
||||||
|
|
||||||
if (m_stepUpCounter < m_stepLength)
|
|
||||||
{
|
|
||||||
m_stepUpCounter++;
|
|
||||||
return m_u0 * StepFunctions::smootherstep(m_stepUpCounter * m_stepDelta);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return m_u0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_stepUpCounter = m_stepDownCounter;
|
|
||||||
|
|
||||||
if (m_stepDownCounter > 0)
|
|
||||||
{
|
|
||||||
m_stepDownCounter--;
|
|
||||||
return m_u0 * StepFunctions::smootherstep(m_stepDownCounter * m_stepDelta);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//MagAGC::MagAGC() :
|
|
||||||
// AGC(),
|
|
||||||
// m_magsq(0.0)
|
|
||||||
//{}
|
|
||||||
|
|
||||||
MagAGC::MagAGC(int historySize, double R, double threshold) :
|
MagAGC::MagAGC(int historySize, double R, double threshold) :
|
||||||
AGC(historySize, R),
|
AGC(historySize, R),
|
||||||
|
@ -241,12 +146,6 @@ double MagAGC::feedAndGetValue(const Complex& ci)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//AlphaAGC::AlphaAGC() :
|
|
||||||
// AGC(),
|
|
||||||
// m_alpha(0.5),
|
|
||||||
// m_magsq(0.0),
|
|
||||||
// m_squelchOpen(true)
|
|
||||||
//{}
|
|
||||||
|
|
||||||
AlphaAGC::AlphaAGC(int historySize, Real R) :
|
AlphaAGC::AlphaAGC(int historySize, Real R) :
|
||||||
AGC(historySize, R),
|
AGC(historySize, R),
|
||||||
|
|
|
@ -29,29 +29,6 @@ protected:
|
||||||
int m_count;
|
int m_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MagSquaredAGC : public AGC
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MagSquaredAGC(int historySize, double R, double threshold);
|
|
||||||
virtual ~MagSquaredAGC();
|
|
||||||
void resize(int historySize, Real R);
|
|
||||||
virtual void feed(Complex& ci);
|
|
||||||
double feedAndGetValue(const Complex& ci);
|
|
||||||
double getMagSq() const { return m_magsq; }
|
|
||||||
void setThreshold(double threshold) { m_threshold = threshold; }
|
|
||||||
void setThresholdEnable(bool enable) { m_thresholdEnable = enable; }
|
|
||||||
void setGate(int gate) { m_gate = gate; }
|
|
||||||
private:
|
|
||||||
double m_magsq;
|
|
||||||
double m_threshold; //!< squelch on magsq average
|
|
||||||
bool m_thresholdEnable; //!< enable squelch on power threshold
|
|
||||||
int m_gate; //!< power threshold gate in number of samples
|
|
||||||
int m_stepLength; //!< transition step length in number of samples
|
|
||||||
double m_stepDelta; //!< transition step unit by sample
|
|
||||||
int m_stepUpCounter; //!< step up transition samples counter
|
|
||||||
int m_stepDownCounter; //!< step down transition samples counter
|
|
||||||
int m_gateCounter; //!< threshold gate samples counter
|
|
||||||
};
|
|
||||||
|
|
||||||
class MagAGC : public AGC
|
class MagAGC : public AGC
|
||||||
{
|
{
|
||||||
|
@ -79,6 +56,7 @@ private:
|
||||||
int m_gateCounter; //!< threshold gate samples counter
|
int m_gateCounter; //!< threshold gate samples counter
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class AlphaAGC : public AGC
|
class AlphaAGC : public AGC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -94,6 +72,7 @@ private:
|
||||||
bool m_squelchOpen;
|
bool m_squelchOpen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SimpleAGC
|
class SimpleAGC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue