11#ifndef __AUDACITY_ENVELOPE__
12#define __AUDACITY_ENVELOPE__
35 double GetT() const noexcept {
return mT; }
36 void SetT(
double t)
noexcept {
mT = t; }
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);
84 bool IsTrivial()
const;
88 bool ConsistencyCheck();
96 void Flatten(
double value);
100 void SetRange(
double minValue,
double maxValue);
107 void WriteXML(
XMLWriter &xmlFile)
const ;
112 void CollapseRegion(
double t0,
double t1,
double sampleDur)
noexcept;
119 void PasteEnvelope(
double t0,
const Envelope *e,
double sampleDur);
121 void InsertSpace(
double t0,
double tlen);
124 void SetOffset(
double newOffset);
125 void SetTrackLen(
double trackLen,
double sampleDur = 0.0 );
126 void RescaleValues(
double minValue,
double maxValue);
127 void RescaleTimes(
double newLength );
128 void RescaleTimesBy(
double ratio);
132 double GetValue(
double t,
double sampleDur = 0 )
const;
138 void GetValues(
double *buffer,
int len,
double t0,
double tstep)
const;
141 void Cap(
double sampleDur );
144 std::pair< int, int > ExpandRegion
145 (
double t0,
double tlen,
double *pLeftVal,
double *pRightVal );
147 void RemoveUnneededPoints
148 (
size_t startAt,
bool rightward,
bool testNeighbors =
true ) noexcept;
150 double GetValueRelative(
double t,
bool leftLimit = false) const noexcept;
151 void GetValuesRelative
152 (
double *buffer,
int len,
double t0,
double tstep,
bool leftLimit = false)
155 int NumberOfPointsAfter(
double t) const;
157 double NextPointAfter(
double t) const;
160 double Average(
double t0,
double t1 ) const;
161 double AverageOfInverse(
double t0,
double t1 ) const;
162 double Integral(
double t0,
double t1 ) const;
163 double IntegralOfInverse(
double t0,
double t1 ) const;
164 double SolveIntegralOfInverse(
double t0,
double area) const;
166 void Clear() { mEnv.clear(); }
170 {
return InsertOrReplaceRelative( when - mOffset, value ); }
175 int Reassign(
double when,
double value);
178 void Delete(
int point);
181 void Insert(
int point,
const EnvPoint &p)
noexcept;
185 void Insert(
double when,
double value);
188 size_t GetNumberOfPoints()
const;
196 double GetDefaultValue()
const;
198 size_t GetVersion()
const;
202 int InsertOrReplaceRelative(
double when,
double value)
noexcept;
204 std::pair<int, int> EqualRange(
double when,
double sampleDur)
const noexcept;
208 void GetPoints(
double *bufferWhen,
210 int bufferLen)
const;
216 void SetDragPoint(
int dragPoint);
218 void SetDragPointValid(
bool valid);
222 void MoveDragPoint(
double newWhen,
double value);
224 void ClearDragPoint();
227 void AddPointAtEnd(
double t,
double val );
230 void BinarySearchForTime(
int &Lo,
int &Hi,
double t)
const noexcept;
231 void BinarySearchForTime_LeftLimit(
int &Lo,
int &Hi,
double t)
233 double GetInterpolationStartValueAtPoint(
int iPoint)
const noexcept;
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 };
256 size_t mVersion { 0 };
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.
EnvPoint(double t, double val) noexcept
bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs) override
XMLTagHandler * HandleXMLChild(const std::string_view &WXUNUSED(tag)) override
double GetT() const noexcept
void SetT(double t) noexcept
double GetVal() const noexcept
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)
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...
const char * end(const char *str) noexcept
const char * begin(const char *str) noexcept