mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-23 15:50:05 +02:00
When Envelope domain is shortened, evaluation inside won't change...
... It doesn't happen in practice yet, all present calls to SetTrackLen make the track the same length or longer. But this is for completeness.
This commit is contained in:
parent
945e411e2c
commit
2d84c65c94
@ -175,7 +175,7 @@ void Envelope::SetRange(double minValue, double maxValue) {
|
||||
}
|
||||
|
||||
// This is used only during construction of an Envelope by complete or partial
|
||||
// copy of another.
|
||||
// copy of another, or when truncating a track.
|
||||
void Envelope::AddPointAtEnd( double t, double val )
|
||||
{
|
||||
mEnv.push_back( EnvPoint{ t, val } );
|
||||
@ -1037,16 +1037,20 @@ void Envelope::SetOffset(double newOffset)
|
||||
}
|
||||
|
||||
void Envelope::SetTrackLen(double trackLen)
|
||||
// NOFAIL-GUARANTEE
|
||||
{
|
||||
mTrackLen = trackLen;
|
||||
// Preserve the right-side limit at trackLen.
|
||||
bool needPoint = ( trackLen < mTrackLen );
|
||||
double value;
|
||||
if ( needPoint )
|
||||
value = GetValueRelative( trackLen );
|
||||
|
||||
int len = mEnv.size();
|
||||
for (int i = 0; i < len; i++)
|
||||
if (mEnv[i].GetT() > mTrackLen) {
|
||||
Delete(i);
|
||||
len--;
|
||||
i--;
|
||||
}
|
||||
mTrackLen = trackLen;
|
||||
int newLen = EqualRange( trackLen, 0 ).second;
|
||||
mEnv.resize( newLen );
|
||||
|
||||
if ( needPoint )
|
||||
AddPointAtEnd( mTrackLen, value );
|
||||
}
|
||||
|
||||
void Envelope::RescaleTimes( double newLength )
|
||||
|
Loading…
x
Reference in New Issue
Block a user