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 54 of file TimeTrack.cpp.

54 :
55 Track()
56 , mZoomInfo(zoomInfo)
57{
58 CleanState();
59}
const ZoomInfo *const mZoomInfo
Definition: TimeTrack.h:108
void CleanState()
Definition: TimeTrack.cpp:61
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 81 of file TimeTrack.cpp.

83 : Track(orig, std::move(a))
84 , mZoomInfo(orig.mZoomInfo)
85{
86 Init(orig); // this copies the TimeTrack metadata (name, range, etc)
87
88 auto len = DBL_MAX;
89 if (pT0 && pT1) {
90 len = *pT1 - *pT0;
91 mEnvelope = std::make_unique<BoundedEnvelope>( *orig.mEnvelope, *pT0, *pT1 );
92 }
93 else
94 mEnvelope = std::make_unique<BoundedEnvelope>( *orig.mEnvelope );
95
98
99 mEnvelope->SetTrackLen( len );
100 mEnvelope->SetOffset(0);
101
103 mRuler = std::make_unique<Ruler>();
104 mRuler->SetUseZoomInfo(0, mZoomInfo);
105 mRuler->SetLabelEdges(false);
106 mRuler->SetFormat(Ruler::TimeFormat);
107}
@ 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:131
double GetRangeLower() const
Definition: TimeTrack.cpp:121
double GetRangeUpper() const
Definition: TimeTrack.cpp:126
void Init(const TimeTrack &orig)
Copy the metadata from another track but not the points.
Definition: TimeTrack.cpp:110
void SetRangeUpper(double upper)
Definition: TimeTrack.cpp:136

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 117 of file TimeTrack.cpp.

118{
119}

Member Function Documentation

◆ ClassTypeInfo()

auto TimeTrack::ClassTypeInfo ( )
static

Definition at line 153 of file TimeTrack.cpp.

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

References typeInfo().

Here is the call graph for this function:

◆ CleanState()

void TimeTrack::CleanState ( )
private

Definition at line 61 of file TimeTrack.cpp.

62{
63 mEnvelope = std::make_unique<BoundedEnvelope>(true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0);
64
65 SetRangeLower( 0.9 );
66 SetRangeUpper( 1.1 );
67 mDisplayLog = false;
68
69 mEnvelope->SetTrackLen(DBL_MAX);
70 mEnvelope->SetOffset(0);
71
72 //Time track is always unique
74
75 mRuler = std::make_unique<Ruler>();
76 mRuler->SetUseZoomInfo(0, mZoomInfo);
77 mRuler->SetLabelEdges(false);
78 mRuler->SetFormat(Ruler::TimeFormat);
79}
#define TIMETRACK_MAX
Definition: TimeTrack.cpp:33
#define TIMETRACK_MIN
Definition: TimeTrack.cpp:32
static wxString GetDefaultName()
Definition: TimeTrack.cpp:40
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 206 of file TimeTrack.cpp.

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

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 235 of file TimeTrack.cpp.

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

◆ Copy()

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

Definition at line 190 of file TimeTrack.cpp.

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

Referenced by Cut().

Here is the caller graph for this function:

◆ Cut()

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

Definition at line 183 of file TimeTrack.cpp.

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

References Clear(), and Copy().

Here is the call graph for this function:

◆ GetDefaultName()

wxString TimeTrack::GetDefaultName ( )
static

Definition at line 40 of file TimeTrack.cpp.

41{
42 return _("Time Track");
43}
#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 242 of file TimeTrack.cpp.

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

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 121 of file TimeTrack.cpp.

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

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 126 of file TimeTrack.cpp.

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

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 148 of file TimeTrack.cpp.

149{
150 return typeInfo();
151}

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 305 of file TimeTrack.cpp.

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

References mEnvelope.

◆ HandleXMLEndTag()

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

Definition at line 295 of file TimeTrack.cpp.

296{
298 {
299 mRescaleXMLValues = false;
300 mEnvelope->RescaleValues(GetRangeLower(), GetRangeUpper());
302 }
303}
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 251 of file TimeTrack.cpp.

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

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 110 of file TimeTrack.cpp.

111{
112 Track::Init(orig);
113 SetName(orig.GetName());
115}
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 230 of file TimeTrack.cpp.

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

References mEnvelope.

◆ New()

TimeTrack * TimeTrack::New ( AudacityProject project)
static

Definition at line 45 of file TimeTrack.cpp.

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

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 212 of file TimeTrack.cpp.

213{
214 bool bOk = src && src->TypeSwitch< bool >( [&] (const TimeTrack *tt) {
215 auto sampleTime = 1.0 / GetRate();
216 mEnvelope->PasteEnvelope
217 (t, tt->mEnvelope.get(), sampleTime);
218 return true;
219 } );
220
221 if (! bOk )
222 // THROW_INCONSISTENCY_EXCEPTION // ?
223 (void)0;// intentionally do nothing.
224}
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 163 of file TimeTrack.cpp.

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

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

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 131 of file TimeTrack.cpp.

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

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 136 of file TimeTrack.cpp.

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

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 226 of file TimeTrack.cpp.

227{
228}

◆ SupportsBasicEditing()

bool TimeTrack::SupportsBasicEditing ( ) const
overridevirtual

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

Reimplemented from Track.

Definition at line 158 of file TimeTrack.cpp.

159{
160 return false;
161}

◆ testMe()

void TimeTrack::testMe ( )

Definition at line 331 of file TimeTrack.cpp.

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

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

References Track::WriteCommonXMLAttributes(), and wxT().

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: