diff --git a/src/tracks/playabletrack/wavetrack/ui/ChangeClipSpeedDialog.cpp b/src/tracks/playabletrack/wavetrack/ui/ChangeClipSpeedDialog.cpp index 9a705302adff..7c365e63a803 100644 --- a/src/tracks/playabletrack/wavetrack/ui/ChangeClipSpeedDialog.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/ChangeClipSpeedDialog.cpp @@ -107,11 +107,11 @@ void ChangeClipSpeedDialog::PopulateOrExchange(ShuttleGui& s) void ChangeClipSpeedDialog::OnOk() { - if (ApplyStretchRatio()) + if (SetClipSpeedFromDialog()) EndModal(wxID_OK); } -bool ChangeClipSpeedDialog::ApplyStretchRatio() +bool ChangeClipSpeedDialog::SetClipSpeedFromDialog() { { ShuttleGui S(this, eIsGettingFromDialog); @@ -133,7 +133,11 @@ bool ChangeClipSpeedDialog::ApplyStretchRatio() nextClip->Start() : std::numeric_limits::infinity(); - const auto expectedEndTime = mTrackInterval.End() * mOldClipSpeed / mClipSpeed; + const auto start = mTrackInterval.Start(); + const auto end = mTrackInterval.End(); + + const auto expectedEndTime = + start + (end - start) * mOldClipSpeed / mClipSpeed; if (expectedEndTime >= maxEndTime) { diff --git a/src/tracks/playabletrack/wavetrack/ui/ChangeClipSpeedDialog.h b/src/tracks/playabletrack/wavetrack/ui/ChangeClipSpeedDialog.h index 264b0d0b9b84..ea44f6876f59 100644 --- a/src/tracks/playabletrack/wavetrack/ui/ChangeClipSpeedDialog.h +++ b/src/tracks/playabletrack/wavetrack/ui/ChangeClipSpeedDialog.h @@ -29,7 +29,7 @@ class ChangeClipSpeedDialog final : public wxDialogWrapper void OnOk(); - bool ApplyStretchRatio(); + bool SetClipSpeedFromDialog(); WaveTrack& mTrack; WaveTrack::Interval& mTrackInterval;