Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
TimeTrack Class Referencefinal

A kind of Track used to 'warp time'. More...

#include <TimeTrack.h>

Inheritance diagram for TimeTrack:
[legend]
Collaboration diagram for TimeTrack:
[legend]

Public Member Functions

 TimeTrack (const ZoomInfo *zoomInfo)
 
 TimeTrack (const TimeTrack &orig, ProtectedCreationArg &&, double *pT0=nullptr, double *pT1=nullptr)
 Copy-Constructor - create a NEW TimeTrack:: which is an independent copy of the original. More...
 
virtual ~TimeTrack ()
 
const TypeInfoGetTypeInfo () const override
 
bool SupportsBasicEditing () const override
 Whether this track type implements cut-copy-paste; by default, true. More...
 
Holder PasteInto (AudacityProject &) const override
 Find or create the destination track for a paste, maybe in a different project. More...
 
Holder Cut (double t0, double t1) override
 
Holder Copy (double t0, double t1, bool forClipboard) const override
 
void Clear (double t0, double t1) override
 
void Paste (double t, const Track *src) override
 
void Silence (double t0, double t1) override
 
void InsertSilence (double t, double len) override
 
double GetOffset () const override
 
void SetOffset (double) override
 
double GetStartTime () const override
 
double GetEndTime () const override
 
bool HandleXMLTag (const std::string_view &tag, const AttributesList &attrs) override
 
void HandleXMLEndTag (const std::string_view &tag) override
 
XMLTagHandlerHandleXMLChild (const std::string_view &tag) override
 
void WriteXML (XMLWriter &xmlFile) const override
 
BoundedEnvelopeGetEnvelope ()
 
const BoundedEnvelopeGetEnvelope () const
 
double GetRangeLower () const
 
double GetRangeUpper () const
 
void SetRangeLower (double lower)
 
void SetRangeUpper (double upper)
 
bool GetDisplayLog () const
 
void SetDisplayLog (bool displayLog)
 
bool GetInterpolateLog () const
 
void SetInterpolateLog (bool interpolateLog)
 
void testMe ()
 
RulerGetRuler () const
 
- Public Member Functions inherited from Track
TrackId GetId () const
 
template<typename Subclass = Track>
std::shared_ptr< Subclass > SharedPointer ()
 
template<typename Subclass = const Track>
auto SharedPointer () const -> std::enable_if_t< std::is_const_v< Subclass >, std::shared_ptr< Subclass > >
 
std::shared_ptr< TrackSubstitutePendingChangedTrack ()
 
std::shared_ptr< const TrackSubstitutePendingChangedTrack () const
 
std::shared_ptr< const TrackSubstituteOriginalTrack () const
 
virtual const TypeInfoGetTypeInfo () const =0
 
virtual const TypeNamesGetTypeNames () const
 
virtual bool SupportsBasicEditing () const
 Whether this track type implements cut-copy-paste; by default, true. More...
 
virtual Holder PasteInto (AudacityProject &) const =0
 Find or create the destination track for a paste, maybe in a different project. More...
 
virtual ConstIntervals GetIntervals () const
 Report times on the track where important intervals begin and end, for UI to snap to. More...
 
virtual Intervals GetIntervals ()
 
int GetIndex () const
 
void SetIndex (int index)
 
virtual bool LinkConsistencyFix (bool doFix=true, bool completeList=true)
 Check consistency of channel groups, and maybe fix it. More...
 
bool LinkConsistencyCheck (bool completeList)
 Do the non-mutating part of consistency fix only and return status. More...
 
bool HasOwner () const
 
std::shared_ptr< TrackListGetOwner () const
 
LinkType GetLinkType () const noexcept
 
bool IsAlignedWithLeader () const
 Returns true if the leader track has link type LinkType::Aligned. More...
 
ChannelGroupDataGetGroupData ()
 
const ChannelGroupDataGetGroupData () const
 
 Track ()
 
 Track (const Track &orig, ProtectedCreationArg &&)
 
Trackoperator= (const Track &orig)=delete
 
virtual ~Track ()
 
void Init (const Track &orig)
 
virtual Holder Duplicate () const
 
virtual void Merge (const Track &orig)
 
wxString GetName () const
 
void SetName (const wxString &n)
 
bool GetSelected () const
 
virtual void SetSelected (bool s)
 
void EnsureVisible (bool modifyState=false)
 
virtual ChannelType GetChannel () const
 
virtual double GetOffset () const =0
 
void Offset (double t)
 
virtual void SetOffset (double o)
 
virtual void SetPan (float)
 
virtual void SetPanFromChannelType ()
 
virtual Holder Cut (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual Holder Copy (double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard=true) const =0
 
virtual void Clear (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void Paste (double WXUNUSED(t), const Track *WXUNUSED(src))=0
 
virtual void SyncLockAdjust (double oldT1, double newT1)
 
virtual void Silence (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void InsertSilence (double WXUNUSED(t), double WXUNUSED(len))=0
 
bool SameKindAs (const Track &track) const
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions)
 Use this function rather than testing track type explicitly and making down-casts. More...
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions) const
 Use this function rather than testing track type explicitly and making down-casts. More...
 
virtual void WriteXML (XMLWriter &xmlFile) const =0
 
virtual bool GetErrorOpening ()
 
virtual double GetStartTime () const =0
 
virtual double GetEndTime () const =0
 
void Notify (int code=-1)
 
bool Any () const
 
bool IsSelected () const
 
bool IsLeader () const
 
bool IsSelectedLeader () const
 
void AdjustPositions ()
 
void WriteCommonXMLAttributes (XMLWriter &xmlFile, bool includeNameAndSelected=true) const
 
bool HandleCommonXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView)
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual bool HandleXMLTag (const std::string_view &tag, const AttributesList &attrs)=0
 
virtual void HandleXMLEndTag (const std::string_view &WXUNUSED(tag))
 
virtual void HandleXMLContent (const std::string_view &WXUNUSED(content))
 
virtual XMLTagHandlerHandleXMLChild (const std::string_view &tag)=0
 
void ReadXMLEndTag (const char *tag)
 
void ReadXMLContent (const char *s, int len)
 
XMLTagHandlerReadXMLChild (const char *tag)
 
- Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
 ~Site ()
 
 Site ()
 
 Site (const Site &other)
 
Siteoperator= (const Site &other)
 
 Site (Site &&other)
 
Siteoperator= (Site &&other)
 
size_t size () const
 How many attachment pointers are in the Site. More...
 
template<typename Subclass = ClientData>
Subclass & Get (const RegisteredFactory &key)
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = const ClientData>
auto Get (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass & >
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = ClientData>
Subclass * Find (const RegisteredFactory &key)
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename Subclass = const ClientData>
auto Find (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass * >
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename ReplacementPointer >
void Assign (const RegisteredFactory &key, ReplacementPointer &&replacement)
 Reassign Site's pointer to ClientData. More...
 

Static Public Member Functions

static wxString GetDefaultName ()
 
static TimeTrackNew (AudacityProject &project)
 
static const TypeInfoClassTypeInfo ()
 
- Static Public Member Functions inherited from Track
template<typename Subclass = Track>
static std::shared_ptr< Subclass > SharedPointer (Track *pTrack)
 
template<typename Subclass = const Track>
static std::shared_ptr< Subclass > SharedPointer (const Track *pTrack)
 
static const TypeInfoClassTypeInfo ()
 
static void FinishCopy (const Track *n, Track *dest)
 
template<typename TrackType >
static void checkTrackType ()
 
template<typename R , typename TrackType , typename... Functions>
static R CallExecutor (R *, std::tuple<> *, TrackType &, const Functions &...)
 
template<typename R , typename TrackType , typename... Functions, typename Executor , typename... Executors>
static R CallExecutor (R *, std::tuple< Executor, Executors... > *, TrackType &track, const Functions &...functions)
 
template<typename ... Executors>
static constexpr unsigned UsedCases (std::tuple< Executors... > *)
 
template<typename Tag , bool IsConst, typename R , typename ... TrackTypes, typename ... Functions>
static R DoTypeSwitch (std::conditional_t< IsConst, const Track, Track > &track, std::tuple< TrackTypes... > *, const Functions &...functions)
 
- Static Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
static size_t slots ()
 How many static factories have been registered with this specialization of Site. More...
 

Private Types

using Holder = std::unique_ptr< TimeTrack >
 

Private Member Functions

void CleanState ()
 
void Init (const TimeTrack &orig)
 Copy the metadata from another track but not the points. More...
 
Track::Holder Clone () const override
 

Private Attributes

const ZoomInfo *const mZoomInfo
 
std::unique_ptr< BoundedEnvelopemEnvelope
 
std::unique_ptr< RulermRuler
 
bool mDisplayLog
 
bool mRescaleXMLValues
 

Additional Inherited Members

- Public Types inherited from Track
enum class  LinkType : int { None = 0 , Group = 2 , Aligned }
 For two tracks describes the type of the linkage. More...
 
enum  ChannelType { LeftChannel = 0 , RightChannel = 1 , MonoChannel = 2 }
 
using ChannelGroupAttachments = ClientData::Site< ChannelGroupData, ClientData::Cloneable<>, ClientData::DeepCopying >
 Hosting of objects attached by higher level code. More...
 
using AttachedObjects = ::AttachedTrackObjects
 Alias for my base type. More...
 
using IntervalData = TrackIntervalData
 
using Interval = TrackInterval
 
using Intervals = std::vector< Interval >
 
using ConstInterval = ConstTrackInterval
 
using ConstIntervals = std::vector< ConstInterval >
 
using Holder = std::shared_ptr< Track >
 
template<typename R = void>
using Continuation = std::function< R() >
 Type of arguments passed as optional second parameter to TypeSwitch() cases. More...
 
using Fallthrough = Continuation<>
 Type of arguments passed as optional second parameter to TypeSwitch<void>() cases. More...
 
- Public Types inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
using DataType = ClientData
 
using DataPointer = Pointer< ClientData >
 
using DataFactory = std::function< DataPointer(Host &) >
 Type of function from which RegisteredFactory is constructed; it builds attachments. More...
 
- Public Attributes inherited from Track
std::pair< int, int > vrulerSize
 
- Protected Member Functions inherited from Track
void SetLinkType (LinkType linkType, bool completeList=true)
 
void SetChannel (ChannelType c) noexcept
 
- Protected Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
template<typename Function >
void ForEach (const Function &function)
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
void ForEach (const Function &function) const
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
ClientData * FindIf (const Function &function)
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
template<typename Function >
const ClientData * FindIf (const Function &function) const
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
void BuildAll ()
 For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it. More...
 
- Protected Attributes inherited from Track
std::weak_ptr< TrackListmList
 
TrackNodePointer mNode {}
 Holds iterator to self, so that TrackList::Find can be constant-time. More...
 
int mIndex
 0-based position of this track in its TrackList More...
 
wxString mName
 
ChannelType mChannel
 
double mOffset
 

Detailed Description

A kind of Track used to 'warp time'.

Definition at line 24 of file TimeTrack.h.

Member Typedef Documentation

◆ Holder

using TimeTrack::Holder = std::unique_ptr<TimeTrack>
private

Definition at line 121 of file TimeTrack.h.

Constructor & Destructor Documentation

◆ TimeTrack() [1/2]

TimeTrack::TimeTrack ( const ZoomInfo zoomInfo)
explicit

Definition at line 55 of file TimeTrack.cpp.

55 :
56 Track()
57 , mZoomInfo(zoomInfo)
58{
59 CleanState();
60}
const ZoomInfo *const mZoomInfo
Definition: TimeTrack.h:108
void CleanState()
Definition: TimeTrack.cpp:62
Track()
Definition: Track.cpp:44

References CleanState().

Here is the call graph for this function:

◆ TimeTrack() [2/2]

TimeTrack::TimeTrack ( const TimeTrack orig,
ProtectedCreationArg &&  a,
double *  pT0 = nullptr,
double *  pT1 = nullptr 
)

Copy-Constructor - create a NEW TimeTrack:: which is an independent copy of the original.

Calls TimeTrack::Init() to copy the track metadata, then does a bunch of manipulations on the Envelope:: and Ruler:: members in order to copy one to the other - unfortunately both lack a copy-constructor to encapsulate this.

Parameters
origThe original track to copy from
pT0if not null, then the start of the sub-range to copy
pT1if not null, then the end of the sub-range to copy

@TODO: Give Ruler:: a copy-constructor instead of this?

Definition at line 82 of file TimeTrack.cpp.

84 : Track(orig, std::move(a))
85 , mZoomInfo(orig.mZoomInfo)
86{
87 Init(orig); // this copies the TimeTrack metadata (name, range, etc)
88
89 auto len = DBL_MAX;
90 if (pT0 && pT1) {
91 len = *pT1 - *pT0;
92 mEnvelope = std::make_unique<BoundedEnvelope>( *orig.mEnvelope, *pT0, *pT1 );
93 }
94 else
95 mEnvelope = std::make_unique<BoundedEnvelope>( *orig.mEnvelope );
96
99
100 mEnvelope->SetTrackLen( len );
101 mEnvelope->SetOffset(0);
102
104 mRuler = std::make_unique<Ruler>();
105 mRuler->SetUseZoomInfo(0, mZoomInfo);
106 mRuler->SetLabelEdges(false);
107 mRuler->SetFormat(Ruler::TimeFormat);
108}
@ TimeFormat
Definition: Ruler.h:33
std::unique_ptr< BoundedEnvelope > mEnvelope
Definition: TimeTrack.h:109
std::unique_ptr< Ruler > mRuler
Definition: TimeTrack.h:110
void SetRangeLower(double lower)
Definition: TimeTrack.cpp:132
double GetRangeLower() const
Definition: TimeTrack.cpp:122
double GetRangeUpper() const
Definition: TimeTrack.cpp:127
void Init(const TimeTrack &orig)
Copy the metadata from another track but not the points.
Definition: TimeTrack.cpp:111
void SetRangeUpper(double upper)
Definition: TimeTrack.cpp:137

References GetRangeLower(), GetRangeUpper(), Init(), mEnvelope, mRuler, mZoomInfo, SetRangeLower(), SetRangeUpper(), and Ruler::TimeFormat.

Here is the call graph for this function:

◆ ~TimeTrack()

TimeTrack::~TimeTrack ( )
virtual

Definition at line 118 of file TimeTrack.cpp.

119{
120}

Member Function Documentation

◆ ClassTypeInfo()

auto TimeTrack::ClassTypeInfo ( )
static

Definition at line 154 of file TimeTrack.cpp.

155{
156 return typeInfo();
157}
static const Track::TypeInfo & typeInfo()
Definition: TimeTrack.cpp:142

References typeInfo().

Here is the call graph for this function:

◆ CleanState()

void TimeTrack::CleanState ( )
private

Definition at line 62 of file TimeTrack.cpp.

63{
64 mEnvelope = std::make_unique<BoundedEnvelope>(true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0);
65
66 SetRangeLower( 0.9 );
67 SetRangeUpper( 1.1 );
68 mDisplayLog = false;
69
70 mEnvelope->SetTrackLen(DBL_MAX);
71 mEnvelope->SetOffset(0);
72
73 //Time track is always unique
75
76 mRuler = std::make_unique<Ruler>();
77 mRuler->SetUseZoomInfo(0, mZoomInfo);
78 mRuler->SetLabelEdges(false);
79 mRuler->SetFormat(Ruler::TimeFormat);
80}
#define TIMETRACK_MAX
Definition: TimeTrack.cpp:34
#define TIMETRACK_MIN
Definition: TimeTrack.cpp:33
static wxString GetDefaultName()
Definition: TimeTrack.cpp:41
bool mDisplayLog
Definition: TimeTrack.h:111
void SetName(const wxString &n)
Definition: Track.cpp:79

References GetDefaultName(), mDisplayLog, mEnvelope, mRuler, mZoomInfo, Track::SetName(), SetRangeLower(), SetRangeUpper(), Ruler::TimeFormat, TIMETRACK_MAX, and TIMETRACK_MIN.

Referenced by TimeTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Clear()

void TimeTrack::Clear ( double  t0,
double  t1 
)
override

Definition at line 207 of file TimeTrack.cpp.

208{
209 auto sampleTime = 1.0 / GetRate();
210 mEnvelope->CollapseRegion( t0, t1, sampleTime );
211}

References anonymous_namespace{TimeTrack.cpp}::GetRate(), and mEnvelope.

Referenced by Cut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Clone()

Track::Holder TimeTrack::Clone ( ) const
overrideprivatevirtual

Implements Track.

Definition at line 236 of file TimeTrack.cpp.

237{
238 auto result = std::make_shared<TimeTrack>(*this, ProtectedCreationArg{});
239 result->Init(*this);
240 return result;
241}

◆ Copy()

Track::Holder TimeTrack::Copy ( double  t0,
double  t1,
bool  forClipboard 
) const
override

Definition at line 191 of file TimeTrack.cpp.

192{
193 auto result = std::make_shared<TimeTrack>(*this, ProtectedCreationArg{}, &t0, &t1);
194 result->Init(*this);
195 return result;
196}

Referenced by Cut().

Here is the caller graph for this function:

◆ Cut()

Track::Holder TimeTrack::Cut ( double  t0,
double  t1 
)
override

Definition at line 184 of file TimeTrack.cpp.

185{
186 auto result = Copy( t0, t1, false );
187 Clear( t0, t1 );
188 return result;
189}
Holder Copy(double t0, double t1, bool forClipboard) const override
Definition: TimeTrack.cpp:191
void Clear(double t0, double t1) override
Definition: TimeTrack.cpp:207

References Clear(), and Copy().

Here is the call graph for this function:

◆ GetDefaultName()

wxString TimeTrack::GetDefaultName ( )
static

Definition at line 41 of file TimeTrack.cpp.

42{
43 return _("Time Track");
44}
#define _(s)
Definition: Internat.h:75

References _.

Referenced by CleanState().

Here is the caller graph for this function:

◆ GetDisplayLog()

bool TimeTrack::GetDisplayLog ( ) const
inline

Definition at line 96 of file TimeTrack.h.

96{ return mDisplayLog; }

Referenced by anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), anonymous_namespace{TimeTrackView.cpp}::DrawTimeTrack(), anonymous_namespace{EnvelopeHandle.cpp}::GetTimeTrackData(), and Init().

Here is the caller graph for this function:

◆ GetEndTime()

double TimeTrack::GetEndTime ( ) const
inlineoverridevirtual

Implements Track.

Definition at line 68 of file TimeTrack.h.

68{ return 0.0; }

◆ GetEnvelope() [1/2]

BoundedEnvelope * TimeTrack::GetEnvelope ( )
inline

Definition at line 85 of file TimeTrack.h.

85{ return mEnvelope.get(); }

Referenced by anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), anonymous_namespace{TimeTrackView.cpp}::DrawTimeTrack(), AUPImportFileHandle::HandleEnvelope(), and testMe().

Here is the caller graph for this function:

◆ GetEnvelope() [2/2]

const BoundedEnvelope * TimeTrack::GetEnvelope ( ) const
inline

Definition at line 86 of file TimeTrack.h.

86{ return mEnvelope.get(); }

◆ GetInterpolateLog()

bool TimeTrack::GetInterpolateLog ( ) const

Definition at line 243 of file TimeTrack.cpp.

244{
245 return mEnvelope->GetExponential();
246}

References mEnvelope.

Referenced by TimeTrackMenuTable::OnTimeTrackLogInt().

Here is the caller graph for this function:

◆ GetOffset()

double TimeTrack::GetOffset ( ) const
inlineoverridevirtual

Implements Track.

Definition at line 64 of file TimeTrack.h.

64{ return 0.0; }

◆ GetRangeLower()

double TimeTrack::GetRangeLower ( ) const

Definition at line 122 of file TimeTrack.cpp.

123{
124 return mEnvelope->GetRangeLower();
125}

References mEnvelope.

Referenced by anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), anonymous_namespace{TimeTrackView.cpp}::DrawTimeTrack(), anonymous_namespace{EnvelopeHandle.cpp}::GetTimeTrackData(), HandleXMLEndTag(), HandleXMLTag(), TimeTrackMenuTable::OnSetTimeTrackRange(), PasteInto(), and TimeTrack().

Here is the caller graph for this function:

◆ GetRangeUpper()

double TimeTrack::GetRangeUpper ( ) const

Definition at line 127 of file TimeTrack.cpp.

128{
129 return mEnvelope->GetRangeUpper();
130}

References mEnvelope.

Referenced by anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), anonymous_namespace{TimeTrackView.cpp}::DrawTimeTrack(), anonymous_namespace{EnvelopeHandle.cpp}::GetTimeTrackData(), HandleXMLEndTag(), HandleXMLTag(), TimeTrackMenuTable::OnSetTimeTrackRange(), PasteInto(), and TimeTrack().

Here is the caller graph for this function:

◆ GetRuler()

Ruler & TimeTrack::GetRuler ( ) const
inline

Definition at line 103 of file TimeTrack.h.

103{ return *mRuler; }

◆ GetStartTime()

double TimeTrack::GetStartTime ( ) const
inlineoverridevirtual

Implements Track.

Definition at line 67 of file TimeTrack.h.

67{ return 0.0; }

◆ GetTypeInfo()

auto TimeTrack::GetTypeInfo ( ) const
overridevirtual

Implements Track.

Definition at line 149 of file TimeTrack.cpp.

150{
151 return typeInfo();
152}

References typeInfo().

Here is the call graph for this function:

◆ HandleXMLChild()

XMLTagHandler * TimeTrack::HandleXMLChild ( const std::string_view &  tag)
overridevirtual

Implements XMLTagHandler.

Definition at line 306 of file TimeTrack.cpp.

307{
308 if (tag == "envelope")
309 return mEnvelope.get();
310
311 return NULL;
312}

References mEnvelope.

◆ HandleXMLEndTag()

void TimeTrack::HandleXMLEndTag ( const std::string_view &  tag)
override

Definition at line 296 of file TimeTrack.cpp.

297{
299 {
300 mRescaleXMLValues = false;
301 mEnvelope->RescaleValues(GetRangeLower(), GetRangeUpper());
303 }
304}
bool mRescaleXMLValues
Definition: TimeTrack.h:112

References GetRangeLower(), GetRangeUpper(), mEnvelope, mRescaleXMLValues, TIMETRACK_MAX, and TIMETRACK_MIN.

Here is the call graph for this function:

◆ HandleXMLTag()

bool TimeTrack::HandleXMLTag ( const std::string_view &  tag,
const AttributesList attrs 
)
overridevirtual

Implements XMLTagHandler.

Definition at line 252 of file TimeTrack.cpp.

253{
254 if (tag == "timetrack") {
255 mRescaleXMLValues = true; // will be set to false if upper/lower is found
256
257 long nValue;
258
259 for (auto pair : attrs)
260 {
261 auto attr = pair.first;
262 auto value = pair.second;
263
264 if (this->Track::HandleCommonXMLAttribute(attr, value))
265 ;
266 else if (attr == "rangelower")
267 {
268 SetRangeLower( value.Get(GetRangeLower()) );
269 mRescaleXMLValues = false;
270 }
271 else if (attr == "rangeupper")
272 {
273 SetRangeUpper( value.Get(GetRangeUpper()) );
274 mRescaleXMLValues = false;
275 }
276 else if (attr == "displaylog" && value.TryGet(nValue))
277 {
278 SetDisplayLog(nValue != 0);
279 //TODO-MB: This causes a graphical glitch, TrackPanel should probably be Refresh()ed after loading.
280 // I don't know where to do this though.
281 }
282 else if (attr == "interpolatelog" && value.TryGet(nValue))
283 {
284 SetInterpolateLog(nValue != 0);
285 }
286
287 } // while
289 mEnvelope->SetRange(0.0, 1.0); // this will be restored to the actual range later
290 return true;
291 }
292
293 return false;
294}
void SetInterpolateLog(bool interpolateLog)
Definition: TimeTrack.cpp:248
void SetDisplayLog(bool displayLog)
Definition: TimeTrack.h:97
bool HandleCommonXMLAttribute(const std::string_view &attr, const XMLAttributeValueView &valueView)
Definition: Track.cpp:1283

References GetRangeLower(), GetRangeUpper(), Track::HandleCommonXMLAttribute(), mEnvelope, mRescaleXMLValues, SetDisplayLog(), SetInterpolateLog(), SetRangeLower(), and SetRangeUpper().

Here is the call graph for this function:

◆ Init()

void TimeTrack::Init ( const TimeTrack orig)
private

Copy the metadata from another track but not the points.

Copies the Name, DefaultName, Range and Display data from the source track

Parameters
origthe TimeTrack to copy from

Definition at line 111 of file TimeTrack.cpp.

112{
113 Track::Init(orig);
114 SetName(orig.GetName());
116}
bool GetDisplayLog() const
Definition: TimeTrack.h:96
wxString GetName() const
Definition: Track.h:466
void Init(const Track &orig)
Definition: Track.cpp:64

References GetDisplayLog(), Track::GetName(), Track::Init(), SetDisplayLog(), and Track::SetName().

Referenced by TimeTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsertSilence()

void TimeTrack::InsertSilence ( double  t,
double  len 
)
override

Definition at line 231 of file TimeTrack.cpp.

232{
233 mEnvelope->InsertSpace(t, len);
234}

References mEnvelope.

◆ New()

TimeTrack * TimeTrack::New ( AudacityProject project)
static

Definition at line 46 of file TimeTrack.cpp.

47{
48 auto &tracks = TrackList::Get( project );
49 auto &viewInfo = ViewInfo::Get( project );
50 auto result = tracks.Add(std::make_shared<TimeTrack>(&viewInfo));
51 result->AttachedTrackObjects::BuildAll();
52 return result;
53}
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References ViewInfo::Get(), and TrackList::Get().

Here is the call graph for this function:

◆ Paste()

void TimeTrack::Paste ( double  t,
const Track src 
)
override

Definition at line 213 of file TimeTrack.cpp.

214{
215 bool bOk = src && src->TypeSwitch< bool >( [&] (const TimeTrack *tt) {
216 auto sampleTime = 1.0 / GetRate();
217 mEnvelope->PasteEnvelope
218 (t, tt->mEnvelope.get(), sampleTime);
219 return true;
220 } );
221
222 if (! bOk )
223 // THROW_INCONSISTENCY_EXCEPTION // ?
224 (void)0;// intentionally do nothing.
225}
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:24
R TypeSwitch(const Functions &...functions)
Use this function rather than testing track type explicitly and making down-casts.
Definition: Track.h:832

References anonymous_namespace{TimeTrack.cpp}::GetRate(), mEnvelope, and Track::TypeSwitch().

Here is the call graph for this function:

◆ PasteInto()

Track::Holder TimeTrack::PasteInto ( AudacityProject ) const
overridevirtual

Find or create the destination track for a paste, maybe in a different project.

Returns
A smart pointer to the track; its use_count() can tell whether it is new

Implements Track.

Definition at line 164 of file TimeTrack.cpp.

165{
166 // Maintain uniqueness of the time track!
167 std::shared_ptr<TimeTrack> pNewTrack;
168 if( auto pTrack = *TrackList::Get( project ).Any<TimeTrack>().begin() )
169 pNewTrack = pTrack->SharedPointer<TimeTrack>();
170 else
171 pNewTrack = std::make_shared<TimeTrack>( &ViewInfo::Get( project ) );
172
173 // Should come here only for .aup3 import, not for paste (because the
174 // track is skipped in cut/copy commands)
175 // And for import we agree to replace the track contents completely
176 pNewTrack->CleanState();
177 pNewTrack->Init(*this);
178 pNewTrack->Paste(0.0, this);
179 pNewTrack->SetRangeLower(this->GetRangeLower());
180 pNewTrack->SetRangeUpper(this->GetRangeUpper());
181 return pNewTrack;
182}
void Paste(double t, const Track *src) override
Definition: TimeTrack.cpp:213
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150

References PackedArray::begin(), ViewInfo::Get(), TrackList::Get(), GetRangeLower(), and GetRangeUpper().

Here is the call graph for this function:

◆ SetDisplayLog()

void TimeTrack::SetDisplayLog ( bool  displayLog)
inline

Definition at line 97 of file TimeTrack.h.

97{ mDisplayLog = displayLog; }

Referenced by HandleXMLTag(), Init(), TimeTrackMenuTable::OnTimeTrackLin(), and TimeTrackMenuTable::OnTimeTrackLog().

Here is the caller graph for this function:

◆ SetInterpolateLog()

void TimeTrack::SetInterpolateLog ( bool  interpolateLog)

Definition at line 248 of file TimeTrack.cpp.

248 {
249 mEnvelope->SetExponential(interpolateLog);
250}

References mEnvelope.

Referenced by HandleXMLTag(), and TimeTrackMenuTable::OnTimeTrackLogInt().

Here is the caller graph for this function:

◆ SetOffset()

void TimeTrack::SetOffset ( double  )
inlineoverridevirtual

Reimplemented from Track.

Definition at line 65 of file TimeTrack.h.

65{}

◆ SetRangeLower()

void TimeTrack::SetRangeLower ( double  lower)

Definition at line 132 of file TimeTrack.cpp.

133{
134 mEnvelope->SetRangeLower( lower );
135}

References mEnvelope.

Referenced by CleanState(), HandleXMLTag(), TimeTrackMenuTable::OnSetTimeTrackRange(), and TimeTrack().

Here is the caller graph for this function:

◆ SetRangeUpper()

void TimeTrack::SetRangeUpper ( double  upper)

Definition at line 137 of file TimeTrack.cpp.

138{
139 mEnvelope->SetRangeUpper( upper );
140}

References mEnvelope.

Referenced by CleanState(), HandleXMLTag(), TimeTrackMenuTable::OnSetTimeTrackRange(), and TimeTrack().

Here is the caller graph for this function:

◆ Silence()

void TimeTrack::Silence ( double  t0,
double  t1 
)
override

Definition at line 227 of file TimeTrack.cpp.

228{
229}

◆ SupportsBasicEditing()

bool TimeTrack::SupportsBasicEditing ( ) const
overridevirtual

Whether this track type implements cut-copy-paste; by default, true.

Reimplemented from Track.

Definition at line 159 of file TimeTrack.cpp.

160{
161 return false;
162}

◆ testMe()

void TimeTrack::testMe ( )

Definition at line 332 of file TimeTrack.cpp.

333{
334 GetEnvelope()->Flatten(0.0);
335 GetEnvelope()->InsertOrReplace(0.0, 0.2);
336 GetEnvelope()->InsertOrReplace(5.0 - 0.001, 0.2);
337 GetEnvelope()->InsertOrReplace(5.0 + 0.001, 1.3);
338 GetEnvelope()->InsertOrReplace(10.0, 1.3);
339
340 double value1 = GetEnvelope()->Integral(2.0, 13.0);
341 double expected1 = (5.0 - 2.0) * 0.2 + (13.0 - 5.0) * 1.3;
342 double value2 = GetEnvelope()->IntegralOfInverse(2.0, 13.0);
343 double expected2 = (5.0 - 2.0) / 0.2 + (13.0 - 5.0) / 1.3;
344 if( fabs(value1 - expected1) > 0.01 )
345 {
346 wxPrintf( "TimeTrack: Integral failed! expected %f got %f\n", expected1, value1);
347 }
348 if( fabs(value2 - expected2) > 0.01 )
349 {
350 wxPrintf( "TimeTrack: IntegralOfInverse failed! expected %f got %f\n", expected2, value2);
351 }
352
353 /*double reqt0 = 10.0 - .1;
354 double reqt1 = 10.0 + .1;
355 double t0 = warp( reqt0 );
356 double t1 = warp( reqt1 );
357 if( t0 > t1 )
358 {
359 wxPrintf( "TimeTrack: Warping reverses an interval! [%.2f,%.2f] -> [%.2f,%.2f]\n",
360 reqt0, reqt1,
361 t0, t1 );
362 }*/
363}
double Integral(double t0, double t1) const
Definition: Envelope.cpp:1166
int InsertOrReplace(double when, double value)
Add a point at a particular absolute time coordinate.
Definition: Envelope.h:173
double IntegralOfInverse(double t0, double t1) const
Definition: Envelope.cpp:1229
void Flatten(double value)
Definition: Envelope.cpp:132
BoundedEnvelope * GetEnvelope()
Definition: TimeTrack.h:85

References Envelope::Flatten(), GetEnvelope(), Envelope::InsertOrReplace(), Envelope::Integral(), and Envelope::IntegralOfInverse().

Here is the call graph for this function:

◆ WriteXML()

void TimeTrack::WriteXML ( XMLWriter xmlFile) const
overridevirtual

Implements Track.

Definition at line 314 of file TimeTrack.cpp.

316{
317 xmlFile.StartTag(wxT("timetrack"));
318 this->Track::WriteCommonXMLAttributes( xmlFile );
319
320 //xmlFile.WriteAttr(wxT("channel"), mChannel);
321 //xmlFile.WriteAttr(wxT("offset"), mOffset, 8);
322 xmlFile.WriteAttr(wxT("rangelower"), GetRangeLower(), 12);
323 xmlFile.WriteAttr(wxT("rangeupper"), GetRangeUpper(), 12);
324 xmlFile.WriteAttr(wxT("displaylog"), GetDisplayLog());
325 xmlFile.WriteAttr(wxT("interpolatelog"), GetInterpolateLog());
326
327 mEnvelope->WriteXML(xmlFile);
328
329 xmlFile.EndTag(wxT("timetrack"));
330}
bool GetInterpolateLog() const
Definition: TimeTrack.cpp:243
void WriteCommonXMLAttributes(XMLWriter &xmlFile, bool includeNameAndSelected=true) const
Definition: Track.cpp:1270
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:80
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:37
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:103

References Track::WriteCommonXMLAttributes().

Here is the call graph for this function:

Member Data Documentation

◆ mDisplayLog

bool TimeTrack::mDisplayLog
private

Definition at line 111 of file TimeTrack.h.

Referenced by CleanState().

◆ mEnvelope

std::unique_ptr<BoundedEnvelope> TimeTrack::mEnvelope
private

◆ mRescaleXMLValues

bool TimeTrack::mRescaleXMLValues
private

Definition at line 112 of file TimeTrack.h.

Referenced by HandleXMLEndTag(), and HandleXMLTag().

◆ mRuler

std::unique_ptr<Ruler> TimeTrack::mRuler
private

Definition at line 110 of file TimeTrack.h.

Referenced by CleanState(), and TimeTrack().

◆ mZoomInfo

const ZoomInfo* const TimeTrack::mZoomInfo
private

Definition at line 108 of file TimeTrack.h.

Referenced by CleanState(), and TimeTrack().


The documentation for this class was generated from the following files: