From fb08489f5a2a65ac48d7ec8b2d74be29647ef217 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 13 Jul 2024 03:23:08 +0200 Subject: [PATCH] WDSP receiver: implemented RIT and fixed audio binaural --- plugins/channelrx/wdsprx/wdsprxgui.cpp | 28 +++++ plugins/channelrx/wdsprx/wdsprxgui.h | 2 + plugins/channelrx/wdsprx/wdsprxgui.ui | 107 +++++++++++++++----- plugins/channelrx/wdsprx/wdsprxsettings.cpp | 16 +++ plugins/channelrx/wdsprx/wdsprxsettings.h | 16 ++- plugins/channelrx/wdsprx/wdsprxsink.cpp | 26 +++-- 6 files changed, 163 insertions(+), 32 deletions(-) diff --git a/plugins/channelrx/wdsprx/wdsprxgui.cpp b/plugins/channelrx/wdsprx/wdsprxgui.cpp index 05ed3c41e..4b87051c0 100644 --- a/plugins/channelrx/wdsprx/wdsprxgui.cpp +++ b/plugins/channelrx/wdsprx/wdsprxgui.cpp @@ -162,6 +162,7 @@ void WDSPRxGUI::on_audioBinaural_toggled(bool binaural) { m_audioBinaural = binaural; m_settings.m_audioBinaural = binaural; + m_settings.m_profiles[m_settings.m_profileIndex].m_audioBinaural = m_settings.m_audioBinaural; applySettings(); } @@ -169,6 +170,7 @@ void WDSPRxGUI::on_audioFlipChannels_toggled(bool flip) { m_audioFlipChannels = flip; m_settings.m_audioFlipChannels = flip; + m_settings.m_profiles[m_settings.m_profileIndex].m_audioFlipChannels = m_settings.m_audioFlipChannels; applySettings(); } @@ -265,6 +267,20 @@ void WDSPRxGUI::on_equalizer_toggled(bool checked) applySettings(); } +void WDSPRxGUI::on_rit_toggled(bool checked) +{ + m_settings.m_rit = checked; + m_settings.m_profiles[m_settings.m_profileIndex].m_rit = m_settings.m_rit; + applySettings(); +} + +void WDSPRxGUI::on_ritFrequency_valueChanged(int value) +{ + m_settings.m_ritFrequency = value; + ui->ritFrequencyText->setText(tr("%1").arg(value)); + applySettings(); +} + void WDSPRxGUI::on_audioMute_toggled(bool checked) { m_audioMute = checked; @@ -312,6 +328,9 @@ void WDSPRxGUI::on_profileIndex_valueChanged(int value) ui->lowCut->setMaximum(480); ui->lowCut->setMinimum(-480); m_settings.m_demod = m_settings.m_profiles[m_settings.m_profileIndex].m_demod; + m_settings.m_audioBinaural = m_settings.m_profiles[m_settings.m_profileIndex].m_audioBinaural; + m_settings.m_audioFlipChannels = m_settings.m_profiles[m_settings.m_profileIndex].m_audioFlipChannels; + m_settings.m_dsb = m_settings.m_profiles[m_settings.m_profileIndex].m_dsb; // AGC setup m_settings.m_agc = m_settings.m_profiles[m_settings.m_profileIndex].m_agc; m_settings.m_agcGain = m_settings.m_profiles[m_settings.m_profileIndex].m_agcGain; @@ -358,6 +377,9 @@ void WDSPRxGUI::on_profileIndex_valueChanged(int value) m_settings.m_equalizer = m_settings.m_profiles[m_settings.m_profileIndex].m_equalizer; m_settings.m_eqF = m_settings.m_profiles[m_settings.m_profileIndex].m_eqF; m_settings.m_eqG = m_settings.m_profiles[m_settings.m_profileIndex].m_eqG; + // RIT + m_settings.m_rit = m_settings.m_profiles[m_settings.m_profileIndex].m_rit; + m_settings.m_ritFrequency = m_settings.m_profiles[m_settings.m_profileIndex].m_ritFrequency; displaySettings(); applyBandwidths(m_settings.m_profiles[m_settings.m_profileIndex].m_spanLog2, true); // does applySettings(true) } @@ -709,6 +731,7 @@ void WDSPRxGUI::applyBandwidths(unsigned int spanLog2, bool force) ui->channelPowerMeter->setRange(WDSPRxSettings::m_minPowerThresholdDB, 0); m_settings.m_dsb = dsb; + m_settings.m_profiles[m_settings.m_profileIndex].m_dsb = dsb; m_settings.m_profiles[m_settings.m_profileIndex].m_spanLog2 = spanLog2; m_settings.m_profiles[m_settings.m_profileIndex].m_highCutoff = bw * 100; m_settings.m_profiles[m_settings.m_profileIndex].m_lowCutoff = lw * 100; @@ -780,6 +803,9 @@ void WDSPRxGUI::displaySettings() ui->squelchThreshold->setValue(m_settings.m_squelchThreshold); ui->squelchThresholdText->setText(tr("%1").arg(m_settings.m_squelchThreshold)); ui->equalizer->setChecked(m_settings.m_equalizer); + ui->rit->setChecked(m_settings.m_rit); + ui->ritFrequency->setValue((int) m_settings.m_ritFrequency); + ui->ritFrequencyText->setText(tr("%1").arg((int) m_settings.m_ritFrequency)); ui->audioBinaural->setChecked(m_settings.m_audioBinaural); ui->audioFlipChannels->setChecked(m_settings.m_audioFlipChannels); ui->audioMute->setChecked(m_settings.m_audioMute); @@ -1326,6 +1352,8 @@ void WDSPRxGUI::makeUIConnections() QObject::connect(ui->squelch, &ButtonSwitch::toggled, this, &WDSPRxGUI::on_squelch_toggled); QObject::connect(ui->squelchThreshold, &QDial::valueChanged, this, &WDSPRxGUI::on_squelchThreshold_valueChanged); QObject::connect(ui->equalizer, &ButtonSwitch::toggled, this, &WDSPRxGUI::on_equalizer_toggled); + QObject::connect(ui->rit, &ButtonSwitch::toggled, this, &WDSPRxGUI::on_rit_toggled); + QObject::connect(ui->ritFrequency, &QDial::valueChanged, this, &WDSPRxGUI::on_ritFrequency_valueChanged); } void WDSPRxGUI::updateAbsoluteCenterFrequency() diff --git a/plugins/channelrx/wdsprx/wdsprxgui.h b/plugins/channelrx/wdsprx/wdsprxgui.h index d80d168a0..807e4f307 100644 --- a/plugins/channelrx/wdsprx/wdsprxgui.h +++ b/plugins/channelrx/wdsprx/wdsprxgui.h @@ -147,6 +147,8 @@ private slots: void on_squelch_toggled(bool checked); void on_squelchThreshold_valueChanged(int value); void on_equalizer_toggled(bool checked); + void on_rit_toggled(bool checked); + void on_ritFrequency_valueChanged(int value); void onWidgetRolled(QWidget* widget, bool rollDown); void onMenuDialogCalled(const QPoint& p); void handleInputMessages(); diff --git a/plugins/channelrx/wdsprx/wdsprxgui.ui b/plugins/channelrx/wdsprx/wdsprxgui.ui index 3a2916937..d758ff25f 100644 --- a/plugins/channelrx/wdsprx/wdsprxgui.ui +++ b/plugins/channelrx/wdsprx/wdsprxgui.ui @@ -6,7 +6,7 @@ 0 0 - 514 + 542 179 @@ -18,7 +18,7 @@ - 452 + 542 0 @@ -36,13 +36,13 @@ 0 0 - 501 + 540 181 - 450 + 540 0 @@ -277,6 +277,53 @@ + + + + + 24 + 24 + + + + Select profile in profile bank + + + 0 + + + 9 + + + 1 + + + 0 + + + + + + + + 10 + 0 + + + + false + + + Filter index in filter bank + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -392,16 +439,10 @@ - 70 + 50 0 - - - 60 - 16777215 - - FFT filter window function @@ -421,7 +462,20 @@ - + + + Toggle RIT + + + RIT + + + true + + + + + 24 @@ -429,13 +483,13 @@ - Select profile in profile bank + RIT frequency (Hz) - 0 + -1000 - 9 + 1000 1 @@ -446,21 +500,18 @@ - + - 10 + 32 0 - - false - - Filter index in filter bank + RIT frequency (Hz) - 0 + -0000 Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -486,7 +537,7 @@ - Low cut + Near cut @@ -568,7 +619,7 @@ - Hi cut + Far cut @@ -822,11 +873,17 @@ + + + 20 + 0 + + Audio volume in dB - 10 + -10 Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter diff --git a/plugins/channelrx/wdsprx/wdsprxsettings.cpp b/plugins/channelrx/wdsprx/wdsprxsettings.cpp index c285d425f..2335b0b1c 100644 --- a/plugins/channelrx/wdsprx/wdsprxsettings.cpp +++ b/plugins/channelrx/wdsprx/wdsprxsettings.cpp @@ -94,6 +94,9 @@ void WDSPRxSettings::resetToDefaults() m_equalizer = false; m_eqF = {0.0, 32.0, 63.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 4000.0, 8000.0, 16000.0}; m_eqG = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + // RIT + m_rit = false; + m_ritFrequency = 0.0; // m_volume = 1.0; m_inputFrequencyOffset = 0; @@ -212,10 +215,15 @@ QByteArray WDSPRxSettings::serialize() const s.writeBlob( 80, m_geometryBytes); s.writeBool( 81, m_hidden); s.writeU32( 82, m_profileIndex); + s.writeBool( 83, m_rit); + s.writeDouble(84, m_ritFrequency); for (unsigned int i = 0; i < 10; i++) { s.writeS32 (104 + 100*i, (int) m_profiles[i].m_demod); + s.writeBool (105 + 100*i, (int) m_profiles[i].m_audioBinaural); + s.writeBool (106 + 100*i, (int) m_profiles[i].m_audioFlipChannels); + s.writeBool (107 + 100*i, (int) m_profiles[i].m_dsb); // Filter s.writeS32 (100 + 100*i, m_profiles[i].m_spanLog2); s.writeS32 (101 + 100*i, m_profiles[i].m_highCutoff / 100.0); @@ -409,6 +417,8 @@ bool WDSPRxSettings::deserialize(const QByteArray& data) d.readBool( 81, &m_hidden, false); d.readU32( 82, &utmp, 0); m_profileIndex = utmp < 10 ? utmp : 0; + d.readBool( 83, &m_rit, false); + d.readDouble( 84, &m_ritFrequency, 0); d.readBool( 90, &m_equalizer, false); d.readFloat(4000, &m_eqF[0], 0.0); @@ -438,6 +448,9 @@ bool WDSPRxSettings::deserialize(const QByteArray& data) { d.readS32 (104 + 100*i, &tmp, 9); m_profiles[i].m_demod = (WDSPRxProfile::WDSPRxDemod) tmp; + d.readBool( 105 + 100*i, &m_profiles[i].m_audioBinaural, false); + d.readBool( 106 + 100*i, &m_profiles[i].m_audioFlipChannels, false); + d.readBool( 107 + 100*i, &m_profiles[i].m_dsb, false); // Filter d.readS32 (100 + 100*i, &m_profiles[i].m_spanLog2, 3); d.readS32 (101 + 100*i, &tmp, 30); @@ -497,6 +510,9 @@ bool WDSPRxSettings::deserialize(const QByteArray& data) d.readDouble(163 + 100*i, &m_profiles[i].m_ssqlTauMute, 0.1); d.readDouble(164 + 100*i, &m_profiles[i].m_ssqlTauUnmute, 0.1); d.readDouble(165 + 100*i, &m_profiles[i].m_amsqMaxTail, 1.5); + // RIT + d.readBool( 183 + 100*i, &m_profiles[i].m_rit, false); + d.readDouble(184 + 100*i, &m_profiles[i].m_ritFrequency, 0.0); // Equalizer d.readBool( 190 + 100*i, &m_profiles[i].m_equalizer, false); d.readFloat(4100 + 100*i, &m_profiles[i].m_eqF[0], 0.0); diff --git a/plugins/channelrx/wdsprx/wdsprxsettings.h b/plugins/channelrx/wdsprx/wdsprxsettings.h index 35ab65deb..e40d442ff 100644 --- a/plugins/channelrx/wdsprx/wdsprxsettings.h +++ b/plugins/channelrx/wdsprx/wdsprxsettings.h @@ -86,6 +86,9 @@ struct WDSPRxProfile }; WDSPRxDemod m_demod; + bool m_audioBinaural; + bool m_audioFlipChannels; + bool m_dsb; // Filter int m_spanLog2; Real m_highCutoff; @@ -139,9 +142,15 @@ struct WDSPRxProfile bool m_equalizer; std::array m_eqF; //!< Frequencies vector. Index 0 is always 0 as this is the preamp position std::array m_eqG; //!< Gains vector (dB). Index 0 is the preamp (common) gain + // RIT + bool m_rit; + double m_ritFrequency; WDSPRxProfile() : m_demod(DemodSSB), + m_audioBinaural(false), + m_audioFlipChannels(false), + m_dsb(false), m_spanLog2(3), m_highCutoff(3000), m_lowCutoff(300), @@ -187,7 +196,9 @@ struct WDSPRxProfile m_amsqMaxTail(1.5), m_equalizer(false), m_eqF{0.0, 32.0, 63.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 4000.0, 8000.0, 16000.0}, - m_eqG{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0} + m_eqG{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + m_rit(false), + m_ritFrequency(0) {} }; @@ -251,6 +262,9 @@ struct WDSPRxSettings bool m_equalizer; std::array m_eqF = {0.0, 32.0, 63.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 4000.0, 8000.0, 16000.0}; //!< Frequencies vector. Index 0 is always 0 as this is the preamp position std::array m_eqG = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; //!< Gains vector (dB). Index 0 is the preamp (common) gain + // RIT + bool m_rit; + double m_ritFrequency; quint32 m_rgbColor; QString m_title; diff --git a/plugins/channelrx/wdsprx/wdsprxsink.cpp b/plugins/channelrx/wdsprx/wdsprxsink.cpp index acae5e8fc..b10eb716d 100644 --- a/plugins/channelrx/wdsprx/wdsprxsink.cpp +++ b/plugins/channelrx/wdsprx/wdsprxsink.cpp @@ -43,6 +43,7 @@ #include "amsq.hpp" #include "fmsq.hpp" #include "eq.hpp" +#include "shift.hpp" #include "wdsprxsink.h" @@ -357,6 +358,8 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force) << " m_nr2Gain: " << settings.m_nr2Gain << " m_nr2NPE: " << settings.m_nr2NPE << " m_nr2ArtifactReduction: " << settings.m_nr2ArtifactReduction + << " m_rit: " << settings.m_rit + << " m_ritFrequency: " << settings.m_ritFrequency << " m_streamIndex: " << settings.m_streamIndex << " m_useReverseAPI: " << settings.m_useReverseAPI << " m_reverseAPIAddress: " << settings.m_reverseAPIAddress @@ -365,6 +368,15 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force) << " m_reverseAPIChannelIndex: " << settings.m_reverseAPIChannelIndex << " force: " << force; + + // RIT + + if ((m_settings.m_rit != settings.m_rit) || (m_settings.m_ritFrequency != settings.m_ritFrequency) || force) + { + WDSP::SHIFT::SetShiftFreq(*m_rxa, settings.m_ritFrequency); + WDSP::SHIFT::SetShiftRun(*m_rxa, settings.m_rit ? 1 : 0); + } + // Filter and mode if((m_settings.m_profiles[m_settings.m_profileIndex].m_highCutoff != settings.m_profiles[settings.m_profileIndex].m_highCutoff) || @@ -735,12 +747,14 @@ void WDSPRxSink::applySettings(const WDSPRxSettings& settings, bool force) WDSP::PANEL::SetPanelGain1(*m_rxa, settings.m_volume); } - if ((m_settings.m_audioBinaural != settings.m_audioBinaural) || force) { - WDSP::PANEL::SetPanelBinaural(*m_rxa, settings.m_audioBinaural ? 1 : 0); - } - - if ((m_settings.m_audioFlipChannels != settings.m_audioFlipChannels) || force) { - WDSP::PANEL::SetPanelCopy(*m_rxa, settings.m_audioFlipChannels ? 3 : 0); + if ((m_settings.m_audioBinaural != settings.m_audioBinaural) + || (m_settings.m_audioFlipChannels != settings.m_audioFlipChannels) || force) + { + if (settings.m_audioBinaural) { + WDSP::PANEL::SetPanelCopy(*m_rxa, settings.m_audioFlipChannels ? 3 : 0); + } else { + WDSP::PANEL::SetPanelCopy(*m_rxa, settings.m_audioFlipChannels ? 2 : 1); + } } // AGC