kopia lustrzana https://github.com/f4exb/sdrangel
				
				
				
			Make CTCSS processing conditional to GUI checkbox
							rodzic
							
								
									952a2b39ed
								
							
						
					
					
						commit
						f5021f5b9e
					
				|  | @ -1,6 +1,7 @@ | |||
| CMakeLists.txt.user* | ||||
| build/* | ||||
| qtbuild/* | ||||
| sdriq/* | ||||
| LOCAL/* | ||||
| sdrangelove.supp | ||||
| .cproject | ||||
|  |  | |||
|  | @ -46,6 +46,7 @@ NFMDemod::NFMDemod() : | |||
| 	m_config.m_afBandwidth = 3000; | ||||
| 	m_config.m_squelch = -30.0; | ||||
| 	m_config.m_volume = 2.0; | ||||
| 	m_config.m_ctcssOn = false; | ||||
| 	m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate(); | ||||
| 
 | ||||
| 	apply(); | ||||
|  | @ -70,9 +71,18 @@ NFMDemod::~NFMDemod() | |||
| 	DSPEngine::instance()->removeAudioSink(&m_audioFifo); | ||||
| } | ||||
| 
 | ||||
| void NFMDemod::configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch) | ||||
| void NFMDemod::configure(MessageQueue* messageQueue, | ||||
| 		Real rfBandwidth, | ||||
| 		Real afBandwidth, | ||||
| 		Real volume, | ||||
| 		Real squelch, | ||||
| 		bool ctcssOn) | ||||
| { | ||||
| 	Message* cmd = MsgConfigureNFMDemod::create(rfBandwidth, afBandwidth, volume, squelch); | ||||
| 	Message* cmd = MsgConfigureNFMDemod::create(rfBandwidth, | ||||
| 			afBandwidth, | ||||
| 			volume, | ||||
| 			squelch, | ||||
| 			ctcssOn); | ||||
| 	messageQueue->push(cmd); | ||||
| } | ||||
| 
 | ||||
|  | @ -170,6 +180,8 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto | |||
| 				} | ||||
| 
 | ||||
| 				if (m_squelchOpen) | ||||
| 				{ | ||||
| 					if (m_running.m_ctcssOn) | ||||
| 					{ | ||||
| 						Real ctcss_sample = m_lowpass.filter(demod); | ||||
| 
 | ||||
|  | @ -197,8 +209,9 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto | |||
| 								} | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 
 | ||||
| 					if (m_ctcssIndexSelected && (m_ctcssIndexSelected != m_ctcssIndex)) | ||||
| 					if (m_running.m_ctcssOn && m_ctcssIndexSelected && (m_ctcssIndexSelected != m_ctcssIndex)) | ||||
| 					{ | ||||
| 						sample = 0; | ||||
| 					} | ||||
|  | @ -297,13 +310,15 @@ bool NFMDemod::handleMessage(const Message& cmd) | |||
| 		m_config.m_afBandwidth = cfg.getAFBandwidth(); | ||||
| 		m_config.m_volume = cfg.getVolume(); | ||||
| 		m_config.m_squelch = cfg.getSquelch(); | ||||
| 		m_config.m_ctcssOn = cfg.getCtcssOn(); | ||||
| 
 | ||||
| 		apply(); | ||||
| 
 | ||||
| 		qDebug() << "  - MsgConfigureNFMDemod: m_rfBandwidth: " << m_config.m_rfBandwidth | ||||
| 				<< " m_afBandwidth: " << m_config.m_afBandwidth | ||||
| 				<< " m_volume: " << m_config.m_volume | ||||
| 				<< " m_squelch: " << m_config.m_squelch; | ||||
| 				<< " m_squelch: " << m_config.m_squelch | ||||
| 				<< " m_ctcssOn: " << m_config.m_ctcssOn; | ||||
| 
 | ||||
| 		return true; | ||||
| 	} | ||||
|  | @ -315,13 +330,13 @@ bool NFMDemod::handleMessage(const Message& cmd) | |||
| 
 | ||||
| void NFMDemod::apply() | ||||
| { | ||||
| 	if((m_config.m_inputFrequencyOffset != m_running.m_inputFrequencyOffset) || | ||||
| 	if ((m_config.m_inputFrequencyOffset != m_running.m_inputFrequencyOffset) || | ||||
| 		(m_config.m_inputSampleRate != m_running.m_inputSampleRate)) | ||||
| 	{ | ||||
| 		m_nco.setFreq(-m_config.m_inputFrequencyOffset, m_config.m_inputSampleRate); | ||||
| 	} | ||||
| 
 | ||||
| 	if((m_config.m_inputSampleRate != m_running.m_inputSampleRate) || | ||||
| 	if ((m_config.m_inputSampleRate != m_running.m_inputSampleRate) || | ||||
| 		(m_config.m_rfBandwidth != m_running.m_rfBandwidth)) | ||||
| 	{ | ||||
| 		m_settingsMutex.lock(); | ||||
|  | @ -331,7 +346,7 @@ void NFMDemod::apply() | |||
| 		m_settingsMutex.unlock(); | ||||
| 	} | ||||
| 
 | ||||
| 	if((m_config.m_afBandwidth != m_running.m_afBandwidth) || | ||||
| 	if ((m_config.m_afBandwidth != m_running.m_afBandwidth) || | ||||
| 		(m_config.m_audioSampleRate != m_running.m_audioSampleRate)) | ||||
| 	{ | ||||
| 		m_settingsMutex.lock(); | ||||
|  | @ -340,7 +355,7 @@ void NFMDemod::apply() | |||
| 		m_settingsMutex.unlock(); | ||||
| 	} | ||||
| 
 | ||||
| 	if(m_config.m_squelch != m_running.m_squelch) | ||||
| 	if (m_config.m_squelch != m_running.m_squelch) | ||||
| 	{ | ||||
| 		m_squelchLevel = pow(10.0, m_config.m_squelch / 10.0); | ||||
| 		m_squelchLevel *= m_squelchLevel; | ||||
|  | @ -355,4 +370,5 @@ void NFMDemod::apply() | |||
| 	m_running.m_squelch = m_config.m_squelch; | ||||
| 	m_running.m_volume = m_config.m_volume; | ||||
| 	m_running.m_audioSampleRate = m_config.m_audioSampleRate; | ||||
| 	m_running.m_ctcssOn = m_config.m_ctcssOn; | ||||
| } | ||||
|  |  | |||
|  | @ -39,7 +39,12 @@ public: | |||
| 	NFMDemod(); | ||||
| 	~NFMDemod(); | ||||
| 
 | ||||
| 	void configure(MessageQueue* messageQueue, Real rfBandwidth, Real afBandwidth, Real volume, Real squelch); | ||||
| 	void configure(MessageQueue* messageQueue, | ||||
| 			Real rfBandwidth, | ||||
| 			Real afBandwidth, | ||||
| 			Real volume, | ||||
| 			Real squelch, | ||||
| 			bool ctcssOn); | ||||
| 
 | ||||
| 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); | ||||
| 	virtual void start(); | ||||
|  | @ -68,10 +73,15 @@ private: | |||
| 		Real getAFBandwidth() const { return m_afBandwidth; } | ||||
| 		Real getVolume() const { return m_volume; } | ||||
| 		Real getSquelch() const { return m_squelch; } | ||||
| 		bool getCtcssOn() const { return m_ctcssOn; } | ||||
| 
 | ||||
| 		static MsgConfigureNFMDemod* create(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch) | ||||
| 		static MsgConfigureNFMDemod* create(Real rfBandwidth, | ||||
| 				Real afBandwidth, | ||||
| 				Real volume, | ||||
| 				Real squelch, | ||||
| 				bool ctcssOn) | ||||
| 		{ | ||||
| 			return new MsgConfigureNFMDemod(rfBandwidth, afBandwidth, volume, squelch); | ||||
| 			return new MsgConfigureNFMDemod(rfBandwidth, afBandwidth, volume, squelch, ctcssOn); | ||||
| 		} | ||||
| 
 | ||||
| 	private: | ||||
|  | @ -79,13 +89,19 @@ private: | |||
| 		Real m_afBandwidth; | ||||
| 		Real m_volume; | ||||
| 		Real m_squelch; | ||||
| 		bool m_ctcssOn; | ||||
| 
 | ||||
| 		MsgConfigureNFMDemod(Real rfBandwidth, Real afBandwidth, Real volume, Real squelch) : | ||||
| 		MsgConfigureNFMDemod(Real rfBandwidth, | ||||
| 				Real afBandwidth, | ||||
| 				Real volume, | ||||
| 				Real squelch, | ||||
| 				bool ctcssOn) : | ||||
| 			Message(), | ||||
| 			m_rfBandwidth(rfBandwidth), | ||||
| 			m_afBandwidth(afBandwidth), | ||||
| 			m_volume(volume), | ||||
| 			m_squelch(squelch) | ||||
| 			m_squelch(squelch), | ||||
| 			m_ctcssOn(ctcssOn) | ||||
| 		{ } | ||||
| 	}; | ||||
| 
 | ||||
|  | @ -107,6 +123,7 @@ private: | |||
| 		Real m_afBandwidth; | ||||
| 		Real m_squelch; | ||||
| 		Real m_volume; | ||||
| 		bool m_ctcssOn; | ||||
| 		int  m_ctcssIndex; | ||||
| 		quint32 m_audioSampleRate; | ||||
| 
 | ||||
|  | @ -117,6 +134,7 @@ private: | |||
| 			m_afBandwidth(-1), | ||||
| 			m_squelch(0), | ||||
| 			m_volume(0), | ||||
| 			m_ctcssOn(false), | ||||
| 			m_ctcssIndex(0), | ||||
| 			m_audioSampleRate(0) | ||||
| 		{ } | ||||
|  |  | |||
|  | @ -52,6 +52,7 @@ void NFMDemodGUI::resetToDefaults() | |||
| 	ui->volume->setValue(20); | ||||
| 	ui->squelch->setValue(-40); | ||||
| 	ui->deltaFrequency->setValue(0); | ||||
| 	ui->ctcssOn->setChecked(false); | ||||
| 
 | ||||
| 	blockApplySettings(false); | ||||
| 	applySettings(); | ||||
|  | @ -67,6 +68,7 @@ QByteArray NFMDemodGUI::serialize() const | |||
| 	s.writeS32(5, ui->squelch->value()); | ||||
| 	s.writeU32(7, m_channelMarker.getColor().rgb()); | ||||
| 	s.writeS32(8, ui->ctcss->currentIndex()); | ||||
| 	s.writeBool(9, ui->ctcssOn->isChecked()); | ||||
| 	return s.final(); | ||||
| } | ||||
| 
 | ||||
|  | @ -85,6 +87,7 @@ bool NFMDemodGUI::deserialize(const QByteArray& data) | |||
| 		QByteArray bytetmp; | ||||
| 		quint32 u32tmp; | ||||
| 		qint32 tmp; | ||||
| 		bool boolTmp; | ||||
| 
 | ||||
| 		blockApplySettings(true); | ||||
| 		m_channelMarker.blockSignals(true); | ||||
|  | @ -108,6 +111,9 @@ bool NFMDemodGUI::deserialize(const QByteArray& data) | |||
| 		d.readS32(8, &tmp, 0); | ||||
| 		ui->ctcss->setCurrentIndex(tmp); | ||||
| 
 | ||||
| 		d.readBool(9, &boolTmp, false); | ||||
| 		ui->ctcssOn->setChecked(boolTmp); | ||||
| 
 | ||||
| 		blockApplySettings(false); | ||||
| 		m_channelMarker.blockSignals(false); | ||||
| 
 | ||||
|  | @ -179,6 +185,12 @@ void NFMDemodGUI::on_squelch_valueChanged(int value) | |||
| 	applySettings(); | ||||
| } | ||||
| 
 | ||||
| void NFMDemodGUI::on_ctcssOn_toggled(bool checked) | ||||
| { | ||||
| 	m_ctcssOn = checked; | ||||
| 	applySettings(); | ||||
| } | ||||
| 
 | ||||
| void NFMDemodGUI::on_ctcss_currentIndexChanged(int index) | ||||
| { | ||||
| 	if (m_nfmDemod != 0) | ||||
|  | @ -280,7 +292,8 @@ void NFMDemodGUI::applySettings() | |||
| 			m_rfBW[ui->rfBW->value()], | ||||
| 			ui->afBW->value() * 1000.0, | ||||
| 			ui->volume->value() / 10.0, | ||||
| 			ui->squelch->value()); | ||||
| 			ui->squelch->value(), | ||||
| 			ui->ctcssOn->isChecked()); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -43,6 +43,7 @@ private slots: | |||
| 	void on_volume_valueChanged(int value); | ||||
| 	void on_squelch_valueChanged(int value); | ||||
| 	void on_ctcss_currentIndexChanged(int index); | ||||
| 	void on_ctcssOn_toggled(bool checked); | ||||
| 	void onWidgetRolled(QWidget* widget, bool rollDown); | ||||
| 	void onMenuDoubleClicked(); | ||||
| 
 | ||||
|  | @ -56,6 +57,7 @@ private: | |||
| 	ThreadedSampleSink* m_threadedChannelizer; | ||||
| 	Channelizer* m_channelizer; | ||||
| 	NFMDemod* m_nfmDemod; | ||||
| 	bool m_ctcssOn; | ||||
| 
 | ||||
| 	static const int m_rfBW[]; | ||||
| 
 | ||||
|  |  | |||
|  | @ -41,7 +41,34 @@ | |||
|     <property name="spacing"> | ||||
|      <number>3</number> | ||||
|     </property> | ||||
|     <item row="3" column="1"> | ||||
|     <item row="5" column="4"> | ||||
|      <layout class="QHBoxLayout" name="CTCSSblock"> | ||||
|       <item> | ||||
|        <widget class="QCheckBox" name="ctcssOn"> | ||||
|         <property name="toolTip"> | ||||
|          <string>Activate CTCSS</string> | ||||
|         </property> | ||||
|         <property name="text"> | ||||
|          <string/> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|       <item> | ||||
|        <widget class="QComboBox" name="ctcss"> | ||||
|         <property name="maximumSize"> | ||||
|          <size> | ||||
|           <width>16777215</width> | ||||
|           <height>16777215</height> | ||||
|          </size> | ||||
|         </property> | ||||
|         <property name="toolTip"> | ||||
|          <string>Set CTCSS Frequency</string> | ||||
|         </property> | ||||
|        </widget> | ||||
|       </item> | ||||
|      </layout> | ||||
|     </item> | ||||
|     <item row="3" column="4"> | ||||
|      <widget class="QSlider" name="volume"> | ||||
|       <property name="maximum"> | ||||
|        <number>100</number> | ||||
|  | @ -54,7 +81,7 @@ | |||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="1" column="1"> | ||||
|     <item row="1" column="4"> | ||||
|      <widget class="QSlider" name="rfBW"> | ||||
|       <property name="maximum"> | ||||
|        <number>8</number> | ||||
|  | @ -101,7 +128,7 @@ | |||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="4" column="1"> | ||||
|     <item row="4" column="4"> | ||||
|      <widget class="QSlider" name="squelch"> | ||||
|       <property name="minimum"> | ||||
|        <number>-60</number> | ||||
|  | @ -120,7 +147,14 @@ | |||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="1" column="2"> | ||||
|     <item row="3" column="0"> | ||||
|      <widget class="QLabel" name="volumeLabel"> | ||||
|       <property name="text"> | ||||
|        <string>Volume</string> | ||||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="1" column="6"> | ||||
|      <widget class="QLabel" name="rfBWText"> | ||||
|       <property name="minimumSize"> | ||||
|        <size> | ||||
|  | @ -136,7 +170,7 @@ | |||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="2" column="2"> | ||||
|     <item row="2" column="6"> | ||||
|      <widget class="QLabel" name="afBWText"> | ||||
|       <property name="minimumSize"> | ||||
|        <size> | ||||
|  | @ -152,14 +186,7 @@ | |||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="3" column="0"> | ||||
|      <widget class="QLabel" name="volumeLabel"> | ||||
|       <property name="text"> | ||||
|        <string>Volume</string> | ||||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="2" column="1"> | ||||
|     <item row="2" column="4"> | ||||
|      <widget class="QSlider" name="afBW"> | ||||
|       <property name="minimum"> | ||||
|        <number>1</number> | ||||
|  | @ -178,7 +205,7 @@ | |||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="4" column="2"> | ||||
|     <item row="4" column="6"> | ||||
|      <widget class="QLabel" name="squelchText"> | ||||
|       <property name="minimumSize"> | ||||
|        <size> | ||||
|  | @ -194,7 +221,7 @@ | |||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="3" column="2"> | ||||
|     <item row="3" column="6"> | ||||
|      <widget class="QLabel" name="volumeText"> | ||||
|       <property name="minimumSize"> | ||||
|        <size> | ||||
|  | @ -210,7 +237,7 @@ | |||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="0" column="2"> | ||||
|     <item row="0" column="6"> | ||||
|      <widget class="QLabel" name="deltaUnits"> | ||||
|       <property name="text"> | ||||
|        <string>Hz</string> | ||||
|  | @ -220,7 +247,14 @@ | |||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="0" column="1"> | ||||
|     <item row="5" column="0"> | ||||
|      <widget class="QLabel" name="ctcssLabel"> | ||||
|       <property name="text"> | ||||
|        <string>CTCSS</string> | ||||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="0" column="4"> | ||||
|      <widget class="ValueDial" name="deltaFrequency" native="true"> | ||||
|       <property name="sizePolicy"> | ||||
|        <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> | ||||
|  | @ -251,21 +285,7 @@ | |||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="5" column="0"> | ||||
|      <widget class="QLabel" name="ctcssLabel"> | ||||
|       <property name="text"> | ||||
|        <string>CTCSS</string> | ||||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="5" column="1"> | ||||
|      <widget class="QComboBox" name="ctcss"> | ||||
|       <property name="toolTip"> | ||||
|        <string>Set CTCSS</string> | ||||
|       </property> | ||||
|      </widget> | ||||
|     </item> | ||||
|     <item row="5" column="2"> | ||||
|     <item row="5" column="6"> | ||||
|      <widget class="QLabel" name="ctcssText"> | ||||
|       <property name="toolTip"> | ||||
|        <string>CTCSS detected</string> | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 f4exb
						f4exb