From bf0f5a0c069117ebb97908e4aeb7ed2d307825ac Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 22 Jan 2020 11:07:33 -0500 Subject: [PATCH] Supress Windows-only LFO spikes (#1497) Windows VSTGUI with the ordering we chose for points drew specious spikes. Re-order the points to avoid this potential bug. Closes #1438 --- src/common/gui/CLFOGui.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/common/gui/CLFOGui.cpp b/src/common/gui/CLFOGui.cpp index 63b5145b096..2042ba7b9d4 100644 --- a/src/common/gui/CLFOGui.cpp +++ b/src/common/gui/CLFOGui.cpp @@ -162,6 +162,7 @@ void CLFOGui::drawVectorized(CDrawContext* dc) #endif int susCountdown = -1; + float priorval = 0.f; for (int i=0; ibeginSubpath(xc, euval); if( ! lfodata->unipolar.val.b ) edpath->beginSubpath(xc, edval); + priorval = val; } else { @@ -213,13 +215,23 @@ void CLFOGui::drawVectorized(CDrawContext* dc) { minval = ( ( - minval + 1.0f ) * 0.5 * 0.8 + 0.1 ) * valScale; maxval = ( ( - maxval + 1.0f ) * 0.5 * 0.8 + 0.1 ) * valScale; - path->addLine(xc, minval ); - path->addLine(xc, maxval ); + // Windows is sensitive to out-of-order line draws in a way which causes spikes. + // Make sure we draw one closest to prior first. See #1438 + float firstval = minval; + float secondval = maxval; + if( priorval - minval < maxval - priorval ) + { + firstval = maxval; + secondval = minval; + } + path->addLine(xc - 0.1 * valScale / totalSamples, firstval ); + path->addLine(xc + 0.1 * valScale / totalSamples, secondval ); } else { path->addLine(xc, val ); } + priorval = val; eupath->addLine(xc, euval); edpath->addLine(xc, edval); }