mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-09-27 15:26:33 -04:00
MIMO: updates to base code
This commit is contained in:
parent
19da4eae76
commit
fba885c609
@ -109,23 +109,19 @@ void DeviceAPI::removeChannelSink(ThreadedBasebandSampleSink* sink, int streamIn
|
||||
|
||||
void DeviceAPI::addChannelSource(BasebandSampleSource* source, int streamIndex)
|
||||
{
|
||||
(void) streamIndex;
|
||||
|
||||
if (m_deviceSinkEngine) {
|
||||
m_deviceSinkEngine->addChannelSource(source);
|
||||
} else if (m_deviceMIMOEngine) {
|
||||
m_deviceMIMOEngine->addChannelSource(source);
|
||||
m_deviceMIMOEngine->addChannelSource(source, streamIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceAPI::removeChannelSource(BasebandSampleSource* source, int streamIndex)
|
||||
{
|
||||
(void) streamIndex;
|
||||
|
||||
if (m_deviceSinkEngine) {
|
||||
m_deviceSinkEngine->removeChannelSource(source);
|
||||
} else if (m_deviceMIMOEngine) {
|
||||
m_deviceMIMOEngine->removeChannelSource(source);
|
||||
m_deviceMIMOEngine->removeChannelSource(source, streamIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
virtual bool handleMessage(const Message& cmd) = 0; //!< Processing of a message. Returns true if message has actually been processed
|
||||
|
||||
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
|
||||
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
|
||||
void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
|
||||
MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; }
|
||||
|
||||
protected:
|
||||
|
@ -439,18 +439,17 @@ void DSPDeviceMIMOEngine::workSamplesSource(SampleVector& data, unsigned int iBe
|
||||
unsigned int nbSamples = iEnd - iBegin;
|
||||
SampleVector::iterator begin = data.begin() + iBegin;
|
||||
|
||||
m_sourceZeroBuffers[streamIndex].allocate(nbSamples, Sample{16384,0});
|
||||
std::copy(
|
||||
m_sourceZeroBuffers[streamIndex].m_vector.begin(),
|
||||
m_sourceZeroBuffers[streamIndex].m_vector.begin() + nbSamples,
|
||||
begin
|
||||
);
|
||||
// pull data from MIMO channels
|
||||
|
||||
m_spectrumSink->feed(begin, begin + nbSamples, false);
|
||||
qDebug("DSPDeviceMIMOEngine::workSamplesSource: nbSamples: %u streamIndex: %u", nbSamples, streamIndex);
|
||||
|
||||
return;
|
||||
for (MIMOChannels::const_iterator it = m_mimoChannels.begin(); it != m_mimoChannels.end(); ++it)
|
||||
{
|
||||
qDebug("DSPDeviceMIMOEngine::workSamplesSource: %s: nbSamples: %u stream: %u",
|
||||
qPrintable((*it)->objectName()), nbSamples, streamIndex);
|
||||
(*it)->pull(begin, nbSamples, streamIndex);
|
||||
}
|
||||
|
||||
if (m_mimoChannels.size() == 0) // Process single stream channels only if there are no MIMO channels
|
||||
{
|
||||
if (m_basebandSampleSources[streamIndex].size() == 0)
|
||||
{
|
||||
m_sourceZeroBuffers[streamIndex].allocate(nbSamples, Sample{0,0});
|
||||
@ -463,6 +462,8 @@ void DSPDeviceMIMOEngine::workSamplesSource(SampleVector& data, unsigned int iBe
|
||||
else if (m_basebandSampleSources[streamIndex].size() == 1)
|
||||
{
|
||||
BasebandSampleSource *sampleSource = m_basebandSampleSources[streamIndex].front();
|
||||
qDebug("DSPDeviceMIMOEngine::workSamplesSource: %s: nbSamples: %u stream: %u",
|
||||
qPrintable(sampleSource->objectName()), nbSamples, streamIndex);
|
||||
sampleSource->pull(begin, nbSamples);
|
||||
}
|
||||
else
|
||||
@ -472,8 +473,9 @@ void DSPDeviceMIMOEngine::workSamplesSource(SampleVector& data, unsigned int iBe
|
||||
BasebandSampleSource *sampleSource = *srcIt;
|
||||
sampleSource->pull(begin, nbSamples);
|
||||
++srcIt;
|
||||
m_sumIndex = 1;
|
||||
|
||||
for (; srcIt != m_basebandSampleSources[streamIndex].end(); ++srcIt)
|
||||
for (; srcIt != m_basebandSampleSources[streamIndex].end(); ++srcIt, m_sumIndex++)
|
||||
{
|
||||
sampleSource = *srcIt;
|
||||
SampleVector::iterator aBegin = m_sourceSampleBuffers[streamIndex].m_vector.begin();
|
||||
@ -483,20 +485,19 @@ void DSPDeviceMIMOEngine::workSamplesSource(SampleVector& data, unsigned int iBe
|
||||
aBegin + nbSamples,
|
||||
begin,
|
||||
begin,
|
||||
[](Sample& a, const Sample& b) -> Sample { // TODO: scale by number of sources
|
||||
return Sample{a.real()+b.real(), a.imag()+b.imag()};
|
||||
[this](Sample& a, const Sample& b) -> Sample {
|
||||
int den = m_sumIndex + 1; // at each stage scale sum by n/n+1 and input by 1/n+1
|
||||
int nom = m_sumIndex; // so that final sum is scaled by N (number of channels)
|
||||
return Sample{
|
||||
a.real()/den + nom*(b.real()/den),
|
||||
a.imag()/den + nom*(b.imag()/den)
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
begin = m_sourceSampleBuffers[streamIndex].m_vector.begin();
|
||||
}
|
||||
|
||||
// pull data from MIMO channels
|
||||
for (MIMOChannels::const_iterator it = m_mimoChannels.begin(); it != m_mimoChannels.end(); ++it)
|
||||
{
|
||||
//qDebug("DSPDeviceMIMOEngine::workSamplesSource: nbSamples: %u stream: %u", nbSamples, streamIndex);
|
||||
(*it)->pull(begin, nbSamples, streamIndex);
|
||||
}
|
||||
|
||||
// possibly feed data to spectrum sink
|
||||
@ -903,7 +904,7 @@ void DSPDeviceMIMOEngine::handleSetMIMO(DeviceSampleMIMO* mimo)
|
||||
);
|
||||
QObject::connect(
|
||||
m_deviceSampleMIMO->getSampleMOFifo(),
|
||||
&SampleMOFifo::dataSyncRead,
|
||||
&SampleMOFifo::dataReadSync,
|
||||
this,
|
||||
&DSPDeviceMIMOEngine::handleDataTxSync,
|
||||
Qt::QueuedConnection
|
||||
@ -924,7 +925,7 @@ void DSPDeviceMIMOEngine::handleSetMIMO(DeviceSampleMIMO* mimo)
|
||||
);
|
||||
QObject::connect(
|
||||
m_deviceSampleMIMO->getSampleMOFifo(),
|
||||
&SampleMOFifo::dataAsyncRead,
|
||||
&SampleMOFifo::dataReadAsync,
|
||||
this,
|
||||
&DSPDeviceMIMOEngine::handleDataTxAsync,
|
||||
Qt::QueuedConnection
|
||||
|
@ -364,6 +364,7 @@ private:
|
||||
std::vector<BasebandSampleSources> m_basebandSampleSources; //!< channel sample sources (per output stream)
|
||||
std::vector<IncrementalVector<Sample>> m_sourceSampleBuffers;
|
||||
std::vector<IncrementalVector<Sample>> m_sourceZeroBuffers;
|
||||
unsigned int m_sumIndex; //!< channel index when summing channels
|
||||
|
||||
typedef std::list<MIMOChannel*> MIMOChannels;
|
||||
MIMOChannels m_mimoChannels; //!< MIMO channels
|
||||
|
@ -37,8 +37,7 @@ DSPDeviceSinkEngine::DSPDeviceSinkEngine(uint32_t uid, QObject* parent) :
|
||||
m_basebandSampleSources(),
|
||||
m_spectrumSink(nullptr),
|
||||
m_sampleRate(0),
|
||||
m_centerFrequency(0),
|
||||
m_multipleSourcesDivisionFactor(1)
|
||||
m_centerFrequency(0)
|
||||
{
|
||||
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
||||
connect(&m_syncMessenger, SIGNAL(messageSent()), this, SLOT(handleSynchronousMessages()), Qt::QueuedConnection);
|
||||
|
@ -103,7 +103,6 @@ private:
|
||||
|
||||
uint32_t m_sampleRate;
|
||||
quint64 m_centerFrequency;
|
||||
uint32_t m_multipleSourcesDivisionFactor;
|
||||
unsigned int m_sumIndex; //!< channel index when summing channels
|
||||
|
||||
void run();
|
||||
|
Loading…
Reference in New Issue
Block a user