| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Copyright (C) 2019 Edouard Griffiths, F4EXB                                   //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is free software; you can redistribute it and/or modify          //
 | 
					
						
							|  |  |  | // it under the terms of the GNU General Public License as published by          //
 | 
					
						
							|  |  |  | // the Free Software Foundation as version 3 of the License, or                  //
 | 
					
						
							|  |  |  | // (at your option) any later version.                                           //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is distributed in the hope that it will be useful,               //
 | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | 
					
						
							|  |  |  | // GNU General Public License V3 for more details.                               //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // You should have received a copy of the GNU General Public License             //
 | 
					
						
							|  |  |  | // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  | #ifndef INCLUDE_CHIRPCHATDEMODBASEBAND_H
 | 
					
						
							|  |  |  | #define INCLUDE_CHIRPCHATDEMODBASEBAND_H
 | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <QObject>
 | 
					
						
							|  |  |  | #include <QMutex>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "dsp/samplesinkfifo.h"
 | 
					
						
							|  |  |  | #include "util/message.h"
 | 
					
						
							|  |  |  | #include "util/messagequeue.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  | #include "chirpchatdemodsink.h"
 | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-13 15:15:21 +01:00
										 |  |  | class DownChannelizer; | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  | class ChirpChatDemodBaseband : public QObject | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  |     class MsgConfigureChirpChatDemodBaseband : public Message { | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  |         const ChirpChatDemodSettings& getSettings() const { return m_settings; } | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  |         bool getForce() const { return m_force; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  |         static MsgConfigureChirpChatDemodBaseband* create(const ChirpChatDemodSettings& settings, bool force) | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  |             return new MsgConfigureChirpChatDemodBaseband(settings, force); | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  |         ChirpChatDemodSettings m_settings; | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  |         bool m_force; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  |         MsgConfigureChirpChatDemodBaseband(const ChirpChatDemodSettings& settings, bool force) : | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  |             Message(), | 
					
						
							|  |  |  |             m_settings(settings), | 
					
						
							|  |  |  |             m_force(force) | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  |     ChirpChatDemodBaseband(); | 
					
						
							|  |  |  |     ~ChirpChatDemodBaseband(); | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  |     void reset(); | 
					
						
							|  |  |  |     void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end); | 
					
						
							|  |  |  |     MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
 | 
					
						
							|  |  |  |     int getChannelSampleRate() const; | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  |     bool getDemodActive() const { return m_sink.getDemodActive(); } | 
					
						
							|  |  |  |     double getCurrentNoiseLevel() const { return m_sink.getCurrentNoiseLevel(); } | 
					
						
							|  |  |  |     double getTotalPower() const { return m_sink.getTotalPower(); } | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  |     void setBasebandSampleRate(int sampleRate); | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  |     void setDecoderMessageQueue(MessageQueue *messageQueue) { m_sink.setDecoderMessageQueue(messageQueue); } | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  |     void setSpectrumSink(BasebandSampleSink* spectrumSink) { m_sink.setSpectrumSink(spectrumSink); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     SampleSinkFifo m_sampleFifo; | 
					
						
							| 
									
										
										
										
											2019-12-13 15:15:21 +01:00
										 |  |  |     DownChannelizer *m_channelizer; | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  |     ChirpChatDemodSink m_sink; | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  | 	MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
 | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  |     ChirpChatDemodSettings m_settings; | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  |     QMutex m_mutex; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool handleMessage(const Message& cmd); | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  |     void applySettings(const ChirpChatDemodSettings& settings, bool force = false); | 
					
						
							| 
									
										
										
										
											2019-12-03 18:49:52 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private slots: | 
					
						
							|  |  |  |     void handleInputMessages(); | 
					
						
							|  |  |  |     void handleData(); //!< Handle data when samples have to be processed
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-09 11:35:18 +01:00
										 |  |  | #endif // INCLUDE_CHIRPCHATDEMODBASEBAND_H
 |