diff --git a/dsd/dsd_symbol.c b/dsd/dsd_symbol.c index 1ce4d9f22..60b10e3d4 100644 --- a/dsd/dsd_symbol.c +++ b/dsd/dsd_symbol.c @@ -108,7 +108,7 @@ int getSymbol(dsd_opts * opts, dsd_state * state, int have_sync) if (state->output_num_samples > state->output_length) { - fprintf(stderr, "WARNING: audio buffer over-run! Truncating output"); + fprintf(stderr, "WARNING: audio buffer over-run! Truncating output\n"); state->output_num_samples = state->output_length; } diff --git a/plugins/channel/demoddsd/dsddemod.cpp b/plugins/channel/demoddsd/dsddemod.cpp index 8b92eef5b..99c6be73b 100644 --- a/plugins/channel/demoddsd/dsddemod.cpp +++ b/plugins/channel/demoddsd/dsddemod.cpp @@ -33,9 +33,7 @@ MESSAGE_CLASS_DEFINITION(DSDDemod::MsgConfigureDSDDemod, Message) DSDDemod::DSDDemod(SampleSink* sampleSink) : m_sampleCount(0), m_squelchCount(0), - m_agcAttack(2400), m_squelchOpen(false), - m_afSquelch(2, afSqTones), m_audioFifo(4, 48000), m_fmExcursion(24), m_settingsMutex(QMutex::Recursive), @@ -64,10 +62,7 @@ DSDDemod::DSDDemod(SampleSink* sampleSink) : m_audioBuffer.resize(1<<14); m_audioBufferFill = 0; - m_agcLevel = 1.0; - m_AGC.resize(m_agcAttack, m_agcLevel); - - m_afSquelch.setCoefficients(24, 600, 48000.0, 200, 0); // 4000 Hz span, 250us, 100ms attack + m_movingAverage.resize(16, 0); DSPEngine::instance()->addAudioSink(&m_audioFifo); } @@ -113,19 +108,19 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto { if (m_interpolator.interpolate(&m_interpolatorDistanceRemain, c, &ci)) { - qint16 sample; - m_AGC.feed(ci); + m_magsq = ((ci.real()*ci.real() + ci.imag()*ci.imag())) / (Real) (1<<30); + m_movingAverage.feed(m_magsq); Real demod = 32768.0f * m_phaseDiscri.phaseDiscriminator(ci) * ((float) m_running.m_demodGain / 100.0f); m_sampleCount++; // AF processing - if (getMag() > m_squelchLevel) + if (getMagSq() > m_squelchLevel) { - if (m_squelchCount < m_agcAttack) + if (m_squelchCount < m_squelchGate) { m_squelchCount++; } @@ -135,7 +130,7 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto m_squelchCount = 0; } - m_squelchOpen = m_squelchCount == m_agcAttack; // wait for AGC to stabilize + m_squelchOpen = m_squelchCount == m_squelchGate; if (m_squelchOpen) { @@ -291,16 +286,14 @@ void DSDDemod::apply() 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); + m_squelchGate = 480 * m_config.m_squelchGate; // gate is given in 10s of ms at 48000 Hz audio sample rate } if (m_config.m_squelch != m_running.m_squelch) { // input is a value in tenths of dB - m_squelchLevel = std::pow(10.0, m_config.m_squelch / 200.0); + m_squelchLevel = std::pow(10.0, m_config.m_squelch / 100.0); //m_squelchLevel *= m_squelchLevel; - m_afSquelch.setThreshold(m_squelchLevel); } m_running.m_inputSampleRate = m_config.m_inputSampleRate; diff --git a/plugins/channel/demoddsd/dsddemod.h b/plugins/channel/demoddsd/dsddemod.h index 16e338cef..a743065d8 100644 --- a/plugins/channel/demoddsd/dsddemod.h +++ b/plugins/channel/demoddsd/dsddemod.h @@ -27,7 +27,7 @@ #include "dsp/lowpass.h" #include "dsp/bandpass.h" #include "dsp/afsquelch.h" -#include "dsp/agc.h" +#include "dsp/movingaverage.h" #include "dsp/afsquelch.h" #include "audio/audiofifo.h" #include "util/message.h" @@ -58,7 +58,7 @@ public: m_dsdDemodGUI = dsdDemodGUI; } - Real getMag() { return m_AGC.getAverage() / (1<<15); } + Real getMagSq() { return m_magsq; } bool getSquelchOpen() const { return m_squelchOpen; } private: @@ -158,16 +158,14 @@ private: Real m_interpolatorDistanceRemain; int m_sampleCount; int m_squelchCount; - int m_agcAttack; + int m_squelchGate; double m_squelchLevel; bool m_squelchOpen; Real m_lastArgument; - MagAGC m_AGC; - AFSquelch m_afSquelch; - Real m_agcLevel; // AGC will aim to this level - Real m_agcFloor; // AGC will not go below this level + MovingAverage m_movingAverage; + Real m_magsq; Real m_fmExcursion; diff --git a/plugins/channel/demoddsd/dsddemodgui.cpp b/plugins/channel/demoddsd/dsddemodgui.cpp index b9ade60a9..fa39a20fe 100644 --- a/plugins/channel/demoddsd/dsddemodgui.cpp +++ b/plugins/channel/demoddsd/dsddemodgui.cpp @@ -354,7 +354,7 @@ void DSDDemodGUI::blockApplySettings(bool block) void DSDDemodGUI::tick() { - Real powDb = CalcDb::dbPower(m_dsdDemod->getMag()) * 2; + Real powDb = CalcDb::dbPower(m_dsdDemod->getMagSq()); m_channelPowerDbAvg.feed(powDb); ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1)); bool squelchOpen = m_dsdDemod->getSquelchOpen();