mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 08:59:28 +02:00
Partial range copy of Envelope will not leave coincident points
This commit is contained in:
parent
f5a7e4ce7c
commit
945e411e2c
@ -174,10 +174,23 @@ void Envelope::SetRange(double minValue, double maxValue) {
|
|||||||
mEnv[i].SetVal( this, mEnv[i].GetVal() ); // this clamps the value to the NEW range
|
mEnv[i].SetVal( this, mEnv[i].GetVal() ); // this clamps the value to the NEW range
|
||||||
}
|
}
|
||||||
|
|
||||||
EnvPoint *Envelope::AddPointAtEnd( double t, double val )
|
// This is used only during construction of an Envelope by complete or partial
|
||||||
|
// copy of another.
|
||||||
|
void Envelope::AddPointAtEnd( double t, double val )
|
||||||
{
|
{
|
||||||
mEnv.push_back( EnvPoint{ t, val } );
|
mEnv.push_back( EnvPoint{ t, val } );
|
||||||
return &mEnv.back();
|
|
||||||
|
// Assume copied points were stored by nondecreasing time.
|
||||||
|
// Allow no more than two points at exactly the same time.
|
||||||
|
// Maybe that happened, because extra points were inserted at the boundary
|
||||||
|
// of the copied range, which were not in the source envelope.
|
||||||
|
auto nn = mEnv.size() - 1;
|
||||||
|
while ( nn >= 2 && mEnv[ nn - 2 ].GetT() == t ) {
|
||||||
|
// Of three or more points at the same time, erase one in the middle,
|
||||||
|
// not the one newly added.
|
||||||
|
mEnv.erase( mEnv.begin() + nn - 1 );
|
||||||
|
--nn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Envelope::Envelope(const Envelope &orig, double t0, double t1)
|
Envelope::Envelope(const Envelope &orig, double t0, double t1)
|
||||||
@ -342,7 +355,8 @@ XMLTagHandler *Envelope::HandleXMLChild(const wxChar *tag)
|
|||||||
if (wxStrcmp(tag, wxT("controlpoint")))
|
if (wxStrcmp(tag, wxT("controlpoint")))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return AddPointAtEnd(0,0);
|
mEnv.push_back( EnvPoint{} );
|
||||||
|
return &mEnv.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Envelope::WriteXML(XMLWriter &xmlFile) const
|
void Envelope::WriteXML(XMLWriter &xmlFile) const
|
||||||
|
@ -215,7 +215,7 @@ private:
|
|||||||
void MoveDragPoint(double newWhen, double value);
|
void MoveDragPoint(double newWhen, double value);
|
||||||
// May delete the drag point. Restores envelope consistency.
|
// May delete the drag point. Restores envelope consistency.
|
||||||
void ClearDragPoint();
|
void ClearDragPoint();
|
||||||
EnvPoint * AddPointAtEnd( double t, double val );
|
void AddPointAtEnd( double t, double val );
|
||||||
void CopyRange(const Envelope &orig, size_t begin, size_t end);
|
void CopyRange(const Envelope &orig, size_t begin, size_t end);
|
||||||
// relative time
|
// relative time
|
||||||
void BinarySearchForTime( int &Lo, int &Hi, double t ) const;
|
void BinarySearchForTime( int &Lo, int &Hi, double t ) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user