mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-06-16 13:32:27 -04:00
NFM demod: fixed squelch
This commit is contained in:
parent
c7db2a3ca7
commit
1db2da3b60
@ -57,7 +57,6 @@ NFMDemod::NFMDemod(DeviceSourceAPI *devieAPI) :
|
|||||||
m_sampleCount(0),
|
m_sampleCount(0),
|
||||||
m_squelchCount(0),
|
m_squelchCount(0),
|
||||||
m_squelchGate(4800),
|
m_squelchGate(4800),
|
||||||
m_squelchDecay(4800),
|
|
||||||
m_squelchLevel(-990),
|
m_squelchLevel(-990),
|
||||||
m_squelchOpen(false),
|
m_squelchOpen(false),
|
||||||
m_afSquelchOpen(false),
|
m_afSquelchOpen(false),
|
||||||
@ -192,7 +191,7 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
|||||||
{
|
{
|
||||||
m_squelchDelayLine.write(demod * m_discriCompensation);
|
m_squelchDelayLine.write(demod * m_discriCompensation);
|
||||||
|
|
||||||
if (m_squelchCount < m_squelchGate + m_squelchDecay) {
|
if (m_squelchCount < 2*m_squelchGate) {
|
||||||
m_squelchCount++;
|
m_squelchCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,76 +218,84 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
|
|||||||
{
|
{
|
||||||
m_squelchDelayLine.write(demod * m_discriCompensation);
|
m_squelchDelayLine.write(demod * m_discriCompensation);
|
||||||
|
|
||||||
if (m_squelchCount < m_squelchGate + m_squelchDecay) {
|
if (m_squelchCount < 2*m_squelchGate) {
|
||||||
m_squelchCount++;
|
m_squelchCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_squelchOpen = (m_squelchCount > m_squelchGate);
|
if (m_settings.m_audioMute)
|
||||||
|
|
||||||
if ((m_squelchOpen) && !m_settings.m_audioMute)
|
|
||||||
{
|
{
|
||||||
if (m_settings.m_ctcssOn)
|
sample = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_squelchOpen = (m_squelchCount > m_squelchGate);
|
||||||
|
|
||||||
|
if (m_squelchOpen)
|
||||||
{
|
{
|
||||||
Real ctcss_sample = m_lowpass.filter(demod * m_discriCompensation);
|
if (m_settings.m_ctcssOn)
|
||||||
|
|
||||||
if ((m_sampleCount & 7) == 7) // decimate 48k -> 6k
|
|
||||||
{
|
{
|
||||||
if (m_ctcssDetector.analyze(&ctcss_sample))
|
Real ctcss_sample = m_lowpass.filter(demod * m_discriCompensation);
|
||||||
{
|
|
||||||
int maxToneIndex;
|
|
||||||
|
|
||||||
if (m_ctcssDetector.getDetectedTone(maxToneIndex))
|
if ((m_sampleCount & 7) == 7) // decimate 48k -> 6k
|
||||||
|
{
|
||||||
|
if (m_ctcssDetector.analyze(&ctcss_sample))
|
||||||
{
|
{
|
||||||
if (maxToneIndex+1 != m_ctcssIndex)
|
int maxToneIndex;
|
||||||
|
|
||||||
|
if (m_ctcssDetector.getDetectedTone(maxToneIndex))
|
||||||
{
|
{
|
||||||
if (getMessageQueueToGUI()) {
|
if (maxToneIndex+1 != m_ctcssIndex)
|
||||||
MsgReportCTCSSFreq *msg = MsgReportCTCSSFreq::create(m_ctcssDetector.getToneSet()[maxToneIndex]);
|
{
|
||||||
getMessageQueueToGUI()->push(msg);
|
if (getMessageQueueToGUI()) {
|
||||||
|
MsgReportCTCSSFreq *msg = MsgReportCTCSSFreq::create(m_ctcssDetector.getToneSet()[maxToneIndex]);
|
||||||
|
getMessageQueueToGUI()->push(msg);
|
||||||
|
}
|
||||||
|
m_ctcssIndex = maxToneIndex+1;
|
||||||
}
|
}
|
||||||
m_ctcssIndex = maxToneIndex+1;
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
|
||||||
{
|
|
||||||
if (m_ctcssIndex != 0)
|
|
||||||
{
|
{
|
||||||
if (getMessageQueueToGUI()) {
|
if (m_ctcssIndex != 0)
|
||||||
MsgReportCTCSSFreq *msg = MsgReportCTCSSFreq::create(0);
|
{
|
||||||
getMessageQueueToGUI()->push(msg);
|
if (getMessageQueueToGUI()) {
|
||||||
|
MsgReportCTCSSFreq *msg = MsgReportCTCSSFreq::create(0);
|
||||||
|
getMessageQueueToGUI()->push(msg);
|
||||||
|
}
|
||||||
|
m_ctcssIndex = 0;
|
||||||
}
|
}
|
||||||
m_ctcssIndex = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (m_settings.m_ctcssOn && m_ctcssIndexSelected && (m_ctcssIndexSelected != m_ctcssIndex))
|
if (m_settings.m_ctcssOn && m_ctcssIndexSelected && (m_ctcssIndexSelected != m_ctcssIndex))
|
||||||
{
|
{
|
||||||
sample = 0;
|
sample = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sample = m_bandpass.filter(m_squelchDelayLine.readBack(m_squelchGate)) * m_settings.m_volume;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sample = m_bandpass.filter(m_squelchDelayLine.readBack(m_squelchGate)) * m_settings.m_volume;
|
if (m_ctcssIndex != 0)
|
||||||
}
|
{
|
||||||
}
|
if (getMessageQueueToGUI()) {
|
||||||
else
|
MsgReportCTCSSFreq *msg = MsgReportCTCSSFreq::create(0);
|
||||||
{
|
getMessageQueueToGUI()->push(msg);
|
||||||
if (m_ctcssIndex != 0)
|
}
|
||||||
{
|
|
||||||
if (getMessageQueueToGUI()) {
|
m_ctcssIndex = 0;
|
||||||
MsgReportCTCSSFreq *msg = MsgReportCTCSSFreq::create(0);
|
|
||||||
getMessageQueueToGUI()->push(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ctcssIndex = 0;
|
sample = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sample = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_audioBuffer[m_audioBufferFill].l = sample;
|
m_audioBuffer[m_audioBufferFill].l = sample;
|
||||||
m_audioBuffer[m_audioBufferFill].r = sample;
|
m_audioBuffer[m_audioBufferFill].r = sample;
|
||||||
++m_audioBufferFill;
|
++m_audioBufferFill;
|
||||||
@ -421,7 +428,6 @@ void NFMDemod::applyAudioSampleRate(int sampleRate)
|
|||||||
m_lowpass.create(301, sampleRate, 250.0);
|
m_lowpass.create(301, sampleRate, 250.0);
|
||||||
m_bandpass.create(301, sampleRate, 300.0, m_settings.m_afBandwidth);
|
m_bandpass.create(301, sampleRate, 300.0, m_settings.m_afBandwidth);
|
||||||
m_squelchGate = (sampleRate / 100) * m_settings.m_squelchGate; // gate is given in 10s of ms at 48000 Hz audio sample rate
|
m_squelchGate = (sampleRate / 100) * m_settings.m_squelchGate; // gate is given in 10s of ms at 48000 Hz audio sample rate
|
||||||
m_squelchDecay = m_squelchGate;
|
|
||||||
m_squelchCount = 0; // reset squelch open counter
|
m_squelchCount = 0; // reset squelch open counter
|
||||||
m_ctcssDetector.setCoefficients(sampleRate/16, sampleRate/8.0f); // 0.5s / 2 Hz resolution
|
m_ctcssDetector.setCoefficients(sampleRate/16, sampleRate/8.0f); // 0.5s / 2 Hz resolution
|
||||||
|
|
||||||
|
@ -195,7 +195,6 @@ private:
|
|||||||
int m_sampleCount;
|
int m_sampleCount;
|
||||||
int m_squelchCount;
|
int m_squelchCount;
|
||||||
int m_squelchGate;
|
int m_squelchGate;
|
||||||
int m_squelchDecay;
|
|
||||||
|
|
||||||
Real m_squelchLevel;
|
Real m_squelchLevel;
|
||||||
bool m_squelchOpen;
|
bool m_squelchOpen;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
const PluginDescriptor NFMPlugin::m_pluginDescriptor = {
|
const PluginDescriptor NFMPlugin::m_pluginDescriptor = {
|
||||||
QString("NFM Demodulator"),
|
QString("NFM Demodulator"),
|
||||||
QString("3.14.4"),
|
QString("3.14.5"),
|
||||||
QString("(c) Edouard Griffiths, F4EXB"),
|
QString("(c) Edouard Griffiths, F4EXB"),
|
||||||
QString("https://github.com/f4exb/sdrangel"),
|
QString("https://github.com/f4exb/sdrangel"),
|
||||||
true,
|
true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user