2014-05-18 11:52:39 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2015-08-12 03:03:02 -04:00
|
|
|
// Copyright (C) 2015 F4EXB //
|
|
|
|
// written by Edouard Griffiths //
|
2014-05-18 11:52:39 -04:00
|
|
|
// //
|
|
|
|
// 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
|
|
|
|
|
2015-10-14 22:05:19 -04:00
|
|
|
#include <QObject>
|
2016-05-11 05:34:44 -04:00
|
|
|
#include <vector>
|
2015-10-14 22:05:19 -04:00
|
|
|
#include "dsp/dspdeviceengine.h"
|
2014-05-18 11:52:39 -04:00
|
|
|
#include "audio/audiooutput.h"
|
|
|
|
#include "util/export.h"
|
2016-05-08 00:00:37 -04:00
|
|
|
#ifdef DSD_USE_SERIALDV
|
|
|
|
#include "dsp/dvserialengine.h"
|
|
|
|
#endif
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2015-10-14 22:05:19 -04:00
|
|
|
class DSPDeviceEngine;
|
2015-08-17 02:29:34 -04:00
|
|
|
class ThreadedSampleSink;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2015-10-14 22:05:19 -04:00
|
|
|
class SDRANGEL_API DSPEngine : public QObject {
|
2014-05-18 11:52:39 -04:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2015-10-14 22:05:19 -04:00
|
|
|
DSPEngine();
|
2014-05-18 11:52:39 -04:00
|
|
|
~DSPEngine();
|
|
|
|
|
2015-08-08 22:09:05 -04:00
|
|
|
static DSPEngine *instance();
|
|
|
|
|
2016-05-11 05:34:44 -04:00
|
|
|
MessageQueue* getInputMessageQueue(uint deviceIndex = 0);
|
|
|
|
MessageQueue* getOutputMessageQueue(uint deviceIndex = 0);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2015-08-23 18:51:27 -04:00
|
|
|
uint getAudioSampleRate() const { return m_audioSampleRate; }
|
|
|
|
|
2016-05-11 18:35:39 -04:00
|
|
|
void stopAllAcquisitions();
|
|
|
|
void stopAllDeviceEngines();
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2016-05-11 17:35:16 -04:00
|
|
|
void startAudio();
|
|
|
|
void stopAudio();
|
|
|
|
|
2016-05-11 05:34:44 -04:00
|
|
|
void setSource(SampleSource* source, uint deviceIndex = 0); //!< Set the sample source type
|
|
|
|
void setSourceSequence(int sequence, uint deviceIndex = 0); //!< Set the sample source sequence in type
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2016-05-11 05:34:44 -04:00
|
|
|
void addSink(SampleSink* sink, uint deviceIndex = 0); //!< Add a sample sink
|
|
|
|
void removeSink(SampleSink* sink, uint deviceIndex = 0); //!< Remove a sample sink
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2016-05-11 11:03:02 -04:00
|
|
|
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, uint deviceIndex = 0); //!< Configure DSP corrections
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2016-05-11 13:14:23 -04:00
|
|
|
DSPDeviceEngine *getDeviceEngineByIndex(uint deviceIndex) { return m_deviceEngines[deviceIndex]; }
|
|
|
|
DSPDeviceEngine *getDeviceEngineByUID(uint uid);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2016-05-11 11:03:02 -04:00
|
|
|
void addAudioSink(AudioFifo* audioFifo); //!< Add the audio sink
|
|
|
|
void removeAudioSink(AudioFifo* audioFifo); //!< Remove the audio sink
|
2016-05-11 05:34:44 -04:00
|
|
|
|
|
|
|
// Serial DV methods:
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2016-05-08 00:00:37 -04:00
|
|
|
bool hasDVSerialSupport()
|
|
|
|
{
|
|
|
|
#ifdef DSD_USE_SERIALDV
|
|
|
|
return m_dvSerialSupport;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDVSerialSupport(bool support);
|
|
|
|
|
2016-05-09 12:17:53 -04:00
|
|
|
void getDVSerialNames(std::vector<std::string>& deviceNames)
|
|
|
|
{
|
|
|
|
#ifdef DSD_USE_SERIALDV
|
|
|
|
m_dvSerialEngine.getDevicesNames(deviceNames);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-05-08 01:02:31 -04:00
|
|
|
void pushMbeFrame(const unsigned char *mbeFrame, int mbeRateIndex, int mbeVolumeIndex, AudioFifo *audioFifo)
|
2016-05-08 00:00:37 -04:00
|
|
|
{
|
|
|
|
#ifdef DSD_USE_SERIALDV
|
2016-05-08 01:02:31 -04:00
|
|
|
m_dvSerialEngine.pushMbeFrame(mbeFrame, mbeRateIndex, mbeVolumeIndex, audioFifo);
|
2016-05-08 00:00:37 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
private:
|
2016-05-11 05:34:44 -04:00
|
|
|
std::vector<DSPDeviceEngine*> m_deviceEngines;
|
2015-08-19 21:38:31 -04:00
|
|
|
AudioOutput m_audioOutput;
|
2015-08-23 18:51:27 -04:00
|
|
|
uint m_audioSampleRate;
|
2016-05-08 00:00:37 -04:00
|
|
|
bool m_dvSerialSupport;
|
2016-05-11 17:35:16 -04:00
|
|
|
uint m_audioUsageCount;
|
2016-05-08 00:00:37 -04:00
|
|
|
#ifdef DSD_USE_SERIALDV
|
|
|
|
DVSerialEngine m_dvSerialEngine;
|
|
|
|
#endif
|
2014-05-18 11:52:39 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_DSPENGINE_H
|