mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-05 14:49:25 +02:00
Envelope::SetTrackLen adds a point only when none was present...
... And if points were present, keeps only the leftmost.
This commit is contained in:
parent
6c2c2733f9
commit
bcc0bed29a
@ -1090,17 +1090,21 @@ void Envelope::SetOffset(double newOffset)
|
||||
mOffset = newOffset;
|
||||
}
|
||||
|
||||
void Envelope::SetTrackLen(double trackLen)
|
||||
void Envelope::SetTrackLen( double trackLen, double sampleTime )
|
||||
// NOFAIL-GUARANTEE
|
||||
{
|
||||
// Preserve the right-side limit at trackLen.
|
||||
bool needPoint = ( trackLen < mTrackLen );
|
||||
// Preserve the left-side limit at trackLen.
|
||||
auto range = EqualRange( trackLen, sampleTime );
|
||||
bool needPoint = ( range.first == range.second && trackLen < mTrackLen );
|
||||
double value;
|
||||
if ( needPoint )
|
||||
value = GetValueRelative( trackLen );
|
||||
|
||||
mTrackLen = trackLen;
|
||||
int newLen = EqualRange( trackLen, 0 ).second;
|
||||
|
||||
// Shrink the array.
|
||||
// If more than one point already at the end, keep only the first of them.
|
||||
int newLen = std::min( 1 + range.first, range.second );
|
||||
mEnv.resize( newLen );
|
||||
|
||||
if ( needPoint )
|
||||
|
@ -128,7 +128,7 @@ public:
|
||||
|
||||
// Control
|
||||
void SetOffset(double newOffset);
|
||||
void SetTrackLen(double trackLen);
|
||||
void SetTrackLen( double trackLen, double sampleTime = 0.0 );
|
||||
void RescaleValues(double minValue, double maxValue);
|
||||
void RescaleTimes( double newLength );
|
||||
|
||||
|
@ -1345,7 +1345,8 @@ void WaveClip::ConvertToSampleFormat(sampleFormat format)
|
||||
void WaveClip::UpdateEnvelopeTrackLen()
|
||||
// NOFAIL-GUARANTEE
|
||||
{
|
||||
mEnvelope->SetTrackLen((mSequence->GetNumSamples().as_double()) / mRate);
|
||||
mEnvelope->SetTrackLen
|
||||
((mSequence->GetNumSamples().as_double()) / mRate, 1.0 / GetRate());
|
||||
}
|
||||
|
||||
void WaveClip::TimeToSamplesClip(double t0, sampleCount *s0) const
|
||||
@ -1630,7 +1631,7 @@ void WaveClip::InsertSilence( double t, double len, double *pEnvelopeValue )
|
||||
pEnvelope->Cap( sampleTime );
|
||||
|
||||
// Ramp across the silence to the given value
|
||||
pEnvelope->SetTrackLen( newLen );
|
||||
pEnvelope->SetTrackLen( newLen, sampleTime );
|
||||
pEnvelope->InsertOrReplace
|
||||
( pEnvelope->GetOffset() + newLen, *pEnvelopeValue );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user