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:
parent
68f742fad7
commit
f57eecee86
@ -15,7 +15,7 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "../../channelrx/demodnfm/nfmdemod.h"
|
#include "nfmdemod.h"
|
||||||
|
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -25,9 +25,9 @@
|
|||||||
#include "audio/audiooutput.h"
|
#include "audio/audiooutput.h"
|
||||||
#include "dsp/pidcontroller.h"
|
#include "dsp/pidcontroller.h"
|
||||||
#include "dsp/dspengine.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)
|
MESSAGE_CLASS_DEFINITION(NFMDemod::MsgConfigureNFMDemod, Message)
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ NFMDemod::NFMDemod() :
|
|||||||
m_movingAverage.resize(32, 0);
|
m_movingAverage.resize(32, 0);
|
||||||
|
|
||||||
m_ctcssDetector.setCoefficients(3000, 6000.0); // 0.5s / 2 Hz resolution
|
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);
|
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_running.m_deltaSquelch)
|
||||||
{
|
{
|
||||||
if (m_afSquelch.analyze(demod)) {
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -270,16 +285,8 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
demod = m_bandpass.filter(demod);
|
demod = m_bandpass.filter(demod);
|
||||||
|
Real squelchFactor = smootherstep((Real) (m_squelchCount - m_squelchGate) / 480.0f);
|
||||||
if (m_running.m_deltaSquelch)
|
sample = demod * m_running.m_volume * squelchFactor;
|
||||||
{
|
|
||||||
sample = demod * m_running.m_volume;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Real squelchFactor = smootherstep((Real) (m_squelchCount - m_squelchGate) / 480.0f);
|
|
||||||
sample = demod * m_running.m_volume * squelchFactor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -208,6 +208,7 @@ void NFMDemodGUI::on_volume_valueChanged(int value)
|
|||||||
|
|
||||||
void NFMDemodGUI::on_squelchGate_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();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,14 +370,13 @@ void NFMDemodGUI::applySettings()
|
|||||||
|
|
||||||
ui->deltaFrequency->setValue(abs(m_channelMarker.getCenterFrequency()));
|
ui->deltaFrequency->setValue(abs(m_channelMarker.getCenterFrequency()));
|
||||||
ui->deltaMinus->setChecked(m_channelMarker.getCenterFrequency() < 0);
|
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_nfmDemod->configure(m_nfmDemod->getInputMessageQueue(),
|
||||||
m_rfBW[ui->rfBW->currentIndex()],
|
m_rfBW[ui->rfBW->currentIndex()],
|
||||||
ui->afBW->value() * 1000.0f,
|
ui->afBW->value() * 1000.0f,
|
||||||
m_fmDev[ui->rfBW->currentIndex()],
|
m_fmDev[ui->rfBW->currentIndex()],
|
||||||
ui->volume->value() / 10.0f,
|
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->deltaSquelch->isChecked(),
|
||||||
ui->squelch->value(), // -1000 -> 0
|
ui->squelch->value(), // -1000 -> 0
|
||||||
ui->ctcssOn->isChecked(),
|
ui->ctcssOn->isChecked(),
|
||||||
|
@ -91,6 +91,12 @@ void AFSquelch::setCoefficients(int N, unsigned int nbAvg, int _samplerate, int
|
|||||||
m_samplesAttack = _samplesAttack;
|
m_samplesAttack = _samplesAttack;
|
||||||
m_samplesDecay = _samplesDecay;
|
m_samplesDecay = _samplesDecay;
|
||||||
m_movingAverages.resize(m_nTones, MovingAverage<double>(m_nbAvg, 1.0));
|
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
|
// for each of the frequencies (tones) of interest calculate
|
||||||
// k and the associated filter coefficient as per the Goertzel
|
// k and the associated filter coefficient as per the Goertzel
|
||||||
|
Loading…
Reference in New Issue
Block a user