From 51202bffb09fe1dd7eacb4fb57c855813a9c9c32 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 4 Dec 2016 14:16:03 -0500 Subject: [PATCH] Fix bug reported by Steve, applying Nyquist effects... ... To short selections (under 1/100 second), at the start of the second of two separated clips, in a project with a high sampling rate of 192000. Symptom was that the audio moved so it was pasted to the end of the first clip. Other uses of the constant WAVETRACK_MERGE_POINT_TOLERANCE should be reviewed too but this is a conservative fix made close to release time. --- src/WaveTrack.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 4c55d6228..b4ffe2cc5 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -873,6 +873,8 @@ bool WaveTrack::ClearAndPaste(double t0, // Start of time to clear } } + const auto tolerance = 2.0 / GetRate(); + // Now, clear the selection if (HandleClear(t0, t1, false, false)) { @@ -894,7 +896,7 @@ bool WaveTrack::ClearAndPaste(double t0, // Start of time to clear for (const auto clip : clips) { // Merge this clip and the previous clip if the end time // falls within it and this isn't the first clip in the track. - if (fabs(t1 - clip->GetStartTime()) < WAVETRACK_MERGE_POINT_TOLERANCE) { + if (fabs(t1 - clip->GetStartTime()) < tolerance) { if (prev) { bool bResult = MergeClips(GetClipIndex(prev), GetClipIndex(clip)); wxASSERT(bResult); // TO DO: Actually handle this. @@ -920,7 +922,7 @@ bool WaveTrack::ClearAndPaste(double t0, // Start of time to clear wxUnusedVar(bResult); break; } - if (fabs(t0 - clip->GetEndTime()) < WAVETRACK_MERGE_POINT_TOLERANCE) + if (fabs(t0 - clip->GetEndTime()) < tolerance) // Merge this clip and the next clip if the start time // falls within it and this isn't the last clip in the track. prev = clip;