1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

Audio CAT SISO: process mono signals as real signals plus fixes

This commit is contained in:
f4exb 2023-06-18 00:45:13 +02:00
parent 107583759f
commit ef0baa35b7
7 changed files with 65 additions and 47 deletions

View File

@ -31,8 +31,7 @@ AudioCATInputWorker::AudioCATInputWorker(SampleMIFifo* sampleFifo, AudioFifo *fi
m_log2Decim(0),
m_iqMapping(AudioCATSISOSettings::IQMapping::L),
m_convertBuffer(m_convBufSamples),
m_sampleFifo(sampleFifo),
m_quNCOPhase(0)
m_sampleFifo(sampleFifo)
{
}
@ -60,31 +59,10 @@ void AudioCATInputWorker::workIQ(unsigned int nbRead)
{
for (uint32_t i = 0; i < nbRead; i++)
{
qint16 r = m_buf[i*2 + (m_iqMapping == AudioCATSISOSettings::IQMapping::R ? 1 : 0)]; // real sample
if (m_quNCOPhase == 0) // 0
{
m_buf[i*2] = r; // 1
m_buf[i*2+1] = 0; // 0
m_quNCOPhase = 1; // next phase
}
else if (m_quNCOPhase == 1) // -pi/2
{
m_buf[i*2] = 0; // 0
m_buf[i*2+1] = -r; // -1
m_quNCOPhase = 2; // next phase
}
else if (m_quNCOPhase == 2) // pi or -pi
{
m_buf[i*2] = -r; // -1
m_buf[i*2+1] = 0; // 0
m_quNCOPhase = 3; // next phase
}
else if (m_quNCOPhase == 3) // pi/2
{
m_buf[i*2] = 0; // 0
m_buf[i*2+1] = r; // 1
m_quNCOPhase = 0; // next phase
if (m_iqMapping == AudioCATSISOSettings::IQMapping::L) {
m_buf[i*2+1] = m_buf[i*2];
} else {
m_buf[i*2] = m_buf[i*2+1];
}
}
}

View File

@ -52,7 +52,6 @@ private:
SampleVector m_convertBuffer;
SampleMIFifo* m_sampleFifo;
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 16, true> m_decimatorsIQ;
int m_quNCOPhase; //!< Quarter sample rate pseudo NCO phase index (0, 90, 180, 270)
void workIQ(unsigned int nbRead);
void decimate(qint16 *buf, unsigned int nbRead);

View File

@ -146,8 +146,11 @@ void AudioCATOutputWorker::callbackPart(SampleVector& data, unsigned int iBegin,
{
for (unsigned int i = iBegin; i < iEnd; i++)
{
m_audioBuffer[m_audioBufferFill].l = (m_iqMapping == AudioCATSISOSettings::LR ? data[i].m_real : data[i].m_imag) * m_volume;
m_audioBuffer[m_audioBufferFill].r = (m_iqMapping == AudioCATSISOSettings::LR ? data[i].m_imag : data[i].m_real) * m_volume;
m_audioBuffer[m_audioBufferFill].l =
((m_iqMapping == AudioCATSISOSettings::LR || m_iqMapping == AudioCATSISOSettings::L) ? data[i].m_real : data[i].m_imag) * m_volume;
m_audioBuffer[m_audioBufferFill].r =
((m_iqMapping == AudioCATSISOSettings::LR || m_iqMapping == AudioCATSISOSettings::R) ? data[i].m_imag : data[i].m_real) * m_volume;
m_audioBufferFill++;
if (m_audioBufferFill >= m_audioBuffer.size())

View File

@ -523,6 +523,8 @@ void AudioCATSISO::applySettings(const AudioCATSISOSettings& settings, const QLi
if (settingsKeys.contains("rxIQMapping") || force)
{
forwardRxChange = true;
if (m_rxRunning) {
m_inputWorker->setIQMapping(settings.m_rxIQMapping);
}
@ -530,6 +532,8 @@ void AudioCATSISO::applySettings(const AudioCATSISOSettings& settings, const QLi
if (settingsKeys.contains("txIQMapping") || force)
{
forwardTxChange = true;
if (m_txRunning) {
m_outputWorker->setIQMapping(settings.m_txIQMapping);
}
@ -579,7 +583,15 @@ void AudioCATSISO::applySettings(const AudioCATSISOSettings& settings, const QLi
if (forwardRxChange)
{
DSPMIMOSignalNotification *notif = new DSPMIMOSignalNotification(m_rxSampleRate, settings.m_rxCenterFrequency, true, 0);
bool realElseComplex = (m_settings.m_rxIQMapping == AudioCATSISOSettings::L)
|| (m_settings.m_rxIQMapping == AudioCATSISOSettings::R);
DSPMIMOSignalNotification *notif = new DSPMIMOSignalNotification(
m_rxSampleRate / (1<<m_settings.m_log2Decim),
settings.m_rxCenterFrequency,
true,
0,
realElseComplex
);
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
}
@ -589,7 +601,15 @@ void AudioCATSISO::applySettings(const AudioCATSISOSettings& settings, const QLi
m_outputWorker->setSamplerate(m_txSampleRate);
}
DSPMIMOSignalNotification *notif = new DSPMIMOSignalNotification(m_txSampleRate, settings.m_txCenterFrequency, false, 0);
bool realElseComplex = (m_settings.m_txIQMapping == AudioCATSISOSettings::L)
|| (m_settings.m_txIQMapping == AudioCATSISOSettings::R);
DSPMIMOSignalNotification *notif = new DSPMIMOSignalNotification(
m_txSampleRate,
settings.m_txCenterFrequency,
false,
0,
realElseComplex
);
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
}
}

View File

@ -208,7 +208,7 @@ void AudioCATSISOGUI::on_streamSide_currentIndexChanged(int index)
m_deviceUISet->setSpectrumScalingFactor(SDR_TX_SCALEF);
}
updateSpectrum();
updateSpectrum(m_rxElseTx);
ui->spectrumSide->blockSignals(true);
ui->spectrumSide->setCurrentIndex(index);
@ -235,13 +235,14 @@ void AudioCATSISOGUI::on_spectrumSide_currentIndexChanged(int index)
m_deviceUISet->setSpectrumScalingFactor(SDR_TX_SCALEF);
}
updateSpectrum();
updateSpectrum(index == 0);
if (ui->streamLock->isChecked())
{
ui->streamSide->blockSignals(true);
ui->streamSide->setCurrentIndex(index);
ui->streamSide->blockSignals(false);
m_rxElseTx = index == 0;
displayFrequency();
displaySampleRate();
}
@ -435,7 +436,7 @@ void AudioCATSISOGUI::displaySettings()
displayFrequency();
displaySampleRate();
displayDecim();
updateSpectrum();
updateSpectrum(ui->spectrumSide->currentIndex() == 0);
displayFcRxTooltip();
displayCatDevice();
displayCatType();
@ -565,7 +566,7 @@ bool AudioCATSISOGUI::handleMessage(const Message& message)
if (sourceOrSink)
{
m_rxSampleRate = notif.getSampleRate();
m_rxSampleRate = notif.getSampleRate() * (1<<m_settings.m_log2Decim);
m_settings.m_rxCenterFrequency = frequency;
}
else
@ -585,7 +586,7 @@ bool AudioCATSISOGUI::handleMessage(const Message& message)
displayFrequency();
displaySampleRate();
updateSpectrum();
updateSpectrum(ui->spectrumSide->currentIndex() == 0);
return true;
}
@ -706,23 +707,30 @@ void AudioCATSISOGUI::updateCATStatus(AudioCATSISOSettings::MsgCATReportStatus::
m_lastCATStatus = status;
}
void AudioCATSISOGUI::updateSpectrum()
void AudioCATSISOGUI::updateSpectrum(bool rxElseTx)
{
qint64 centerFrequency;
int sampleRate;
bool realElseComplex;
if (m_rxElseTx) {
if (rxElseTx)
{
realElseComplex = (m_settings.m_rxIQMapping == AudioCATSISOSettings::L)
|| (m_settings.m_rxIQMapping == AudioCATSISOSettings::R);
sampleRate = m_rxSampleRate/(1<<m_settings.m_log2Decim);
centerFrequency = m_settings.m_rxCenterFrequency;
} else {
}
else
{
realElseComplex = (m_settings.m_txIQMapping == AudioCATSISOSettings::L)
|| (m_settings.m_txIQMapping == AudioCATSISOSettings::R);
centerFrequency = m_settings.m_txCenterFrequency;
sampleRate = m_txSampleRate;
}
m_deviceUISet->getSpectrum()->setCenterFrequency(centerFrequency);
if (m_rxElseTx) {
m_deviceUISet->getSpectrum()->setSampleRate(m_rxSampleRate/(1<<m_settings.m_log2Decim));
} else {
m_deviceUISet->getSpectrum()->setSampleRate(m_txSampleRate);
}
m_deviceUISet->getSpectrum()->setSampleRate(sampleRate);
m_deviceUISet->getSpectrum()->setSsbSpectrum(realElseComplex);
}
void AudioCATSISOGUI::openDeviceSettingsDialog(const QPoint& p)

View File

@ -76,7 +76,7 @@ private:
void displayCatDevice();
void displayCatType();
void updateTxEnable();
void updateSpectrum();
void updateSpectrum(bool rxElseTx);
void updateCATStatus(AudioCATSISOSettings::MsgCATReportStatus::Status status);
void sendSettings();
void setCenterFrequency(qint64 centerFrequency);

View File

@ -790,6 +790,16 @@
<string>I=R, Q=L</string>
</property>
</item>
<item>
<property name="text">
<string>Mono L</string>
</property>
</item>
<item>
<property name="text">
<string>Mono R</string>
</property>
</item>
</widget>
</item>
</layout>