11#ifndef __AUDACITY_ENVELOPE__
12#define __AUDACITY_ENVELOPE__
42 if (tag ==
"controlpoint") {
43 for(
auto pair : attrs) {
44 auto attr = pair.first;
45 auto value = pair.second;
49 else if (attr ==
"val")
75 Envelope(
bool exponential,
double minValue,
double maxValue,
double defaultValue);
86 bool IsTrivial()
const;
90 bool ConsistencyCheck();
98 void Flatten(
double value);
102 void SetRange(
double minValue,
double maxValue);
109 void WriteXML(
XMLWriter &xmlFile)
const ;
114 void CollapseRegion(
double t0,
double t1,
double sampleDur);
121 void PasteEnvelope(
double t0,
const Envelope *e,
double sampleDur);
123 void InsertSpace(
double t0,
double tlen);
126 void SetOffset(
double newOffset);
127 void SetTrackLen(
double trackLen,
double sampleDur = 0.0 );
128 void RescaleValues(
double minValue,
double maxValue);
129 void RescaleTimes(
double newLength );
133 double GetValue(
double t,
double sampleDur = 0 )
const;
139 void GetValues(
double *buffer,
int len,
double t0,
double tstep)
const;
142 void Cap(
double sampleDur );
145 std::pair< int, int > ExpandRegion
146 (
double t0,
double tlen,
double *pLeftVal,
double *pRightVal );
148 void RemoveUnneededPoints
149 (
size_t startAt,
bool rightward,
bool testNeighbors =
true );
151 double GetValueRelative(
double t,
bool leftLimit =
false)
const;
152 void GetValuesRelative
153 (
double *buffer,
int len,
double t0,
double tstep,
bool leftLimit =
false)
156 int NumberOfPointsAfter(
double t)
const;
158 double NextPointAfter(
double t)
const;
161 double Average(
double t0,
double t1 )
const;
162 double AverageOfInverse(
double t0,
double t1 )
const;
163 double Integral(
double t0,
double t1 )
const;
164 double IntegralOfInverse(
double t0,
double t1 )
const;
165 double SolveIntegralOfInverse(
double t0,
double area)
const;
176 {
return InsertOrReplaceRelative( when - mOffset, value ); }
181 int Reassign(
double when,
double value);
184 void Delete(
int point);
187 void Insert(
int point,
const EnvPoint &p);
191 void Insert(
double when,
double value);
194 size_t GetNumberOfPoints()
const;
203 int InsertOrReplaceRelative(
double when,
double value);
205 std::pair<int, int> EqualRange(
double when,
double sampleDur )
const;
209 void GetPoints(
double *bufferWhen,
211 int bufferLen)
const;
217 void SetDragPoint(
int dragPoint);
219 void SetDragPointValid(
bool valid);
223 void MoveDragPoint(
double newWhen,
double value);
225 void ClearDragPoint();
228 void AddPointAtEnd(
double t,
double val );
231 void BinarySearchForTime(
int &Lo,
int &Hi,
double t )
const;
232 void BinarySearchForTime_LeftLimit(
int &Lo,
int &Hi,
double t )
const;
233 double GetInterpolationStartValueAtPoint(
int iPoint )
const;
239 double mOffset { 0.0 };
242 double mTrackLen { 0.0 };
248 double mTrackEpsilon { 1.0 / 200000.0 };
254 bool mDragPointValid {
false };
255 int mDragPoint { -1 };
257 mutable int mSearchGuess { -2 };
std::vector< EnvPoint > EnvArray
std::vector< Attribute > AttributesList
double GetRangeUpper() const
void SetRangeUpper(double upper)
double GetRangeLower() const
void SetRangeLower(double lower)
EnvPoint, derived from XMLTagHandler, provides Envelope with a draggable point type.
bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs) override
XMLTagHandler * HandleXMLChild(const std::string_view &WXUNUSED(tag)) override
EnvPoint(double t, double val)
void SetVal(Envelope *pEnvelope, double val)
Piecewise linear or piecewise exponential function from double to double.
Envelope(bool exponential, double minValue, double maxValue, double defaultValue)
int InsertOrReplace(double when, double value)
Add a point at a particular absolute time coordinate.
bool GetExponential() const
double ClampValue(double value)
void Initialize(int numPoints)
double GetTrackLen() const
double GetMaxValue() const
void SetExponential(bool db)
bool GetDragPointValid() const
double GetMinValue() const
This class is an interface which should be implemented by classes which wish to be able to load and s...
virtual XMLTagHandler * HandleXMLChild(const std::string_view &tag)=0
virtual bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs)=0
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.