| 
									
										
										
										
											2021-05-07 21:50:27 +01:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Copyright (C) 2019 Edouard Griffiths, F4EXB                                   //
 | 
					
						
							|  |  |  | // Copyright (C) 2020 Jon Beniston, M7RCE                                        //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef INCLUDE_AISMODBASEBAND_H
 | 
					
						
							|  |  |  | #define INCLUDE_AISMODBASEBAND_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QObject>
 | 
					
						
							| 
									
										
										
										
											2022-09-15 21:59:42 +02:00
										 |  |  | #include <QRecursiveMutex>
 | 
					
						
							| 
									
										
										
										
											2021-05-07 21:50:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "dsp/samplesourcefifo.h"
 | 
					
						
							| 
									
										
										
										
											2021-05-30 13:12:00 +02:00
										 |  |  | #include "dsp/scopevis.h"
 | 
					
						
							| 
									
										
										
										
											2021-05-07 21:50:27 +01:00
										 |  |  | #include "util/message.h"
 | 
					
						
							|  |  |  | #include "util/messagequeue.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "aismodsource.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class UpChannelizer; | 
					
						
							|  |  |  | class ChannelAPI; | 
					
						
							| 
									
										
										
										
											2021-05-29 20:09:28 +02:00
										 |  |  | class ScopeVis; | 
					
						
							| 
									
										
										
										
											2021-05-07 21:50:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | class AISModBaseband : public QObject | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     class MsgConfigureAISModBaseband : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         const AISModSettings& getSettings() const { return m_settings; } | 
					
						
							|  |  |  |         bool getForce() const { return m_force; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static MsgConfigureAISModBaseband* create(const AISModSettings& settings, bool force) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return new MsgConfigureAISModBaseband(settings, force); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         AISModSettings m_settings; | 
					
						
							|  |  |  |         bool m_force; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         MsgConfigureAISModBaseband(const AISModSettings& settings, bool force) : | 
					
						
							|  |  |  |             Message(), | 
					
						
							|  |  |  |             m_settings(settings), | 
					
						
							|  |  |  |             m_force(force) | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     AISModBaseband(); | 
					
						
							|  |  |  |     ~AISModBaseband(); | 
					
						
							|  |  |  |     void reset(); | 
					
						
							|  |  |  |     void pull(const SampleVector::iterator& begin, unsigned int nbSamples); | 
					
						
							|  |  |  |     MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
 | 
					
						
							|  |  |  |     double getMagSq() const { return m_source.getMagSq(); } | 
					
						
							|  |  |  |     int getChannelSampleRate() const; | 
					
						
							|  |  |  |     void setSpectrumSampleSink(BasebandSampleSink* sampleSink) { m_source.setSpectrumSink(sampleSink); } | 
					
						
							| 
									
										
										
										
											2021-05-30 13:12:00 +02:00
										 |  |  |     ScopeVis *getScopeSink() { return &m_scopeSink; } | 
					
						
							| 
									
										
										
										
											2021-05-07 21:50:27 +01:00
										 |  |  |     void setChannel(ChannelAPI *channel); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | signals: | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Level changed | 
					
						
							|  |  |  |      * \param rmsLevel RMS level in range 0.0 - 1.0 | 
					
						
							|  |  |  |      * \param peakLevel Peak level in range 0.0 - 1.0 | 
					
						
							|  |  |  |      * \param numSamples Number of audio samples analyzed | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     SampleSourceFifo m_sampleFifo; | 
					
						
							|  |  |  |     UpChannelizer *m_channelizer; | 
					
						
							|  |  |  |     AISModSource m_source; | 
					
						
							|  |  |  |     MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
 | 
					
						
							|  |  |  |     AISModSettings m_settings; | 
					
						
							| 
									
										
										
										
											2021-05-30 13:12:00 +02:00
										 |  |  |     ScopeVis m_scopeSink; | 
					
						
							| 
									
										
										
										
											2022-09-15 21:59:42 +02:00
										 |  |  |     QRecursiveMutex m_mutex; | 
					
						
							| 
									
										
										
										
											2021-05-07 21:50:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     void processFifo(SampleVector& data, unsigned int iBegin, unsigned int iEnd); | 
					
						
							|  |  |  |     bool handleMessage(const Message& cmd); | 
					
						
							|  |  |  |     void applySettings(const AISModSettings& settings, bool force = false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private slots: | 
					
						
							|  |  |  |     void handleInputMessages(); | 
					
						
							|  |  |  |     void handleData(); //!< Handle data when samples have to be processed
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // INCLUDE_AISMODBASEBAND_H
 |