Skip to content

Commit

Permalink
Remove clamping from Y-coordinate calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
argilo committed Oct 2, 2023
1 parent 919a90a commit e5f95b2
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/qtgui/plotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1543,12 +1543,8 @@ void CPlotter::draw(bool newData)
{
const int ix = i + xmin;
const qreal ixPlot = (qreal)ix;
const qreal yMaxD = (qreal)std::max(std::min(
panddBGainFactor * (m_PandMaxdB - 10.0f * log10f(m_fftMaxBuf[ix])),
(float)plotHeight), 0.0f);
const qreal yAvgD = (qreal)std::max(std::min(
panddBGainFactor * (m_PandMaxdB - 10.0f * log10f(m_fftAvgBuf[ix])),
(float)plotHeight), 0.0f);
const qreal yMaxD = (qreal)(panddBGainFactor * (m_PandMaxdB - 10.0f * log10f(m_fftMaxBuf[ix])));
const qreal yAvgD = (qreal)(panddBGainFactor * (m_PandMaxdB - 10.0f * log10f(m_fftAvgBuf[ix])));

if (m_PlotMode == PLOT_MODE_HISTOGRAM)
{
Expand Down Expand Up @@ -1615,9 +1611,7 @@ void CPlotter::draw(bool newData)
{
const int ix = i + xmin;
const qreal ixPlot = (qreal)ix;
const qreal yMaxHoldD = (qreal)std::max(std::min(
panddBGainFactor * (m_PandMaxdB - 10.0f * log10f(m_fftMaxHoldBuf[ix])),
(float)plotHeight), 0.0f);
const qreal yMaxHoldD = (qreal)(panddBGainFactor * (m_PandMaxdB - 10.0f * log10f(m_fftMaxHoldBuf[ix])));
maxLineBuf[i] = QPointF(ixPlot, yMaxHoldD);
}
// NOT scaling to DPR due to performance
Expand All @@ -1635,9 +1629,7 @@ void CPlotter::draw(bool newData)
{
const int ix = i + xmin;
const qreal ixPlot = (qreal)ix;
const qreal yMinHoldD = (qreal)std::max(std::min(
panddBGainFactor * (m_PandMaxdB - 10.0f * log10f(m_fftMinHoldBuf[ix])),
(float)plotHeight), 0.0f);
const qreal yMinHoldD = (qreal)(panddBGainFactor * (m_PandMaxdB - 10.0f * log10f(m_fftMinHoldBuf[ix])));
maxLineBuf[i] = QPointF(ixPlot, yMinHoldD);
}
// NOT scaling to DPR due to performance
Expand Down Expand Up @@ -1685,9 +1677,7 @@ void CPlotter::draw(bool newData)
m_peakSmoothBuf[ix] = avgV;
if (vi == maxV && (vi > 2.0f * avgV) && (vi > 4.0f * minV))
{
const qreal y = (qreal)std::max(std::min(
panddBGainFactor * (m_PandMaxdB - 10.0f * log10f(vi)),
(float)plotHeight - 0.0f), 0.0f);
const qreal y = (qreal)(panddBGainFactor * (m_PandMaxdB - 10.0f * log10f(vi)));
m_Peaks[ix] = y;
}
}
Expand All @@ -1709,9 +1699,7 @@ void CPlotter::draw(bool newData)
const float avgV = sumV / (float)(pw2 * 2);
if (vi == maxV && (vi > 2.0f * avgV) && (vi > 4.0f * minV))
{
const qreal y = (qreal)std::max(std::min(
panddBGainFactor * (m_PandMaxdB - 10.0f * log10f(vi)),
(float)plotHeight - 0.0f), 0.0f);
const qreal y = (qreal)(panddBGainFactor * (m_PandMaxdB - 10.0f * log10f(vi)));

// Show the wider peak only if there is no very close narrow peak
bool found = false;
Expand Down

0 comments on commit e5f95b2

Please sign in to comment.