mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-11-13 03:33:23 -05:00
Interferometer and BladeRF2 MIMO fixes
This commit is contained in:
parent
2ebcb42bd9
commit
afc5b97863
@ -98,15 +98,6 @@ void Interferometer::stop()
|
|||||||
|
|
||||||
void Interferometer::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, unsigned int sinkIndex)
|
void Interferometer::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, unsigned int sinkIndex)
|
||||||
{
|
{
|
||||||
// if (sinkIndex == 0) {
|
|
||||||
// m_count0 = end - begin;
|
|
||||||
// } else if (sinkIndex == 1) {
|
|
||||||
// m_count1 = end - begin;
|
|
||||||
// if (m_count1 != m_count0) {
|
|
||||||
// qDebug("Interferometer::feed: c0: %d 1: %d", m_count0, m_count1);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
m_sink->feed(begin, end, sinkIndex);
|
m_sink->feed(begin, end, sinkIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,18 @@
|
|||||||
#include "dsp/fftengine.h"
|
#include "dsp/fftengine.h"
|
||||||
#include "interferometercorr.h"
|
#include "interferometercorr.h"
|
||||||
|
|
||||||
|
Sample sFirst(const Sample& a, const Sample& b) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sample sSecond(const Sample& a, const Sample& b) {
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sample sSecondInv(const Sample& a, const Sample& b) {
|
||||||
|
return Sample{-b.real(), -b.imag()};
|
||||||
|
}
|
||||||
|
|
||||||
Sample sAdd(const Sample& a, const Sample& b) { //!< Sample addition
|
Sample sAdd(const Sample& a, const Sample& b) { //!< Sample addition
|
||||||
return Sample{a.real() + b.real(), a.imag() + b.imag()};
|
return Sample{a.real() + b.real(), a.imag() + b.imag()};
|
||||||
}
|
}
|
||||||
@ -68,8 +80,8 @@ Sample sMulConjInv(const Sample& a, const Sample& b) { //!< Sample multiply with
|
|||||||
|
|
||||||
Sample invfft2s(const std::complex<float>& a) { //!< Complex float to Sample
|
Sample invfft2s(const std::complex<float>& a) { //!< Complex float to Sample
|
||||||
Sample s;
|
Sample s;
|
||||||
s.setReal(a.real());
|
s.setReal(a.real()/2.0f);
|
||||||
s.setImag(a.imag());
|
s.setImag(a.imag()/2.0f);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,8 +104,10 @@ InterferometerCorrelator::InterferometerCorrelator(int fftSize) :
|
|||||||
m_invFFT->configure(2*fftSize, true);
|
m_invFFT->configure(2*fftSize, true);
|
||||||
|
|
||||||
m_dataj = new std::complex<float>[2*fftSize]; // receives actual FFT result hence twice the data FFT size
|
m_dataj = new std::complex<float>[2*fftSize]; // receives actual FFT result hence twice the data FFT size
|
||||||
m_scorr.resize(2*fftSize);
|
m_scorr.resize(fftSize);
|
||||||
m_tcorr.resize(2*fftSize);
|
m_tcorr.resize(fftSize);
|
||||||
|
m_scorrSize = fftSize;
|
||||||
|
m_tcorrSize = fftSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterferometerCorrelator::~InterferometerCorrelator()
|
InterferometerCorrelator::~InterferometerCorrelator()
|
||||||
@ -119,6 +133,12 @@ bool InterferometerCorrelator::performCorr(
|
|||||||
{
|
{
|
||||||
switch (m_corrType)
|
switch (m_corrType)
|
||||||
{
|
{
|
||||||
|
case InterferometerSettings::Correlation0:
|
||||||
|
results = performOpCorr(data0, size0, data1, size1, sFirst);
|
||||||
|
break;
|
||||||
|
case InterferometerSettings::Correlation1:
|
||||||
|
results = performOpCorr(data0, size0, data1, size1, sSecond);
|
||||||
|
break;
|
||||||
case InterferometerSettings::CorrelationAdd:
|
case InterferometerSettings::CorrelationAdd:
|
||||||
results = performOpCorr(data0, size0, data1, size1, sAdd);
|
results = performOpCorr(data0, size0, data1, size1, sAdd);
|
||||||
break;
|
break;
|
||||||
@ -136,6 +156,12 @@ bool InterferometerCorrelator::performCorr(
|
|||||||
{
|
{
|
||||||
switch (m_corrType)
|
switch (m_corrType)
|
||||||
{
|
{
|
||||||
|
case InterferometerSettings::Correlation0:
|
||||||
|
results = performOpCorr(data0, size0, data1, size1, sFirst);
|
||||||
|
break;
|
||||||
|
case InterferometerSettings::Correlation1:
|
||||||
|
results = performOpCorr(data0, size0, data1, size1, sSecondInv);
|
||||||
|
break;
|
||||||
case InterferometerSettings::CorrelationAdd:
|
case InterferometerSettings::CorrelationAdd:
|
||||||
results = performOpCorr(data0, size0, data1, size1, sAddInv);
|
results = performOpCorr(data0, size0, data1, size1, sAddInv);
|
||||||
break;
|
break;
|
||||||
@ -173,6 +199,12 @@ bool InterferometerCorrelator::performCorr(
|
|||||||
|
|
||||||
switch (m_corrType)
|
switch (m_corrType)
|
||||||
{
|
{
|
||||||
|
case InterferometerSettings::Correlation0:
|
||||||
|
results = performOpCorr(data0, size0, m_data1p, size1, sFirst);
|
||||||
|
break;
|
||||||
|
case InterferometerSettings::Correlation1:
|
||||||
|
results = performOpCorr(data0, size0, m_data1p, size1, sSecond);
|
||||||
|
break;
|
||||||
case InterferometerSettings::CorrelationAdd:
|
case InterferometerSettings::CorrelationAdd:
|
||||||
results = performOpCorr(data0, size0, m_data1p, size1, sAdd);
|
results = performOpCorr(data0, size0, m_data1p, size1, sAdd);
|
||||||
break;
|
break;
|
||||||
@ -199,9 +231,6 @@ bool InterferometerCorrelator::performOpCorr(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
unsigned int size = std::min(size0, size1);
|
unsigned int size = std::min(size0, size1);
|
||||||
// if (size0 != size1) {
|
|
||||||
// qDebug("InterferometerCorrelator::performOpCorr: size0: %d, size1: %d", size0, size1);
|
|
||||||
// }
|
|
||||||
adjustTCorrSize(size);
|
adjustTCorrSize(size);
|
||||||
|
|
||||||
std::transform(
|
std::transform(
|
||||||
@ -232,7 +261,7 @@ bool InterferometerCorrelator::performFFTCorr(
|
|||||||
adjustSCorrSize(size);
|
adjustSCorrSize(size);
|
||||||
adjustTCorrSize(size);
|
adjustTCorrSize(size);
|
||||||
|
|
||||||
while (size > m_fftSize)
|
while (size >= m_fftSize)
|
||||||
{
|
{
|
||||||
// FFT[0]
|
// FFT[0]
|
||||||
std::transform(
|
std::transform(
|
||||||
@ -263,7 +292,7 @@ bool InterferometerCorrelator::performFFTCorr(
|
|||||||
// conjugate FFT[1]
|
// conjugate FFT[1]
|
||||||
std::transform(
|
std::transform(
|
||||||
m_fft[1]->out(),
|
m_fft[1]->out(),
|
||||||
m_fft[1]->out()+2*m_fftSize,
|
m_fft[1]->out() + 2*m_fftSize,
|
||||||
m_dataj,
|
m_dataj,
|
||||||
[](const std::complex<float>& c) -> std::complex<float> {
|
[](const std::complex<float>& c) -> std::complex<float> {
|
||||||
return std::conj(c);
|
return std::conj(c);
|
||||||
@ -273,7 +302,7 @@ bool InterferometerCorrelator::performFFTCorr(
|
|||||||
// product of FFT[1]* with FFT[0] and store in inverse FFT input
|
// product of FFT[1]* with FFT[0] and store in inverse FFT input
|
||||||
std::transform(
|
std::transform(
|
||||||
m_fft[0]->out(),
|
m_fft[0]->out(),
|
||||||
m_fft[0]->out()+2*m_fftSize,
|
m_fft[0]->out() + 2*m_fftSize,
|
||||||
m_dataj,
|
m_dataj,
|
||||||
m_invFFT->in(),
|
m_invFFT->in(),
|
||||||
[](std::complex<float>& a, const std::complex<float>& b) -> std::complex<float> {
|
[](std::complex<float>& a, const std::complex<float>& b) -> std::complex<float> {
|
||||||
@ -284,8 +313,8 @@ bool InterferometerCorrelator::performFFTCorr(
|
|||||||
// copy product to correlation spectrum - convert and scale to FFT size
|
// copy product to correlation spectrum - convert and scale to FFT size
|
||||||
std::transform(
|
std::transform(
|
||||||
m_invFFT->in(),
|
m_invFFT->in(),
|
||||||
m_invFFT->in() + 2*m_fftSize,
|
m_invFFT->in() + m_fftSize,
|
||||||
m_scorr.begin(),
|
m_scorr.begin() + nfft*m_fftSize,
|
||||||
[this](const std::complex<float>& a) -> Sample {
|
[this](const std::complex<float>& a) -> Sample {
|
||||||
Sample s;
|
Sample s;
|
||||||
s.setReal(a.real()*(SDR_RX_SCALEF/m_fftSize));
|
s.setReal(a.real()*(SDR_RX_SCALEF/m_fftSize));
|
||||||
@ -298,8 +327,8 @@ bool InterferometerCorrelator::performFFTCorr(
|
|||||||
m_invFFT->transform();
|
m_invFFT->transform();
|
||||||
std::transform(
|
std::transform(
|
||||||
m_invFFT->out(),
|
m_invFFT->out(),
|
||||||
m_invFFT->out() + 2*m_fftSize,
|
m_invFFT->out() + m_fftSize,
|
||||||
m_tcorr.begin(),
|
m_tcorr.begin() + nfft*m_fftSize,
|
||||||
invfft2s
|
invfft2s
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -319,19 +348,23 @@ bool InterferometerCorrelator::performFFTCorr(
|
|||||||
|
|
||||||
void InterferometerCorrelator::adjustSCorrSize(int size)
|
void InterferometerCorrelator::adjustSCorrSize(int size)
|
||||||
{
|
{
|
||||||
if (size > m_scorrSize)
|
int nFFTSize = (size/m_fftSize)*m_fftSize;
|
||||||
|
|
||||||
|
if (nFFTSize > m_scorrSize)
|
||||||
{
|
{
|
||||||
m_scorr.resize(size);
|
m_scorr.resize(nFFTSize);
|
||||||
m_scorrSize = size;
|
m_scorrSize = nFFTSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterferometerCorrelator::adjustTCorrSize(int size)
|
void InterferometerCorrelator::adjustTCorrSize(int size)
|
||||||
{
|
{
|
||||||
if (size > m_tcorrSize)
|
int nFFTSize = (size/m_fftSize)*m_fftSize;
|
||||||
|
|
||||||
|
if (nFFTSize > m_tcorrSize)
|
||||||
{
|
{
|
||||||
m_tcorr.resize(size);
|
m_tcorr.resize(nFFTSize);
|
||||||
m_tcorrSize = size;
|
m_tcorrSize = nFFTSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -171,12 +171,22 @@
|
|||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add</string>
|
<string>A</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Mul*</string>
|
<string>B</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>A+B</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>A.B*</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
@ -27,6 +27,8 @@ struct InterferometerSettings
|
|||||||
{
|
{
|
||||||
enum CorrelationType
|
enum CorrelationType
|
||||||
{
|
{
|
||||||
|
Correlation0,
|
||||||
|
Correlation1,
|
||||||
CorrelationAdd,
|
CorrelationAdd,
|
||||||
CorrelationMultiply,
|
CorrelationMultiply,
|
||||||
CorrelationFFT
|
CorrelationFFT
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <QMutexLocker>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "dsp/downchannelizer.h"
|
#include "dsp/downchannelizer.h"
|
||||||
@ -30,25 +31,29 @@ MESSAGE_CLASS_DEFINITION(InterferometerSink::MsgConfigureCorrelation, Message)
|
|||||||
InterferometerSink::InterferometerSink(int fftSize) :
|
InterferometerSink::InterferometerSink(int fftSize) :
|
||||||
m_correlator(fftSize),
|
m_correlator(fftSize),
|
||||||
m_spectrumSink(nullptr),
|
m_spectrumSink(nullptr),
|
||||||
m_scopeSink(nullptr)
|
m_scopeSink(nullptr),
|
||||||
|
m_mutex(QMutex::Recursive)
|
||||||
{
|
{
|
||||||
m_sampleMIFifo.init(2, 96000 * 4);
|
m_sampleMIFifo.init(2, 96000 * 8);
|
||||||
|
m_vbegin.resize(2);
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
m_sinks[i].setStreamIndex(i);
|
m_sinks[i].setStreamIndex(i);
|
||||||
m_channelizers[i] = new DownChannelizer(&m_sinks[i]);
|
m_channelizers[i] = new DownChannelizer(&m_sinks[i]);
|
||||||
|
m_sizes[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
&m_sampleMIFifo,
|
&m_sampleMIFifo,
|
||||||
&SampleMIFifo::dataAsyncReady,
|
&SampleMIFifo::dataSyncReady,
|
||||||
this,
|
this,
|
||||||
&InterferometerSink::handleDataAsync,
|
&InterferometerSink::handleData,
|
||||||
Qt::QueuedConnection
|
Qt::QueuedConnection
|
||||||
);
|
);
|
||||||
|
|
||||||
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
||||||
|
m_lastStream = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterferometerSink::~InterferometerSink()
|
InterferometerSink::~InterferometerSink()
|
||||||
@ -61,7 +66,12 @@ InterferometerSink::~InterferometerSink()
|
|||||||
|
|
||||||
void InterferometerSink::reset()
|
void InterferometerSink::reset()
|
||||||
{
|
{
|
||||||
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
m_sampleMIFifo.reset();
|
m_sampleMIFifo.reset();
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
m_sinks[i].reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterferometerSink::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, unsigned int streamIndex)
|
void InterferometerSink::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, unsigned int streamIndex)
|
||||||
@ -70,86 +80,64 @@ void InterferometerSink::feed(const SampleVector::const_iterator& begin, const S
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sampleMIFifo.writeAsync(begin, end - begin, streamIndex);
|
if (streamIndex == m_lastStream) {
|
||||||
}
|
qWarning("InterferometerSink::feed: twice same stream in a row: %u", streamIndex);
|
||||||
|
}
|
||||||
|
|
||||||
void InterferometerSink::handleDataAsync(int sinkIndex)
|
m_lastStream = streamIndex;
|
||||||
{
|
m_vbegin[streamIndex] = begin;
|
||||||
SampleVector::const_iterator part1begin;
|
m_sizes[streamIndex] = end - begin;
|
||||||
SampleVector::const_iterator part1end;
|
|
||||||
SampleVector::const_iterator part2begin;
|
|
||||||
SampleVector::const_iterator part2end;
|
|
||||||
|
|
||||||
while ((m_sampleMIFifo.fillAsync(sinkIndex) > 0) && (m_inputMessageQueue.size() == 0))
|
if (streamIndex == 1)
|
||||||
{
|
{
|
||||||
m_sampleMIFifo.readAsync(&part1begin, &part1end, &part2begin, &part2end, sinkIndex);
|
if (m_sizes[0] != m_sizes[1])
|
||||||
|
{
|
||||||
if (part1begin != part1end) { // first part of FIFO data
|
qWarning("InterferometerSink::feed: unequal sizes: [0]: %d [1]: %d", m_sizes[0], m_sizes[1]);
|
||||||
//qDebug("InterferometerSink::handleSinkFifo: part1-stream: %u count: %u", sinkIndex, count);
|
m_sampleMIFifo.writeSync(m_vbegin, std::min(m_sizes[0], m_sizes[1]));
|
||||||
processFifo(part1begin, part1end, sinkIndex);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (part2begin != part2end) { // second part of FIFO data (used when block wraps around)
|
{
|
||||||
//qDebug("InterferometerSink::handleSinkFifo: part2-stream: %u count: %u", sinkIndex, count);
|
m_sampleMIFifo.writeSync(m_vbegin, m_sizes[0]);
|
||||||
processFifo(part2begin, part2end, sinkIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// int samplesDone = 0;
|
|
||||||
|
|
||||||
// while ((m_sinkFifos[sinkIndex].fill() > 0)
|
|
||||||
// && (m_inputMessageQueue.size() == 0))
|
|
||||||
// //&& (samplesDone < m_channelizers[sinkIndex]->getInputSampleRate()))
|
|
||||||
// {
|
|
||||||
// SampleVector::iterator part1begin;
|
|
||||||
// SampleVector::iterator part1end;
|
|
||||||
// SampleVector::iterator part2begin;
|
|
||||||
// SampleVector::iterator part2end;
|
|
||||||
|
|
||||||
// unsigned int count = m_sinkFifos[sinkIndex].readBegin(m_sinkFifos[sinkIndex].fill(), &part1begin, &part1end, &part2begin, &part2end);
|
|
||||||
|
|
||||||
// if (part1begin != part1end) { // first part of FIFO data
|
|
||||||
// //qDebug("InterferometerSink::handleSinkFifo: part1-stream: %u count: %u", sinkIndex, count);
|
|
||||||
// processFifo(part1begin, part1end, sinkIndex);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (part2begin != part2end) { // second part of FIFO data (used when block wraps around)
|
|
||||||
// //qDebug("InterferometerSink::handleSinkFifo: part2-stream: %u count: %u", sinkIndex, count);
|
|
||||||
// processFifo(part2begin, part2end, sinkIndex);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// m_sinkFifos[sinkIndex].readCommit((unsigned int) count); // adjust FIFO pointers
|
|
||||||
// samplesDone += count;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//qDebug("InterferometerSink::handleSinkFifo: done");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterferometerSink::processFifo(const SampleVector::const_iterator& vbegin, const SampleVector::const_iterator& vend, unsigned int sinkIndex)
|
void InterferometerSink::handleData()
|
||||||
{
|
{
|
||||||
// if (sinkIndex == 0) {
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
// m_count0 = vend - vbegin;
|
|
||||||
// } else if (sinkIndex == 1) {
|
|
||||||
// m_count1 = vend - vbegin;
|
|
||||||
// if (m_count1 != m_count0) {
|
|
||||||
// qDebug("InterferometerSink::processFifo: c0: %d 1: %d", m_count0, m_count1);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
m_channelizers[sinkIndex]->feed(vbegin, vend, false);
|
const std::vector<SampleVector>& data = m_sampleMIFifo.getData();
|
||||||
|
|
||||||
if (sinkIndex == 1) {
|
unsigned int ipart1begin;
|
||||||
run();
|
unsigned int ipart1end;
|
||||||
|
unsigned int ipart2begin;
|
||||||
|
unsigned int ipart2end;
|
||||||
|
|
||||||
|
while ((m_sampleMIFifo.fillSync() > 0) && (m_inputMessageQueue.size() == 0))
|
||||||
|
{
|
||||||
|
m_sampleMIFifo.readSync(ipart1begin, ipart1end, ipart2begin, ipart2end);
|
||||||
|
|
||||||
|
if (ipart1begin != ipart1end) { // first part of FIFO data
|
||||||
|
processFifo(data, ipart1begin, ipart1end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ipart2begin != ipart2end) { // second part of FIFO data (used when block wraps around)
|
||||||
|
processFifo(data, ipart2begin, ipart2end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InterferometerSink::processFifo(const std::vector<SampleVector>& data, unsigned int ibegin, unsigned int iend)
|
||||||
|
{
|
||||||
|
for (unsigned int stream = 0; stream < 2; stream++) {
|
||||||
|
m_channelizers[stream]->feed(data[stream].begin() + ibegin, data[stream].begin() + iend, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterferometerSink::run()
|
void InterferometerSink::run()
|
||||||
{
|
{
|
||||||
// if (m_sinks[0].getSize() != m_sinks[1].getSize()) {
|
|
||||||
// qDebug("InterferometerSink::run: size0: %d, size1: %d", m_sinks[0].getSize(), m_sinks[1].getSize());
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (m_correlator.performCorr(m_sinks[0].getData(), m_sinks[0].getSize(), m_sinks[1].getData(), m_sinks[1].getSize()))
|
if (m_correlator.performCorr(m_sinks[0].getData(), m_sinks[0].getSize(), m_sinks[1].getData(), m_sinks[1].getSize()))
|
||||||
{
|
{
|
||||||
if (m_scopeSink) {
|
if (m_scopeSink) {
|
||||||
@ -195,6 +183,7 @@ bool InterferometerSink::handleMessage(const Message& cmd)
|
|||||||
{
|
{
|
||||||
if (MsgConfigureChannelizer::match(cmd))
|
if (MsgConfigureChannelizer::match(cmd))
|
||||||
{
|
{
|
||||||
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
|
MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
|
||||||
int log2Decim = cfg.getLog2Decim();
|
int log2Decim = cfg.getLog2Decim();
|
||||||
int filterChainHash = cfg.getFilterChainHash();
|
int filterChainHash = cfg.getFilterChainHash();
|
||||||
@ -208,6 +197,7 @@ bool InterferometerSink::handleMessage(const Message& cmd)
|
|||||||
m_channelizers[i]->set(m_channelizers[i]->getInputMessageQueue(),
|
m_channelizers[i]->set(m_channelizers[i]->getInputMessageQueue(),
|
||||||
log2Decim,
|
log2Decim,
|
||||||
filterChainHash);
|
filterChainHash);
|
||||||
|
m_sinks[i].reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
#define INCLUDE_INTERFEROMETERSINK_H
|
#define INCLUDE_INTERFEROMETERSINK_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
//#include "dsp/samplesinkvector.h"
|
//#include "dsp/samplesinkvector.h"
|
||||||
#include "dsp/samplemififo.h"
|
#include "dsp/samplemififo.h"
|
||||||
@ -110,22 +111,25 @@ public:
|
|||||||
void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, unsigned int streamIndex);
|
void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, unsigned int streamIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void processFifo(const SampleVector::const_iterator& vbegin, const SampleVector::const_iterator& vend, unsigned int sinkIndex);
|
void processFifo(const std::vector<SampleVector>& data, unsigned int ibegin, unsigned int iend);
|
||||||
void run();
|
void run();
|
||||||
bool handleMessage(const Message& cmd);
|
bool handleMessage(const Message& cmd);
|
||||||
|
|
||||||
InterferometerCorrelator m_correlator;
|
InterferometerCorrelator m_correlator;
|
||||||
SampleMIFifo m_sampleMIFifo;
|
SampleMIFifo m_sampleMIFifo;
|
||||||
|
std::vector<SampleVector::const_iterator> m_vbegin;
|
||||||
|
int m_sizes[2];
|
||||||
InterferometerStreamSink m_sinks[2];
|
InterferometerStreamSink m_sinks[2];
|
||||||
DownChannelizer *m_channelizers[2];
|
DownChannelizer *m_channelizers[2];
|
||||||
BasebandSampleSink *m_spectrumSink;
|
BasebandSampleSink *m_spectrumSink;
|
||||||
BasebandSampleSink *m_scopeSink;
|
BasebandSampleSink *m_scopeSink;
|
||||||
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
|
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
|
||||||
int m_count0, m_count1;
|
QMutex m_mutex;
|
||||||
|
unsigned int m_lastStream;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleInputMessages();
|
void handleInputMessages();
|
||||||
void handleDataAsync(int sinkIndex); //!< Handle data when samples have to be processed
|
void handleData(); //!< Handle data when samples have to be processed
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDE_INTERFEROMETERSINK_H
|
#endif // INCLUDE_INTERFEROMETERSINK_H
|
||||||
|
|||||||
@ -15,7 +15,9 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <QMutexLocker>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "dsp/downchannelizer.h"
|
#include "dsp/downchannelizer.h"
|
||||||
|
|
||||||
#include "interferometerstreamsink.h"
|
#include "interferometerstreamsink.h"
|
||||||
@ -40,7 +42,7 @@ void InterferometerStreamSink::stop()
|
|||||||
|
|
||||||
void InterferometerStreamSink::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly)
|
void InterferometerStreamSink::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly)
|
||||||
{
|
{
|
||||||
m_settingsMutex.lock();
|
QMutexLocker mutexLocker(&m_settingsMutex);
|
||||||
m_dataSize = (end - begin) + m_dataStart;
|
m_dataSize = (end - begin) + m_dataStart;
|
||||||
|
|
||||||
if (m_dataSize > m_bufferSize)
|
if (m_dataSize > m_bufferSize)
|
||||||
@ -50,7 +52,6 @@ void InterferometerStreamSink::feed(const SampleVector::const_iterator& begin, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::copy(begin, end, m_data.begin() + m_dataStart);
|
std::copy(begin, end, m_data.begin() + m_dataStart);
|
||||||
m_settingsMutex.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InterferometerStreamSink::handleMessage(const Message& cmd)
|
bool InterferometerStreamSink::handleMessage(const Message& cmd)
|
||||||
@ -72,3 +73,9 @@ bool InterferometerStreamSink::handleMessage(const Message& cmd)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InterferometerStreamSink::reset()
|
||||||
|
{
|
||||||
|
QMutexLocker mutexLocker(&m_settingsMutex);
|
||||||
|
m_dataStart = 0;
|
||||||
|
}
|
||||||
|
|||||||
@ -36,6 +36,7 @@ public:
|
|||||||
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
||||||
virtual bool handleMessage(const Message& cmd); //!< Processing of a message. Returns true if message has actually been processed
|
virtual bool handleMessage(const Message& cmd); //!< Processing of a message. Returns true if message has actually been processed
|
||||||
|
|
||||||
|
void reset();
|
||||||
unsigned int getStreamIndex() const { return m_streamIndex; }
|
unsigned int getStreamIndex() const { return m_streamIndex; }
|
||||||
void setStreamIndex(unsigned int streamIndex) { m_streamIndex = streamIndex; }
|
void setStreamIndex(unsigned int streamIndex) { m_streamIndex = streamIndex; }
|
||||||
SampleVector& getData() { return m_data; }
|
SampleVector& getData() { return m_data; }
|
||||||
|
|||||||
@ -490,6 +490,7 @@ void BladeRF2MIMOGui::on_sampleRate_changed(quint64 value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
displaySampleRate();
|
||||||
displayFcTooltip();
|
displayFcTooltip();
|
||||||
sendSettings();
|
sendSettings();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,17 +129,26 @@ void BladeRF2MIThread::callback(const qint16* buf, qint32 samplesPerChannel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<SampleVector::const_iterator> vbegin;
|
std::vector<SampleVector::const_iterator> vbegin;
|
||||||
|
int lengths[2];
|
||||||
|
|
||||||
for (unsigned int channel = 0; channel < 2; channel++)
|
for (unsigned int channel = 0; channel < 2; channel++)
|
||||||
{
|
{
|
||||||
channelCallback(&buf[2*samplesPerChannel*channel], 2*samplesPerChannel, channel);
|
lengths[channel] = channelCallback(&buf[2*samplesPerChannel*channel], 2*samplesPerChannel, channel);
|
||||||
vbegin.push_back(m_convertBuffer[channel].begin());
|
vbegin.push_back(m_convertBuffer[channel].begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sampleFifo->writeSync(vbegin, samplesPerChannel/(1<<m_log2Decim));
|
if (lengths[0] == lengths[1])
|
||||||
|
{
|
||||||
|
m_sampleFifo->writeSync(vbegin, lengths[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning("BladeRF2MIThread::callback: unequal channel lengths: [0]=%d [1]=%d", lengths[0], lengths[1]);
|
||||||
|
m_sampleFifo->writeSync(vbegin, std::min(lengths[0], lengths[1]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BladeRF2MIThread::channelCallback(const qint16* buf, qint32 len, int channel)
|
int BladeRF2MIThread::channelCallback(const qint16* buf, qint32 len, int channel)
|
||||||
{
|
{
|
||||||
SampleVector::iterator it = m_convertBuffer[channel].begin();
|
SampleVector::iterator it = m_convertBuffer[channel].begin();
|
||||||
|
|
||||||
@ -228,4 +237,6 @@ void BladeRF2MIThread::channelCallback(const qint16* buf, qint32 len, int channe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return it - m_convertBuffer[channel].begin();
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ private:
|
|||||||
|
|
||||||
void run();
|
void run();
|
||||||
void callback(const qint16* buf, qint32 samplesPerChannel);
|
void callback(const qint16* buf, qint32 samplesPerChannel);
|
||||||
void channelCallback(const qint16* buf, qint32 len, int channel);
|
int channelCallback(const qint16* buf, qint32 len, int channel);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLUGINS_SAMPLEMIMO_BLADERF2MIMO_BLADERF2MITHREAD_H_
|
#endif // PLUGINS_SAMPLEMIMO_BLADERF2MIMO_BLADERF2MITHREAD_H_
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user