1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-12 19:36:10 -05:00

Spectrum averaging: added a no averaging mode that disables averaging completely

This commit is contained in:
f4exb 2018-07-01 22:36:36 +02:00
parent e88a0d6b57
commit 024fbf5525
5 changed files with 47 additions and 8 deletions

View File

@ -26,12 +26,12 @@ SpectrumVis::SpectrumVis(Real scalef, GLSpectrum* glSpectrum) :
m_scalef(scalef),
m_glSpectrum(glSpectrum),
m_averageNb(0),
m_averagingMode(AvgModeMoving),
m_averagingMode(AvgModeNone),
m_ofs(0),
m_mutex(QMutex::Recursive)
{
setObjectName("SpectrumVis");
handleConfigure(1024, 0, 0, AvgModeMoving, FFTWindow::BlackmanHarris);
handleConfigure(1024, 0, 0, AvgModeNone, FFTWindow::BlackmanHarris);
}
SpectrumVis::~SpectrumVis()
@ -111,7 +111,39 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV
Real v;
std::size_t halfSize = m_fftSize / 2;
if (m_averagingMode == AvgModeMoving)
if (m_averagingMode == AvgModeNone)
{
if ( positiveOnly )
{
for (std::size_t i = 0; i < halfSize; i++)
{
c = fftOut[i];
v = c.real() * c.real() + c.imag() * c.imag();
v = m_mult * log2f(v) + m_ofs;
m_logPowerSpectrum[i * 2] = v;
m_logPowerSpectrum[i * 2 + 1] = v;
}
}
else
{
for (std::size_t i = 0; i < halfSize; i++)
{
c = fftOut[i + halfSize];
v = c.real() * c.real() + c.imag() * c.imag();
v = m_mult * log2f(v) + m_ofs;
m_logPowerSpectrum[i] = v;
c = fftOut[i];
v = c.real() * c.real() + c.imag() * c.imag();
v = m_mult * log2f(v) + m_ofs;
m_logPowerSpectrum[i + halfSize] = v;
}
}
// send new data to visualisation
m_glSpectrum->newSpectrum(m_logPowerSpectrum, m_fftSize);
}
else if (m_averagingMode == AvgModeMoving)
{
if ( positiveOnly )
{

View File

@ -18,6 +18,7 @@ class SDRGUI_API SpectrumVis : public BasebandSampleSink {
public:
enum AveragingMode
{
AvgModeNone,
AvgModeMoving,
AvgModeFixed
};
@ -33,7 +34,7 @@ public:
m_averageNb(averageNb),
m_window(window)
{
m_averagingMode = averagingMode < 0 ? AvgModeMoving : averagingMode > 1 ? AvgModeFixed : (SpectrumVis::AveragingMode) averagingMode;
m_averagingMode = averagingMode < 0 ? AvgModeNone : averagingMode > 2 ? AvgModeFixed : (SpectrumVis::AveragingMode) averagingMode;
}
int getFFTSize() const { return m_fftSize; }

View File

@ -28,7 +28,7 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) :
m_displayHistogram(false),
m_displayGrid(false),
m_invert(true),
m_averagingMode(AvgModeMoving),
m_averagingMode(AvgModeNone),
m_averagingIndex(0),
m_averagingMaxScale(2),
m_averagingNb(0)
@ -75,7 +75,7 @@ void GLSpectrumGUI::resetToDefaults()
m_displayHistogram = false;
m_displayGrid = false;
m_invert = true;
m_averagingMode = AvgModeMoving;
m_averagingMode = AvgModeNone;
m_averagingIndex = 0;
applySettings();
}
@ -138,7 +138,7 @@ bool GLSpectrumGUI::deserialize(const QByteArray& data)
Real waterfallShare;
d.readReal(18, &waterfallShare, 0.66);
d.readS32(19, &tmp, 0);
m_averagingMode = tmp < 0 ? AvgModeMoving : tmp > 1 ? AvgModeFixed : (AveragingMode) tmp;
m_averagingMode = tmp < 0 ? AvgModeNone : tmp > 2 ? AvgModeFixed : (AveragingMode) tmp;
d.readS32(20, &tmp, 0);
m_averagingIndex = getAveragingIndex(tmp);
m_averagingNb = getAveragingValue(m_averagingIndex);
@ -235,7 +235,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;
m_averagingMode = index < 0 ? AvgModeNone : index > 2 ? AvgModeFixed : (AveragingMode) index;
if(m_spectrumVis != 0) {
m_spectrumVis->configure(m_messageQueueToVis,

View File

@ -20,6 +20,7 @@ class SDRGUI_API GLSpectrumGUI : public QWidget, public Serializable {
public:
enum AveragingMode
{
AvgModeNone,
AvgModeMoving,
AvgModeFixed
};

View File

@ -547,6 +547,11 @@
<property name="toolTip">
<string>Averaging type</string>
</property>
<item>
<property name="text">
<string>No</string>
</property>
</item>
<item>
<property name="text">
<string>Mov</string>