| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Copyright (C) 2015 F4EXB                                                      //
 | 
					
						
							|  |  |  | // written by Edouard Griffiths                                                  //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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                  //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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_DSPENGINE_H
 | 
					
						
							|  |  |  | #define INCLUDE_DSPENGINE_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QObject>
 | 
					
						
							| 
									
										
										
										
											2017-10-24 16:45:47 +02:00
										 |  |  | #include <QTimer>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | #include <vector>
 | 
					
						
							|  |  |  | #include "audio/audiooutput.h"
 | 
					
						
							| 
									
										
										
										
											2016-11-29 01:09:06 +01:00
										 |  |  | #include "audio/audioinput.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | #include "util/export.h"
 | 
					
						
							|  |  |  | #ifdef DSD_USE_SERIALDV
 | 
					
						
							|  |  |  | #include "dsp/dvserialengine.h"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DSPDeviceSourceEngine; | 
					
						
							| 
									
										
										
										
											2016-10-19 14:29:23 +02:00
										 |  |  | class DSPDeviceSinkEngine; | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | class SDRANGEL_API DSPEngine : public QObject { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	DSPEngine(); | 
					
						
							|  |  |  | 	~DSPEngine(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	static DSPEngine *instance(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-29 01:09:06 +01:00
										 |  |  | 	uint getAudioSampleRate() const { return m_audioOutputSampleRate; } | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 01:11:32 +02:00
										 |  |  | 	DSPDeviceSourceEngine *addDeviceSourceEngine(); | 
					
						
							|  |  |  | 	void removeLastDeviceSourceEngine(); | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-19 14:29:23 +02:00
										 |  |  | 	DSPDeviceSinkEngine *addDeviceSinkEngine(); | 
					
						
							|  |  |  | 	void removeLastDeviceSinkEngine(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-29 01:09:06 +01:00
										 |  |  | 	void startAudioOutput(); | 
					
						
							|  |  |  | 	void stopAudioOutput(); | 
					
						
							|  |  |  |     void startAudioOutputImmediate(); | 
					
						
							|  |  |  |     void stopAudioOutputImmediate(); | 
					
						
							| 
									
										
										
										
											2017-01-06 16:04:32 +01:00
										 |  |  |     void setAudioOutputDeviceIndex(int index) { m_audioOutputDeviceIndex = index; } | 
					
						
							| 
									
										
										
										
											2016-11-29 01:09:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     void startAudioInput(); | 
					
						
							|  |  |  |     void stopAudioInput(); | 
					
						
							|  |  |  |     void startAudioInputImmediate(); | 
					
						
							|  |  |  |     void stopAudioInputImmediate(); | 
					
						
							| 
									
										
										
										
											2017-01-06 15:28:01 +01:00
										 |  |  |     void setAudioInputVolume(float volume) { m_audioInput.setVolume(volume); } | 
					
						
							| 
									
										
										
										
											2017-01-06 16:04:32 +01:00
										 |  |  |     void setAudioInputDeviceIndex(int index) { m_audioInputDeviceIndex = index; } | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 01:11:32 +02:00
										 |  |  |     DSPDeviceSourceEngine *getDeviceSourceEngineByIndex(uint deviceIndex) { return m_deviceSourceEngines[deviceIndex]; } | 
					
						
							|  |  |  |     DSPDeviceSourceEngine *getDeviceSourceEngineByUID(uint uid); | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-19 14:29:23 +02:00
										 |  |  |     DSPDeviceSinkEngine *getDeviceSinkEngineByIndex(uint deviceIndex) { return m_deviceSinkEngines[deviceIndex]; } | 
					
						
							|  |  |  |     DSPDeviceSinkEngine *getDeviceSinkEngineByUID(uint uid); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void addAudioSink(AudioFifo* audioFifo); //!< Add the audio sink
 | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | 	void removeAudioSink(AudioFifo* audioFifo); //!< Remove the audio sink
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-29 01:09:06 +01:00
										 |  |  | 	void addAudioSource(AudioFifo* audioFifo); //!< Add an audio source
 | 
					
						
							|  |  |  |     void removeAudioSource(AudioFifo* audioFifo); //!< Remove an audio source
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | 	// Serial DV methods:
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-22 12:01:04 +02:00
										 |  |  | 	bool hasDVSerialSupport(); | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | 	void setDVSerialSupport(bool support); | 
					
						
							| 
									
										
										
										
											2017-10-22 12:01:04 +02:00
										 |  |  | 	void getDVSerialNames(std::vector<std::string>& deviceNames); | 
					
						
							|  |  |  | 	void pushMbeFrame(const unsigned char *mbeFrame, int mbeRateIndex, int mbeVolumeIndex, unsigned char channels, AudioFifo *audioFifo); | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-24 16:45:47 +02:00
										 |  |  |     const QTimer& getMasterTimer() const { return m_masterTimer; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2016-10-11 01:11:32 +02:00
										 |  |  | 	std::vector<DSPDeviceSourceEngine*> m_deviceSourceEngines; | 
					
						
							|  |  |  | 	uint m_deviceSourceEnginesUIDSequence; | 
					
						
							| 
									
										
										
										
											2016-10-19 14:29:23 +02:00
										 |  |  | 	std::vector<DSPDeviceSinkEngine*> m_deviceSinkEngines; | 
					
						
							|  |  |  | 	uint m_deviceSinkEnginesUIDSequence; | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | 	AudioOutput m_audioOutput; | 
					
						
							| 
									
										
										
										
											2016-11-29 01:09:06 +01:00
										 |  |  | 	AudioInput m_audioInput; | 
					
						
							|  |  |  | 	uint m_audioOutputSampleRate; | 
					
						
							|  |  |  |     uint m_audioInputSampleRate; | 
					
						
							| 
									
										
										
										
											2017-01-06 16:04:32 +01:00
										 |  |  |     int m_audioInputDeviceIndex; | 
					
						
							|  |  |  |     int m_audioOutputDeviceIndex; | 
					
						
							| 
									
										
										
										
											2017-10-24 16:45:47 +02:00
										 |  |  |     QTimer m_masterTimer; | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  | 	bool m_dvSerialSupport; | 
					
						
							|  |  |  | #ifdef DSD_USE_SERIALDV
 | 
					
						
							|  |  |  | 	DVSerialEngine m_dvSerialEngine; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // INCLUDE_DSPENGINE_H
 |