mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-31 13:00:26 -04: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_audioMute(false), | ||||||
|     m_agc(12000, agcTarget, 1e-2), |     m_agc(12000, agcTarget, 1e-2), | ||||||
|     m_agcActive(false), |     m_agcActive(false), | ||||||
|  |     m_agcClamping(false), | ||||||
|     m_agcNbSamples(12000), |     m_agcNbSamples(12000), | ||||||
|     m_agcPowerThreshold(1e-2), |     m_agcPowerThreshold(1e-2), | ||||||
|     m_agcThresholdGate(0), |     m_agcThresholdGate(0), | ||||||
| @ -69,7 +70,7 @@ SSBDemod::SSBDemod(BasebandSampleSink* sampleSink) : | |||||||
| 	m_magsqCount = 0; | 	m_magsqCount = 0; | ||||||
| 
 | 
 | ||||||
| 	m_agc.setClampMax(32768.0*32768.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); | 	SSBFilter = new fftfilt(m_LowCutoff / m_audioSampleRate, m_Bandwidth / m_audioSampleRate, ssbFftLen); | ||||||
| 	DSBFilter = new fftfilt((2.0f * m_Bandwidth) / m_audioSampleRate, 2 * ssbFftLen); | 	DSBFilter = new fftfilt((2.0f * m_Bandwidth) / m_audioSampleRate, 2 * ssbFftLen); | ||||||
| @ -95,6 +96,7 @@ void SSBDemod::configure(MessageQueue* messageQueue, | |||||||
| 		bool dsb, | 		bool dsb, | ||||||
| 		bool audioMute, | 		bool audioMute, | ||||||
| 		bool agc, | 		bool agc, | ||||||
|  | 		bool agcClamping, | ||||||
|         int agcTimeLog2, |         int agcTimeLog2, | ||||||
|         int agcPowerThreshold, |         int agcPowerThreshold, | ||||||
|         int agcThresholdGate) |         int agcThresholdGate) | ||||||
| @ -109,6 +111,7 @@ void SSBDemod::configure(MessageQueue* messageQueue, | |||||||
| 	        dsb, | 	        dsb, | ||||||
| 	        audioMute, | 	        audioMute, | ||||||
| 	        agc, | 	        agc, | ||||||
|  | 	        agcClamping, | ||||||
| 	        agcTimeLog2, | 	        agcTimeLog2, | ||||||
| 	        agcPowerThreshold, | 	        agcPowerThreshold, | ||||||
| 	        agcThresholdGate); | 	        agcThresholdGate); | ||||||
| @ -324,6 +327,7 @@ bool SSBDemod::handleMessage(const Message& cmd) | |||||||
|         m_agc.setThresholdEnable(cfg.getAGCPowerThershold() != -99); |         m_agc.setThresholdEnable(cfg.getAGCPowerThershold() != -99); | ||||||
| 		double agcPowerThreshold = CalcDb::powerFromdB(cfg.getAGCPowerThershold()) * (1<<30); | 		double agcPowerThreshold = CalcDb::powerFromdB(cfg.getAGCPowerThershold()) * (1<<30); | ||||||
| 		int agcThresholdGate = 48 * cfg.getAGCThersholdGate(); // ms
 | 		int agcThresholdGate = 48 * cfg.getAGCThersholdGate(); // ms
 | ||||||
|  | 		bool agcClamping = cfg.getAGCClamping(); | ||||||
| 
 | 
 | ||||||
| 		if (m_agcNbSamples != agcNbSamples) | 		if (m_agcNbSamples != agcNbSamples) | ||||||
| 		{ | 		{ | ||||||
| @ -344,6 +348,12 @@ bool SSBDemod::handleMessage(const Message& cmd) | |||||||
| 		    m_agcThresholdGate = agcThresholdGate; | 		    m_agcThresholdGate = agcThresholdGate; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | 		if (m_agcClamping != agcClamping) | ||||||
|  | 		{ | ||||||
|  | 		    m_agc.setClamping(agcClamping); | ||||||
|  | 		    m_agcClamping = agcClamping; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		m_settingsMutex.unlock(); | 		m_settingsMutex.unlock(); | ||||||
| 
 | 
 | ||||||
| 		qDebug() << "SBDemod::handleMessage: MsgConfigureSSBDemod: m_Bandwidth: " << m_Bandwidth | 		qDebug() << "SBDemod::handleMessage: MsgConfigureSSBDemod: m_Bandwidth: " << m_Bandwidth | ||||||
| @ -355,6 +365,7 @@ bool SSBDemod::handleMessage(const Message& cmd) | |||||||
| 				<< " m_dsb: " << m_dsb | 				<< " m_dsb: " << m_dsb | ||||||
| 				<< " m_audioMute: " << m_audioMute | 				<< " m_audioMute: " << m_audioMute | ||||||
| 				<< " m_agcActive: " << m_agcActive | 				<< " m_agcActive: " << m_agcActive | ||||||
|  | 				<< " m_agcClamping: " << m_agcClamping | ||||||
| 				<< " agcNbSamples: " << agcNbSamples | 				<< " agcNbSamples: " << agcNbSamples | ||||||
| 				<< " agcPowerThreshold: " << agcPowerThreshold | 				<< " agcPowerThreshold: " << agcPowerThreshold | ||||||
| 				<< " agcThresholdGate: " << agcThresholdGate; | 				<< " agcThresholdGate: " << agcThresholdGate; | ||||||
|  | |||||||
| @ -46,6 +46,7 @@ public: | |||||||
| 			bool dsb, | 			bool dsb, | ||||||
| 			bool audioMute, | 			bool audioMute, | ||||||
| 			bool agc, | 			bool agc, | ||||||
|  | 			bool agcClamping, | ||||||
| 			int agcTimeLog2, | 			int agcTimeLog2, | ||||||
| 			int agcPowerThreshold, | 			int agcPowerThreshold, | ||||||
| 			int agcThresholdGate); | 			int agcThresholdGate); | ||||||
| @ -83,6 +84,7 @@ private: | |||||||
| 		bool getDSB() const { return m_dsb; } | 		bool getDSB() const { return m_dsb; } | ||||||
| 		bool getAudioMute() const { return m_audioMute; } | 		bool getAudioMute() const { return m_audioMute; } | ||||||
| 		bool getAGC() const { return m_agc; } | 		bool getAGC() const { return m_agc; } | ||||||
|  | 		bool getAGCClamping() const { return m_agcClamping; } | ||||||
| 		int  getAGCTimeLog2() const { return m_agcTimeLog2; } | 		int  getAGCTimeLog2() const { return m_agcTimeLog2; } | ||||||
| 		int  getAGCPowerThershold() const { return m_agcPowerThreshold; } | 		int  getAGCPowerThershold() const { return m_agcPowerThreshold; } | ||||||
|         int  getAGCThersholdGate() const { return m_agcThresholdGate; } |         int  getAGCThersholdGate() const { return m_agcThresholdGate; } | ||||||
| @ -96,6 +98,7 @@ private: | |||||||
| 				bool dsb, | 				bool dsb, | ||||||
| 				bool audioMute, | 				bool audioMute, | ||||||
|                 bool agc, |                 bool agc, | ||||||
|  |                 bool agcClamping, | ||||||
|                 int  agcTimeLog2, |                 int  agcTimeLog2, | ||||||
|                 int  agcPowerThreshold, |                 int  agcPowerThreshold, | ||||||
|                 int  agcThresholdGate) |                 int  agcThresholdGate) | ||||||
| @ -110,6 +113,7 @@ private: | |||||||
| 			        dsb, | 			        dsb, | ||||||
| 			        audioMute, | 			        audioMute, | ||||||
| 			        agc, | 			        agc, | ||||||
|  | 			        agcClamping, | ||||||
| 			        agcTimeLog2, | 			        agcTimeLog2, | ||||||
| 			        agcPowerThreshold, | 			        agcPowerThreshold, | ||||||
| 			        agcThresholdGate); | 			        agcThresholdGate); | ||||||
| @ -125,6 +129,7 @@ private: | |||||||
| 		bool m_dsb; | 		bool m_dsb; | ||||||
| 		bool m_audioMute; | 		bool m_audioMute; | ||||||
| 		bool m_agc; | 		bool m_agc; | ||||||
|  | 		bool m_agcClamping; | ||||||
| 		int  m_agcTimeLog2; | 		int  m_agcTimeLog2; | ||||||
| 		int  m_agcPowerThreshold; | 		int  m_agcPowerThreshold; | ||||||
| 		int  m_agcThresholdGate; | 		int  m_agcThresholdGate; | ||||||
| @ -138,6 +143,7 @@ private: | |||||||
| 				bool dsb, | 				bool dsb, | ||||||
| 				bool audioMute, | 				bool audioMute, | ||||||
| 				bool agc, | 				bool agc, | ||||||
|  | 				bool agcClamping, | ||||||
| 				int  agcTimeLog2, | 				int  agcTimeLog2, | ||||||
| 				int  agcPowerThreshold, | 				int  agcPowerThreshold, | ||||||
| 				int  agcThresholdGate) : | 				int  agcThresholdGate) : | ||||||
| @ -151,6 +157,7 @@ private: | |||||||
| 			m_dsb(dsb), | 			m_dsb(dsb), | ||||||
| 			m_audioMute(audioMute), | 			m_audioMute(audioMute), | ||||||
| 			m_agc(agc), | 			m_agc(agc), | ||||||
|  | 			m_agcClamping(agcClamping), | ||||||
| 			m_agcTimeLog2(agcTimeLog2), | 			m_agcTimeLog2(agcTimeLog2), | ||||||
| 			m_agcPowerThreshold(agcPowerThreshold), | 			m_agcPowerThreshold(agcPowerThreshold), | ||||||
| 			m_agcThresholdGate(agcThresholdGate) | 			m_agcThresholdGate(agcThresholdGate) | ||||||
| @ -183,6 +190,7 @@ private: | |||||||
|     int  m_magsqCount; |     int  m_magsqCount; | ||||||
|     MagAGC m_agc; |     MagAGC m_agc; | ||||||
|     bool m_agcActive; |     bool m_agcActive; | ||||||
|  |     bool m_agcClamping; | ||||||
|     int m_agcNbSamples;         //!< number of audio (48 kHz) samples for AGC averaging
 |     int m_agcNbSamples;         //!< number of audio (48 kHz) samples for AGC averaging
 | ||||||
|     double m_agcPowerThreshold; //!< AGC power threshold (linear)
 |     double m_agcPowerThreshold; //!< AGC power threshold (linear)
 | ||||||
|     int m_agcThresholdGate;     //!< Gate length in number of samples befor threshold triggers
 |     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(12, ui->agcTimeLog2->value()); | ||||||
| 	s.writeS32(13, ui->agcPowerThreshold->value()); | 	s.writeS32(13, ui->agcPowerThreshold->value()); | ||||||
|     s.writeS32(14, ui->agcThresholdGate->value()); |     s.writeS32(14, ui->agcThresholdGate->value()); | ||||||
|  |     s.writeBool(15, ui->agcClamping->isChecked()); | ||||||
| 	return s.final(); | 	return s.final(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -139,6 +140,8 @@ bool SSBDemodGUI::deserialize(const QByteArray& data) | |||||||
|         ui->agcPowerThreshold->setValue(tmp); |         ui->agcPowerThreshold->setValue(tmp); | ||||||
|         d.readS32(14, &tmp, 4); |         d.readS32(14, &tmp, 4); | ||||||
|         ui->agcThresholdGate->setValue(tmp); |         ui->agcThresholdGate->setValue(tmp); | ||||||
|  |         d.readBool(15, &booltmp, false); | ||||||
|  |         ui->agcClamping->setChecked(booltmp); | ||||||
| 
 | 
 | ||||||
|         displaySettings(); |         displaySettings(); | ||||||
| 
 | 
 | ||||||
| @ -290,6 +293,11 @@ void SSBDemodGUI::on_agc_toggled(bool checked __attribute((__unused__))) | |||||||
|     applySettings(); |     applySettings(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void SSBDemodGUI::on_agcClamping_toggled(bool checked __attribute((__unused__))) | ||||||
|  | { | ||||||
|  |     applySettings(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void SSBDemodGUI::on_agcTimeLog2_valueChanged(int value) | void SSBDemodGUI::on_agcTimeLog2_valueChanged(int value) | ||||||
| { | { | ||||||
|     QString s = QString::number((1<<value), 'f', 0); |     QString s = QString::number((1<<value), 'f', 0); | ||||||
| @ -518,6 +526,7 @@ void SSBDemodGUI::applySettings() | |||||||
| 			m_dsb, | 			m_dsb, | ||||||
| 			ui->audioMute->isChecked(), | 			ui->audioMute->isChecked(), | ||||||
| 			ui->agc->isChecked(), | 			ui->agc->isChecked(), | ||||||
|  | 			ui->agcClamping->isChecked(), | ||||||
| 			ui->agcTimeLog2->value(), | 			ui->agcTimeLog2->value(), | ||||||
| 			ui->agcPowerThreshold->value(), | 			ui->agcPowerThreshold->value(), | ||||||
| 			ui->agcThresholdGate->value()); | 			ui->agcThresholdGate->value()); | ||||||
|  | |||||||
| @ -49,6 +49,7 @@ private slots: | |||||||
| 	void on_lowCut_valueChanged(int value); | 	void on_lowCut_valueChanged(int value); | ||||||
| 	void on_volume_valueChanged(int value); | 	void on_volume_valueChanged(int value); | ||||||
| 	void on_agc_toggled(bool checked); | 	void on_agc_toggled(bool checked); | ||||||
|  |     void on_agcClamping_toggled(bool checked); | ||||||
| 	void on_agcTimeLog2_valueChanged(int value); | 	void on_agcTimeLog2_valueChanged(int value); | ||||||
|     void on_agcPowerThreshold_valueChanged(int value); |     void on_agcPowerThreshold_valueChanged(int value); | ||||||
|     void on_agcThresholdGate_valueChanged(int value); |     void on_agcThresholdGate_valueChanged(int value); | ||||||
|  | |||||||
| @ -474,6 +474,19 @@ | |||||||
|         </property> |         </property> | ||||||
|        </widget> |        </widget> | ||||||
|       </item> |       </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> |       <item> | ||||||
|        <widget class="QDial" name="agcTimeLog2"> |        <widget class="QDial" name="agcTimeLog2"> | ||||||
|         <property name="maximumSize"> |         <property name="maximumSize"> | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ | |||||||
| 
 | 
 | ||||||
| const PluginDescriptor SSBPlugin::m_pluginDescriptor = { | const PluginDescriptor SSBPlugin::m_pluginDescriptor = { | ||||||
| 	QString("SSB Demodulator"), | 	QString("SSB Demodulator"), | ||||||
| 	QString("3.5.3"), | 	QString("3.5.4"), | ||||||
| 	QString("(c) Edouard Griffiths, F4EXB"), | 	QString("(c) Edouard Griffiths, F4EXB"), | ||||||
| 	QString("https://github.com/f4exb/sdrangel"), | 	QString("https://github.com/f4exb/sdrangel"), | ||||||
| 	true, | 	true, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user