mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 09:48:45 -05:00
Attempt to fix AF squelch
This commit is contained in:
parent
c8bd0e8e85
commit
db1a620fc2
@ -27,7 +27,7 @@
|
||||
#include "dsp/dspengine.h"
|
||||
#include "nfmdemodgui.h"
|
||||
|
||||
static const double afSqTones[2] = {1200.0, 8000.0}; // {1200.0, 8000.0};
|
||||
static const double afSqTones[2] = {1000.0, 6000.0}; // {1200.0, 8000.0};
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(NFMDemod::MsgConfigureNFMDemod, Message)
|
||||
|
||||
@ -75,7 +75,7 @@ NFMDemod::NFMDemod() :
|
||||
m_movingAverage.resize(32, 0);
|
||||
|
||||
m_ctcssDetector.setCoefficients(3000, 6000.0); // 0.5s / 2 Hz resolution
|
||||
m_afSquelch.setCoefficients(24, 600, 48000.0, 200, 0); // 0.5ms test period, 300ms average span, 48kS/s SR, 100ms attack, no decay
|
||||
m_afSquelch.setCoefficients(24, 60, 48000.0, 20, 0); // 0.5ms test period, 30ms average span, 48kS/s SR, 10ms attack, no decay
|
||||
|
||||
DSPEngine::instance()->addAudioSink(&m_audioFifo);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ AFSquelch::AFSquelch() :
|
||||
m_attackCount(0),
|
||||
m_samplesDecay(0),
|
||||
m_decayCount(0),
|
||||
m_squelchCount(0),
|
||||
m_isOpen(false),
|
||||
m_threshold(0.0)
|
||||
{
|
||||
@ -65,6 +66,7 @@ AFSquelch::AFSquelch(unsigned int nbTones, const double *tones) :
|
||||
m_attackCount(0),
|
||||
m_samplesDecay(0),
|
||||
m_decayCount(0),
|
||||
m_squelchCount(0),
|
||||
m_isOpen(false),
|
||||
m_threshold(0.0)
|
||||
{
|
||||
@ -117,6 +119,7 @@ void AFSquelch::setCoefficients(
|
||||
m_maxPowerIndex = 0;
|
||||
m_attackCount = 0;
|
||||
m_decayCount = 0;
|
||||
m_squelchCount = 0;
|
||||
m_isOpen = false;
|
||||
m_threshold = 0.0;
|
||||
|
||||
@ -239,33 +242,56 @@ bool AFSquelch::evaluate()
|
||||
}
|
||||
}
|
||||
|
||||
// m_isOpen = ((minPower/maxPower < m_threshold) && (minIndex > maxIndex));
|
||||
|
||||
if ((minPower/maxPower < m_threshold) && (minIndex > maxIndex)) // open condition
|
||||
{
|
||||
if ((m_samplesAttack > 0) && (m_attackCount < m_samplesAttack))
|
||||
if (m_squelchCount < m_samplesAttack + m_samplesDecay)
|
||||
{
|
||||
m_isOpen = false;
|
||||
m_attackCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isOpen = true;
|
||||
m_decayCount = 0;
|
||||
m_squelchCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((m_samplesDecay > 0) && (m_decayCount < m_samplesDecay))
|
||||
if (m_squelchCount > m_samplesAttack)
|
||||
{
|
||||
m_isOpen = true;
|
||||
m_decayCount++;
|
||||
m_squelchCount--;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isOpen = false;
|
||||
m_attackCount = 0;
|
||||
m_squelchCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
m_isOpen = (m_squelchCount >= m_samplesAttack) ;
|
||||
|
||||
// if ((minPower/maxPower < m_threshold) && (minIndex > maxIndex)) // open condition
|
||||
// {
|
||||
// if ((m_samplesAttack > 0) && (m_attackCount < m_samplesAttack))
|
||||
// {
|
||||
// m_isOpen = false;
|
||||
// m_attackCount++;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_isOpen = true;
|
||||
// m_decayCount = 0;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if ((m_samplesDecay > 0) && (m_decayCount < m_samplesDecay))
|
||||
// {
|
||||
// m_isOpen = true;
|
||||
// m_decayCount++;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// m_isOpen = false;
|
||||
// m_attackCount = 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
return m_isOpen;
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,7 @@ private:
|
||||
unsigned int m_attackCount;
|
||||
unsigned int m_samplesDecay;
|
||||
unsigned int m_decayCount;
|
||||
unsigned int m_squelchCount;
|
||||
bool m_isOpen;
|
||||
double m_threshold;
|
||||
double *m_k;
|
||||
|
Loading…
Reference in New Issue
Block a user