1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 14:02:57 +02:00

Bug842: rescale clip offsets, envelope times when setting track rate

This commit is contained in:
Paul Licameli
2017-05-04 08:32:23 -04:00
parent e36070e671
commit d2acf1f3e5
4 changed files with 24 additions and 2 deletions

View File

@@ -1038,6 +1038,21 @@ void Envelope::SetTrackLen(double trackLen)
}
}
void Envelope::RescaleTimes( double newLength )
// NOFAIL-GUARANTEE
{
if ( mTrackLen == 0 ) {
for ( auto &point : mEnv )
point.SetT( 0 );
}
else {
auto ratio = newLength / mTrackLen;
for ( auto &point : mEnv )
point.SetT( point.GetT() * ratio );
}
mTrackLen = newLength;
}
// Accessors
double Envelope::GetValue(double t) const
{