1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

Local Sink: implemented reverse FFT bands

This commit is contained in:
f4exb 2022-12-13 07:00:50 +01:00
parent c42d163d3b
commit 66d4c665c8
6 changed files with 27 additions and 4 deletions

View File

@ -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<int>::of(&QComboBox::currentIndexChanged), this, &LocalSinkGUI::on_fftSize_currentIndexChanged);
QObject::connect(ui->fftWindow, QOverload<int>::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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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<std::pair<float, float>> m_fftBands;
int m_streamIndex; //!< MIMO channel. Not relevant when connected to SI (single Rx).

View File

@ -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) {

View File

@ -227,7 +227,8 @@ void fftfilt::create_filter(const std::vector<std::pair<float, float>>& 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<std::pair<float, float>>& limits,
std::vector<std::pair<int,int>> 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<int,int>{i, 0});
indexesNegList.push_back(std::pair<int,int>{i, defaultSecond});
}
if ((canvasNeg[i] == 0) && (cn == 1)) {
@ -254,7 +256,7 @@ void fftfilt::create_filter(const std::vector<std::pair<float, float>>& limits,
}
if ((canvasPos[i] == 1) && (cp == 0)) {
indexesPosList.push_back(std::pair<int,int>{i, 0});
indexesPosList.push_back(std::pair<int,int>{i, defaultSecond});
}
if ((canvasPos[i] == 0) && (cp == 1)) {