mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-04-04 02:28:33 -04:00
Spectrum: use common constants for FFT size limits and set limits to 64 to 8k
This commit is contained in:
parent
986b6f3711
commit
aad48501a1
@ -63,6 +63,8 @@ public:
|
||||
bool m_usb; //!< USB display with increasing frequencies towads the right - else decreasing frequencies
|
||||
QString m_wsSpectrumAddress;
|
||||
uint16_t m_wsSpectrumPort;
|
||||
static const int m_log2FFTSizeMin = 6; // 64
|
||||
static const int m_log2FFTSizeMax = 13; // 8k
|
||||
|
||||
SpectrumSettings();
|
||||
virtual ~SpectrumSettings();
|
||||
|
@ -30,8 +30,6 @@
|
||||
|
||||
#include "spectrumvis.h"
|
||||
|
||||
#define MAX_FFT_SIZE 4096
|
||||
|
||||
#ifndef LINUX
|
||||
inline double log2(double n)
|
||||
{
|
||||
@ -53,9 +51,9 @@ SpectrumVis::SpectrumVis(Real scalef) :
|
||||
m_running(true),
|
||||
m_fft(nullptr),
|
||||
m_fftEngineSequence(0),
|
||||
m_fftBuffer(MAX_FFT_SIZE),
|
||||
m_powerSpectrum(MAX_FFT_SIZE),
|
||||
m_psd(MAX_FFT_SIZE),
|
||||
m_fftBuffer(4096),
|
||||
m_powerSpectrum(4096),
|
||||
m_psd(4096),
|
||||
m_fftBufferFill(0),
|
||||
m_needMoreSamples(false),
|
||||
m_frequencyZoomFactor(1.0f),
|
||||
@ -774,10 +772,10 @@ void SpectrumVis::applySettings(const SpectrumSettings& settings, bool force)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
int fftSize = settings.m_fftSize > MAX_FFT_SIZE ?
|
||||
MAX_FFT_SIZE :
|
||||
settings.m_fftSize < 64 ?
|
||||
64 :
|
||||
int fftSize = settings.m_fftSize > (1<<SpectrumSettings::m_log2FFTSizeMax) ?
|
||||
(1<<SpectrumSettings::m_log2FFTSizeMax) :
|
||||
settings.m_fftSize < (1<<SpectrumSettings::m_log2FFTSizeMin) ?
|
||||
(1<<SpectrumSettings::m_log2FFTSizeMin) :
|
||||
settings.m_fftSize;
|
||||
|
||||
qDebug() << "SpectrumVis::applySettings:"
|
||||
@ -808,6 +806,13 @@ void SpectrumVis::applySettings(const SpectrumSettings& settings, bool force)
|
||||
m_fftEngineSequence = fftFactory->getEngine(fftSize, false, &m_fft);
|
||||
m_ofs = 20.0f * log10f(1.0f / fftSize);
|
||||
m_powFFTDiv = fftSize * fftSize;
|
||||
|
||||
if (fftSize > m_settings.m_fftSize)
|
||||
{
|
||||
m_fftBuffer.resize(fftSize);
|
||||
m_powerSpectrum.resize(fftSize);
|
||||
m_psd.resize(fftSize);
|
||||
}
|
||||
}
|
||||
|
||||
if ((fftSize != m_settings.m_fftSize)
|
||||
|
@ -138,11 +138,11 @@ void GLSpectrumGUI::displaySettings()
|
||||
|
||||
ui->fftWindow->setCurrentIndex(m_settings.m_fftWindow);
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
for (int i = SpectrumSettings::m_log2FFTSizeMin; i <= SpectrumSettings::m_log2FFTSizeMax; i++)
|
||||
{
|
||||
if (m_settings.m_fftSize == (1 << (i + 7)))
|
||||
if (m_settings.m_fftSize == (1 << i))
|
||||
{
|
||||
ui->fftSize->setCurrentIndex(i);
|
||||
ui->fftSize->setCurrentIndex(i - SpectrumSettings::m_log2FFTSizeMin);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -236,7 +236,7 @@ void GLSpectrumGUI::on_fftWindow_currentIndexChanged(int index)
|
||||
void GLSpectrumGUI::on_fftSize_currentIndexChanged(int index)
|
||||
{
|
||||
qDebug("GLSpectrumGUI::on_fftSize_currentIndexChanged: %d", index);
|
||||
m_settings.m_fftSize = 1 << (7 + index);
|
||||
m_settings.m_fftSize = 1 << (SpectrumSettings::m_log2FFTSizeMin + index);
|
||||
setMaximumOverlap();
|
||||
applySettings();
|
||||
setAveragingToolitp();
|
||||
@ -576,7 +576,13 @@ void GLSpectrumGUI::setAveragingToolitp()
|
||||
|
||||
void GLSpectrumGUI::setFFTSize(int log2FFTSize)
|
||||
{
|
||||
ui->fftSize->setCurrentIndex(log2FFTSize < 7 ? 0 : log2FFTSize > 12 ? 5 : log2FFTSize - 7); // 128 to 4096 in powers of 2
|
||||
ui->fftSize->setCurrentIndex(
|
||||
log2FFTSize < SpectrumSettings::m_log2FFTSizeMin ?
|
||||
0
|
||||
: log2FFTSize > SpectrumSettings::m_log2FFTSizeMax ?
|
||||
SpectrumSettings::m_log2FFTSizeMax - SpectrumSettings::m_log2FFTSizeMin
|
||||
: log2FFTSize - SpectrumSettings::m_log2FFTSizeMin
|
||||
);
|
||||
}
|
||||
|
||||
void GLSpectrumGUI::setMaximumOverlap()
|
||||
|
@ -129,6 +129,11 @@
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>64</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>128</string>
|
||||
@ -159,6 +164,11 @@
|
||||
<string>4k</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>8k</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
Loading…
Reference in New Issue
Block a user