Skip to content

Commit

Permalink
Fixes wrong clip speed when clip start is non zero
Browse files Browse the repository at this point in the history
  • Loading branch information
crsib committed Sep 26, 2023
1 parent 86500e2 commit 80fce43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/tracks/playabletrack/wavetrack/ui/ChangeClipSpeedDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -133,7 +133,11 @@ bool ChangeClipSpeedDialog::ApplyStretchRatio()
nextClip->Start() :
std::numeric_limits<double>::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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ChangeClipSpeedDialog final : public wxDialogWrapper

void OnOk();

bool ApplyStretchRatio();
bool SetClipSpeedFromDialog();

WaveTrack& mTrack;
WaveTrack::Interval& mTrackInterval;
Expand Down

0 comments on commit 80fce43

Please sign in to comment.