Skip to content

Commit

Permalink
Supress Windows-only LFO spikes (surge-synthesizer#1497)
Browse files Browse the repository at this point in the history
Windows VSTGUI with the ordering we chose for points
drew specious spikes. Re-order the points to avoid this
potential bug.

Closes surge-synthesizer#1438
  • Loading branch information
baconpaul authored Jan 22, 2020
1 parent b0c3c7f commit bf0f5a0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/common/gui/CLFOGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ void CLFOGui::drawVectorized(CDrawContext* dc)
#endif
int susCountdown = -1;

float priorval = 0.f;
for (int i=0; i<totalSamples; i += averagingWindow )
{
float val = 0;
Expand Down Expand Up @@ -206,20 +207,31 @@ void CLFOGui::drawVectorized(CDrawContext* dc)
eupath->beginSubpath(xc, euval);
if( ! lfodata->unipolar.val.b )
edpath->beginSubpath(xc, edval);
priorval = val;
}
else
{
if( maxval - minval > 0.2 )
{
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);
}
Expand Down

0 comments on commit bf0f5a0

Please sign in to comment.