18#include <wx/wxcrtvararg.h>
26#define TIMETRACK_MIN 0.01
27#define TIMETRACK_MAX 10.0
36 return _(
"Time Track");
42 auto result =
tracks.Add(std::make_shared<TimeTrack>());
43 result->AttachedTrackObjects::BuildAll();
68 double *pT0,
double *pT1
146 std::shared_ptr<TimeTrack> pNewTrack;
149 pNewTrack = pTrack->SharedPointer<
TimeTrack>();
151 pNewTrack = std::make_shared<TimeTrack>();
158 pNewTrack->CleanState();
159 pNewTrack->Init(*
this);
160 pNewTrack->Paste(0.0, *
this);
168 auto result =
Copy(t0, t1,
false);
183 if (
auto pList = track.
GetOwner()) {
184 if (
auto pProject = pList->GetOwner())
193 auto sampleTime = 1.0 /
GetRate(*
this);
194 mEnvelope->CollapseRegion( t0, t1, sampleTime );
200 auto sampleTime = 1.0 /
GetRate(*
this);
201 mEnvelope->PasteEnvelope(t, tt.mEnvelope.get(), sampleTime);
233 mEnvelope->SetExponential(interpolateLog);
238 if (tag ==
"timetrack") {
243 for (
auto pair : attrs)
245 auto attr = pair.first;
246 auto value = pair.second;
250 else if (attr ==
"rangelower")
255 else if (attr ==
"rangeupper")
260 else if (attr ==
"displaylog" && value.TryGet(nValue))
266 else if (attr ==
"interpolatelog" && value.TryGet(nValue))
292 if (tag ==
"envelope")
301 xmlFile.StartTag(
wxT(
"timetrack"));
306 xmlFile.WriteAttr(
wxT(
"rangelower"), GetRangeLower(), 12);
307 xmlFile.WriteAttr(
wxT(
"rangeupper"), GetRangeUpper(), 12);
308 xmlFile.WriteAttr(
wxT(
"displaylog"), GetDisplayLog());
309 xmlFile.WriteAttr(
wxT(
"interpolatelog"), GetInterpolateLog());
311 mEnvelope->WriteXML(xmlFile);
313 xmlFile.EndTag(
wxT(
"timetrack"));
321std::shared_ptr<WideChannelGroupInterval>
336 double expected1 = (5.0 - 2.0) * 0.2 + (13.0 - 5.0) * 1.3;
338 double expected2 = (5.0 - 2.0) / 0.2 + (13.0 - 5.0) / 1.3;
339 if( fabs(value1 - expected1) > 0.01 )
341 wxPrintf(
"TimeTrack: Integral failed! expected %f got %f\n", expected1, value1);
343 if( fabs(value2 - expected2) > 0.01 )
345 wxPrintf(
"TimeTrack: IntegralOfInverse failed! expected %f got %f\n", expected2, value2);
366 if (
auto pTimeTrack = *list.Any<
const TimeTrack>().begin())
367 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::function< void(double)> ProgressReporter
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()
std::shared_ptr< WideChannelGroupInterval > DoGetInterval(size_t iInterval) override
Retrieve an interval.
void WriteXML(XMLWriter &xmlFile) const override
void SetInterpolateLog(bool interpolateLog)
void HandleXMLEndTag(const std::string_view &tag) override
void Paste(double t, const Track &src) override
Weak precondition allows overrides to replicate one channel into many.
static const TypeInfo & ClassTypeInfo()
Track::Holder PasteInto(AudacityProject &project, TrackList &list) const override
void SetDisplayLog(bool displayLog)
void Silence(double t0, double t1, ProgressReporter reportProgress={}) override
std::unique_ptr< BoundedEnvelope > mEnvelope
Track::Holder Copy(double t0, double t1, bool forClipboard) const override
Create new tracks and don't modify this track.
bool GetInterpolateLog() const
bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs) override
XMLTagHandler * HandleXMLChild(const std::string_view &tag) override
Track::Holder Cut(double t0, double t1) override
Create tracks and modify this track.
BoundedEnvelope * GetEnvelope()
bool GetDisplayLog() const
size_t NIntervals() const override
Report the number of intervals.
void InsertSilence(double t, double len) override
const TypeInfo & GetTypeInfo() const override
void SetRangeLower(double lower)
Track::Holder Clone(bool backup) const override
static TimeTrack * New(AudacityProject &project)
double GetRangeLower() const
double GetRangeUpper() const
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)
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)
TrackKind * Add(const std::shared_ptr< TrackKind > &t, bool assignIds=true)
Generates overrides of channel-related functions.
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...
double GetRate(const Track &track)
const char * begin(const char *str) noexcept
Empty argument passed to some public constructors.