1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-29 19:28:47 -05:00

DOA2: removed useless scope modes

This commit is contained in:
f4exb 2022-05-27 16:49:32 +02:00
parent 4e373478e7
commit 0e08a35d49
5 changed files with 14 additions and 331 deletions

View File

@ -119,7 +119,7 @@ Sample invfft2star(const std::complex<float>& a) { //!< Complex float to Sample
} }
DOA2Correlator::DOA2Correlator(int fftSize) : DOA2Correlator::DOA2Correlator(int fftSize) :
m_corrType(DOA2Settings::CorrelationAdd), m_corrType(DOA2Settings::CorrelationFFT),
m_fftSize(fftSize) m_fftSize(fftSize)
{ {
setPhase(0); setPhase(0);
@ -177,34 +177,16 @@ bool DOA2Correlator::performCorr(
case DOA2Settings::Correlation1: case DOA2Settings::Correlation1:
results = performOpCorr(data0, size0, data1, size1, sSecond); results = performOpCorr(data0, size0, data1, size1, sSecond);
break; break;
case DOA2Settings::CorrelationAdd:
results = performOpCorr(data0, size0, data1, size1, sAdd);
break;
case DOA2Settings::CorrelationMultiply:
results = performOpCorr(data0, size0, data1, size1, sMulConj);
break;
case DOA2Settings::CorrelationIFFT:
results = performIFFTCorr(data0, size0, data1, size1);
break;
case DOA2Settings::CorrelationIFFTStar:
results = performIFFTCorr(data0, size0, data1, size1, true);
break;
case DOA2Settings::CorrelationFFT: case DOA2Settings::CorrelationFFT:
results = performFFTProd(data0, size0, data1, size1); results = performFFTProd(data0, size0, data1, size1);
break; break;
case DOA2Settings::CorrelationIFFT2:
results = performIFFT2Corr(data0, size0, data1, size1);
break;
default: default:
break; break;
} }
} }
else if ((m_phase == -180) || (m_phase == 180)) else if ((m_phase == -180) || (m_phase == 180))
{ {
if ((m_corrType == DOA2Settings::CorrelationIFFT) if (m_corrType == DOA2Settings::CorrelationFFT)
|| (m_corrType == DOA2Settings::CorrelationIFFT2)
|| (m_corrType == DOA2Settings::CorrelationIFFTStar)
|| (m_corrType == DOA2Settings::CorrelationFFT))
{ {
if (size1 > m_data1p.size()) { if (size1 > m_data1p.size()) {
m_data1p.resize(size1); m_data1p.resize(size1);
@ -228,24 +210,9 @@ bool DOA2Correlator::performCorr(
case DOA2Settings::Correlation1: case DOA2Settings::Correlation1:
results = performOpCorr(data0, size0, data1, size1, sSecondInv); results = performOpCorr(data0, size0, data1, size1, sSecondInv);
break; break;
case DOA2Settings::CorrelationAdd:
results = performOpCorr(data0, size0, data1, size1, sAddInv);
break;
case DOA2Settings::CorrelationMultiply:
results = performOpCorr(data0, size0, data1, size1, sMulConjInv);
break;
case DOA2Settings::CorrelationIFFT:
results = performIFFTCorr(data0, size0, m_data1p, size1);
break;
case DOA2Settings::CorrelationIFFTStar:
results = performIFFTCorr(data0, size0, m_data1p, size1, true);
break;
case DOA2Settings::CorrelationFFT: case DOA2Settings::CorrelationFFT:
results = performFFTProd(data0, size0, m_data1p, size1); results = performFFTProd(data0, size0, m_data1p, size1);
break; break;
case DOA2Settings::CorrelationIFFT2:
results = performIFFT2Corr(data0, size0, m_data1p, size1);
break;
default: default:
break; break;
} }
@ -280,24 +247,9 @@ bool DOA2Correlator::performCorr(
case DOA2Settings::Correlation1: case DOA2Settings::Correlation1:
results = performOpCorr(data0, size0, m_data1p, size1, sSecond); results = performOpCorr(data0, size0, m_data1p, size1, sSecond);
break; break;
case DOA2Settings::CorrelationAdd:
results = performOpCorr(data0, size0, m_data1p, size1, sAdd);
break;
case DOA2Settings::CorrelationMultiply:
results = performOpCorr(data0, size0, m_data1p, size1, sMulConj);
break;
case DOA2Settings::CorrelationIFFT:
results = performIFFTCorr(data0, size0, m_data1p, size1);
break;
case DOA2Settings::CorrelationIFFTStar:
results = performIFFTCorr(data0, size0, m_data1p, size1, true);
break;
case DOA2Settings::CorrelationFFT: case DOA2Settings::CorrelationFFT:
results = performFFTProd(data0, size0, m_data1p, size1); results = performFFTProd(data0, size0, m_data1p, size1);
break; break;
case DOA2Settings::CorrelationIFFT2:
results = performIFFT2Corr(data0, size0, m_data1p, size1);
break;
default: default:
break; break;
} }
@ -331,239 +283,6 @@ bool DOA2Correlator::performOpCorr(
return true; return true;
} }
bool DOA2Correlator::performIFFTCorr(
const SampleVector& data0,
unsigned int size0,
const SampleVector& data1,
unsigned int size1,
bool star
)
{
unsigned int size = std::min(size0, size1);
int nfft = 0;
SampleVector::const_iterator begin0 = data0.begin();
SampleVector::const_iterator begin1 = data1.begin();
adjustSCorrSize(size);
adjustTCorrSize(size);
while (size >= m_fftSize)
{
// FFT[0]
std::transform(
begin0,
begin0 + m_fftSize,
m_fft[0]->in(),
s2c
);
m_window.apply(m_fft[0]->in());
std::fill(m_fft[0]->in() + m_fftSize, m_fft[0]->in() + 2*m_fftSize, std::complex<float>{0, 0});
m_fft[0]->transform();
// FFT[1]
std::transform(
begin1,
begin1 + m_fftSize,
m_fft[1]->in(),
s2c
);
m_window.apply(m_fft[1]->in());
std::fill(m_fft[1]->in() + m_fftSize, m_fft[1]->in() + 2*m_fftSize, std::complex<float>{0, 0});
m_fft[1]->transform();
// conjugate FFT[1]
std::transform(
m_fft[1]->out(),
m_fft[1]->out() + 2*m_fftSize,
m_dataj,
[](const std::complex<float>& c) -> std::complex<float> {
return std::conj(c);
}
);
// product of FFT[1]* with FFT[0] and store in inverse FFT input
std::transform(
m_fft[0]->out(),
m_fft[0]->out() + 2*m_fftSize,
m_dataj,
m_invFFT->in(),
[](std::complex<float>& a, const std::complex<float>& b) -> std::complex<float> {
return (a*b);
}
);
// copy product to correlation spectrum - convert and scale to FFT size and Hanning window
std::transform(
m_invFFT->in(),
m_invFFT->in() + m_fftSize,
m_scorr.begin() + nfft*m_fftSize,
[this](const std::complex<float>& a) -> Sample {
Sample s;
s.setReal(a.real()*(SDR_RX_SCALEF/m_fftSize));
s.setImag(a.imag()*(SDR_RX_SCALEF/m_fftSize));
return s;
}
);
// do the inverse FFT to get time correlation
m_invFFT->transform();
if (star)
{
// sum first half with the reversed second half as one is the conjugate of the other this should yield constant phase
*m_tcorr.begin() = invfft2star(m_invFFT->out()[0]); // t = 0
std::reverse(m_invFFT->out() + m_fftSize, m_invFFT->out() + 2*m_fftSize);
std::transform(
m_invFFT->out() + 1,
m_invFFT->out() + m_fftSize,
m_invFFT->out() + m_fftSize,
m_tcorr.begin() + nfft*m_fftSize,
[](const std::complex<float>& a, const std::complex<float>& b) -> Sample {
Sample s;
std::complex<float> sum = a + b;
s.setReal(sum.real()/12.0f);
s.setImag(sum.imag()/12.0f);
return s;
}
);
}
else
{
std::transform(
m_invFFT->out(),
m_invFFT->out() + m_fftSize,
m_tcorr.begin() + nfft*m_fftSize,
[](const std::complex<float>& a) -> Sample {
Sample s;
s.setReal(a.real()/6.0f);
s.setImag(a.imag()/6.0f);
return s;
}
);
}
size -= m_fftSize;
begin0 += m_fftSize;
begin1 += m_fftSize;
nfft++;
}
// update the samples counters
m_processed = nfft*m_fftSize;
m_remaining[0] = size0 - nfft*m_fftSize;
m_remaining[1] = size1 - nfft*m_fftSize;
return nfft > 0;
}
bool DOA2Correlator::performIFFT2Corr(
const SampleVector& data0,
unsigned int size0,
const SampleVector& data1,
unsigned int size1
)
{
unsigned int size = std::min(size0, size1);
int nfft = 0;
SampleVector::const_iterator begin0 = data0.begin();
SampleVector::const_iterator begin1 = data1.begin();
adjustSCorrSize(size);
adjustTCorrSize(size);
while (size >= m_fftSize)
{
// FFT[0]
std::transform(
begin0,
begin0 + m_fftSize,
m_fft2[0]->in(),
s2c
);
m_window.apply(m_fft2[0]->in());
m_fft2[0]->transform();
// FFT[1]
std::transform(
begin1,
begin1 + m_fftSize,
m_fft2[1]->in(),
s2c
);
m_window.apply(m_fft2[1]->in());
m_fft2[1]->transform();
// conjugate FFT[1]
std::transform(
m_fft2[1]->out(),
m_fft2[1]->out() + m_fftSize,
m_dataj,
[](const std::complex<float>& c) -> std::complex<float> {
return std::conj(c);
}
);
// product of FFT[1]* with FFT[0] and store in inverse FFT input
std::transform(
m_fft2[0]->out(),
m_fft2[0]->out() + m_fftSize,
m_dataj,
m_invFFT2->in(),
[](std::complex<float>& a, const std::complex<float>& b) -> std::complex<float> {
return (a*b);
}
);
// copy product to correlation spectrum - convert and scale to FFT size
std::transform(
m_invFFT2->in(),
m_invFFT2->in() + m_fftSize,
m_scorr.begin() + nfft*m_fftSize,
[this](const std::complex<float>& a) -> Sample {
Sample s;
s.setReal(a.real()*(SDR_RX_SCALEF/m_fftSize));
s.setImag(a.imag()*(SDR_RX_SCALEF/m_fftSize));
return s;
}
);
// do the inverse FFT to get time correlation
m_invFFT2->transform();
std::transform(
m_invFFT2->out() + m_fftSize/2,
m_invFFT2->out() + m_fftSize,
m_tcorr.begin() + nfft*m_fftSize,
[](const std::complex<float>& a) -> Sample {
Sample s;
s.setReal(a.real()/3.0f);
s.setImag(a.imag()/3.0f);
return s;
}
);
std::transform(
m_invFFT2->out(),
m_invFFT2->out() + m_fftSize/2,
m_tcorr.begin() + nfft*m_fftSize + m_fftSize/2,
[](const std::complex<float>& a) -> Sample {
Sample s;
s.setReal(a.real()/3.0f);
s.setImag(a.imag()/3.0f);
return s;
}
);
size -= m_fftSize;
begin0 += m_fftSize;
begin1 += m_fftSize;
nfft++;
}
// update the samples counters
m_processed = nfft*m_fftSize;
m_remaining[0] = size0 - nfft*m_fftSize;
m_remaining[1] = size1 - nfft*m_fftSize;
return nfft > 0;
}
bool DOA2Correlator::performFFTProd( bool DOA2Correlator::performFFTProd(
const SampleVector& data0, const SampleVector& data0,
unsigned int size0, unsigned int size0,

View File

@ -62,19 +62,6 @@ private:
unsigned int size1, unsigned int size1,
Sample sampleOp(const Sample& a, const Sample& b) Sample sampleOp(const Sample& a, const Sample& b)
); );
bool performIFFTCorr( //!< Returns true if results were produced
const SampleVector& data0,
unsigned int size0,
const SampleVector& data1,
unsigned int size1,
bool star = false
);
bool performIFFT2Corr( //!< Returns true if results were produced
const SampleVector& data0,
unsigned int size0,
const SampleVector& data1,
unsigned int size1
);
bool performFFTProd( //!< Returns true if results were produced bool performFFTProd( //!< Returns true if results were produced
const SampleVector& data0, const SampleVector& data0,
unsigned int size0, unsigned int size0,

View File

@ -179,7 +179,7 @@
<item> <item>
<widget class="QComboBox" name="correlationType"> <widget class="QComboBox" name="correlationType">
<property name="toolTip"> <property name="toolTip">
<string>Correlation type</string> <string>Scope correlation type</string>
</property> </property>
<item> <item>
<property name="text"> <property name="text">
@ -191,36 +191,11 @@
<string>B</string> <string>B</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>A+B</string>
</property>
</item>
<item>
<property name="text">
<string>A.B*</string>
</property>
</item>
<item>
<property name="text">
<string>IFFT</string>
</property>
</item>
<item>
<property name="text">
<string>IFFT*</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>FFT</string> <string>FFT</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>IFFT2</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item> <item>
@ -377,7 +352,7 @@
</size> </size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Time domain</string> <string>Scope</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayoutScope"> <layout class="QVBoxLayout" name="verticalLayoutScope">
<property name="spacing"> <property name="spacing">
@ -465,7 +440,14 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="DOA2Compass" name="compass" native="true"/> <widget class="DOA2Compass" name="compass" native="true">
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>9</pointsize>
</font>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>

View File

@ -33,7 +33,7 @@ DOA2Settings::DOA2Settings() :
void DOA2Settings::resetToDefaults() void DOA2Settings::resetToDefaults()
{ {
m_correlationType = CorrelationAdd; m_correlationType = CorrelationFFT;
m_rgbColor = QColor(250, 120, 120).rgb(); m_rgbColor = QColor(250, 120, 120).rgb();
m_title = "DOA 2 sources"; m_title = "DOA 2 sources";
m_log2Decim = 0; m_log2Decim = 0;
@ -98,7 +98,7 @@ bool DOA2Settings::deserialize(const QByteArray& data)
d.readS32(2, &tmp, 0); d.readS32(2, &tmp, 0);
m_correlationType = (CorrelationType) tmp; m_correlationType = (CorrelationType) tmp;
d.readU32(3, &m_rgbColor); d.readU32(3, &m_rgbColor);
d.readString(4, &m_title, "Interpolator"); d.readString(4, &m_title, "DOA 2 sources");
d.readU32(5, &utmp, 0); d.readU32(5, &utmp, 0);
m_log2Decim = utmp > 6 ? 6 : utmp; m_log2Decim = utmp > 6 ? 6 : utmp;
d.readU32(6, &m_filterChainHash, 0); d.readU32(6, &m_filterChainHash, 0);

View File

@ -29,12 +29,7 @@ struct DOA2Settings
{ {
Correlation0, Correlation0,
Correlation1, Correlation1,
CorrelationAdd,
CorrelationMultiply,
CorrelationIFFT,
CorrelationIFFTStar,
CorrelationFFT, CorrelationFFT,
CorrelationIFFT2
}; };
CorrelationType m_correlationType; CorrelationType m_correlationType;