From 68ed0013ea1f33d3b7b7c2efc737d5c3cf9d98ce Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 31 Mar 2016 19:38:39 +0200 Subject: [PATCH] NFM demod: added adjustable squelch gate time (AGC attack) to adjust the length of transient elimination from default 50ms --- plugins/channel/demodnfm/nfmdemod.cpp | 12 +++++ plugins/channel/demodnfm/nfmdemod.h | 12 ++++- plugins/channel/demodnfm/nfmdemodgui.cpp | 11 +++++ plugins/channel/demodnfm/nfmdemodgui.h | 1 + plugins/channel/demodnfm/nfmdemodgui.ui | 62 +++++++++++++++++++++--- sdrbase/gui/aboutdialog.ui | 2 +- 6 files changed, 91 insertions(+), 9 deletions(-) diff --git a/plugins/channel/demodnfm/nfmdemod.cpp b/plugins/channel/demodnfm/nfmdemod.cpp index 677ca19fb..e9dc0d582 100644 --- a/plugins/channel/demodnfm/nfmdemod.cpp +++ b/plugins/channel/demodnfm/nfmdemod.cpp @@ -48,6 +48,7 @@ NFMDemod::NFMDemod() : m_config.m_inputFrequencyOffset = 0; m_config.m_rfBandwidth = 12500; m_config.m_afBandwidth = 3000; + m_config.m_squelchGate = 5; // 10s of ms at 48000 Hz sample rate. Corresponds to 2400 for AGC attack m_config.m_squelch = -30.0; m_config.m_volume = 1.0; m_config.m_ctcssOn = false; @@ -78,6 +79,7 @@ void NFMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, + int squelchGate, Real squelch, bool ctcssOn, bool audioMute) @@ -85,6 +87,7 @@ void NFMDemod::configure(MessageQueue* messageQueue, Message* cmd = MsgConfigureNFMDemod::create(rfBandwidth, afBandwidth, volume, + squelchGate, squelch, ctcssOn, audioMute); @@ -295,6 +298,7 @@ bool NFMDemod::handleMessage(const Message& cmd) m_config.m_rfBandwidth = cfg.getRFBandwidth(); m_config.m_afBandwidth = cfg.getAFBandwidth(); m_config.m_volume = cfg.getVolume(); + m_config.m_squelchGate = cfg.getSquelchGate(); m_config.m_squelch = cfg.getSquelch(); m_config.m_ctcssOn = cfg.getCtcssOn(); m_config.m_audioMute = cfg.getAudioMute(); @@ -304,6 +308,7 @@ bool NFMDemod::handleMessage(const Message& cmd) qDebug() << "NFMDemod::handleMessage: MsgConfigureNFMDemod: m_rfBandwidth: " << m_config.m_rfBandwidth << " m_afBandwidth: " << m_config.m_afBandwidth << " m_volume: " << m_config.m_volume + << " m_squelchGate" << m_config.m_squelchGate << " m_squelch: " << m_config.m_squelch << " m_ctcssOn: " << m_config.m_ctcssOn << " m_audioMute: " << m_config.m_audioMute; @@ -345,6 +350,12 @@ void NFMDemod::apply() m_settingsMutex.unlock(); } + if (m_config.m_squelchGate != m_running.m_squelchGate) + { + m_agcAttack = 480 * m_config.m_squelchGate; // gate is given in 10s of ms at 48000 Hz audio sample rate + m_AGC.resize(m_agcAttack, m_agcLevel); + } + if (m_config.m_squelch != m_running.m_squelch) { // input is a value in tenths of dB @@ -357,6 +368,7 @@ void NFMDemod::apply() m_running.m_inputFrequencyOffset = m_config.m_inputFrequencyOffset; m_running.m_rfBandwidth = m_config.m_rfBandwidth; m_running.m_afBandwidth = m_config.m_afBandwidth; + m_running.m_squelchGate = m_config.m_squelchGate; m_running.m_squelch = m_config.m_squelch; m_running.m_volume = m_config.m_volume; m_running.m_audioSampleRate = m_config.m_audioSampleRate; diff --git a/plugins/channel/demodnfm/nfmdemod.h b/plugins/channel/demodnfm/nfmdemod.h index e24eb59a6..885ed2ba8 100644 --- a/plugins/channel/demodnfm/nfmdemod.h +++ b/plugins/channel/demodnfm/nfmdemod.h @@ -44,6 +44,7 @@ public: Real rfBandwidth, Real afBandwidth, Real volume, + int squelchGate, Real squelch, bool ctcssOn, bool audioMute); @@ -76,7 +77,8 @@ private: public: Real getRFBandwidth() const { return m_rfBandwidth; } Real getAFBandwidth() const { return m_afBandwidth; } - Real getVolume() const { return m_volume; } + Real getVolume() const { return m_volume; }\ + int getSquelchGate() const { return m_squelchGate; } Real getSquelch() const { return m_squelch; } bool getCtcssOn() const { return m_ctcssOn; } bool getAudioMute() const { return m_audioMute; } @@ -84,17 +86,19 @@ private: static MsgConfigureNFMDemod* create(Real rfBandwidth, Real afBandwidth, Real volume, + int squelchGate, Real squelch, bool ctcssOn, bool audioMute) { - return new MsgConfigureNFMDemod(rfBandwidth, afBandwidth, volume, squelch, ctcssOn, audioMute); + return new MsgConfigureNFMDemod(rfBandwidth, afBandwidth, volume, squelchGate, squelch, ctcssOn, audioMute); } private: Real m_rfBandwidth; Real m_afBandwidth; Real m_volume; + int m_squelchGate; Real m_squelch; bool m_ctcssOn; bool m_audioMute; @@ -102,6 +106,7 @@ private: MsgConfigureNFMDemod(Real rfBandwidth, Real afBandwidth, Real volume, + int squelchGate, Real squelch, bool ctcssOn, bool audioMute) : @@ -109,6 +114,7 @@ private: m_rfBandwidth(rfBandwidth), m_afBandwidth(afBandwidth), m_volume(volume), + m_squelchGate(squelchGate), m_squelch(squelch), m_ctcssOn(ctcssOn), m_audioMute(audioMute) @@ -131,6 +137,7 @@ private: qint64 m_inputFrequencyOffset; Real m_rfBandwidth; Real m_afBandwidth; + int m_squelchGate; Real m_squelch; Real m_volume; bool m_ctcssOn; @@ -143,6 +150,7 @@ private: m_inputFrequencyOffset(0), m_rfBandwidth(-1), m_afBandwidth(-1), + m_squelchGate(50), m_squelch(0), m_volume(0), m_ctcssOn(false), diff --git a/plugins/channel/demodnfm/nfmdemodgui.cpp b/plugins/channel/demodnfm/nfmdemodgui.cpp index 9f93bab8f..6b1d650da 100644 --- a/plugins/channel/demodnfm/nfmdemodgui.cpp +++ b/plugins/channel/demodnfm/nfmdemodgui.cpp @@ -57,6 +57,7 @@ void NFMDemodGUI::resetToDefaults() ui->rfBW->setValue(4); ui->afBW->setValue(3); ui->volume->setValue(20); + ui->squelchGate->setValue(5); ui->squelch->setValue(-40); ui->deltaFrequency->setValue(0); ui->ctcssOn->setChecked(false); @@ -78,6 +79,7 @@ QByteArray NFMDemodGUI::serialize() const s.writeS32(8, ui->ctcss->currentIndex()); s.writeBool(9, ui->ctcssOn->isChecked()); s.writeBool(10, ui->audioMute->isChecked()); + s.writeS32(11, ui->squelchGate->value()); return s.final(); } @@ -123,6 +125,8 @@ bool NFMDemodGUI::deserialize(const QByteArray& data) ui->ctcssOn->setChecked(boolTmp); d.readBool(10, &boolTmp, false); ui->audioMute->setChecked(boolTmp); + d.readS32(11, &tmp, 5); + ui->squelchGate->setValue(tmp); blockApplySettings(false); m_channelMarker.blockSignals(false); @@ -189,6 +193,12 @@ void NFMDemodGUI::on_volume_valueChanged(int value) applySettings(); } +void NFMDemodGUI::on_squelchGate_valueChanged(int value) +{ + ui->squelchGateText->setText(QString("%1").arg(value * 10.0, 0, 'f', 0)); + applySettings(); +} + void NFMDemodGUI::on_squelch_valueChanged(int value) { ui->squelchText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1)); @@ -312,6 +322,7 @@ void NFMDemodGUI::applySettings() m_rfBW[ui->rfBW->value()], ui->afBW->value() * 1000.0, ui->volume->value() / 10.0, + ui->squelchGate->value(), // in 10ths of ms ui->squelch->value(), ui->ctcssOn->isChecked(), ui->audioMute->isChecked()); diff --git a/plugins/channel/demodnfm/nfmdemodgui.h b/plugins/channel/demodnfm/nfmdemodgui.h index e044a8f00..61e0a6fb5 100644 --- a/plugins/channel/demodnfm/nfmdemodgui.h +++ b/plugins/channel/demodnfm/nfmdemodgui.h @@ -43,6 +43,7 @@ private slots: void on_rfBW_valueChanged(int value); void on_afBW_valueChanged(int value); void on_volume_valueChanged(int value); + void on_squelchGate_valueChanged(int value); void on_squelch_valueChanged(int value); void on_ctcss_currentIndexChanged(int index); void on_ctcssOn_toggled(bool checked); diff --git a/plugins/channel/demodnfm/nfmdemodgui.ui b/plugins/channel/demodnfm/nfmdemodgui.ui index df7f707b2..1011c9690 100644 --- a/plugins/channel/demodnfm/nfmdemodgui.ui +++ b/plugins/channel/demodnfm/nfmdemodgui.ui @@ -6,8 +6,8 @@ 0 0 - 281 - 162 + 279 + 172 @@ -25,7 +25,7 @@ 0 0 271 - 131 + 161 @@ -243,7 +243,7 @@ - Volume + Vol @@ -289,14 +289,14 @@ - Squelch + Sq - Squelch + Squelch threshold (dB) -1000 @@ -323,6 +323,9 @@ 0 + + Squelch threshold (dB) + -15.0 @@ -331,6 +334,53 @@ + + + + + 24 + 24 + + + + Squelch gate (ms) + + + 1 + + + 50 + + + 1 + + + 5 + + + 5 + + + + + + + + 25 + 0 + + + + Squelch gate (ms) + + + 000 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + diff --git a/sdrbase/gui/aboutdialog.ui b/sdrbase/gui/aboutdialog.ui index 39a9c5364..bee6db737 100644 --- a/sdrbase/gui/aboutdialog.ui +++ b/sdrbase/gui/aboutdialog.ui @@ -84,7 +84,7 @@ - <html><head/><body><p>Version 1.1.5 - Copyright (C) 2015-2016 Edouard Griffiths, F4EXB. </p><p>Code at <a href="https://github.com/f4exb/sdrangel"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/f4exb/sdrangel</span></a> This is a complete redesign from RTL-SDRangelove at <a href="https://github.com/hexameron/rtl-sdrangelove"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/hexameron/rtl-sdrangelove</span></a></p><p>Many thanks to the original developers:</p><p>The osmocom developer team - especially horizon, Hoernchen &amp; tnt.</p><p>Christian Daniel from maintech GmbH.</p><p>John Greb (hexameron) for the contributions in RTL-SDRangelove</p><p>The following rules apply to the SDRangel main application and libsdrbase:<br/>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program. If not, see <a href="http://www.gnu.org/licenses/"><span style=" text-decoration: underline; color:#0000ff;">http://www.gnu.org/licenses/</span></a>.</p><p>For the license of installed plugins, look into the plugin list.</p></body></html> + <html><head/><body><p>Version 1.1.6 - Copyright (C) 2015-2016 Edouard Griffiths, F4EXB. </p><p>Code at <a href="https://github.com/f4exb/sdrangel"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/f4exb/sdrangel</span></a> This is a complete redesign from RTL-SDRangelove at <a href="https://github.com/hexameron/rtl-sdrangelove"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/hexameron/rtl-sdrangelove</span></a></p><p>Many thanks to the original developers:</p><p>The osmocom developer team - especially horizon, Hoernchen &amp; tnt.</p><p>Christian Daniel from maintech GmbH.</p><p>John Greb (hexameron) for the contributions in RTL-SDRangelove</p><p>The following rules apply to the SDRangel main application and libsdrbase:<br/>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program. If not, see <a href="http://www.gnu.org/licenses/"><span style=" text-decoration: underline; color:#0000ff;">http://www.gnu.org/licenses/</span></a>.</p><p>For the license of installed plugins, look into the plugin list.</p></body></html> true