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
 
TrackListHolder Cut (double t0, double t1) override
 Create tracks and modify this track. More...
 
TrackListHolder 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
 Retrieve a channel. More...
 
- 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 &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
 
TrackListGetHolder () const
 
LinkType GetLinkType () const noexcept
 
ChannelGroupDataGetGroupData ()
 
const ChannelGroupDataGetGroupData () const
 May make group data on demand, but consider that logically const. More...
 
 Track ()
 
 Track (const Track &orig, ProtectedCreationArg &&)
 
Trackoperator= (const Track &orig)=delete
 
virtual ~Track ()
 
void Init (const Track &orig)
 
virtual TrackListHolder Duplicate () const
 public nonvirtual duplication function that invokes Clone() More...
 
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)
 
void OnProjectTempoChange (double newTempo)
 method to set project tempo on track More...
 
virtual TrackListHolder Cut (double t0, double t1)=0
 Create tracks and modify this track. More...
 
virtual TrackListHolder 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...
 
void Paste (double t, const TrackList &src)
 
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 override
 
bool IsSelectedLeader () const
 
void AdjustPositions ()
 
void WriteCommonXMLAttributes (XMLWriter &xmlFile, bool includeNameAndSelected=true) const
 
bool HandleCommonXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView)
 
const std::optional< double > & GetProjectTempo () const
 
- 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...
 
virtual bool IsLeader () const =0
 
ChannelGroupDataGetGroupData ()
 Make attachment site on demand as needed. More...
 
const ChannelGroupDataGetGroupData () const
 
ChannelGroupDataFindGroupData ()
 Do not make attachment site on demand if absent. More...
 
const ChannelGroupDataFindGroupData () const
 Do not make attachment site on demand if absent. More...
 
void Init (const ChannelGroup &other)
 Copy, including cloning of attached objects. More...
 
void DestroyGroupData ()
 Leave all attachments null. More...
 
std::unique_ptr< ChannelGroupDataDetachGroupData ()
 Move attachments out. More...
 
void AssignGroupData (std::unique_ptr< ChannelGroupData > pGroupData)
 Replace any previous attachments. 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...
 
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 ReallyGetChannelIndex () 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 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 DoOnProjectTempoChange (const std::optional< double > &oldTempo, double newTempo) override
 
void Init (const TimeTrack &orig)
 Copy the metadata from another track but not the points. More...
 
TrackListHolder Clone () 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 = ClientData::Site< ChannelGroupData, ClientData::Cloneable<>, ClientData::DeepCopying >
 
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)
 
virtual void DoOnProjectTempoChange (const std::optional< double > &oldTempo, double newTempo)=0
 
- 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...
 
virtual std::shared_ptr< ChannelDoGetChannel (size_t iChannel)=0
 Retrieve a channel. More...
 
virtual std::shared_ptr< IntervalDoGetInterval (size_t iInterval)=0
 Retrieve an interval. More...
 
- Protected Member Functions inherited from Channel
virtual ChannelGroupDoGetChannelGroup () const =0
 Subclass must override. More...
 
virtual ChannelGroupReallyDoGetChannelGroup () const
 This is temporary! It defaults to call the above. 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...
 

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 123 of file TimeTrack.h.

Constructor & Destructor Documentation

◆ TimeTrack() [1/2]

TimeTrack::TimeTrack ( )

Definition at line 49 of file TimeTrack.cpp.

50{
51 CleanState();
52}
void CleanState()
Definition: TimeTrack.cpp:54

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

81 : UniqueChannelTrack{ orig, std::move(a) }
82{
83 Init(orig); // this copies the TimeTrack metadata (name, range, etc)
84
85 auto len = DBL_MAX;
86 if (pT0 && pT1) {
87 len = *pT1 - *pT0;
88 mEnvelope = std::make_unique<BoundedEnvelope>( *orig.mEnvelope, *pT0, *pT1 );
89 }
90 else
91 mEnvelope = std::make_unique<BoundedEnvelope>( *orig.mEnvelope );
92
95
96 mEnvelope->SetTrackLen( len );
97 mEnvelope->SetOffset(0);
98}
std::unique_ptr< BoundedEnvelope > mEnvelope
Definition: TimeTrack.h:112
void SetRangeLower(double lower)
Definition: TimeTrack.cpp:122
double GetRangeLower() const
Definition: TimeTrack.cpp:112
double GetRangeUpper() const
Definition: TimeTrack.cpp:117
void Init(const TimeTrack &orig)
Copy the metadata from another track but not the points.
Definition: TimeTrack.cpp:101
void SetRangeUpper(double upper)
Definition: TimeTrack.cpp:127
Generates overrides of channel-related functions.
Definition: Track.h:490

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

Here is the call graph for this function:

◆ ~TimeTrack()

TimeTrack::~TimeTrack ( )
virtual

Definition at line 108 of file TimeTrack.cpp.

109{
110}

Member Function Documentation

◆ ClassTypeInfo()

auto TimeTrack::ClassTypeInfo ( )
static

Definition at line 144 of file TimeTrack.cpp.

145{
146 return typeInfo();
147}
static const Track::TypeInfo & typeInfo()
Definition: TimeTrack.cpp:132

References typeInfo().

Here is the call graph for this function:

◆ CleanState()

void TimeTrack::CleanState ( )
private

Definition at line 54 of file TimeTrack.cpp.

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

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

Precondition
IsLeader()

Implements Track.

Definition at line 205 of file TimeTrack.cpp.

206{
207 assert(IsLeader());
208 auto sampleTime = 1.0 / GetRate(*this);
209 mEnvelope->CollapseRegion( t0, t1, sampleTime );
210}
bool IsLeader() const override
Definition: Track.cpp:291
double GetRate(const Track &track)
Definition: TimeTrack.cpp:196

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

Referenced by Cut().

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

◆ Clone()

TrackListHolder TimeTrack::Clone ( ) const
overrideprivatevirtual

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

Parameters
unstretchIntervalIf set, this time interval's stretching must be applied.
Precondition
!unstretchInterval.has_value() || unstretchInterval->first < unstretchInterval->second
IsLeader()
Postcondition
result: NChannels() == result->NChannels()

Implements Track.

Definition at line 237 of file TimeTrack.cpp.

238{
239 assert(IsLeader());
240 auto result = std::make_shared<TimeTrack>(*this, ProtectedCreationArg{});
241 result->Init(*this);
242 return TrackList::Temporary(nullptr, result, nullptr);
243}
static TrackListHolder Temporary(AudacityProject *pProject, const Track::Holder &left={}, const Track::Holder &right={})
Definition: Track.cpp:1418

References Track::IsLeader(), and TrackList::Temporary().

Here is the call graph for this function:

◆ Copy()

TrackListHolder 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
Precondition
IsLeader
Postcondition
result: result->NChannels() == NChannels()

Implements Track.

Definition at line 187 of file TimeTrack.cpp.

188{
189 auto track =
190 std::make_shared<TimeTrack>(*this, ProtectedCreationArg{}, &t0, &t1);
191 track->Init(*this);
192 return TrackList::Temporary(nullptr, track, nullptr);
193}

References TrackList::Temporary().

Referenced by Cut().

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

◆ Cut()

TrackListHolder TimeTrack::Cut ( double  t0,
double  t1 
)
overridevirtual

Create tracks and modify this track.

Returns
non-NULL or else throw May assume precondition: t0 <= t1
Precondition
IsLeader()
Postcondition
result: result->NChannels() == NChannels()

Implements Track.

Definition at line 179 of file TimeTrack.cpp.

180{
181 assert(IsLeader());
182 auto result = Copy(t0, t1, false);
183 Clear(t0, t1);
184 return result;
185}
TrackListHolder Copy(double t0, double t1, bool forClipboard) const override
Create new tracks and don't modify this track.
Definition: TimeTrack.cpp:187
void Clear(double t0, double t1) override
Definition: TimeTrack.cpp:205

References Clear(), Copy(), and Track::IsLeader().

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

342{
343 return {};
344}

◆ DoOnProjectTempoChange()

void TimeTrack::DoOnProjectTempoChange ( const std::optional< double > &  oldTempo,
double  newTempo 
)
overrideprivatevirtual
Precondition
IsLeader()

Implements Track.

Definition at line 69 of file TimeTrack.cpp.

71{
72 assert(IsLeader());
73 if (!oldTempo.has_value())
74 return;
75 const auto ratio = *oldTempo / newTempo;
76 mEnvelope->RescaleTimesBy(ratio);
77}

References Track::IsLeader(), and mEnvelope.

Here is the call graph for this function:

◆ GetDefaultName()

wxString TimeTrack::GetDefaultName ( )
static

Definition at line 36 of file TimeTrack.cpp.

37{
38 return _("Time Track");
39}
#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 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 245 of file TimeTrack.cpp.

246{
247 return mEnvelope->GetExponential();
248}

References mEnvelope.

Referenced by TimeTrackMenuTable::OnTimeTrackLogInt().

Here is the caller graph for this function:

◆ GetRangeLower()

double TimeTrack::GetRangeLower ( ) const

Definition at line 112 of file TimeTrack.cpp.

113{
114 return mEnvelope->GetRangeLower();
115}

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

118{
119 return mEnvelope->GetRangeUpper();
120}

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:

◆ GetTypeInfo()

auto TimeTrack::GetTypeInfo ( ) const
overridevirtual

Implements Track.

Definition at line 139 of file TimeTrack.cpp.

140{
141 return typeInfo();
142}

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

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

References mEnvelope.

◆ HandleXMLEndTag()

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

Definition at line 298 of file TimeTrack.cpp.

299{
301 {
302 mRescaleXMLValues = false;
303 mEnvelope->RescaleValues(GetRangeLower(), GetRangeUpper());
305 }
306}
bool mRescaleXMLValues
Definition: TimeTrack.h:114

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

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

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

102{
103 Track::Init(orig);
104 SetName(orig.GetName());
106}
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:56
void Init(const Track &orig)
Definition: Track.cpp:50

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

Precondition
IsLeader()

Implements Track.

Definition at line 231 of file TimeTrack.cpp.

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

References Track::IsLeader(), and mEnvelope.

Here is the call graph for this function:

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

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

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

336{
337 return 0;
338}

◆ Paste()

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

Weak precondition allows overrides to replicate one channel into many.

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

Implements Track.

Definition at line 212 of file TimeTrack.cpp.

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

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

Precondition
IsLeader()
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 leader track

Implements Track.

Definition at line 154 of file TimeTrack.cpp.

156{
157 assert(IsLeader());
158 // Maintain uniqueness of the time track!
159 std::shared_ptr<TimeTrack> pNewTrack;
160 if (auto pTrack = *TrackList::Get(project).Any<TimeTrack>().begin())
161 // leave list unchanged
162 pNewTrack = pTrack->SharedPointer<TimeTrack>();
163 else {
164 pNewTrack = std::make_shared<TimeTrack>();
165 list.Add(pNewTrack);
166 }
167
168 // Should come here only for .aup3 import, not for paste (because the
169 // track is skipped in cut/copy commands)
170 // And for import we agree to replace the track contents completely
171 pNewTrack->CleanState();
172 pNewTrack->Init(*this);
173 pNewTrack->Paste(0.0, *this);
174 pNewTrack->SetRangeLower(this->GetRangeLower());
175 pNewTrack->SetRangeUpper(this->GetRangeUpper());
176 return pNewTrack;
177}
TrackKind * Add(const std::shared_ptr< TrackKind > &t)
Definition: Track.h:1183
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150

References TrackList::Add(), PackedArray::begin(), TrackList::Get(), GetRangeLower(), GetRangeUpper(), Track::IsLeader(), 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 250 of file TimeTrack.cpp.

250 {
251 mEnvelope->SetExponential(interpolateLog);
252}

References mEnvelope.

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

Here is the caller graph for this function:

◆ SetRangeLower()

void TimeTrack::SetRangeLower ( double  lower)

Definition at line 122 of file TimeTrack.cpp.

123{
124 mEnvelope->SetRangeLower( lower );
125}

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

128{
129 mEnvelope->SetRangeUpper( upper );
130}

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,
ProgressReporter  reportProgress = {} 
)
overridevirtual
Precondition
IsLeader()

Implements Track.

Definition at line 225 of file TimeTrack.cpp.

227{
228 assert(IsLeader());
229}

References Track::IsLeader().

Here is the call graph for this function:

◆ SupportsBasicEditing()

bool TimeTrack::SupportsBasicEditing ( ) const
overridevirtual

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

Reimplemented from Track.

Definition at line 149 of file TimeTrack.cpp.

150{
151 return false;
152}

◆ testMe()

void TimeTrack::testMe ( )

Definition at line 346 of file TimeTrack.cpp.

347{
348 GetEnvelope()->Flatten(0.0);
349 GetEnvelope()->InsertOrReplace(0.0, 0.2);
350 GetEnvelope()->InsertOrReplace(5.0 - 0.001, 0.2);
351 GetEnvelope()->InsertOrReplace(5.0 + 0.001, 1.3);
352 GetEnvelope()->InsertOrReplace(10.0, 1.3);
353
354 double value1 = GetEnvelope()->Integral(2.0, 13.0);
355 double expected1 = (5.0 - 2.0) * 0.2 + (13.0 - 5.0) * 1.3;
356 double value2 = GetEnvelope()->IntegralOfInverse(2.0, 13.0);
357 double expected2 = (5.0 - 2.0) / 0.2 + (13.0 - 5.0) / 1.3;
358 if( fabs(value1 - expected1) > 0.01 )
359 {
360 wxPrintf( "TimeTrack: Integral failed! expected %f got %f\n", expected1, value1);
361 }
362 if( fabs(value2 - expected2) > 0.01 )
363 {
364 wxPrintf( "TimeTrack: IntegralOfInverse failed! expected %f got %f\n", expected2, value2);
365 }
366
367 /*double reqt0 = 10.0 - .1;
368 double reqt1 = 10.0 + .1;
369 double t0 = warp( reqt0 );
370 double t1 = warp( reqt1 );
371 if( t0 > t1 )
372 {
373 wxPrintf( "TimeTrack: Warping reverses an interval! [%.2f,%.2f] -> [%.2f,%.2f]\n",
374 reqt0, reqt1,
375 t0, t1 );
376 }*/
377}
double Integral(double t0, double t1) const
Definition: Envelope.cpp:1180
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:1243
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 316 of file TimeTrack.cpp.

318{
319 assert(IsLeader());
320 xmlFile.StartTag(wxT("timetrack"));
321 this->Track::WriteCommonXMLAttributes( xmlFile );
322
323 //xmlFile.WriteAttr(wxT("channel"), mChannel);
324 //xmlFile.WriteAttr(wxT("offset"), mOffset, 8);
325 xmlFile.WriteAttr(wxT("rangelower"), GetRangeLower(), 12);
326 xmlFile.WriteAttr(wxT("rangeupper"), GetRangeUpper(), 12);
327 xmlFile.WriteAttr(wxT("displaylog"), GetDisplayLog());
328 xmlFile.WriteAttr(wxT("interpolatelog"), GetInterpolateLog());
329
330 mEnvelope->WriteXML(xmlFile);
331
332 xmlFile.EndTag(wxT("timetrack"));
333}
wxT("CloseDown"))
bool GetInterpolateLog() const
Definition: TimeTrack.cpp:245
void WriteCommonXMLAttributes(XMLWriter &xmlFile, bool includeNameAndSelected=true) const
Definition: Track.cpp:1219
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 113 of file TimeTrack.h.

Referenced by CleanState().

◆ mEnvelope

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

◆ mRescaleXMLValues

bool TimeTrack::mRescaleXMLValues
private

Definition at line 114 of file TimeTrack.h.

Referenced by HandleXMLEndTag(), and HandleXMLTag().


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