1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-09 17:07:43 +02:00

More Envelope::GetValueRelative; add point for join only as needed

This commit is contained in:
Paul Licameli 2017-05-09 15:54:49 -04:00
parent 250a2ea12a
commit 6c2c2733f9
3 changed files with 14 additions and 5 deletions

View File

@ -701,7 +701,7 @@ void Envelope::Paste(double t0, const Envelope *e)
unsigned int len = mEnv.size(); unsigned int len = mEnv.size();
// get values to perform framing of the insertion // get values to perform framing of the insertion
double splitval = GetValue(t0 + mOffset); const double splitval = GetValueRelative( t0 );
/* /*
Old analysis of cases: Old analysis of cases:
@ -852,8 +852,8 @@ Old analysis of cases:
// Add end points in case they are not not in e. // Add end points in case they are not not in e.
// If they are in e, no harm, because the repeated Insert // If they are in e, no harm, because the repeated Insert
// calls for the start and end times will have no effect. // calls for the start and end times will have no effect.
const double leftval = e->GetValue(0 + e->mOffset); const double leftval = e->GetValueRelative( 0 );
const double rightval = e->GetValue(e->mTrackLen + e->mOffset); const double rightval = e->GetValueRelative( e->mTrackLen );
InsertOrReplaceRelative(t0, leftval); InsertOrReplaceRelative(t0, leftval);
InsertOrReplaceRelative(t0 + e->mTrackLen, rightval); InsertOrReplaceRelative(t0 + e->mTrackLen, rightval);
} }
@ -983,6 +983,13 @@ void Envelope::GetPoints(double *bufferWhen,
} }
} }
void Envelope::Cap( double sampleTime )
{
auto range = EqualRange( mTrackLen, sampleTime );
if ( range.first == range.second )
InsertOrReplaceRelative( mTrackLen, GetValueRelative( mTrackLen ) );
}
// Private methods // Private methods
// We no longer tolerate multiple envelope control points at the exact // We no longer tolerate multiple envelope control points at the exact

View File

@ -147,6 +147,9 @@ public:
void GetValues void GetValues
(double *buffer, int bufferLen, int leftOffset, const ZoomInfo &zoomInfo) const; (double *buffer, int bufferLen, int leftOffset, const ZoomInfo &zoomInfo) const;
// Guarantee an envelope point at the end of the domain.
void Cap( double sampleTime );
private: private:
double GetValueRelative(double t) const; double GetValueRelative(double t) const;
void GetValuesRelative void GetValuesRelative

View File

@ -1626,9 +1626,8 @@ void WaveClip::InsertSilence( double t, double len, double *pEnvelopeValue )
// Preserve limit value at the end // Preserve limit value at the end
auto oldLen = pEnvelope->GetTrackLen(); auto oldLen = pEnvelope->GetTrackLen();
auto oldT = pEnvelope->GetOffset() + oldLen;
auto newLen = oldLen + len; auto newLen = oldLen + len;
pEnvelope->InsertOrReplace( oldT, pEnvelope->GetValue( oldT ) ); pEnvelope->Cap( sampleTime );
// Ramp across the silence to the given value // Ramp across the silence to the given value
pEnvelope->SetTrackLen( newLen ); pEnvelope->SetTrackLen( newLen );