1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 12:51:49 -05:00

NFM demod: af squeelch optimization

This commit is contained in:
f4exb 2017-05-13 12:10:03 +02:00
parent 68f742fad7
commit f57eecee86
3 changed files with 30 additions and 17 deletions

View File

@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "../../channelrx/demodnfm/nfmdemod.h"
#include "nfmdemod.h"
#include <QTime>
#include <QDebug>
@ -25,9 +25,9 @@
#include "audio/audiooutput.h"
#include "dsp/pidcontroller.h"
#include "dsp/dspengine.h"
#include "../../channelrx/demodnfm/nfmdemodgui.h"
#include "nfmdemodgui.h"
static const Real afSqTones[2] = {1200.0, 6400.0}; // {1200.0, 8000.0};
static const Real afSqTones[2] = {1200.0, 8000.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); // 4000 Hz span, 250us, 100ms attack
m_afSquelch.setCoefficients(24, 600, 48000.0, 200, 0); // 0.5ms test period, 300ms average span, 48kS/s SR, 100ms attack, no decay
DSPEngine::instance()->addAudioSink(&m_audioFifo);
}
@ -184,8 +184,23 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
if (m_running.m_deltaSquelch)
{
if (m_afSquelch.analyze(demod)) {
m_squelchCount = m_afSquelch.evaluate() ? m_squelchGate + 480 : 0;
m_afSquelchOpen = m_afSquelch.evaluate() ? m_squelchGate + 480 : 0;
}
if (m_afSquelchOpen)
{
if (m_squelchCount < m_squelchGate + 480)
{
m_squelchCount++;
}
}
else
{
if (m_squelchCount > 0)
{
m_squelchCount--;
}
}
}
else
{
@ -270,16 +285,8 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
else
{
demod = m_bandpass.filter(demod);
if (m_running.m_deltaSquelch)
{
sample = demod * m_running.m_volume;
}
else
{
Real squelchFactor = smootherstep((Real) (m_squelchCount - m_squelchGate) / 480.0f);
sample = demod * m_running.m_volume * squelchFactor;
}
Real squelchFactor = smootherstep((Real) (m_squelchCount - m_squelchGate) / 480.0f);
sample = demod * m_running.m_volume * squelchFactor;
}
}
else

View File

@ -208,6 +208,7 @@ void NFMDemodGUI::on_volume_valueChanged(int value)
void NFMDemodGUI::on_squelchGate_valueChanged(int value)
{
ui->squelchGateText->setText(QString("%1").arg(ui->squelchGate->value() * 10.0f, 0, 'f', 0));
applySettings();
}
@ -369,14 +370,13 @@ void NFMDemodGUI::applySettings()
ui->deltaFrequency->setValue(abs(m_channelMarker.getCenterFrequency()));
ui->deltaMinus->setChecked(m_channelMarker.getCenterFrequency() < 0);
ui->squelchGateText->setText(QString("%1").arg(ui->squelchGate->value() * 10.0f, 0, 'f', 0));
m_nfmDemod->configure(m_nfmDemod->getInputMessageQueue(),
m_rfBW[ui->rfBW->currentIndex()],
ui->afBW->value() * 1000.0f,
m_fmDev[ui->rfBW->currentIndex()],
ui->volume->value() / 10.0f,
ui->squelchGate->value(), // in 10ths of ms
ui->squelchGate->value(), // in 10ths of ms 1 -> 50
ui->deltaSquelch->isChecked(),
ui->squelch->value(), // -1000 -> 0
ui->ctcssOn->isChecked(),

View File

@ -91,6 +91,12 @@ void AFSquelch::setCoefficients(int N, unsigned int nbAvg, int _samplerate, int
m_samplesAttack = _samplesAttack;
m_samplesDecay = _samplesDecay;
m_movingAverages.resize(m_nTones, MovingAverage<double>(m_nbAvg, 1.0));
m_samplesProcessed = 0;
m_maxPowerIndex = 0;
m_attackCount = 0;
m_decayCount = 0;
m_isOpen = false;
m_threshold = 0.0;
// for each of the frequencies (tones) of interest calculate
// k and the associated filter coefficient as per the Goertzel