diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index 32e0d008c..4c32e0845 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -474,6 +474,16 @@ bool WaveClip::AfterClip(double t) const return ts > GetEndSample() + mAppendBufferLen; } +// A sample at time t could be in the clip, but +// a clip start at time t still be from a clip +// not overlapping this one, with this test. +bool WaveClip::IsClipStartAfterClip(double t) const +{ + auto ts = (sampleCount)floor(t * mRate + 0.5); + return ts >= GetEndSample() + mAppendBufferLen; +} + + ///Delete the wave cache - force redraw. Thread-safe void WaveClip::ClearWaveCache() { diff --git a/src/WaveClip.h b/src/WaveClip.h index 08a90c650..dbb20b18a 100644 --- a/src/WaveClip.h +++ b/src/WaveClip.h @@ -231,6 +231,7 @@ public: bool WithinClip(double t) const; bool BeforeClip(double t) const; bool AfterClip(double t) const; + bool IsClipStartAfterClip(double t) const; bool GetSamples(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, bool mayThrow = true) const; diff --git a/src/tracks/ui/TimeShiftHandle.cpp b/src/tracks/ui/TimeShiftHandle.cpp index ed830e728..f39bac624 100644 --- a/src/tracks/ui/TimeShiftHandle.cpp +++ b/src/tracks/ui/TimeShiftHandle.cpp @@ -108,13 +108,13 @@ namespace void AddClipsToCaptured ( ClipMoveState &state, Track *t, double t0, double t1 ) { - bool exclude = true; + bool exclude = true; // to exclude a whole track. auto &clips = state.capturedClipArray; t->TypeSwitch( [&](WaveTrack *wt) { exclude = false; for(const auto &clip: wt->GetClips()) - if ( ! clip->AfterClip(t0) && ! clip->BeforeClip(t1) && + if ( ! clip->IsClipStartAfterClip(t0) && ! clip->BeforeClip(t1) && // Avoid getting clips that were already captured ! std::any_of( clips.begin(), clips.end(), [&](const TrackClip &c) { return c.clip == clip.get(); } ) )