1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 12:51:49 -05:00

Spectrum averaging: fixed average (2)

This commit is contained in:
f4exb 2018-07-01 03:11:36 +02:00
parent 56e49baa3b
commit 0b496bd800
5 changed files with 31 additions and 3 deletions

View File

@ -38,6 +38,7 @@ GLSpectrum::GLSpectrum(QWidget* parent) :
m_powerRange(100),
m_decay(0),
m_sampleRate(500000),
m_timingRate(1),
m_fftSize(512),
m_displayGrid(true),
m_displayGridIntensity(5),
@ -196,6 +197,13 @@ void GLSpectrum::setSampleRate(qint32 sampleRate)
update();
}
void GLSpectrum::setTimingRate(qint32 timingRate)
{
m_timingRate = timingRate;
m_changesPending = true;
update();
}
void GLSpectrum::setDisplayWaterfall(bool display)
{
m_displayWaterfall = display;
@ -1043,7 +1051,7 @@ void GLSpectrum::applyChanges()
if(m_sampleRate > 0)
{
float scaleDiv = (float)m_sampleRate * (m_ssbSpectrum ? 2 : 1);
float scaleDiv = ((float)m_sampleRate / (float)m_timingRate) * (m_ssbSpectrum ? 2 : 1);
if(!m_invertedWaterfall)
{

View File

@ -46,6 +46,7 @@ public:
void setCenterFrequency(qint64 frequency);
void setSampleRate(qint32 sampleRate);
void setTimingRate(qint32 timingRate);
void setReferenceLevel(Real referenceLevel);
void setPowerRange(Real powerRange);
void setDecay(int decay);
@ -110,6 +111,7 @@ private:
Real m_powerRange;
int m_decay;
quint32 m_sampleRate;
quint32 m_timingRate;
int m_fftSize;

View File

@ -229,6 +229,7 @@ void GLSpectrumGUI::on_fftSize_currentIndexChanged(int index)
void GLSpectrumGUI::on_averagingMode_currentIndexChanged(int index)
{
m_averagingMode = index < 0 ? AvgModeMoving : index > 1 ? AvgModeFixed : (AveragingMode) index;
if(m_spectrumVis != 0) {
m_spectrumVis->configure(m_messageQueue,
m_fftSize,
@ -237,12 +238,22 @@ void GLSpectrumGUI::on_averagingMode_currentIndexChanged(int index)
m_averagingMode,
(FFTWindow::Function)m_fftWindow);
}
if (m_glSpectrum != 0)
{
if (m_averagingMode == AvgModeFixed) {
m_glSpectrum->setTimingRate(m_averagingNb == 0 ? 1 : m_averagingNb);
} else {
m_glSpectrum->setTimingRate(1);
}
}
}
void GLSpectrumGUI::on_averaging_currentIndexChanged(int index)
{
m_averagingIndex = index;
m_averagingNb = getAveragingValue(index);
if(m_spectrumVis != 0) {
m_spectrumVis->configure(m_messageQueue,
m_fftSize,
@ -251,6 +262,13 @@ void GLSpectrumGUI::on_averaging_currentIndexChanged(int index)
m_averagingMode,
(FFTWindow::Function)m_fftWindow);
}
if (m_glSpectrum != 0)
{
if (m_averagingMode == AvgModeFixed) {
m_glSpectrum->setTimingRate(m_averagingNb == 0 ? 1 : m_averagingNb);
}
}
}
void GLSpectrumGUI::on_refLevel_currentIndexChanged(int index)

View File

@ -29,7 +29,7 @@ static double trunc(double d)
QString ScaleEngine::formatTick(double value, int decimalPlaces, bool fancyTime)
{
if((m_physicalUnit != Unit::Time) || (!fancyTime) || 1)
if((m_physicalUnit != Unit::Time) || (!fancyTime))
{
return QString("%1").arg(m_makeOpposite ? -value : value, 0, 'f', decimalPlaces);
}

View File

@ -58,7 +58,7 @@ private:
int m_decimalPlaces;
bool m_makeOpposite; // will show -value instead of value
QString formatTick(double value, int decimalPlaces, bool fancyTime = true);
QString formatTick(double value, int decimalPlaces, bool fancyTime = false);
void calcCharSize();
void calcScaleFactor();
double calcMajorTickUnits(double distance, int* retDecimalPlaces);