diff --git a/plugins/channelrx/localsink/localsinkgui.cpp b/plugins/channelrx/localsink/localsinkgui.cpp index b3de4abe5..9a876bc75 100644 --- a/plugins/channelrx/localsink/localsinkgui.cpp +++ b/plugins/channelrx/localsink/localsinkgui.cpp @@ -210,6 +210,7 @@ void LocalSinkGUI::displaySettings() ui->fft->setChecked(m_settings.m_fftOn); ui->fftSize->setCurrentIndex(m_settings.m_log2FFT-6); ui->fftWindow->setCurrentIndex((int) m_settings.m_fftWindow); + ui->fftFilterReverse->setChecked(m_settings.m_reverseFilter); ui->filterF2orW->setChecked(m_showFilterHighCut); applyDecimation(); updateIndexLabel(); @@ -459,6 +460,13 @@ void LocalSinkGUI::on_fftWindow_currentIndexChanged(int index) applySettings(); } +void LocalSinkGUI::on_fftFilterReverse_toggled(bool checked) +{ + m_settings.m_reverseFilter = checked; + m_settingsKeys.append("reverseFilter"); + applySettings(); +} + void LocalSinkGUI::on_fftBandAdd_clicked() { if (m_settings.m_fftBands.size() == m_settings.m_maxFFTBands) { @@ -572,6 +580,7 @@ void LocalSinkGUI::makeUIConnections() QObject::connect(ui->fft, &ButtonSwitch::toggled, this, &LocalSinkGUI::on_fft_toggled); QObject::connect(ui->fftSize, QOverload::of(&QComboBox::currentIndexChanged), this, &LocalSinkGUI::on_fftSize_currentIndexChanged); QObject::connect(ui->fftWindow, QOverload::of(&QComboBox::currentIndexChanged), this, &LocalSinkGUI::on_fftWindow_currentIndexChanged); + QObject::connect(ui->fftFilterReverse, &ButtonSwitch::toggled, this, &LocalSinkGUI::on_fftFilterReverse_toggled); QObject::connect(ui->fftBandAdd, &QPushButton::clicked, this, &LocalSinkGUI::on_fftBandAdd_clicked); QObject::connect(ui->fftBandDel, &QPushButton::clicked, this, &LocalSinkGUI::on_fftBandDel_clicked); QObject::connect(ui->bandIndex, &QSlider::valueChanged, this, &LocalSinkGUI::on_bandIndex_valueChanged); diff --git a/plugins/channelrx/localsink/localsinkgui.h b/plugins/channelrx/localsink/localsinkgui.h index 39ba9d713..948322816 100644 --- a/plugins/channelrx/localsink/localsinkgui.h +++ b/plugins/channelrx/localsink/localsinkgui.h @@ -114,6 +114,7 @@ private slots: void on_fft_toggled(bool checked); void on_fftSize_currentIndexChanged(int index); void on_fftWindow_currentIndexChanged(int index); + void on_fftFilterReverse_toggled(bool checked); void on_fftBandAdd_clicked(); void on_fftBandDel_clicked(); void on_bandIndex_valueChanged(int value); diff --git a/plugins/channelrx/localsink/localsinksettings.cpp b/plugins/channelrx/localsink/localsinksettings.cpp index e830e6b2a..06ac63226 100644 --- a/plugins/channelrx/localsink/localsinksettings.cpp +++ b/plugins/channelrx/localsink/localsinksettings.cpp @@ -43,6 +43,7 @@ void LocalSinkSettings::resetToDefaults() m_fftOn = false; m_log2FFT = 10; m_fftWindow = FFTWindow::Function::Rectangle; + m_reverseFilter = false; m_streamIndex = 0; m_useReverseAPI = false; m_reverseAPIAddress = "127.0.0.1"; @@ -89,6 +90,7 @@ QByteArray LocalSinkSettings::serialize() const s.writeBool(22, m_fftOn); s.writeU32(23, (int) m_fftWindow); + s.writeBool(24, m_reverseFilter); s.writeU32(99, m_fftBands.size()); int i = 0; @@ -175,6 +177,7 @@ bool LocalSinkSettings::deserialize(const QByteArray& data) m_fftWindow = (utmp > (uint32_t) FFTWindow::Function::BlackmanHarris7) ? FFTWindow::Function::BlackmanHarris7 : (FFTWindow::Function) utmp; + d.readBool(24, &m_reverseFilter, false); uint32_t nbBands; d.readU32(99, &nbBands, 0); @@ -232,6 +235,9 @@ void LocalSinkSettings::applySettings(const QStringList& settingsKeys, const Loc if (settingsKeys.contains("fftWindow")) { m_fftWindow = settings.m_fftWindow; } + if (settingsKeys.contains("reverseFilter")) { + m_reverseFilter = settings.m_reverseFilter; + } if (settingsKeys.contains("streamIndex")) { m_streamIndex = settings.m_streamIndex; } @@ -295,6 +301,9 @@ QString LocalSinkSettings::getDebugString(const QStringList& settingsKeys, bool if (settingsKeys.contains("fftWindow") || force) { ostr << " m_fftWindow: " << m_fftWindow; } + if (settingsKeys.contains("reverseFilter") || force) { + ostr << " m_reverseFilter: " << m_reverseFilter; + } if (settingsKeys.contains("streamIndex") || force) { ostr << " m_streamIndex: " << m_streamIndex; } diff --git a/plugins/channelrx/localsink/localsinksettings.h b/plugins/channelrx/localsink/localsinksettings.h index b03c8c839..c4562bbd8 100644 --- a/plugins/channelrx/localsink/localsinksettings.h +++ b/plugins/channelrx/localsink/localsinksettings.h @@ -38,6 +38,7 @@ struct LocalSinkSettings bool m_fftOn; uint32_t m_log2FFT; FFTWindow::Function m_fftWindow; + bool m_reverseFilter; static const uint32_t m_maxFFTBands = 20; std::vector> m_fftBands; int m_streamIndex; //!< MIMO channel. Not relevant when connected to SI (single Rx). diff --git a/plugins/channelrx/localsink/localsinksink.cpp b/plugins/channelrx/localsink/localsinksink.cpp index 9ab7578b8..fa1462bd0 100644 --- a/plugins/channelrx/localsink/localsinksink.cpp +++ b/plugins/channelrx/localsink/localsinksink.cpp @@ -199,9 +199,10 @@ void LocalSinkSink::applySettings(const LocalSinkSettings& settings, const QList if (settingsKeys.contains("fftWindow") || settingsKeys.contains("fftBands") + || settingsKeys.contains("reverseFilter") || force) { - m_fftFilter->create_filter(settings.m_fftBands, true, settings.m_fftWindow); + m_fftFilter->create_filter(settings.m_fftBands, !settings.m_reverseFilter, settings.m_fftWindow); } if (force) { diff --git a/sdrbase/dsp/fftfilt.cpp b/sdrbase/dsp/fftfilt.cpp index 11d2daee1..8d2391a13 100644 --- a/sdrbase/dsp/fftfilt.cpp +++ b/sdrbase/dsp/fftfilt.cpp @@ -227,7 +227,8 @@ void fftfilt::create_filter(const std::vector>& limits, } else // reject { - if ((i >= f1*flen) && (i <= f2*flen)) { + if ((i >= f1*flen) && (i <= f2*flen)) + { if (i < flen2) { canvasNeg[flen2-1-i] = 0; } else { @@ -242,11 +243,12 @@ void fftfilt::create_filter(const std::vector>& limits, std::vector> indexesPosList; int cn = 0; int cp = 0; + int defaultSecond = pass ? 0 : flen2 - 1; for (int i = 0; i < flen2; i++) { if ((canvasNeg[i] == 1) && (cn == 0)) { - indexesNegList.push_back(std::pair{i, 0}); + indexesNegList.push_back(std::pair{i, defaultSecond}); } if ((canvasNeg[i] == 0) && (cn == 1)) { @@ -254,7 +256,7 @@ void fftfilt::create_filter(const std::vector>& limits, } if ((canvasPos[i] == 1) && (cp == 0)) { - indexesPosList.push_back(std::pair{i, 0}); + indexesPosList.push_back(std::pair{i, defaultSecond}); } if ((canvasPos[i] == 0) && (cp == 1)) {