1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 09:18:54 -05:00

Spectrum: limit averaging depth to 1000 when in moving average mode to avoid memory exhaustion

This commit is contained in:
f4exb 2018-10-16 23:56:09 +02:00
parent efb48ce1cc
commit 673a145490
4 changed files with 18 additions and 2 deletions

1
debian/changelog vendored
View File

@ -1,6 +1,7 @@
sdrangel (4.2.3-1) unstable; urgency=medium
* Scope: fixed channel rate affecting scope in memory mode. Issue #227
* Spectrum: limit depth to 1000 when in moving average mode to avoid RAM exhaustion
-- Edouard Griffiths, F4EXB <f4exb06@gmail.com> Sun, 21 Oct 2018 21:14:18 +0200

View File

@ -364,7 +364,7 @@ void SpectrumVis::handleConfigure(int fftSize,
m_overlapSize = (m_fftSize * m_overlapPercent) / 100;
m_refillSize = m_fftSize - m_overlapSize;
m_fftBufferFill = m_overlapSize;
m_movingAverage.resize(fftSize, averageNb);
m_movingAverage.resize(fftSize, averageNb > 1000 ? 1000 : averageNb); // Capping to avoid out of memory condition
m_fixedAverage.resize(fftSize, averageNb);
m_max.resize(fftSize, averageNb);
m_averageNb = averageNb;

View File

@ -246,6 +246,18 @@ void GLSpectrumGUI::on_averagingMode_currentIndexChanged(int index)
{
m_averagingMode = index < 0 ? AvgModeNone : index > 3 ? AvgModeMax : (AveragingMode) index;
if (m_averagingMode == AvgModeMoving)
{
m_averagingMaxScale = 2;
setAveragingCombo();
m_averagingNb = m_averagingNb > 1000 ? 1000 : m_averagingNb;
}
else
{
m_averagingMaxScale = 5;
setAveragingCombo();
}
if(m_spectrumVis != 0) {
m_spectrumVis->configure(m_messageQueueToVis,
m_fftSize,
@ -507,6 +519,7 @@ int GLSpectrumGUI::getAveragingValue(int averagingIndex) const
void GLSpectrumGUI::setAveragingCombo()
{
int index = ui->averaging->currentIndex();
ui->averaging->clear();
ui->averaging->addItem(QString("1"));
@ -524,6 +537,8 @@ void GLSpectrumGUI::setAveragingCombo()
setNumberStr(x, s);
ui->averaging->addItem(s);
}
ui->averaging->setCurrentIndex(index >= ui->averaging->count() ? ui->averaging->count() - 1 : index);
}
void GLSpectrumGUI::setNumberStr(int n, QString& s)

View File

@ -273,7 +273,7 @@ Use this combo to select which averaging mode is applied:
<h4>4.6. Number of averaged samples</h4>
Each FFT bin (squared magnitude) is averaged or max'ed over a number of samples. This combo allows selecting the number of samples between these values: 1 (no averaging), 2, 5, 10, 20, 50, 100, 200, 500, 1k (1000), 2k, 5k, 10k, 20k, 50k, 1e5 (100000), 2e5, 5e5, 1M (1000000). The tooltip mentions the resulting averaging period considering the baseband sample rate and FFT size.
Each FFT bin (squared magnitude) is averaged or max'ed over a number of samples. This combo allows selecting the number of samples between these values: 1 (no averaging), 2, 5, 10, 20, 50, 100, 200, 500, 1k (1000) for all modes and in addition 2k, 5k, 10k, 20k, 50k, 1e5 (100000), 2e5, 5e5, 1M (1000000) for "fixed" and "max" modes. The tooltip mentions the resulting averaging period considering the baseband sample rate and FFT size.
Averaging reduces the noise variance and can be used to better detect weak continuous signals. The fixed averaging mode allows long time monitoring on the waterfall. The max mode helps showing short bursts that may appear during the "averaging" period.
&#9758; Note: The spectrum display is refreshed every 50ms (20 FPS). Setting an averaging time above this value will make sure that a short burst is not missed particularly when using the max mode.