From bbab89b52c2ff70847d6ffda7cc9488efc59efc7 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 26 Jun 2017 12:04:21 -0400 Subject: [PATCH] Cut then paste has no net effect on envelope in some more cases... ... whereas before, some incorrect disconituities could remain near the start of the selection. To find reproducible cases before this commit might involve varying the left edge of the selection by small amounts, because this problem depended on little roundoff errors. --- src/Envelope.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Envelope.cpp b/src/Envelope.cpp index ff949de37..8e241fcb8 100644 --- a/src/Envelope.cpp +++ b/src/Envelope.cpp @@ -717,7 +717,13 @@ void Envelope::CollapseRegion( double t0, double t1, double sampleDur ) auto len = mEnv.size(); for ( size_t i = begin; i < len; ++i ) { auto &point = mEnv[i]; - point.SetT( point.GetT() - (t1 - t0) ); + if (rightPoint && i == begin) + // Avoid roundoff error. + // Make exactly equal times of neighboring points so that we have + // a real discontinuity. + point.SetT( t0 ); + else + point.SetT( point.GetT() - (t1 - t0) ); } // See if the discontinuity is removable.