1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-05-23 18:52:28 -04:00

Scope: corrected mean power dB overlay displays

This commit is contained in:
f4exb 2018-06-25 23:44:11 +02:00
parent 5f120fb2cb
commit facb282c23
2 changed files with 15 additions and 14 deletions

View File

@ -465,10 +465,10 @@ int ScopeVisNG::processTraces(const SampleVector::const_iterator& cbegin, const
} }
else if (projectionType == Projector::ProjectionMagDB) else if (projectionType == Projector::ProjectionMagDB)
{ {
// there is no processing advantage in direct calculation without projector Real re = begin->m_real / SDR_RX_SCALEF;
// uint32_t magsq = begin->m_real*begin->m_real + begin->m_imag*begin->m_imag; Real im = begin->m_imag / SDR_RX_SCALEF;
// v = ((log10f(magsq/1073741824.0f)*0.2f - 2.0f*itData->m_ofs) + 2.0f)*itData->m_amp - 1.0f; double magsq = re*re + im*im;
float pdB = (*itCtl)->m_projector.run(*begin); float pdB = log10f(magsq) * 10.0f;
float p = pdB - (100.0f * itData->m_ofs); float p = pdB - (100.0f * itData->m_ofs);
v = ((p/50.0f) + 2.0f)*itData->m_amp - 1.0f; v = ((p/50.0f) + 2.0f)*itData->m_amp - 1.0f;
@ -476,28 +476,29 @@ int ScopeVisNG::processTraces(const SampleVector::const_iterator& cbegin, const
{ {
if (traceCount == shift) if (traceCount == shift)
{ {
(*itCtl)->m_maxPow = -200.0f; (*itCtl)->m_maxPow = 0.0f;
(*itCtl)->m_sumPow = 0.0f; (*itCtl)->m_sumPow = 0.0f;
(*itCtl)->m_nbPow = 1; (*itCtl)->m_nbPow = 1;
} }
if (pdB > -200.0f) if (magsq > 0.0f)
{ {
if (pdB > (*itCtl)->m_maxPow) if (magsq > (*itCtl)->m_maxPow)
{ {
(*itCtl)->m_maxPow = pdB; (*itCtl)->m_maxPow = magsq;
} }
(*itCtl)->m_sumPow += pdB; (*itCtl)->m_sumPow += magsq;
(*itCtl)->m_nbPow++; (*itCtl)->m_nbPow++;
} }
} }
if ((m_nbSamples == 1) && ((*itCtl)->m_nbPow > 0)) // on last sample create power display overlay if ((m_nbSamples == 1) && ((*itCtl)->m_nbPow > 0)) // on last sample create power display overlay
{ {
double avgPow = (*itCtl)->m_sumPow / (*itCtl)->m_nbPow; double avgPow = log10f((*itCtl)->m_sumPow / (*itCtl)->m_nbPow)*10.0;
double peakToAvgPow = (*itCtl)->m_maxPow - avgPow; double peakPow = log10f((*itCtl)->m_maxPow)*10.0;
itData->m_textOverlay = QString("%1 %2 %3").arg((*itCtl)->m_maxPow, 0, 'f', 1).arg(avgPow, 0, 'f', 1).arg(peakToAvgPow, 4, 'f', 1, ' '); double peakToAvgPow = peakPow - avgPow;
itData->m_textOverlay = QString("%1 %2 %3").arg(peakPow, 0, 'f', 1).arg(avgPow, 0, 'f', 1).arg(peakToAvgPow, 4, 'f', 1, ' ');
(*itCtl)->m_nbPow = 0; (*itCtl)->m_nbPow = 0;
} }
} }

View File

@ -681,8 +681,8 @@ private:
{ {
Projector m_projector; //!< Projector transform from complex trace to real (displayable) trace Projector m_projector; //!< Projector transform from complex trace to real (displayable) trace
uint32_t m_traceCount[2]; //!< Count of samples processed (double buffered) uint32_t m_traceCount[2]; //!< Count of samples processed (double buffered)
Real m_maxPow; //!< Maximum power over the current trace for MagDB overlay display double m_maxPow; //!< Maximum power over the current trace for MagDB overlay display
Real m_sumPow; //!< Cumulative power over the current trace for MagDB overlay display double m_sumPow; //!< Cumulative power over the current trace for MagDB overlay display
int m_nbPow; //!< Number of power samples over the current trace for MagDB overlay display int m_nbPow; //!< Number of power samples over the current trace for MagDB overlay display
TraceControl() : m_projector(Projector::ProjectionReal) TraceControl() : m_projector(Projector::ProjectionReal)