From 7d3389977052283426b90bb5073e37a4c0768fb1 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 9 Feb 2021 07:12:32 +0100 Subject: [PATCH] Spectrum overlap: basic implementation --- sdrbase/dsp/spectrumvis.cpp | 4 +- sdrgui/gui/glspectrumgui.cpp | 24 +- sdrgui/gui/glspectrumgui.h | 2 + sdrgui/gui/glspectrumgui.ui | 870 +++++++++++++++++++---------------- 4 files changed, 490 insertions(+), 410 deletions(-) diff --git a/sdrbase/dsp/spectrumvis.cpp b/sdrbase/dsp/spectrumvis.cpp index 7107bd7e8..8cc41c460 100644 --- a/sdrbase/dsp/spectrumvis.cpp +++ b/sdrbase/dsp/spectrumvis.cpp @@ -734,8 +734,8 @@ void SpectrumVis::applySettings(const GLSpectrumSettings& settings, bool force) if ((fftSize != m_settings.m_fftSize) || (settings.m_fftOverlap != m_settings.m_fftOverlap) || force) { - m_overlapSize = settings.m_fftOverlap >= fftSize ? fftSize - 1 : - settings.m_fftOverlap < 0 ? 0 : settings.m_fftOverlap; + m_overlapSize = settings.m_fftOverlap < 0 ? 0 : + settings.m_fftOverlap < fftSize/2 ? settings.m_fftOverlap : (fftSize/2) - 1; m_refillSize = fftSize - m_overlapSize; m_fftBufferFill = m_overlapSize; } diff --git a/sdrgui/gui/glspectrumgui.cpp b/sdrgui/gui/glspectrumgui.cpp index 2cfdad140..d120d8199 100644 --- a/sdrgui/gui/glspectrumgui.cpp +++ b/sdrgui/gui/glspectrumgui.cpp @@ -133,15 +133,18 @@ void GLSpectrumGUI::displaySettings() ui->fftWindow->setCurrentIndex(m_settings.m_fftWindow); - for (unsigned int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { - if (m_settings.m_fftSize == (1U << (i + 7))) + if (m_settings.m_fftSize == (1 << (i + 7))) { ui->fftSize->setCurrentIndex(i); break; } } + ui->fftOverlap->setValue(m_settings.m_fftOverlap); + ui->fftOverlapText->setText(tr("%1").arg(m_settings.m_fftOverlap)); + setMaximumOverlap(); ui->averaging->setCurrentIndex(m_settings.m_averagingIndex); ui->averagingMode->setCurrentIndex((int) m_settings.m_averagingMode); ui->linscale->setChecked(m_settings.m_linear); @@ -218,10 +221,20 @@ void GLSpectrumGUI::on_fftSize_currentIndexChanged(int index) { qDebug("GLSpectrumGUI::on_fftSize_currentIndexChanged: %d", index); m_settings.m_fftSize = 1 << (7 + index); + setMaximumOverlap(); applySettings(); setAveragingToolitp(); } +void GLSpectrumGUI::on_fftOverlap_valueChanged(int value) +{ + qDebug("GLSpectrumGUI::on_fftOverlap_valueChanged: %d", value); + m_settings.m_fftOverlap = value; + ui->fftOverlapText->setText(tr("%1").arg(m_settings.m_fftOverlap)); + setMaximumOverlap(); + applySettings(); +} + void GLSpectrumGUI::on_averagingMode_currentIndexChanged(int index) { qDebug("GLSpectrumGUI::on_averagingMode_currentIndexChanged: %d", index); @@ -501,6 +514,13 @@ void GLSpectrumGUI::setFFTSize(int log2FFTSize) ui->fftSize->setCurrentIndex(log2FFTSize < 7 ? 0 : log2FFTSize > 12 ? 5 : log2FFTSize - 7); // 128 to 4096 in powers of 2 } +void GLSpectrumGUI::setMaximumOverlap() +{ + ui->fftOverlap->setMaximum((m_settings.m_fftSize/2)-1); + int value = ui->fftOverlap->value(); + ui->fftOverlapText->setText(tr("%1").arg(value)); +} + bool GLSpectrumGUI::handleMessage(const Message& message) { if (GLSpectrum::MsgReportSampleRate::match(message)) diff --git a/sdrgui/gui/glspectrumgui.h b/sdrgui/gui/glspectrumgui.h index 41309ef89..d5edfbc79 100644 --- a/sdrgui/gui/glspectrumgui.h +++ b/sdrgui/gui/glspectrumgui.h @@ -79,11 +79,13 @@ private: void setNumberStr(int n, QString& s); void setNumberStr(float v, int decimalPlaces, QString& s); void setAveragingToolitp(); + void setMaximumOverlap(); bool handleMessage(const Message& message); private slots: void on_fftWindow_currentIndexChanged(int index); void on_fftSize_currentIndexChanged(int index); + void on_fftOverlap_valueChanged(int value); void on_refLevel_valueChanged(int value); void on_levelRange_valueChanged(int value); void on_decay_valueChanged(int index); diff --git a/sdrgui/gui/glspectrumgui.ui b/sdrgui/gui/glspectrumgui.ui index 233bb22d9..d958b1a7d 100644 --- a/sdrgui/gui/glspectrumgui.ui +++ b/sdrgui/gui/glspectrumgui.ui @@ -6,8 +6,8 @@ 0 0 - 420 - 75 + 397 + 112 @@ -19,7 +19,10 @@ Spectrum - + + + 3 + 2 @@ -32,11 +35,464 @@ 2 - - 3 - - - + + + + 3 + + + + + + 0 + 0 + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + FFT window function + + + QComboBox::AdjustToContents + + + + Bart + + + + + B-H + + + + + FT + + + + + Ham + + + + + Han + + + + + Rec + + + + + Kai + + + + + + + + + 0 + 0 + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + FFT size + + + QComboBox::AdjustToContents + + + + 128 + + + + + 256 + + + + + 512 + + + + + 1k + + + + + 2k + + + + + 4k + + + + + + + + + 24 + 24 + + + + FFT overlap + + + 63 + + + 1 + + + + + + + + 30 + 0 + + + + FFT overlap + + + 0000 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + Averaging type + + + + No + + + + + Mov + + + + + Fix + + + + + Max + + + + + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + Number of averaging samples + + + + 1 + + + + + 2 + + + + + 5 + + + + + 10 + + + + + 20 + + + + + 50 + + + + + 100 + + + + + 200 + + + + + 500 + + + + + 1k + + + + + 2k + + + + + 5k + + + + + 10k + + + + + 20k + + + + + 50k + + + + + 1e5 + + + + + 2e5 + + + + + 5e5 + + + + + 1M + + + + + + + + Play/Pause spectrum display + + + + :/pause.png + :/play.png:/pause.png + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 3 + + + + + + 50 + 24 + + + + + 50 + 16777215 + + + + Reference level (dB) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + -110 + + + 0 + + + + + + + + 45 + 24 + + + + + 45 + 16777215 + + + + Range (dB) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 1 + + + 100 + + + + + + + Logarithmic / Linear scale selection + + + + + + + :/logarithmic.png + :/linear.png:/logarithmic.png + + + true + + + + + + + Left: toggle websocket spectrum - Right: websocket spectrum parameters + + + + :/stream.png + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 3 @@ -311,21 +767,6 @@ - - - - Play/Pause spectrum display - - - - :/pause.png - :/play.png:/pause.png - - - true - - - @@ -341,389 +782,6 @@ - - - - 3 - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - FFT window function - - - QComboBox::AdjustToContents - - - - Bart - - - - - B-H - - - - - FT - - - - - Ham - - - - - Han - - - - - Rec - - - - - Kai - - - - - - - - - 0 - 0 - - - - - 45 - 0 - - - - - 45 - 16777215 - - - - FFT size - - - QComboBox::AdjustToContents - - - - 128 - - - - - 256 - - - - - 512 - - - - - 1k - - - - - 2k - - - - - 4k - - - - - - - - - 50 - 24 - - - - - 50 - 16777215 - - - - Reference level (dB) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - -110 - - - 0 - - - - - - - - 45 - 24 - - - - - 45 - 16777215 - - - - Range (dB) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1 - - - 100 - - - - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - Averaging type - - - - No - - - - - Mov - - - - - Fix - - - - - Max - - - - - - - - - 45 - 0 - - - - - 45 - 16777215 - - - - Number of averaging samples - - - - 1 - - - - - 2 - - - - - 5 - - - - - 10 - - - - - 20 - - - - - 50 - - - - - 100 - - - - - 200 - - - - - 500 - - - - - 1k - - - - - 2k - - - - - 5k - - - - - 10k - - - - - 20k - - - - - 50k - - - - - 1e5 - - - - - 2e5 - - - - - 5e5 - - - - - 1M - - - - - - - - Logarithmic / Linear scale selection - - - - - - - :/logarithmic.png - :/linear.png:/logarithmic.png - - - true - - - - - - - Left: toggle websocket spectrum - Right: websocket spectrum parameters - - - - :/stream.png - - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - -