mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 01:39:05 -05:00
NFM Demod: AF squelch crap
This commit is contained in:
parent
07fc282d89
commit
74f65fcbdc
@ -38,6 +38,7 @@ NFMDemod::NFMDemod() :
|
||||
m_squelchGate(2400),
|
||||
m_audioMute(false),
|
||||
m_squelchOpen(false),
|
||||
m_afSquelchOpen(false),
|
||||
m_magsq(0.0f),
|
||||
m_magsqSum(0.0f),
|
||||
m_magsqPeak(0.0f),
|
||||
@ -180,22 +181,46 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
||||
|
||||
// AF processing
|
||||
|
||||
if ( (m_running.m_deltaSquelch && ((deviation > m_squelchLevel) || (deviation < -m_squelchLevel))) ||
|
||||
(!m_running.m_deltaSquelch && (m_movingAverage.average() < m_squelchLevel)) )
|
||||
if (m_running.m_deltaSquelch)
|
||||
{
|
||||
if (m_squelchCount > 0)
|
||||
{
|
||||
m_squelchCount--;
|
||||
}
|
||||
if (m_afSquelch.analyze(demod)) {
|
||||
m_squelchCount = m_afSquelch.evaluate() ? m_squelchGate + 480 : 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_squelchCount < m_squelchGate + 480)
|
||||
{
|
||||
m_squelchCount++;
|
||||
}
|
||||
if (m_movingAverage.average() < m_squelchLevel)
|
||||
{
|
||||
if (m_squelchCount > 0)
|
||||
{
|
||||
m_squelchCount--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_squelchCount < m_squelchGate + 480)
|
||||
{
|
||||
m_squelchCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if ( (m_running.m_deltaSquelch && ((deviation > m_squelchLevel) || (deviation < -m_squelchLevel))) ||
|
||||
// (!m_running.m_deltaSquelch && (m_movingAverage.average() < m_squelchLevel)) )
|
||||
// {
|
||||
// if (m_squelchCount > 0)
|
||||
// {
|
||||
// m_squelchCount--;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (m_squelchCount < m_squelchGate + 480)
|
||||
// {
|
||||
// m_squelchCount++;
|
||||
// }
|
||||
// }
|
||||
|
||||
//squelchOpen = (getMag() > m_squelchLevel);
|
||||
m_squelchOpen = (m_squelchCount > m_squelchGate);
|
||||
|
||||
@ -244,9 +269,17 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
||||
}
|
||||
else
|
||||
{
|
||||
Real squelchFactor = (Real) (m_squelchCount - m_squelchGate) / 480.0f;
|
||||
demod = m_bandpass.filter(demod);
|
||||
sample = demod * m_running.m_volume * squelchFactor * squelchFactor;
|
||||
demod = m_bandpass.filter(demod);
|
||||
|
||||
if (m_running.m_deltaSquelch)
|
||||
{
|
||||
sample = demod * m_running.m_volume;
|
||||
}
|
||||
else
|
||||
{
|
||||
Real squelchFactor = (Real) (m_squelchCount - m_squelchGate) / 480.0f;
|
||||
sample = demod * m_running.m_volume * squelchFactor * squelchFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -400,13 +433,17 @@ void NFMDemod::apply()
|
||||
if ((m_config.m_squelch != m_running.m_squelch) ||
|
||||
(m_config.m_deltaSquelch != m_running.m_deltaSquelch))
|
||||
{
|
||||
if (m_config.m_deltaSquelch) { // input is a value in negative millis
|
||||
m_squelchLevel = - m_config.m_squelch / 1000.0;
|
||||
} else { // input is a value in centi-Bels
|
||||
if (m_config.m_deltaSquelch)
|
||||
{ // input is a value in negative millis
|
||||
m_squelchLevel = (- m_config.m_squelch) / 1000.0;
|
||||
m_afSquelch.setThreshold(m_squelchLevel);
|
||||
}
|
||||
else
|
||||
{ // input is a value in centi-Bels
|
||||
m_squelchLevel = std::pow(10.0, m_config.m_squelch / 100.0);
|
||||
}
|
||||
//m_squelchLevel *= m_squelchLevel;
|
||||
//m_afSquelch.setThreshold(m_squelchLevel);
|
||||
//m_afSquelch.setThreshold(m_squelchLevel);
|
||||
}
|
||||
|
||||
m_running.m_inputSampleRate = m_config.m_inputSampleRate;
|
||||
|
@ -215,6 +215,7 @@ private:
|
||||
|
||||
Real m_squelchLevel;
|
||||
bool m_squelchOpen;
|
||||
bool m_afSquelchOpen;
|
||||
Real m_magsq; //!< displayed averaged value
|
||||
Real m_magsqSum;
|
||||
Real m_magsqPeak;
|
||||
|
@ -216,7 +216,7 @@ void NFMDemodGUI::on_deltaSquelch_toggled(bool checked)
|
||||
if (ui->deltaSquelch->isChecked())
|
||||
{
|
||||
ui->squelchText->setText(QString("%1").arg((-ui->squelch->value()) / 10.0, 0, 'f', 1));
|
||||
ui->squelchText->setToolTip(tr("Squelch deviation threshold (%)"));
|
||||
ui->squelchText->setToolTip(tr("Squelch AF balance threshold (%)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -407,8 +407,11 @@
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Toggle frequency deviation (on) or channel power (off) based squelch</string>
|
||||
<string>Toggle AF balance (on) or channel power (off) based squelch</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>D</string>
|
||||
|
@ -37,7 +37,7 @@ AFSquelch::AFSquelch() :
|
||||
m_u0 = new double[m_nTones];
|
||||
m_u1 = new double[m_nTones];
|
||||
m_power = new double[m_nTones];
|
||||
m_movingAverages.resize(m_nTones, MovingAverage<Real>(m_nbAvg, 0.0));
|
||||
m_movingAverages.resize(m_nTones, MovingAverage<double>(m_nbAvg, 0.0));
|
||||
|
||||
m_toneSet[0] = 2000.0;
|
||||
m_toneSet[1] = 10000.0;
|
||||
@ -89,7 +89,7 @@ void AFSquelch::setCoefficients(int N, unsigned int nbAvg, int _samplerate, int
|
||||
m_sampleRate = _samplerate;
|
||||
m_samplesAttack = _samplesAttack;
|
||||
m_samplesDecay = _samplesDecay;
|
||||
m_movingAverages.resize(m_nTones, MovingAverage<Real>(m_nbAvg, 0.0));
|
||||
m_movingAverages.resize(m_nTones, MovingAverage<double>(m_nbAvg, 1.0));
|
||||
|
||||
// for each of the frequencies (tones) of interest calculate
|
||||
// k and the associated filter coefficient as per the Goertzel
|
||||
@ -169,7 +169,7 @@ void AFSquelch::reset()
|
||||
|
||||
bool AFSquelch::evaluate()
|
||||
{
|
||||
double maxPower = 0.0;
|
||||
double maxPower = 1.0;
|
||||
double minPower;
|
||||
int minIndex = 0, maxIndex = 0;
|
||||
|
||||
@ -194,6 +194,7 @@ bool AFSquelch::evaluate()
|
||||
|
||||
// principle is to open if power is uneven because noise gives even power
|
||||
bool open = (minPower/maxPower < m_threshold) && (minIndex > maxIndex);
|
||||
//qDebug("AFSquelch::evaluate: %g : %g", minPower/maxPower, m_threshold);
|
||||
|
||||
if (open)
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ private:
|
||||
double *m_u0;
|
||||
double *m_u1;
|
||||
double *m_power;
|
||||
std::vector<MovingAverage<Real> > m_movingAverages;
|
||||
std::vector<MovingAverage<double> > m_movingAverages;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user