From 5bdee74205aac0f20147d4aab449e00a131b41d3 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 18 Mar 2020 14:23:35 +1100 Subject: [PATCH] waveformview: corrected rectified waveform algorithm Fixed bug where code erroneously multipled by full channel height. This is an incorrect assumption since the full range of -1.0 to 1.0 is 2.0 which means the difference needs to be halfed to create a range from 0.0 to 1.0. --- app/widget/viewer/waveformview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/widget/viewer/waveformview.cpp b/app/widget/viewer/waveformview.cpp index c57ea502f..ec695a4c1 100644 --- a/app/widget/viewer/waveformview.cpp +++ b/app/widget/viewer/waveformview.cpp @@ -69,7 +69,7 @@ void WaveformView::DrawWaveform(QPainter *painter, const QRect& rect, const doub if (Config::Current()[QStringLiteral("RectifiedWaveforms")].toBool()) { int channel_bottom = rect.y() + channel_height * (j + 1); - int diff = qRound((summary.at(j).max - summary.at(j).min) * channel_height); + int diff = qRound((summary.at(j).max - summary.at(j).min) * channel_half_height); painter->drawLine(line_x, channel_bottom - diff, @@ -135,7 +135,7 @@ void WaveformView::paintEvent(QPaintEvent *event) if (Config::Current()[QStringLiteral("RectifiedWaveforms")].toBool()) { int channel_bottom = channel_height * (i + 1); - int diff = qRound((samples.at(i).max - samples.at(i).min) * channel_height); + int diff = qRound((samples.at(i).max - samples.at(i).min) * channel_half_height); p.drawLine(x, channel_bottom - diff,