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...
 
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 ()
 
- 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 ()
 
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
 
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 EnsureVisible (bool modifyState=false)
 
virtual double GetOffset () const =0
 
void Offset (double t)
 
virtual void SetOffset (double o)
 
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 (bool allChannels, 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, TypeList::List< TrackTypes... >, const Functions &...functions)
 Deduce two packs from arguments. More...
 
- 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

std::unique_ptr< BoundedEnvelopemEnvelope
 
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...
 
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)
 
- 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...
 
double mOffset
 

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

71 : Track(orig, std::move(a))
72{
73 Init(orig); // this copies the TimeTrack metadata (name, range, etc)
74
75 auto len = DBL_MAX;
76 if (pT0 && pT1) {
77 len = *pT1 - *pT0;
78 mEnvelope = std::make_unique<BoundedEnvelope>( *orig.mEnvelope, *pT0, *pT1 );
79 }
80 else
81 mEnvelope = std::make_unique<BoundedEnvelope>( *orig.mEnvelope );
82
85
86 mEnvelope->SetTrackLen( len );
87 mEnvelope->SetOffset(0);
88}
std::unique_ptr< BoundedEnvelope > mEnvelope
Definition: TimeTrack.h:104
void SetRangeLower(double lower)
Definition: TimeTrack.cpp:112
double GetRangeLower() const
Definition: TimeTrack.cpp:102
double GetRangeUpper() const
Definition: TimeTrack.cpp:107
void Init(const TimeTrack &orig)
Copy the metadata from another track but not the points.
Definition: TimeTrack.cpp:91
void SetRangeUpper(double upper)
Definition: TimeTrack.cpp:117
Track()
Definition: Track.cpp:39

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

Here is the call graph for this function:

◆ ~TimeTrack()

TimeTrack::~TimeTrack ( )
virtual

Definition at line 98 of file TimeTrack.cpp.

99{
100}

Member Function Documentation

◆ ClassTypeInfo()

auto TimeTrack::ClassTypeInfo ( )
static

Definition at line 134 of file TimeTrack.cpp.

135{
136 return typeInfo();
137}
static const Track::TypeInfo & typeInfo()
Definition: TimeTrack.cpp:122

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.9 );
59 SetRangeUpper( 1.1 );
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:105
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 
)
override

Definition at line 188 of file TimeTrack.cpp.

189{
190 auto sampleTime = 1.0 / GetRate(*this);
191 mEnvelope->CollapseRegion( t0, t1, sampleTime );
192}
double GetRate(const Track &track)
Definition: TimeTrack.cpp:179

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

218{
219 auto result = std::make_shared<TimeTrack>(*this, ProtectedCreationArg{});
220 result->Init(*this);
221 return result;
222}

◆ Copy()

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

Definition at line 171 of file TimeTrack.cpp.

172{
173 auto result = std::make_shared<TimeTrack>(*this, ProtectedCreationArg{}, &t0, &t1);
174 result->Init(*this);
175 return result;
176}

Referenced by Cut().

Here is the caller graph for this function:

◆ Cut()

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

Definition at line 164 of file TimeTrack.cpp.

165{
166 auto result = Copy( t0, t1, false );
167 Clear( t0, t1 );
168 return result;
169}
Holder Copy(double t0, double t1, bool forClipboard) const override
Definition: TimeTrack.cpp:171
void Clear(double t0, double t1) override
Definition: TimeTrack.cpp:188

References Clear(), and Copy().

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:

◆ GetEndTime()

double TimeTrack::GetEndTime ( ) const
inlineoverridevirtual

Implements Track.

Definition at line 66 of file TimeTrack.h.

66{ return 0.0; }

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

225{
226 return mEnvelope->GetExponential();
227}

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

62{ return 0.0; }

◆ GetRangeLower()

double TimeTrack::GetRangeLower ( ) const

Definition at line 102 of file TimeTrack.cpp.

103{
104 return mEnvelope->GetRangeLower();
105}

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

108{
109 return mEnvelope->GetRangeUpper();
110}

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:

◆ GetStartTime()

double TimeTrack::GetStartTime ( ) const
inlineoverridevirtual

Implements Track.

Definition at line 65 of file TimeTrack.h.

65{ return 0.0; }

◆ GetTypeInfo()

auto TimeTrack::GetTypeInfo ( ) const
overridevirtual

Implements Track.

Definition at line 129 of file TimeTrack.cpp.

130{
131 return typeInfo();
132}

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

288{
289 if (tag == "envelope")
290 return mEnvelope.get();
291
292 return NULL;
293}

References mEnvelope.

◆ HandleXMLEndTag()

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

Definition at line 277 of file TimeTrack.cpp.

278{
280 {
281 mRescaleXMLValues = false;
282 mEnvelope->RescaleValues(GetRangeLower(), GetRangeUpper());
284 }
285}
bool mRescaleXMLValues
Definition: TimeTrack.h:106

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

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

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

92{
93 Track::Init(orig);
94 SetName(orig.GetName());
96}
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:55

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

213{
214 mEnvelope->InsertSpace(t, len);
215}

References mEnvelope.

◆ 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}
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:360

References TrackList::Get().

Here is the call graph for this function:

◆ Paste()

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

Definition at line 194 of file TimeTrack.cpp.

195{
196 bool bOk = src && src->TypeSwitch< bool >( [&] (const TimeTrack *tt) {
197 auto sampleTime = 1.0 / GetRate(*this);
198 mEnvelope->PasteEnvelope
199 (t, tt->mEnvelope.get(), sampleTime);
200 return true;
201 } );
202
203 if (! bOk )
204 // THROW_INCONSISTENCY_EXCEPTION // ?
205 (void)0;// intentionally do nothing.
206}
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:22
R TypeSwitch(const Functions &...functions)
Use this function rather than testing track type explicitly and making down-casts.
Definition: Track.h:755

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

145{
146 // Maintain uniqueness of the time track!
147 std::shared_ptr<TimeTrack> pNewTrack;
148 if( auto pTrack = *TrackList::Get( project ).Any<TimeTrack>().begin() )
149 pNewTrack = pTrack->SharedPointer<TimeTrack>();
150 else
151 pNewTrack = std::make_shared<TimeTrack>();
152
153 // Should come here only for .aup3 import, not for paste (because the
154 // track is skipped in cut/copy commands)
155 // And for import we agree to replace the track contents completely
156 pNewTrack->CleanState();
157 pNewTrack->Init(*this);
158 pNewTrack->Paste(0.0, this);
159 pNewTrack->SetRangeLower(this->GetRangeLower());
160 pNewTrack->SetRangeUpper(this->GetRangeUpper());
161 return pNewTrack;
162}
void Paste(double t, const Track *src) override
Definition: TimeTrack.cpp:194
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150

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

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

229 {
230 mEnvelope->SetExponential(interpolateLog);
231}

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

63{}

◆ SetRangeLower()

void TimeTrack::SetRangeLower ( double  lower)

Definition at line 112 of file TimeTrack.cpp.

113{
114 mEnvelope->SetRangeLower( lower );
115}

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

118{
119 mEnvelope->SetRangeUpper( upper );
120}

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

209{
210}

◆ SupportsBasicEditing()

bool TimeTrack::SupportsBasicEditing ( ) const
overridevirtual

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

Reimplemented from Track.

Definition at line 139 of file TimeTrack.cpp.

140{
141 return false;
142}

◆ testMe()

void TimeTrack::testMe ( )

Definition at line 313 of file TimeTrack.cpp.

314{
315 GetEnvelope()->Flatten(0.0);
316 GetEnvelope()->InsertOrReplace(0.0, 0.2);
317 GetEnvelope()->InsertOrReplace(5.0 - 0.001, 0.2);
318 GetEnvelope()->InsertOrReplace(5.0 + 0.001, 1.3);
319 GetEnvelope()->InsertOrReplace(10.0, 1.3);
320
321 double value1 = GetEnvelope()->Integral(2.0, 13.0);
322 double expected1 = (5.0 - 2.0) * 0.2 + (13.0 - 5.0) * 1.3;
323 double value2 = GetEnvelope()->IntegralOfInverse(2.0, 13.0);
324 double expected2 = (5.0 - 2.0) / 0.2 + (13.0 - 5.0) / 1.3;
325 if( fabs(value1 - expected1) > 0.01 )
326 {
327 wxPrintf( "TimeTrack: Integral failed! expected %f got %f\n", expected1, value1);
328 }
329 if( fabs(value2 - expected2) > 0.01 )
330 {
331 wxPrintf( "TimeTrack: IntegralOfInverse failed! expected %f got %f\n", expected2, value2);
332 }
333
334 /*double reqt0 = 10.0 - .1;
335 double reqt1 = 10.0 + .1;
336 double t0 = warp( reqt0 );
337 double t1 = warp( reqt1 );
338 if( t0 > t1 )
339 {
340 wxPrintf( "TimeTrack: Warping reverses an interval! [%.2f,%.2f] -> [%.2f,%.2f]\n",
341 reqt0, reqt1,
342 t0, t1 );
343 }*/
344}
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: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 295 of file TimeTrack.cpp.

297{
298 xmlFile.StartTag(wxT("timetrack"));
299 this->Track::WriteCommonXMLAttributes( xmlFile );
300
301 //xmlFile.WriteAttr(wxT("channel"), mChannel);
302 //xmlFile.WriteAttr(wxT("offset"), mOffset, 8);
303 xmlFile.WriteAttr(wxT("rangelower"), GetRangeLower(), 12);
304 xmlFile.WriteAttr(wxT("rangeupper"), GetRangeUpper(), 12);
305 xmlFile.WriteAttr(wxT("displaylog"), GetDisplayLog());
306 xmlFile.WriteAttr(wxT("interpolatelog"), GetInterpolateLog());
307
308 mEnvelope->WriteXML(xmlFile);
309
310 xmlFile.EndTag(wxT("timetrack"));
311}
wxT("CloseDown"))
bool GetInterpolateLog() const
Definition: TimeTrack.cpp:224
void WriteCommonXMLAttributes(XMLWriter &xmlFile, bool includeNameAndSelected=true) const
Definition: Track.cpp:1149
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 105 of file TimeTrack.h.

Referenced by CleanState().

◆ mEnvelope

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

◆ mRescaleXMLValues

bool TimeTrack::mRescaleXMLValues
private

Definition at line 106 of file TimeTrack.h.

Referenced by HandleXMLEndTag(), and HandleXMLTag().


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