1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-25 16:48:44 +02:00

Bug 1844 - Nyquist effects move subsequent envelope points by selection's length

Also renamed Envelop::Paste to Envelope::PasteEnvelope, since it was hard to find
just its usages, given the many usages of WaveTrack::Paste.
This commit is contained in:
James Crook 2018-08-07 10:39:18 +01:00
parent 511b810fdc
commit 0022e0c06c
4 changed files with 15 additions and 6 deletions

View File

@ -754,7 +754,7 @@ void Envelope::CollapseRegion( double t0, double t1, double sampleDur )
// envelope point applies to the first sample, but the t=tracklen
// envelope point applies one-past the last actual sample.
// t0 should be in the domain of this; if not, it is trimmed.
void Envelope::Paste( double t0, const Envelope *e, double sampleDur )
void Envelope::PasteEnvelope( double t0, const Envelope *e, double sampleDur )
// NOFAIL-GUARANTEE
{
const bool wasEmpty = (this->mEnv.size() == 0);
@ -774,7 +774,8 @@ void Envelope::Paste( double t0, const Envelope *e, double sampleDur )
return;
}
// Make t0 relative and trim it to the domain of this
// Make t0 relative to the offset of the envelope we are pasting into,
// and trim it to the domain of this
t0 = std::min( mTrackLen, std::max( 0.0, t0 - mOffset ) );
// Adjust if the insertion point rounds off near a discontinuity in this
@ -812,7 +813,13 @@ void Envelope::Paste( double t0, const Envelope *e, double sampleDur )
for ( size_t index = insertAt, last = insertAt + otherSize;
index < last; ++index ) {
auto &point = mEnv[ index ];
point.SetT( point.GetT() + otherOffset + t0 );
// The mOffset of the envelope-pasted-from is irrelevant.
// The GetT() times in it are relative to its start.
// The new GetT() times are relative to the envelope-pasted-to start.
// We are pasting at t0 relative to the envelope-pasted-to start.
// Hence we adjust by just t0.
// Bug 1844 was that we also adjusted by the envelope-pasted-from offset.
point.SetT( point.GetT() + /*otherOffset +*/ t0 );
}
// Treat removable discontinuities

View File

@ -131,7 +131,9 @@ public:
// Envelope has no notion of rate and control point times are not quantized;
// but a tolerance is needed in the Paste routine, and better to inform it
// of an appropriate number, than use hidden arbitrary constants.
void Paste(double t0, const Envelope *e, double sampleDur);
// The function is called 'PasteEnvelope' rather than 'Paste' to make it
// easier to find where it is used in source code.
void PasteEnvelope(double t0, const Envelope *e, double sampleDur);
void InsertSpace(double t0, double tlen);

View File

@ -124,7 +124,7 @@ void TimeTrack::Paste(double t, const Track * src)
return;
auto sampleTime = 1.0 / GetActiveProject()->GetRate();
mEnvelope->Paste
mEnvelope->PasteEnvelope
(t, static_cast<const TimeTrack*>(src)->mEnvelope.get(), sampleTime);
}

View File

@ -1625,7 +1625,7 @@ void WaveClip::Paste(double t0, const WaveClip* other)
// Assume NOFAIL-GUARANTEE in the remaining
MarkChanged();
auto sampleTime = 1.0 / GetRate();
mEnvelope->Paste
mEnvelope->PasteEnvelope
(s0.as_double()/mRate + mOffset, pastedClip->mEnvelope.get(), sampleTime);
OffsetCutLines(t0, pastedClip->GetEndTime() - pastedClip->GetStartTime());