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

Spectrum overlap: basic implementation

This commit is contained in:
f4exb 2021-02-09 07:12:32 +01:00
parent 59d0ea671b
commit 7d33899770
4 changed files with 490 additions and 410 deletions

View File

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

View File

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

View File

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

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>75</height>
<width>397</width>
<height>112</height>
</rect>
</property>
<property name="font">
@ -19,7 +19,10 @@
<property name="windowTitle">
<string>Spectrum</string>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
@ -32,11 +35,464 @@
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="Line1Layout">
<property name="spacing">
<number>3</number>
</property>
<item row="3" column="0" colspan="3">
<layout class="QHBoxLayout" name="controlBtns">
<item>
<widget class="QComboBox" name="fftWindow">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>FFT window function</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>Bart</string>
</property>
</item>
<item>
<property name="text">
<string>B-H</string>
</property>
</item>
<item>
<property name="text">
<string>FT</string>
</property>
</item>
<item>
<property name="text">
<string>Ham</string>
</property>
</item>
<item>
<property name="text">
<string>Han</string>
</property>
</item>
<item>
<property name="text">
<string>Rec</string>
</property>
</item>
<item>
<property name="text">
<string>Kai</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="fftSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>45</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>45</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>FFT size</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>128</string>
</property>
</item>
<item>
<property name="text">
<string>256</string>
</property>
</item>
<item>
<property name="text">
<string>512</string>
</property>
</item>
<item>
<property name="text">
<string>1k</string>
</property>
</item>
<item>
<property name="text">
<string>2k</string>
</property>
</item>
<item>
<property name="text">
<string>4k</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QDial" name="fftOverlap">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>FFT overlap</string>
</property>
<property name="maximum">
<number>63</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fftOverlapText">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>FFT overlap</string>
</property>
<property name="text">
<string>0000</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="averagingMode">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Averaging type</string>
</property>
<item>
<property name="text">
<string>No</string>
</property>
</item>
<item>
<property name="text">
<string>Mov</string>
</property>
</item>
<item>
<property name="text">
<string>Fix</string>
</property>
</item>
<item>
<property name="text">
<string>Max</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="averaging">
<property name="minimumSize">
<size>
<width>45</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>45</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Number of averaging samples</string>
</property>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>5</string>
</property>
</item>
<item>
<property name="text">
<string>10</string>
</property>
</item>
<item>
<property name="text">
<string>20</string>
</property>
</item>
<item>
<property name="text">
<string>50</string>
</property>
</item>
<item>
<property name="text">
<string>100</string>
</property>
</item>
<item>
<property name="text">
<string>200</string>
</property>
</item>
<item>
<property name="text">
<string>500</string>
</property>
</item>
<item>
<property name="text">
<string>1k</string>
</property>
</item>
<item>
<property name="text">
<string>2k</string>
</property>
</item>
<item>
<property name="text">
<string>5k</string>
</property>
</item>
<item>
<property name="text">
<string>10k</string>
</property>
</item>
<item>
<property name="text">
<string>20k</string>
</property>
</item>
<item>
<property name="text">
<string>50k</string>
</property>
</item>
<item>
<property name="text">
<string>1e5</string>
</property>
</item>
<item>
<property name="text">
<string>2e5</string>
</property>
</item>
<item>
<property name="text">
<string>5e5</string>
</property>
</item>
<item>
<property name="text">
<string>1M</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="freeze">
<property name="toolTip">
<string>Play/Pause spectrum display</string>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/pause.png</normaloff>
<normalon>:/play.png</normalon>:/pause.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="Line2Layout">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QSpinBox" name="refLevel">
<property name="minimumSize">
<size>
<width>50</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Reference level (dB)</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>-110</number>
</property>
<property name="maximum">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="levelRange">
<property name="minimumSize">
<size>
<width>45</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>45</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Range (dB)</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="linscale">
<property name="toolTip">
<string>Logarithmic / Linear scale selection</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/logarithmic.png</normaloff>
<normalon>:/linear.png</normalon>:/logarithmic.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="wsSpectrum">
<property name="toolTip">
<string>Left: toggle websocket spectrum - Right: websocket spectrum parameters</string>
</property>
<property name="icon">
<iconset>
<normalon>:/stream.png</normalon>
</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="Line3Layout">
<property name="spacing">
<number>3</number>
</property>
@ -311,21 +767,6 @@
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="freeze">
<property name="toolTip">
<string>Play/Pause spectrum display</string>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/pause.png</normaloff>
<normalon>:/play.png</normalon>:/pause.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
@ -341,389 +782,6 @@
</item>
</layout>
</item>
<item row="2" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QComboBox" name="fftWindow">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>FFT window function</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>Bart</string>
</property>
</item>
<item>
<property name="text">
<string>B-H</string>
</property>
</item>
<item>
<property name="text">
<string>FT</string>
</property>
</item>
<item>
<property name="text">
<string>Ham</string>
</property>
</item>
<item>
<property name="text">
<string>Han</string>
</property>
</item>
<item>
<property name="text">
<string>Rec</string>
</property>
</item>
<item>
<property name="text">
<string>Kai</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="fftSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>45</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>45</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>FFT size</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>128</string>
</property>
</item>
<item>
<property name="text">
<string>256</string>
</property>
</item>
<item>
<property name="text">
<string>512</string>
</property>
</item>
<item>
<property name="text">
<string>1k</string>
</property>
</item>
<item>
<property name="text">
<string>2k</string>
</property>
</item>
<item>
<property name="text">
<string>4k</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QSpinBox" name="refLevel">
<property name="minimumSize">
<size>
<width>50</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Reference level (dB)</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>-110</number>
</property>
<property name="maximum">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="levelRange">
<property name="minimumSize">
<size>
<width>45</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>45</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Range (dB)</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="averagingMode">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Averaging type</string>
</property>
<item>
<property name="text">
<string>No</string>
</property>
</item>
<item>
<property name="text">
<string>Mov</string>
</property>
</item>
<item>
<property name="text">
<string>Fix</string>
</property>
</item>
<item>
<property name="text">
<string>Max</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="averaging">
<property name="minimumSize">
<size>
<width>45</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>45</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Number of averaging samples</string>
</property>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>5</string>
</property>
</item>
<item>
<property name="text">
<string>10</string>
</property>
</item>
<item>
<property name="text">
<string>20</string>
</property>
</item>
<item>
<property name="text">
<string>50</string>
</property>
</item>
<item>
<property name="text">
<string>100</string>
</property>
</item>
<item>
<property name="text">
<string>200</string>
</property>
</item>
<item>
<property name="text">
<string>500</string>
</property>
</item>
<item>
<property name="text">
<string>1k</string>
</property>
</item>
<item>
<property name="text">
<string>2k</string>
</property>
</item>
<item>
<property name="text">
<string>5k</string>
</property>
</item>
<item>
<property name="text">
<string>10k</string>
</property>
</item>
<item>
<property name="text">
<string>20k</string>
</property>
</item>
<item>
<property name="text">
<string>50k</string>
</property>
</item>
<item>
<property name="text">
<string>1e5</string>
</property>
</item>
<item>
<property name="text">
<string>2e5</string>
</property>
</item>
<item>
<property name="text">
<string>5e5</string>
</property>
</item>
<item>
<property name="text">
<string>1M</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QToolButton" name="linscale">
<property name="toolTip">
<string>Logarithmic / Linear scale selection</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/logarithmic.png</normaloff>
<normalon>:/linear.png</normalon>:/logarithmic.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="wsSpectrum">
<property name="toolTip">
<string>Left: toggle websocket spectrum - Right: websocket spectrum parameters</string>
</property>
<property name="icon">
<iconset>
<normalon>:/stream.png</normalon>
</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>