From f56bea2afeb27184dd4c13127c918d45d8ab9dcd Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 20 Aug 2017 23:44:40 +0200 Subject: [PATCH] UDP source plugin: optimize squelch gate and release times for SSB --- plugins/channelrx/udpsrc/udpsrc.cpp | 34 +++++++++++++++++++++++---- plugins/channelrx/udpsrc/udpsrc.h | 15 ++++++------ plugins/channelrx/udpsrc/udpsrcgui.ui | 2 +- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/plugins/channelrx/udpsrc/udpsrc.cpp b/plugins/channelrx/udpsrc/udpsrc.cpp index a878fd759..a0a10f70b 100644 --- a/plugins/channelrx/udpsrc/udpsrc.cpp +++ b/plugins/channelrx/udpsrc/udpsrc.cpp @@ -37,7 +37,8 @@ UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, BasebandSampl m_squelchOpen(false), m_squelchOpenCount(0), m_squelchCloseCount(0), - m_squelchThreshold(4800), + m_squelchGate(4800), + m_squelchRelease(4800), m_agc(9600, m_agcTarget, 1e-6), m_settingsMutex(QMutex::Recursive) { @@ -448,11 +449,23 @@ void UDPSrc::apply(bool force) m_interpolator.create(16, m_config.m_inputSampleRate, m_config.m_rfBandwidth / 2.0); m_sampleDistanceRemain = m_config.m_inputSampleRate / m_config.m_outputSampleRate; - m_squelchThreshold = m_config.m_outputSampleRate * m_config.m_squelchGate; + if ((m_config.m_sampleFormat == FormatLSB) || + (m_config.m_sampleFormat == FormatLSBMono) || + (m_config.m_sampleFormat == FormatUSB) || + (m_config.m_sampleFormat == FormatUSBMono)) + { + m_squelchGate = m_config.m_outputSampleRate * 0.05; + } + else + { + m_squelchGate = m_config.m_outputSampleRate * m_config.m_squelchGate; + } + + m_squelchRelease = m_config.m_outputSampleRate * m_config.m_squelchGate; initSquelch(m_squelchOpen); m_agc.resize(m_config.m_outputSampleRate * 0.2, m_agcTarget); // Fixed 200 ms m_agc.setStepDownDelay( m_config.m_outputSampleRate * (m_config.m_squelchGate == 0 ? 0.01 : m_config.m_squelchGate)); - m_agc.setGate(m_config.m_outputSampleRate * 0.02); + m_agc.setGate(m_config.m_outputSampleRate * 0.05); m_bandpass.create(301, m_config.m_outputSampleRate, 300.0, m_config.m_rfBandwidth / 2.0f); @@ -476,10 +489,21 @@ void UDPSrc::apply(bool force) if ((m_config.m_squelchGate != m_running.m_squelchGate) || force) { - m_squelchThreshold = m_config.m_outputSampleRate * m_config.m_squelchGate; + if ((m_config.m_sampleFormat == FormatLSB) || + (m_config.m_sampleFormat == FormatLSBMono) || + (m_config.m_sampleFormat == FormatUSB) || + (m_config.m_sampleFormat == FormatUSBMono)) + { + m_squelchGate = m_config.m_outputSampleRate * 0.05; + } + else + { + m_squelchGate = m_config.m_outputSampleRate * m_config.m_squelchGate; + } + + m_squelchRelease = m_config.m_outputSampleRate * m_config.m_squelchGate; initSquelch(m_squelchOpen); m_agc.setStepDownDelay(m_config.m_outputSampleRate * (m_config.m_squelchGate == 0 ? 0.01 : m_config.m_squelchGate)); // same delay for up and down - m_agc.setGate(m_config.m_outputSampleRate * 0.02); } if ((m_config.m_squelch != m_running.m_squelch) || force) diff --git a/plugins/channelrx/udpsrc/udpsrc.h b/plugins/channelrx/udpsrc/udpsrc.h index 3f5257274..5a49aba84 100644 --- a/plugins/channelrx/udpsrc/udpsrc.h +++ b/plugins/channelrx/udpsrc/udpsrc.h @@ -340,7 +340,8 @@ protected: bool m_squelchOpen; int m_squelchOpenCount; int m_squelchCloseCount; - int m_squelchThreshold; //!< number of samples computed from given gate + int m_squelchGate; //!< number of samples computed from given gate + int m_squelchRelease; MagAGC m_agc; Bandpass m_bandpass; @@ -353,26 +354,26 @@ protected: { if ((!m_running.m_squelchEnabled) || (value > m_running.m_squelch)) { - if (m_squelchThreshold == 0) + if (m_squelchGate == 0) { m_squelchOpen = true; } else { - if (m_squelchOpenCount < m_squelchThreshold) + if (m_squelchOpenCount < m_squelchGate) { m_squelchOpenCount++; } else { - m_squelchCloseCount = m_squelchThreshold; + m_squelchCloseCount = m_squelchRelease; m_squelchOpen = true; } } } else { - if (m_squelchThreshold == 0) + if (m_squelchGate == 0) { m_squelchOpen = false; } @@ -396,8 +397,8 @@ protected: if (open) { m_squelchOpen = true; - m_squelchOpenCount = m_squelchThreshold; - m_squelchCloseCount = m_squelchThreshold; + m_squelchOpenCount = m_squelchGate; + m_squelchCloseCount = m_squelchRelease; } else { diff --git a/plugins/channelrx/udpsrc/udpsrcgui.ui b/plugins/channelrx/udpsrc/udpsrcgui.ui index 5daae8808..f53605430 100644 --- a/plugins/channelrx/udpsrc/udpsrcgui.ui +++ b/plugins/channelrx/udpsrc/udpsrcgui.ui @@ -641,7 +641,7 @@ Squelch gate (ms) - 50 + 90 1