diff --git a/plugins/channelrx/demodssb/ssbdemod.cpp b/plugins/channelrx/demodssb/ssbdemod.cpp index 56bb0e861..8c8f2159a 100644 --- a/plugins/channelrx/demodssb/ssbdemod.cpp +++ b/plugins/channelrx/demodssb/ssbdemod.cpp @@ -35,6 +35,7 @@ SSBDemod::SSBDemod(BasebandSampleSink* sampleSink) : m_audioMute(false), m_agc(12000, agcTarget, 1e-2), m_agcActive(false), + m_agcClamping(false), m_agcNbSamples(12000), m_agcPowerThreshold(1e-2), m_agcThresholdGate(0), @@ -69,7 +70,7 @@ SSBDemod::SSBDemod(BasebandSampleSink* sampleSink) : m_magsqCount = 0; m_agc.setClampMax(32768.0*32768.0); - m_agc.setClamping(true); + m_agc.setClamping(m_agcClamping); SSBFilter = new fftfilt(m_LowCutoff / m_audioSampleRate, m_Bandwidth / m_audioSampleRate, ssbFftLen); DSBFilter = new fftfilt((2.0f * m_Bandwidth) / m_audioSampleRate, 2 * ssbFftLen); @@ -95,6 +96,7 @@ void SSBDemod::configure(MessageQueue* messageQueue, bool dsb, bool audioMute, bool agc, + bool agcClamping, int agcTimeLog2, int agcPowerThreshold, int agcThresholdGate) @@ -109,6 +111,7 @@ void SSBDemod::configure(MessageQueue* messageQueue, dsb, audioMute, agc, + agcClamping, agcTimeLog2, agcPowerThreshold, agcThresholdGate); @@ -324,6 +327,7 @@ bool SSBDemod::handleMessage(const Message& cmd) m_agc.setThresholdEnable(cfg.getAGCPowerThershold() != -99); double agcPowerThreshold = CalcDb::powerFromdB(cfg.getAGCPowerThershold()) * (1<<30); int agcThresholdGate = 48 * cfg.getAGCThersholdGate(); // ms + bool agcClamping = cfg.getAGCClamping(); if (m_agcNbSamples != agcNbSamples) { @@ -344,6 +348,12 @@ bool SSBDemod::handleMessage(const Message& cmd) m_agcThresholdGate = agcThresholdGate; } + if (m_agcClamping != agcClamping) + { + m_agc.setClamping(agcClamping); + m_agcClamping = agcClamping; + } + m_settingsMutex.unlock(); qDebug() << "SBDemod::handleMessage: MsgConfigureSSBDemod: m_Bandwidth: " << m_Bandwidth @@ -355,6 +365,7 @@ bool SSBDemod::handleMessage(const Message& cmd) << " m_dsb: " << m_dsb << " m_audioMute: " << m_audioMute << " m_agcActive: " << m_agcActive + << " m_agcClamping: " << m_agcClamping << " agcNbSamples: " << agcNbSamples << " agcPowerThreshold: " << agcPowerThreshold << " agcThresholdGate: " << agcThresholdGate; diff --git a/plugins/channelrx/demodssb/ssbdemod.h b/plugins/channelrx/demodssb/ssbdemod.h index befe97a6c..97581f499 100644 --- a/plugins/channelrx/demodssb/ssbdemod.h +++ b/plugins/channelrx/demodssb/ssbdemod.h @@ -46,6 +46,7 @@ public: bool dsb, bool audioMute, bool agc, + bool agcClamping, int agcTimeLog2, int agcPowerThreshold, int agcThresholdGate); @@ -83,6 +84,7 @@ private: bool getDSB() const { return m_dsb; } bool getAudioMute() const { return m_audioMute; } bool getAGC() const { return m_agc; } + bool getAGCClamping() const { return m_agcClamping; } int getAGCTimeLog2() const { return m_agcTimeLog2; } int getAGCPowerThershold() const { return m_agcPowerThreshold; } int getAGCThersholdGate() const { return m_agcThresholdGate; } @@ -96,6 +98,7 @@ private: bool dsb, bool audioMute, bool agc, + bool agcClamping, int agcTimeLog2, int agcPowerThreshold, int agcThresholdGate) @@ -110,6 +113,7 @@ private: dsb, audioMute, agc, + agcClamping, agcTimeLog2, agcPowerThreshold, agcThresholdGate); @@ -125,6 +129,7 @@ private: bool m_dsb; bool m_audioMute; bool m_agc; + bool m_agcClamping; int m_agcTimeLog2; int m_agcPowerThreshold; int m_agcThresholdGate; @@ -138,6 +143,7 @@ private: bool dsb, bool audioMute, bool agc, + bool agcClamping, int agcTimeLog2, int agcPowerThreshold, int agcThresholdGate) : @@ -151,6 +157,7 @@ private: m_dsb(dsb), m_audioMute(audioMute), m_agc(agc), + m_agcClamping(agcClamping), m_agcTimeLog2(agcTimeLog2), m_agcPowerThreshold(agcPowerThreshold), m_agcThresholdGate(agcThresholdGate) @@ -183,6 +190,7 @@ private: int m_magsqCount; MagAGC m_agc; bool m_agcActive; + bool m_agcClamping; int m_agcNbSamples; //!< number of audio (48 kHz) samples for AGC averaging double m_agcPowerThreshold; //!< AGC power threshold (linear) int m_agcThresholdGate; //!< Gate length in number of samples befor threshold triggers diff --git a/plugins/channelrx/demodssb/ssbdemodgui.cpp b/plugins/channelrx/demodssb/ssbdemodgui.cpp index 97b9c0a55..11f92ed8c 100644 --- a/plugins/channelrx/demodssb/ssbdemodgui.cpp +++ b/plugins/channelrx/demodssb/ssbdemodgui.cpp @@ -86,6 +86,7 @@ QByteArray SSBDemodGUI::serialize() const s.writeS32(12, ui->agcTimeLog2->value()); s.writeS32(13, ui->agcPowerThreshold->value()); s.writeS32(14, ui->agcThresholdGate->value()); + s.writeBool(15, ui->agcClamping->isChecked()); return s.final(); } @@ -139,6 +140,8 @@ bool SSBDemodGUI::deserialize(const QByteArray& data) ui->agcPowerThreshold->setValue(tmp); d.readS32(14, &tmp, 4); ui->agcThresholdGate->setValue(tmp); + d.readBool(15, &booltmp, false); + ui->agcClamping->setChecked(booltmp); displaySettings(); @@ -290,6 +293,11 @@ void SSBDemodGUI::on_agc_toggled(bool checked __attribute((__unused__))) applySettings(); } +void SSBDemodGUI::on_agcClamping_toggled(bool checked __attribute((__unused__))) +{ + applySettings(); +} + void SSBDemodGUI::on_agcTimeLog2_valueChanged(int value) { QString s = QString::number((1<audioMute->isChecked(), ui->agc->isChecked(), + ui->agcClamping->isChecked(), ui->agcTimeLog2->value(), ui->agcPowerThreshold->value(), ui->agcThresholdGate->value()); diff --git a/plugins/channelrx/demodssb/ssbdemodgui.h b/plugins/channelrx/demodssb/ssbdemodgui.h index 0ec35c327..6b3ba2bff 100644 --- a/plugins/channelrx/demodssb/ssbdemodgui.h +++ b/plugins/channelrx/demodssb/ssbdemodgui.h @@ -49,6 +49,7 @@ private slots: void on_lowCut_valueChanged(int value); void on_volume_valueChanged(int value); void on_agc_toggled(bool checked); + void on_agcClamping_toggled(bool checked); void on_agcTimeLog2_valueChanged(int value); void on_agcPowerThreshold_valueChanged(int value); void on_agcThresholdGate_valueChanged(int value); diff --git a/plugins/channelrx/demodssb/ssbdemodgui.ui b/plugins/channelrx/demodssb/ssbdemodgui.ui index b51f98f33..2d185d643 100644 --- a/plugins/channelrx/demodssb/ssbdemodgui.ui +++ b/plugins/channelrx/demodssb/ssbdemodgui.ui @@ -474,6 +474,19 @@ + + + + Toggle AGC clamping to maximum allowable signal + + + CL + + + true + + + diff --git a/plugins/channelrx/demodssb/ssbplugin.cpp b/plugins/channelrx/demodssb/ssbplugin.cpp index 4744acc10..5615e1e93 100644 --- a/plugins/channelrx/demodssb/ssbplugin.cpp +++ b/plugins/channelrx/demodssb/ssbplugin.cpp @@ -7,7 +7,7 @@ const PluginDescriptor SSBPlugin::m_pluginDescriptor = { QString("SSB Demodulator"), - QString("3.5.3"), + QString("3.5.4"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true,