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 ()
 
 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...
 
Track::Holder PasteInto (AudacityProject &project, TrackList &list) const override
 
Track::Holder Cut (double t0, double t1) override
 Create tracks and modify this track. More...
 
Track::Holder Copy (double t0, double t1, bool forClipboard) const override
 Create new tracks and don't modify this track. More...
 
void Clear (double t0, double t1) override
 
void Paste (double t, const Track &src) override
 Weak precondition allows overrides to replicate one channel into many. More...
 
void Silence (double t0, double t1, ProgressReporter reportProgress={}) override
 
void InsertSilence (double t, double len) override
 
void MoveTo (double) override
 Change start time to given time point. More...
 
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 ()
 
size_t NIntervals () const override
 Report the number of intervals. More...
 
- Public Member Functions inherited from UniqueChannelTrack< Base >
size_t NChannels () const override
 Report the number of channels. More...
 
std::shared_ptr< ChannelDoGetChannel (size_t iChannel) override
 
- 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 > >
 
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 &project, TrackList &list) const =0
 
virtual bool LinkConsistencyFix (bool doFix=true)
 Check consistency of channel groups, and maybe fix it. More...
 
bool LinkConsistencyCheck ()
 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
 
 Track ()
 
 Track (const Track &orig, ProtectedCreationArg &&)
 
Trackoperator= (const Track &orig)=delete
 
virtual ~Track ()
 
void Init (const Track &orig)
 
virtual Holder Duplicate (DuplicateOptions={}) const
 public nonvirtual duplication function that invokes Clone() More...
 
void ReparentAllAttachments ()
 
const wxString & GetName () const
 Name is always the same for all channels of a group. More...
 
void SetName (const wxString &n)
 
bool GetSelected () const
 Selectedness is always the same for all channels of a group. More...
 
virtual void SetSelected (bool s)
 
virtual Holder Cut (double t0, double t1)=0
 Create tracks and modify this track. More...
 
virtual Holder Copy (double t0, double t1, bool forClipboard=true) const =0
 Create new tracks and don't modify this track. More...
 
virtual void Clear (double t0, double t1)=0
 
virtual void Paste (double t, const Track &src)=0
 Weak precondition allows overrides to replicate one channel into many. More...
 
virtual void SyncLockAdjust (double oldT1, double newT1)
 
virtual void Silence (double t0, double t1, ProgressReporter reportProgress={})=0
 
virtual void InsertSilence (double t, double len)=0
 
bool SameKindAs (const Track &track) const
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions)
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions) const
 
virtual void WriteXML (XMLWriter &xmlFile) const =0
 
virtual std::optional< TranslatableStringGetErrorOpening () const
 
void Notify (bool allChannels, int code=-1)
 
bool Any () const
 
bool IsSelected () const
 
bool IsLeader () 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...
 
- Public Member Functions inherited from ChannelGroup
virtual ~ChannelGroup ()
 
double GetStartTime () const
 Get the minimum of Start() values of intervals, or 0 when none. More...
 
double GetEndTime () const
 Get the maximum of End() values of intervals, or 0 when none. More...
 
void ShiftBy (double t)
 Change start time by given duration. More...
 
virtual void MoveTo (double o)=0
 Change start time to given time point. More...
 
template<typename ChannelType = Channel>
std::shared_ptr< ChannelType > GetChannel (size_t iChannel)
 Retrieve a channel, cast to the given type. More...
 
template<typename ChannelType = const Channel>
auto GetChannel (size_t iChannel) const -> std::enable_if_t< std::is_const_v< ChannelType >, std::shared_ptr< ChannelType > >
 
template<typename ChannelType = Channel>
IteratorRange< ChannelIterator< ChannelType > > Channels ()
 Get range of channels with mutative access. More...
 
template<typename ChannelType = const Channel>
auto Channels () const -> std::enable_if_t< std::is_const_v< ChannelType >, IteratorRange< ChannelIterator< ChannelType > > >
 Get range of channels with read-only access. More...
 
std::shared_ptr< ChannelNthChannel (size_t nChannel)
 
std::shared_ptr< const ChannelNthChannel (size_t nChannel) const
 
template<typename IntervalType = Interval>
std::shared_ptr< IntervalType > GetInterval (size_t iInterval)
 Retrieve an interval, cast to the given type. More...
 
template<typename IntervalType = const Interval>
auto GetInterval (size_t iInterval) const -> std::enable_if_t< std::is_const_v< IntervalType >, std::shared_ptr< IntervalType > >
 
template<typename IntervalType = Interval>
IteratorRange< IntervalIterator< IntervalType > > Intervals ()
 Get range of intervals with mutative access. More...
 
template<typename IntervalType = const Interval>
auto Intervals () const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< IntervalIterator< IntervalType > > >
 Get range of intervals with read-only access. More...
 
- Public Member Functions inherited from Channel
virtual ~Channel ()
 
ChannelGroupGetChannelGroup ()
 Channel object's lifetime is assumed to be nested in its Track's. More...
 
const ChannelGroupGetChannelGroup () const
 Channel object's lifetime is assumed to be nested in its Track's. More...
 
size_t GetChannelIndex () const
 
size_t NIntervals () const
 Report the number of intervals. More...
 
template<typename IntervalType = Interval>
std::shared_ptr< IntervalType > GetInterval (size_t iInterval)
 Retrieve an interval, cast to the given type. More...
 
template<typename IntervalType = const Interval>
auto GetInterval (size_t iInterval) const -> std::enable_if_t< std::is_const_v< IntervalType >, std::shared_ptr< IntervalType > >
 
template<typename IntervalType = Interval>
IteratorRange< IntervalIterator< IntervalType > > Intervals ()
 Get range of intervals with mutative access. More...
 
template<typename IntervalType = const Interval>
auto Intervals () const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< IntervalIterator< IntervalType > > >
 Get range of intervals with read-only access. 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 CopyAttachments (Track &dst, const Track &src, bool deep)
 Copy (deep) or just share (!deep) AttachedTrackObjects. More...
 
- Static Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
static size_t numFactories ()
 How many static factories have been registered with this specialization of Site. More...
 

Private Types

using Holder = std::unique_ptr< TimeTrack >
 

Private Member Functions

std::shared_ptr< WideChannelGroupIntervalDoGetInterval (size_t iInterval) override
 Retrieve an interval. More...
 
void CleanState ()
 
void Init (const TimeTrack &orig)
 Copy the metadata from another track but not the points. More...
 
Track::Holder Clone (bool backup) const override
 

Private Attributes

std::unique_ptr< BoundedEnvelopemEnvelope
 
bool mDisplayLog
 
bool mRescaleXMLValues
 

Additional Inherited Members

- Public Types inherited from Track
using AttachedObjects = ::AttachedTrackObjects
 Alias for my base type. More...
 
using Holder = std::shared_ptr< Track >
 
- 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 Types inherited from ChannelGroup
enum class  LinkType : int { None = 0 , Group = 2 , Aligned }
 For two tracks describes the type of the linkage. More...
 
using Attachments = ChannelGroupAttachments
 
using Interval = WideChannelGroupInterval
 
- Public Types inherited from Channel
using Interval = ChannelInterval
 
- Protected Member Functions inherited from UniqueChannelTrack< Base >
ChannelGroupDoGetChannelGroup () const override
 Subclass must override. More...
 
- Protected Member Functions inherited from Track
void SetLinkType (LinkType linkType, bool completeList=true)
 
- 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 >
void ForCorresponding (Site &other, const Function &function, bool create=true)
 
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...
 
template<typename Function >
void EraseIf (const Function &function)
 Erase attached objects satisfying a predicate. More...
 
void BuildAll ()
 For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it. More...
 
virtual std::shared_ptr< ChannelDoGetChannel (size_t iChannel)=0
 
virtual std::shared_ptr< IntervalDoGetInterval (size_t iInterval)=0
 Retrieve an interval. More...
 
virtual ChannelGroupDoGetChannelGroup () const =0
 Subclass must override. 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...
 

Detailed Description

A kind of Track used to 'warp time'.

Definition at line 22 of file TimeTrack.h.

Member Typedef Documentation

◆ Holder

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

Definition at line 120 of file TimeTrack.h.

Constructor & Destructor Documentation

◆ TimeTrack() [1/2]

TimeTrack::TimeTrack ( )

Definition at line 47 of file TimeTrack.cpp.

48{
49 CleanState();
50}
void CleanState()
Definition: TimeTrack.cpp:52

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:: 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

Definition at line 67 of file TimeTrack.cpp.

69 : UniqueChannelTrack{ orig, std::move(a) }
70{
71 Init(orig); // this copies the TimeTrack metadata (name, range, etc)
72
73 auto len = DBL_MAX;
74 if (pT0 && pT1) {
75 len = *pT1 - *pT0;
76 mEnvelope = std::make_unique<BoundedEnvelope>( *orig.mEnvelope, *pT0, *pT1 );
77 }
78 else
79 mEnvelope = std::make_unique<BoundedEnvelope>( *orig.mEnvelope );
80
83
84 mEnvelope->SetTrackLen( len );
85 mEnvelope->SetOffset(0);
86}
std::unique_ptr< BoundedEnvelope > mEnvelope
Definition: TimeTrack.h:109
void SetRangeLower(double lower)
Definition: TimeTrack.cpp:110
double GetRangeLower() const
Definition: TimeTrack.cpp:100
double GetRangeUpper() const
Definition: TimeTrack.cpp:105
void Init(const TimeTrack &orig)
Copy the metadata from another track but not the points.
Definition: TimeTrack.cpp:89
void SetRangeUpper(double upper)
Definition: TimeTrack.cpp:115
Generates overrides of channel-related functions.
Definition: Track.h:450

References GetRangeLower(), GetRangeUpper(), Init(), mEnvelope, SetRangeLower(), and SetRangeUpper().

Here is the call graph for this function:

◆ ~TimeTrack()

TimeTrack::~TimeTrack ( )
virtual

Definition at line 96 of file TimeTrack.cpp.

97{
98}

Member Function Documentation

◆ ClassTypeInfo()

auto TimeTrack::ClassTypeInfo ( )
static

Definition at line 132 of file TimeTrack.cpp.

133{
134 return typeInfo();
135}
static const Track::TypeInfo & typeInfo()
Definition: TimeTrack.cpp:120

References typeInfo().

Here is the call graph for this function:

◆ CleanState()

void TimeTrack::CleanState ( )
private

Definition at line 52 of file TimeTrack.cpp.

53{
54 mEnvelope = std::make_unique<BoundedEnvelope>(true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0);
55
56 SetRangeLower( 0.2 );
57 SetRangeUpper( 2.0 );
58 mDisplayLog = false;
59
60 mEnvelope->SetTrackLen(DBL_MAX);
61 mEnvelope->SetOffset(0);
62
63 //Time track is always unique
65}
#define TIMETRACK_MAX
Definition: TimeTrack.cpp:27
#define TIMETRACK_MIN
Definition: TimeTrack.cpp:26
static wxString GetDefaultName()
Definition: TimeTrack.cpp:34
bool mDisplayLog
Definition: TimeTrack.h:110
void SetName(const wxString &n)
Definition: Track.cpp:69

References GetDefaultName(), mDisplayLog, mEnvelope, Track::SetName(), SetRangeLower(), SetRangeUpper(), 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 
)
overridevirtual

May assume precondition: t0 <= t1

Implements Track.

Definition at line 191 of file TimeTrack.cpp.

192{
193 auto sampleTime = 1.0 / GetRate(*this);
194 mEnvelope->CollapseRegion( t0, t1, sampleTime );
195}
double GetRate(const Track &track)
Definition: TimeTrack.cpp:182

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 ( bool  backup) const
overrideprivatevirtual

Subclass responsibility implements only a part of Duplicate(), copying the track data proper (not associated data such as for groups and views) including TrackId

Parameters
backupwhether the duplication is for backup purposes while opening a project, instead of other editing operations
Postcondition
result tracks have same TrackIds as the channels of this

Implements Track.

Definition at line 220 of file TimeTrack.cpp.

221{
222 auto result = std::make_shared<TimeTrack>(*this, ProtectedCreationArg{});
223 result->Init(*this);
224 return result;
225}

◆ Copy()

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

Create new tracks and don't modify this track.

Returns
non-NULL or else throw Note that subclasses may want to distinguish tracks stored in a clipboard from those stored in a project May assume precondition: t0 <= t1 Should invoke Track::Init

Implements Track.

Definition at line 173 of file TimeTrack.cpp.

174{
175 auto track =
176 std::make_shared<TimeTrack>(*this, ProtectedCreationArg{}, &t0, &t1);
177 track->Init(*this);
178 return track;
179}

Referenced by Cut().

Here is the caller graph for this function:

◆ Cut()

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

Create tracks and modify this track.

Returns
non-NULL or else throw May assume precondition: t0 <= t1

Implements Track.

Definition at line 166 of file TimeTrack.cpp.

167{
168 auto result = Copy(t0, t1, false);
169 Clear(t0, t1);
170 return result;
171}
Track::Holder Copy(double t0, double t1, bool forClipboard) const override
Create new tracks and don't modify this track.
Definition: TimeTrack.cpp:173
void Clear(double t0, double t1) override
Definition: TimeTrack.cpp:191

References Clear(), and Copy().

Here is the call graph for this function:

◆ DoGetInterval()

std::shared_ptr< WideChannelGroupInterval > TimeTrack::DoGetInterval ( size_t  iInterval)
overrideprivatevirtual

Retrieve an interval.

Postcondition
result: !(iInterval < NIntervals()) || result

Implements ChannelGroup.

Definition at line 322 of file TimeTrack.cpp.

323{
324 return {};
325}

◆ GetDefaultName()

wxString TimeTrack::GetDefaultName ( )
static

Definition at line 34 of file TimeTrack.cpp.

35{
36 return _("Time Track");
37}
#define _(s)
Definition: Internat.h:73

References _.

Referenced by CleanState().

Here is the caller graph for this function:

◆ GetDisplayLog()

bool TimeTrack::GetDisplayLog ( ) const
inline

Definition at line 94 of file TimeTrack.h.

94{ 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:

◆ GetEnvelope() [1/2]

BoundedEnvelope * TimeTrack::GetEnvelope ( )
inline

Definition at line 83 of file TimeTrack.h.

83{ return mEnvelope.get(); }

Referenced by DEFINE_ATTACHED_VIRTUAL_OVERRIDE(), 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 84 of file TimeTrack.h.

84{ return mEnvelope.get(); }

◆ GetInterpolateLog()

bool TimeTrack::GetInterpolateLog ( ) const

Definition at line 227 of file TimeTrack.cpp.

228{
229 return mEnvelope->GetExponential();
230}

References mEnvelope.

◆ GetRangeLower()

double TimeTrack::GetRangeLower ( ) const

Definition at line 100 of file TimeTrack.cpp.

101{
102 return mEnvelope->GetRangeLower();
103}

References mEnvelope.

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

Here is the caller graph for this function:

◆ GetRangeUpper()

double TimeTrack::GetRangeUpper ( ) const

Definition at line 105 of file TimeTrack.cpp.

106{
107 return mEnvelope->GetRangeUpper();
108}

References mEnvelope.

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

Here is the caller graph for this function:

◆ GetTypeInfo()

auto TimeTrack::GetTypeInfo ( ) const
overridevirtual

Implements Track.

Definition at line 127 of file TimeTrack.cpp.

128{
129 return typeInfo();
130}

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

291{
292 if (tag == "envelope")
293 return mEnvelope.get();
294
295 return NULL;
296}

References mEnvelope.

◆ HandleXMLEndTag()

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

Definition at line 280 of file TimeTrack.cpp.

281{
283 {
284 mRescaleXMLValues = false;
285 mEnvelope->RescaleValues(GetRangeLower(), GetRangeUpper());
287 }
288}
bool mRescaleXMLValues
Definition: TimeTrack.h:111

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

237{
238 if (tag == "timetrack") {
239 mRescaleXMLValues = true; // will be set to false if upper/lower is found
240
241 long nValue;
242
243 for (auto pair : attrs)
244 {
245 auto attr = pair.first;
246 auto value = pair.second;
247
248 if (this->Track::HandleCommonXMLAttribute(attr, value))
249 ;
250 else if (attr == "rangelower")
251 {
252 SetRangeLower( value.Get(GetRangeLower()) );
253 mRescaleXMLValues = false;
254 }
255 else if (attr == "rangeupper")
256 {
257 SetRangeUpper( value.Get(GetRangeUpper()) );
258 mRescaleXMLValues = false;
259 }
260 else if (attr == "displaylog" && value.TryGet(nValue))
261 {
262 SetDisplayLog(nValue != 0);
263 //TODO-MB: This causes a graphical glitch, TrackPanel should probably be Refresh()ed after loading.
264 // I don't know where to do this though.
265 }
266 else if (attr == "interpolatelog" && value.TryGet(nValue))
267 {
268 SetInterpolateLog(nValue != 0);
269 }
270
271 } // while
273 mEnvelope->SetRange(0.0, 1.0); // this will be restored to the actual range later
274 return true;
275 }
276
277 return false;
278}
void SetInterpolateLog(bool interpolateLog)
Definition: TimeTrack.cpp:232
void SetDisplayLog(bool displayLog)
Definition: TimeTrack.h:95
bool HandleCommonXMLAttribute(const std::string_view &attr, const XMLAttributeValueView &valueView)
Definition: Track.cpp:819

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

90{
91 Track::Init(orig);
92 SetName(orig.GetName());
94}
bool GetDisplayLog() const
Definition: TimeTrack.h:94
const wxString & GetName() const
Name is always the same for all channels of a group.
Definition: Track.cpp:64
void Init(const Track &orig)
Definition: Track.cpp:47

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 
)
overridevirtual

May assume precondition: t0 <= t1

Implements Track.

Definition at line 215 of file TimeTrack.cpp.

216{
217 mEnvelope->InsertSpace(t, len);
218}

References mEnvelope.

◆ MoveTo()

void TimeTrack::MoveTo ( double  o)
inlineoverridevirtual

Change start time to given time point.

Implements ChannelGroup.

Definition at line 66 of file TimeTrack.h.

66{}

◆ New()

TimeTrack * TimeTrack::New ( AudacityProject project)
static

Definition at line 39 of file TimeTrack.cpp.

40{
41 auto &tracks = TrackList::Get( project );
42 auto result = tracks.Add(std::make_shared<TimeTrack>());
43 result->AttachedTrackObjects::BuildAll();
44 return result;
45}
const auto tracks
const auto project
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314

References TrackList::Get(), project, and tracks.

Here is the call graph for this function:

◆ NIntervals()

size_t TimeTrack::NIntervals ( ) const
overridevirtual

Report the number of intervals.

Implements ChannelGroup.

Definition at line 316 of file TimeTrack.cpp.

317{
318 return 0;
319}

◆ Paste()

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

Weak precondition allows overrides to replicate one channel into many.

Precondition
SameKindAs(src)
src.NChannels() == 1 || src.NChannels() == NChannels()

Implements Track.

Definition at line 197 of file TimeTrack.cpp.

198{
199 bool bOk = src.TypeSwitch<bool>([&](const TimeTrack &tt) {
200 auto sampleTime = 1.0 / GetRate(*this);
201 mEnvelope->PasteEnvelope(t, tt.mEnvelope.get(), sampleTime);
202 return true;
203 });
204
205 if (!bOk)
206 // THROW_INCONSISTENCY_EXCEPTION // ?
207 (void)0;// intentionally do nothing.
208}
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:24
R TypeSwitch(const Functions &...functions)
Definition: Track.h:381

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

Here is the call graph for this function:

◆ PasteInto()

Track::Holder TimeTrack::PasteInto ( AudacityProject project,
TrackList list 
) const
overridevirtual

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

Parameters
listto which any newly created tracks are added; but left unchanged if an existing track is found in the project instead
Returns
A smart pointer to a track

Implements Track.

Definition at line 142 of file TimeTrack.cpp.

144{
145 // Maintain uniqueness of the time track!
146 std::shared_ptr<TimeTrack> pNewTrack;
147 if (auto pTrack = *TrackList::Get(project).Any<TimeTrack>().begin())
148 // leave list unchanged
149 pNewTrack = pTrack->SharedPointer<TimeTrack>();
150 else {
151 pNewTrack = std::make_shared<TimeTrack>();
152 list.Add(pNewTrack);
153 }
154
155 // Should come here only for .aup3 import, not for paste (because the
156 // track is skipped in cut/copy commands)
157 // And for import we agree to replace the track contents completely
158 pNewTrack->CleanState();
159 pNewTrack->Init(*this);
160 pNewTrack->Paste(0.0, *this);
161 pNewTrack->SetRangeLower(this->GetRangeLower());
162 pNewTrack->SetRangeUpper(this->GetRangeUpper());
163 return pNewTrack;
164}
TrackKind * Add(const std::shared_ptr< TrackKind > &t, bool assignIds=true)
Definition: Track.h:1048
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101

References TrackList::Add(), details::begin(), TrackList::Get(), GetRangeLower(), GetRangeUpper(), and project.

Here is the call graph for this function:

◆ SetDisplayLog()

void TimeTrack::SetDisplayLog ( bool  displayLog)
inline

Definition at line 95 of file TimeTrack.h.

95{ 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 232 of file TimeTrack.cpp.

232 {
233 mEnvelope->SetExponential(interpolateLog);
234}

References mEnvelope.

Referenced by HandleXMLTag().

Here is the caller graph for this function:

◆ SetRangeLower()

void TimeTrack::SetRangeLower ( double  lower)

Definition at line 110 of file TimeTrack.cpp.

111{
112 mEnvelope->SetRangeLower( lower );
113}

References mEnvelope.

Referenced by CleanState(), HandleXMLTag(), and TimeTrack().

Here is the caller graph for this function:

◆ SetRangeUpper()

void TimeTrack::SetRangeUpper ( double  upper)

Definition at line 115 of file TimeTrack.cpp.

116{
117 mEnvelope->SetRangeUpper( upper );
118}

References mEnvelope.

Referenced by CleanState(), HandleXMLTag(), and TimeTrack().

Here is the caller graph for this function:

◆ Silence()

void TimeTrack::Silence ( double  t0,
double  t1,
ProgressReporter  reportProgress = {} 
)
overridevirtual

Implements Track.

Definition at line 210 of file TimeTrack.cpp.

212{
213}

◆ SupportsBasicEditing()

bool TimeTrack::SupportsBasicEditing ( ) const
overridevirtual

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

Reimplemented from Track.

Definition at line 137 of file TimeTrack.cpp.

138{
139 return false;
140}

◆ testMe()

void TimeTrack::testMe ( )

Definition at line 327 of file TimeTrack.cpp.

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

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

300{
301 xmlFile.StartTag(wxT("timetrack"));
302 this->Track::WriteCommonXMLAttributes( xmlFile );
303
304 //xmlFile.WriteAttr(wxT("channel"), mChannel);
305 //xmlFile.WriteAttr(wxT("offset"), mOffset, 8);
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());
310
311 mEnvelope->WriteXML(xmlFile);
312
313 xmlFile.EndTag(wxT("timetrack"));
314}
wxT("CloseDown"))
bool GetInterpolateLog() const
Definition: TimeTrack.cpp:227
void WriteCommonXMLAttributes(XMLWriter &xmlFile, bool includeNameAndSelected=true) const
Definition: Track.cpp:803
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:79
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:36
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 110 of file TimeTrack.h.

Referenced by CleanState().

◆ mEnvelope

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

◆ mRescaleXMLValues

bool TimeTrack::mRescaleXMLValues
private

Definition at line 111 of file TimeTrack.h.

Referenced by HandleXMLEndTag(), and HandleXMLTag().


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