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 );
130 void RescaleTimesBy(
double ratio);
134 double GetValue(
double t,
double sampleDur = 0 )
const;
140 void GetValues(
double *buffer,
int len,
double t0,
double tstep)
const;
143 void Cap(
double sampleDur );
146 std::pair< int, int > ExpandRegion
147 (
double t0,
double tlen,
double *pLeftVal,
double *pRightVal );
149 void RemoveUnneededPoints
150 (
size_t startAt,
bool rightward,
bool testNeighbors =
true );
152 double GetValueRelative(
double t,
bool leftLimit =
false)
const;
153 void GetValuesRelative
154 (
double *buffer,
int len,
double t0,
double tstep,
bool leftLimit =
false)
157 int NumberOfPointsAfter(
double t)
const;
159 double NextPointAfter(
double t)
const;
162 double Average(
double t0,
double t1 )
const;
163 double AverageOfInverse(
double t0,
double t1 )
const;
164 double Integral(
double t0,
double t1 )
const;
165 double IntegralOfInverse(
double t0,
double t1 )
const;
166 double SolveIntegralOfInverse(
double t0,
double area)
const;
177 {
return InsertOrReplaceRelative( when - mOffset, value ); }
182 int Reassign(
double when,
double value);
185 void Delete(
int point);
188 void Insert(
int point,
const EnvPoint &p);
192 void Insert(
double when,
double value);
195 size_t GetNumberOfPoints()
const;
204 int InsertOrReplaceRelative(
double when,
double value);
206 std::pair<int, int> EqualRange(
double when,
double sampleDur )
const;
210 void GetPoints(
double *bufferWhen,
212 int bufferLen)
const;
218 void SetDragPoint(
int dragPoint);
220 void SetDragPointValid(
bool valid);
224 void MoveDragPoint(
double newWhen,
double value);
226 void ClearDragPoint();
229 void AddPointAtEnd(
double t,
double val );
232 void BinarySearchForTime(
int &Lo,
int &Hi,
double t )
const;
233 void BinarySearchForTime_LeftLimit(
int &Lo,
int &Hi,
double t )
const;
234 double GetInterpolationStartValueAtPoint(
int iPoint )
const;
240 double mOffset { 0.0 };
243 double mTrackLen { 0.0 };
249 double mTrackEpsilon { 1.0 / 200000.0 };
255 bool mDragPointValid {
false };
256 int mDragPoint { -1 };
258 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.