1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 09:18:54 -05:00

AM demod: fixed delayed squelch

This commit is contained in:
f4exb 2018-05-06 22:56:24 +02:00
parent 1ac7ceae80
commit 97677075b1
3 changed files with 18 additions and 35 deletions

3
debian/changelog vendored
View File

@ -4,8 +4,9 @@ sdrangel (3.14.5-1) unstable; urgency=medium
* Added a benchmark program testing decimators
* Optimization of decimators using even/odd technique
* SSB mod: fixed channel unregistration
* AM demod: fixed delayed squelch
-- Edouard Griffiths, F4EXB <f4exb06@gmail.com> Fri, 04 May 2018 20:14:18 +0200
-- Edouard Griffiths, F4EXB <f4exb06@gmail.com> Sun, 06 May 2018 20:14:18 +0200
sdrangel (3.14.4-1) unstable; urgency=medium

View File

@ -49,7 +49,7 @@ AMDemod::AMDemod(DeviceSourceAPI *deviceAPI) :
m_inputFrequencyOffset(0),
m_running(false),
m_squelchOpen(false),
m_squelchDelayLine(12000),
m_squelchDelayLine(9600),
m_magsqSum(0.0f),
m_magsqPeak(0.0f),
m_magsqCount(0),
@ -232,7 +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_squelchDelayLine.resize(sampleRate/5);
m_settingsMutex.unlock();
m_audioSampleRate = sampleRate;

View File

@ -30,7 +30,6 @@
#include "audio/audiofifo.h"
#include "util/message.h"
#include "util/doublebufferfifo.h"
#include "amdemodsettings.h"
class DeviceSourceAPI;
@ -183,8 +182,8 @@ private:
void processOneSample(Complex &ci)
{
Real re = ci.real() / SDR_RX_SCALED;
Real im = ci.imag() / SDR_RX_SCALED;
Real re = ci.real() / SDR_RX_SCALEF;
Real im = ci.imag() / SDR_RX_SCALEF;
Real magsq = re*re + im*im;
m_movingAverage(magsq);
m_magsq = m_movingAverage.asDouble();
@ -197,43 +196,28 @@ private:
m_magsqCount++;
// if (m_magsq >= m_squelchLevel)
// {
// if (m_squelchCount <= m_audioSampleRate / 10)
// {
// m_squelchCount++;
// }
// }
// else
// {
// if (m_squelchCount > 1)
// {
// m_squelchCount -= 2;
// }
// }
m_squelchDelayLine.write(magsq);
if (m_magsq >= m_squelchLevel)
{
if (m_squelchCount < m_audioSampleRate / 10) {
m_squelchCount++;
}
m_squelchDelayLine.write(magsq);
}
else
if (m_magsq < m_squelchLevel)
{
if (m_squelchCount > 0) {
m_squelchCount--;
}
m_squelchDelayLine.write(0);
}
else
{
if (m_squelchCount < m_audioSampleRate / 10) {
m_squelchCount++;
}
}
qint16 sample;
if ((m_squelchCount >= m_audioSampleRate / 20) && !m_settings.m_audioMute)
m_squelchOpen = (m_squelchCount >= m_audioSampleRate / 20);
if (m_squelchOpen && !m_settings.m_audioMute)
{
Real demod = sqrt(m_squelchDelayLine.readBack(m_audioSampleRate / 20));
Real demod = sqrt(m_squelchDelayLine.readBack(m_audioSampleRate/20));
m_volumeAGC.feed(demod);
demod = (demod - m_volumeAGC.getValue()) / m_volumeAGC.getValue();
@ -245,12 +229,10 @@ private:
Real attack = (m_squelchCount - 0.05f * m_audioSampleRate) / (0.05f * m_audioSampleRate);
sample = demod * attack * (m_audioSampleRate/24) * m_settings.m_volume;
m_squelchOpen = true;
}
else
{
sample = 0;
m_squelchOpen = false;
}
m_audioBuffer[m_audioBufferFill].l = sample;