20#include <wx/wxcrtvararg.h>
28#define TIMETRACK_MIN 0.01
29#define TIMETRACK_MAX 10.0
38 return _(
"Time Track");
44 auto result = tracks.Add(std::make_shared<TimeTrack>());
45 result->AttachedTrackObjects::BuildAll();
70 double *pT0,
double *pT1
147 std::shared_ptr<TimeTrack> pNewTrack;
149 pNewTrack = pTrack->SharedPointer<
TimeTrack>();
151 pNewTrack = std::make_shared<TimeTrack>();
156 pNewTrack->CleanState();
157 pNewTrack->Init(*
this);
158 pNewTrack->Paste(0.0,
this);
166 auto result =
Copy( t0, t1,
false );
180 if (
auto pList = track.
GetOwner()) {
181 if (
auto pProject = pList->GetOwner())
190 auto sampleTime = 1.0 /
GetRate(*
this);
191 mEnvelope->CollapseRegion( t0, t1, sampleTime );
197 auto sampleTime = 1.0 /
GetRate(*
this);
199 (t, tt->mEnvelope.get(), sampleTime);
230 mEnvelope->SetExponential(interpolateLog);
235 if (tag ==
"timetrack") {
240 for (
auto pair : attrs)
242 auto attr = pair.first;
243 auto value = pair.second;
247 else if (attr ==
"rangelower")
252 else if (attr ==
"rangeupper")
257 else if (attr ==
"displaylog" && value.TryGet(nValue))
263 else if (attr ==
"interpolatelog" && value.TryGet(nValue))
289 if (tag ==
"envelope")
298 xmlFile.StartTag(
wxT(
"timetrack"));
303 xmlFile.WriteAttr(
wxT(
"rangelower"), GetRangeLower(), 12);
304 xmlFile.WriteAttr(
wxT(
"rangeupper"), GetRangeUpper(), 12);
305 xmlFile.WriteAttr(
wxT(
"displaylog"), GetDisplayLog());
306 xmlFile.WriteAttr(
wxT(
"interpolatelog"), GetInterpolateLog());
308 mEnvelope->WriteXML(xmlFile);
310 xmlFile.EndTag(
wxT(
"timetrack"));
322 double expected1 = (5.0 - 2.0) * 0.2 + (13.0 - 5.0) * 1.3;
324 double expected2 = (5.0 - 2.0) / 0.2 + (13.0 - 5.0) / 1.3;
325 if( fabs(value1 - expected1) > 0.01 )
327 wxPrintf(
"TimeTrack: Integral failed! expected %f got %f\n", expected1, value1);
329 if( fabs(value2 - expected2) > 0.01 )
331 wxPrintf(
"TimeTrack: IntegralOfInverse failed! expected %f got %f\n", expected2, value2);
350 if (
auto pTimeTrack = *list.Any<
const TimeTrack>().begin())
351 return pTimeTrack->GetEnvelope();
an object holding per-project preferred sample rate
static Mixer::WarpOptions::DefaultWarp::Scope installer
Installer of the time warper.
static ProjectFileIORegistry::ObjectReaderEntry readerEntry
static const Track::TypeInfo & typeInfo()
std::vector< Attribute > AttributesList
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
double Integral(double t0, double t1) const
int InsertOrReplace(double when, double value)
Add a point at a particular absolute time coordinate.
double IntegralOfInverse(double t0, double t1) const
void Flatten(double value)
typename GlobalVariable< DefaultWarp, const std::function< const BoundedEnvelope * >, nullptr, Options... >::Scope Scope
static ProjectRate & Get(AudacityProject &project)
A kind of Track used to 'warp time'.
static wxString GetDefaultName()
void Paste(double t, const Track *src) override
void WriteXML(XMLWriter &xmlFile) const override
void SetInterpolateLog(bool interpolateLog)
void HandleXMLEndTag(const std::string_view &tag) override
static const TypeInfo & ClassTypeInfo()
void SetDisplayLog(bool displayLog)
std::unique_ptr< BoundedEnvelope > mEnvelope
Holder Copy(double t0, double t1, bool forClipboard) const override
Track::Holder Clone() const override
bool GetInterpolateLog() const
bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs) override
XMLTagHandler * HandleXMLChild(const std::string_view &tag) override
Holder Cut(double t0, double t1) override
BoundedEnvelope * GetEnvelope()
bool GetDisplayLog() const
void InsertSilence(double t, double len) override
const TypeInfo & GetTypeInfo() const override
void SetRangeLower(double lower)
void Silence(double t0, double t1) override
static TimeTrack * New(AudacityProject &project)
double GetRangeLower() const
double GetRangeUpper() const
Holder PasteInto(AudacityProject &) const override
Find or create the destination track for a paste, maybe in a different project.
void Clear(double t0, double t1) override
bool SupportsBasicEditing() const override
Whether this track type implements cut-copy-paste; by default, true.
void Init(const TimeTrack &orig)
Copy the metadata from another track but not the points.
void SetRangeUpper(double upper)
Abstract base class for an object holding data associated with points on a time axis.
static const TypeInfo & ClassTypeInfo()
std::shared_ptr< TrackList > GetOwner() const
R TypeSwitch(const Functions &...functions)
Use this function rather than testing track type explicitly and making down-casts.
std::shared_ptr< Track > Holder
bool HandleCommonXMLAttribute(const std::string_view &attr, const XMLAttributeValueView &valueView)
const wxString & GetName() const
Name is always the same for all channels of a group.
void Init(const Track &orig)
void WriteCommonXMLAttributes(XMLWriter &xmlFile, bool includeNameAndSelected=true) const
void SetName(const wxString &n)
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
static TrackList & Get(AudacityProject &project)
This class is an interface which should be implemented by classes which wish to be able to load and s...
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
double GetRate(const Track &track)
Empty argument passed to some public constructors.