mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-11-03 21:20:31 -05:00 
			
		
		
		
	SSB demod: make AGC clamping optional
This commit is contained in:
		
							parent
							
								
									f90ddf20eb
								
							
						
					
					
						commit
						4c37f40ed6
					
				@ -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;
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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<<value), 'f', 0);
 | 
			
		||||
@ -518,6 +526,7 @@ void SSBDemodGUI::applySettings()
 | 
			
		||||
			m_dsb,
 | 
			
		||||
			ui->audioMute->isChecked(),
 | 
			
		||||
			ui->agc->isChecked(),
 | 
			
		||||
			ui->agcClamping->isChecked(),
 | 
			
		||||
			ui->agcTimeLog2->value(),
 | 
			
		||||
			ui->agcPowerThreshold->value(),
 | 
			
		||||
			ui->agcThresholdGate->value());
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
 | 
			
		||||
@ -474,6 +474,19 @@
 | 
			
		||||
        </property>
 | 
			
		||||
       </widget>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item>
 | 
			
		||||
       <widget class="ButtonSwitch" name="agcClamping">
 | 
			
		||||
        <property name="toolTip">
 | 
			
		||||
         <string>Toggle AGC clamping to maximum allowable signal</string>
 | 
			
		||||
        </property>
 | 
			
		||||
        <property name="text">
 | 
			
		||||
         <string>CL</string>
 | 
			
		||||
        </property>
 | 
			
		||||
        <property name="checkable">
 | 
			
		||||
         <bool>true</bool>
 | 
			
		||||
        </property>
 | 
			
		||||
       </widget>
 | 
			
		||||
      </item>
 | 
			
		||||
      <item>
 | 
			
		||||
       <widget class="QDial" name="agcTimeLog2">
 | 
			
		||||
        <property name="maximumSize">
 | 
			
		||||
 | 
			
		||||
@ -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,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user