From 107583759fed748e8e5189fdfaf41c53dffd9b6e Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 18 Jun 2023 00:44:20 +0200 Subject: [PATCH] Audio CAT SISO: implement real else complex indicator --- sdrbase/dsp/dspcommands.h | 12 +++++++++--- sdrbase/dsp/dspdevicemimoengine.cpp | 19 ++++++++++++++++--- sdrbase/dsp/dspdevicemimoengine.h | 2 ++ sdrbase/dsp/dspdevicesinkengine.cpp | 9 ++++++--- sdrbase/dsp/dspdevicesinkengine.h | 1 + sdrbase/dsp/dspdevicesourceengine.cpp | 16 +++++++--------- sdrbase/dsp/dspdevicesourceengine.h | 1 + 7 files changed, 42 insertions(+), 18 deletions(-) diff --git a/sdrbase/dsp/dspcommands.h b/sdrbase/dsp/dspcommands.h index 9553ce2e6..c3aa14adb 100644 --- a/sdrbase/dsp/dspcommands.h +++ b/sdrbase/dsp/dspcommands.h @@ -269,37 +269,43 @@ class SDRBASE_API DSPSignalNotification : public Message { MESSAGE_CLASS_DECLARATION public: - DSPSignalNotification(int samplerate, qint64 centerFrequency) : + DSPSignalNotification(int samplerate, qint64 centerFrequency, bool realElseComplex = false) : Message(), m_sampleRate(samplerate), - m_centerFrequency(centerFrequency) + m_centerFrequency(centerFrequency), + m_realElseComplex(realElseComplex) { } int getSampleRate() const { return m_sampleRate; } qint64 getCenterFrequency() const { return m_centerFrequency; } + bool getRealElseComplex() const { return m_realElseComplex; } private: int m_sampleRate; qint64 m_centerFrequency; + bool m_realElseComplex; }; class SDRBASE_API DSPMIMOSignalNotification : public Message { MESSAGE_CLASS_DECLARATION public: - DSPMIMOSignalNotification(int samplerate, qint64 centerFrequency, bool sourceOrSink, unsigned int index) : + DSPMIMOSignalNotification(int samplerate, qint64 centerFrequency, bool sourceOrSink, unsigned int index, bool realElseComplex = false) : Message(), m_sampleRate(samplerate), m_centerFrequency(centerFrequency), + m_realElseComplex(realElseComplex), m_sourceOrSink(sourceOrSink), m_index(index) { } int getSampleRate() const { return m_sampleRate; } qint64 getCenterFrequency() const { return m_centerFrequency; } + bool getRealElseComplex() const { return m_realElseComplex; } bool getSourceOrSink() const { return m_sourceOrSink; } unsigned int getIndex() const { return m_index; } private: int m_sampleRate; qint64 m_centerFrequency; + bool m_realElseComplex; bool m_sourceOrSink; unsigned int m_index; }; diff --git a/sdrbase/dsp/dspdevicemimoengine.cpp b/sdrbase/dsp/dspdevicemimoengine.cpp index ae44ef44f..deab6f04c 100644 --- a/sdrbase/dsp/dspdevicemimoengine.cpp +++ b/sdrbase/dsp/dspdevicemimoengine.cpp @@ -399,7 +399,9 @@ void DSPDeviceMIMOEngine::workSampleSourceFifo(unsigned int streamIndex) */ void DSPDeviceMIMOEngine::workSamplesSink(const SampleVector::const_iterator& vbegin, const SampleVector::const_iterator& vend, unsigned int streamIndex) { - bool positiveOnly = false; + std::map::const_iterator rcIt = m_rxRealElseComplex.find(streamIndex); + bool positiveOnly = (rcIt == m_rxRealElseComplex.end() ? false : rcIt->second); + // DC and IQ corrections // if (m_sourcesCorrections[streamIndex].m_dcOffsetCorrection) { // iqCorrections(vbegin, vend, streamIndex, m_sourcesCorrections[streamIndex].m_iqImbalanceCorrection); @@ -483,8 +485,11 @@ void DSPDeviceMIMOEngine::workSamplesSource(SampleVector& data, unsigned int iBe } // possibly feed data to spectrum sink + std::map::const_iterator rcIt = m_txRealElseComplex.find(streamIndex); + bool positiveOnly = (rcIt == m_txRealElseComplex.end() ? false : rcIt->second); + if ((m_spectrumSink) && (!m_spectrumInputSourceElseSink) && (streamIndex == m_spectrumInputIndex)) { - m_spectrumSink->feed(begin, begin + nbSamples, false); + m_spectrumSink->feed(begin, begin + nbSamples, positiveOnly); } } @@ -1173,12 +1178,20 @@ void DSPDeviceMIMOEngine::handleInputMessages() unsigned int istream = notif->getIndex(); int sampleRate = notif->getSampleRate(); qint64 centerFrequency = notif->getCenterFrequency(); + bool realElseComplex = notif->getRealElseComplex(); qDebug() << "DeviceMIMOEngine::handleInputMessages: DSPMIMOSignalNotification:" << " sourceElseSink: " << sourceElseSink << " istream: " << istream << " sampleRate: " << sampleRate - << " centerFrequency: " << centerFrequency; + << " centerFrequency: " << centerFrequency + << " realElseComplex" << realElseComplex; + + if (sourceElseSink) { + m_rxRealElseComplex[istream] = realElseComplex; + } else { + m_txRealElseComplex[istream] = realElseComplex; + } for (MIMOChannels::const_iterator it = m_mimoChannels.begin(); it != m_mimoChannels.end(); ++it) { diff --git a/sdrbase/dsp/dspdevicemimoengine.h b/sdrbase/dsp/dspdevicemimoengine.h index e2de68a3c..347c4347e 100644 --- a/sdrbase/dsp/dspdevicemimoengine.h +++ b/sdrbase/dsp/dspdevicemimoengine.h @@ -324,8 +324,10 @@ private: typedef std::list BasebandSampleSinks; std::vector m_basebandSampleSinks; //!< ancillary sample sinks on main thread (per input stream) + std::map m_rxRealElseComplex; //!< map of real else complex indicators for device sources (by input stream) typedef std::list BasebandSampleSources; std::vector m_basebandSampleSources; //!< channel sample sources (per output stream) + std::map m_txRealElseComplex; //!< map of real else complex indicators for device sinks (by input stream) std::vector> m_sourceSampleBuffers; std::vector> m_sourceZeroBuffers; unsigned int m_sumIndex; //!< channel index when summing channels diff --git a/sdrbase/dsp/dspdevicesinkengine.cpp b/sdrbase/dsp/dspdevicesinkengine.cpp index 6b94871d5..6977175fe 100644 --- a/sdrbase/dsp/dspdevicesinkengine.cpp +++ b/sdrbase/dsp/dspdevicesinkengine.cpp @@ -36,7 +36,8 @@ DSPDeviceSinkEngine::DSPDeviceSinkEngine(uint32_t uid, QObject* parent) : m_basebandSampleSources(), m_spectrumSink(nullptr), m_sampleRate(0), - m_centerFrequency(0) + m_centerFrequency(0), + m_realElseComplex(false) { connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection); connect(&m_syncMessenger, SIGNAL(messageSent()), this, SLOT(handleSynchronousMessages()), Qt::QueuedConnection); @@ -242,7 +243,7 @@ void DSPDeviceSinkEngine::workSamples(SampleVector& data, unsigned int iBegin, u // possibly feed data to spectrum sink if (m_spectrumSink) { - m_spectrumSink->feed(data.begin() + iBegin, data.begin() + iEnd, false); + m_spectrumSink->feed(data.begin() + iBegin, data.begin() + iEnd, m_realElseComplex); } } @@ -515,10 +516,12 @@ void DSPDeviceSinkEngine::handleInputMessages() m_sampleRate = notif->getSampleRate(); m_centerFrequency = notif->getCenterFrequency(); + m_realElseComplex = notif->getRealElseComplex(); qDebug() << "DSPDeviceSinkEngine::handleInputMessages: DSPSignalNotification:" << " m_sampleRate: " << m_sampleRate - << " m_centerFrequency: " << m_centerFrequency; + << " m_centerFrequency: " << m_centerFrequency + << " m_realElseComplex" << m_realElseComplex; // forward source changes to sources with immediate execution diff --git a/sdrbase/dsp/dspdevicesinkengine.h b/sdrbase/dsp/dspdevicesinkengine.h index a26a39558..7829eb9d0 100644 --- a/sdrbase/dsp/dspdevicesinkengine.h +++ b/sdrbase/dsp/dspdevicesinkengine.h @@ -103,6 +103,7 @@ private: uint32_t m_sampleRate; quint64 m_centerFrequency; + bool m_realElseComplex; unsigned int m_sumIndex; //!< channel index when summing channels void run(); diff --git a/sdrbase/dsp/dspdevicesourceengine.cpp b/sdrbase/dsp/dspdevicesourceengine.cpp index 519279639..d506caccd 100644 --- a/sdrbase/dsp/dspdevicesourceengine.cpp +++ b/sdrbase/dsp/dspdevicesourceengine.cpp @@ -35,6 +35,7 @@ DSPDeviceSourceEngine::DSPDeviceSourceEngine(uint uid, QObject* parent) : m_basebandSampleSinks(), m_sampleRate(0), m_centerFrequency(0), + m_realElseComplex(false), m_dcOffsetCorrection(false), m_iqImbalanceCorrection(false), m_iOffset(0), @@ -320,7 +321,7 @@ void DSPDeviceSourceEngine::work() { SampleSinkFifo* sampleFifo = m_deviceSampleSource->getSampleFifo(); std::size_t samplesDone = 0; - bool positiveOnly = false; + bool positiveOnly = m_realElseComplex; while ((sampleFifo->fill() > 0) && (m_inputMessageQueue.size() == 0) && (samplesDone < m_sampleRate)) { @@ -335,14 +336,12 @@ void DSPDeviceSourceEngine::work() if (part1begin != part1end) { // correct stuff - if (m_dcOffsetCorrection) - { + if (m_dcOffsetCorrection) { iqCorrections(part1begin, part1end, m_iqImbalanceCorrection); } // feed data to direct sinks - for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); ++it) - { + for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); ++it) { (*it)->feed(part1begin, part1end, positiveOnly); } @@ -352,14 +351,12 @@ void DSPDeviceSourceEngine::work() if(part2begin != part2end) { // correct stuff - if (m_dcOffsetCorrection) - { + if (m_dcOffsetCorrection) { iqCorrections(part2begin, part2end, m_iqImbalanceCorrection); } // feed data to direct sinks - for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); it++) - { + for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); it++) { (*it)->feed(part2begin, part2end, positiveOnly); } @@ -655,6 +652,7 @@ void DSPDeviceSourceEngine::handleInputMessages() m_sampleRate = notif->getSampleRate(); m_centerFrequency = notif->getCenterFrequency(); + m_realElseComplex = notif->getRealElseComplex(); qDebug() << "DSPDeviceSourceEngine::handleInputMessages: DSPSignalNotification:" << " m_sampleRate: " << m_sampleRate diff --git a/sdrbase/dsp/dspdevicesourceengine.h b/sdrbase/dsp/dspdevicesourceengine.h index 1b4fab35b..b7336d071 100644 --- a/sdrbase/dsp/dspdevicesourceengine.h +++ b/sdrbase/dsp/dspdevicesourceengine.h @@ -92,6 +92,7 @@ private: uint m_sampleRate; quint64 m_centerFrequency; + bool m_realElseComplex; bool m_dcOffsetCorrection; bool m_iqImbalanceCorrection;