1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

AM demod: use buffered delay squelch

This commit is contained in:
f4exb 2018-04-22 10:23:11 +02:00
parent 7e6267f41c
commit 06cd90e354
3 changed files with 29 additions and 7 deletions

View File

@ -49,6 +49,7 @@ AMDemod::AMDemod(DeviceSourceAPI *deviceAPI) :
m_inputFrequencyOffset(0),
m_running(false),
m_squelchOpen(false),
m_squelchDelayLine(12000),
m_magsqSum(0.0f),
m_magsqPeak(0.0f),
m_magsqCount(0),
@ -231,6 +232,7 @@ void AMDemod::applyAudioSampleRate(int sampleRate)
m_interpolatorDistance = (Real) m_inputSampleRate / (Real) sampleRate;
m_bandpass.create(301, sampleRate, 300.0, m_settings.m_rfBandwidth / 2.0f);
m_audioFifo.setSize(sampleRate);
m_squelchDelayLine.resize(sampleRate/4);
m_settingsMutex.unlock();
m_audioSampleRate = sampleRate;

View File

@ -29,6 +29,8 @@
#include "dsp/bandpass.h"
#include "audio/audiofifo.h"
#include "util/message.h"
#include "util/doublebufferfifo.h"
#include "amdemodsettings.h"
class DeviceSourceAPI;
@ -155,6 +157,7 @@ private:
Real m_squelchLevel;
uint32_t m_squelchCount;
bool m_squelchOpen;
DoubleBufferFIFO<Real> m_squelchDelayLine;
double m_magsq;
double m_magsqSum;
double m_magsqPeak;
@ -194,26 +197,43 @@ private:
m_magsqCount++;
// if (m_magsq >= m_squelchLevel)
// {
// if (m_squelchCount <= m_audioSampleRate / 10)
// {
// m_squelchCount++;
// }
// }
// else
// {
// if (m_squelchCount > 1)
// {
// m_squelchCount -= 2;
// }
// }
if (m_magsq >= m_squelchLevel)
{
if (m_squelchCount <= m_audioSampleRate / 10)
{
if (m_squelchCount < m_audioSampleRate / 10) {
m_squelchCount++;
}
m_squelchDelayLine.write(magsq);
}
else
{
if (m_squelchCount > 1)
{
m_squelchCount -= 2;
if (m_squelchCount > 0) {
m_squelchCount--;
}
m_squelchDelayLine.write(0);
}
qint16 sample;
if ((m_squelchCount >= m_audioSampleRate / 20) && !m_settings.m_audioMute)
{
Real demod = sqrt(magsq);
Real demod = sqrt(m_squelchDelayLine.readBack(m_audioSampleRate / 20));
m_volumeAGC.feed(demod);
demod = (demod - m_volumeAGC.getValue()) / m_volumeAGC.getValue();

View File

@ -9,7 +9,7 @@
const PluginDescriptor AMDemodPlugin::m_pluginDescriptor = {
QString("AM Demodulator"),
QString("3.14.2"),
QString("3.14.4"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,