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

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

#include <TimeTrack.h>

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

Public Member Functions

 TimeTrack (const ZoomInfo *zoomInfo)
 
 TimeTrack (const TimeTrack &orig, double *pT0=nullptr, double *pT1=nullptr)
 Copy-Constructor - create a NEW TimeTrack:: which is an independent copy of the original. More...
 
virtual ~TimeTrack ()
 
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 wxChar *tag, const wxChar **attrs) override
 
void HandleXMLEndTag (const wxChar *tag) override
 
XMLTagHandlerHandleXMLChild (const wxChar *tag) override
 
void WriteXML (XMLWriter &xmlFile) const override
 
BoundedEnvelopeGetEnvelope ()
 
const BoundedEnvelopeGetEnvelope () const
 
double GetRangeLower () const
 
double GetRangeUpper () const
 
void SetRangeLower (double lower)
 
void SetRangeUpper (double upper)
 
bool GetDisplayLog () const
 
void SetDisplayLog (bool displayLog)
 
bool GetInterpolateLog () const
 
void SetInterpolateLog (bool interpolateLog)
 
void testMe ()
 
RulerGetRuler () const
 
- Public Member Functions inherited from Track
TrackId GetId () const
 
template<typename Subclass = Track>
std::shared_ptr< Subclass > SharedPointer ()
 
template<typename Subclass = const Track>
auto SharedPointer () const -> typename std::enable_if< std::is_const< Subclass >::value, std::shared_ptr< Subclass > >::type
 
std::shared_ptr< TrackSubstitutePendingChangedTrack ()
 
std::shared_ptr< const TrackSubstitutePendingChangedTrack () const
 
std::shared_ptr< const TrackSubstituteOriginalTrack () const
 
virtual ConstIntervals GetIntervals () const
 Report times on the track where important intervals begin and end, for UI to snap to. More...
 
virtual Intervals GetIntervals ()
 
const std::shared_ptr< CommonTrackCell > & GetTrackView ()
 
void SetTrackView (const std::shared_ptr< CommonTrackCell > &pView)
 
const std::shared_ptr< CommonTrackCell > & GetTrackControls ()
 
void SetTrackControls (const std::shared_ptr< CommonTrackCell > &pControls)
 
int GetIndex () const
 
void SetIndex (int index)
 
virtual bool LinkConsistencyCheck ()
 
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...
 
 Track ()
 
 Track (const Track &orig)
 
virtual ~ Track ()
 
void Init (const Track &orig)
 
virtual Holder Duplicate () const
 
virtual void Merge (const Track &orig)
 
wxString GetName () const
 
void SetName (const wxString &n)
 
wxString GetDefaultName () const
 
void SetDefaultName (const wxString &n)
 
bool GetSelected () const
 
virtual void SetSelected (bool s)
 
void EnsureVisible (bool modifyState=false)
 
virtual ChannelType GetChannel () const
 
void Offset (double t)
 
virtual void SetPan (float)
 
virtual void SetPanFromChannelType ()
 
virtual Holder Cut (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual Holder Copy (double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard=true) const =0
 
virtual void Clear (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void Paste (double WXUNUSED(t), const Track *WXUNUSED(src))=0
 
virtual void SyncLockAdjust (double oldT1, double newT1)
 
virtual void Silence (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void InsertSilence (double WXUNUSED(t), double WXUNUSED(len))=0
 
bool SameKindAs (const Track &track) const
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions)
 Use this function rather than testing track type explicitly and making down-casts. More...
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions) const
 Use this function rather than testing track type explicitly and making down-casts. More...
 
virtual bool GetErrorOpening ()
 
bool IsSyncLockSelected () const
 
void Notify (int code=-1)
 
bool Any () const
 
bool IsSelected () const
 
bool IsSelectedOrSyncLockSelected () const
 
bool IsLeader () const
 
bool IsSelectedLeader () const
 
void AdjustPositions ()
 
void WriteCommonXMLAttributes (XMLWriter &xmlFile, bool includeNameAndSelected=true) const
 
bool HandleCommonXMLAttribute (const wxChar *attr, const wxChar *value)
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual void HandleXMLEndTag (const wxChar *WXUNUSED(tag))
 
virtual void HandleXMLContent (const wxString &WXUNUSED(content))
 
bool ReadXMLTag (const char *tag, const char **attrs)
 
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 -> typename std::enable_if< std::is_const< Subclass >::value, Subclass & >::type
 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 -> typename std::enable_if< std::is_const< Subclass >::value, Subclass * >::type
 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...
 

Private Types

using Holder = std::unique_ptr< TimeTrack >
 

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Public Types inherited from Track
enum  LinkType : int { LinkType::None = 0, LinkType::Group = 2, LinkType::Aligned }
 For two tracks describes the type of the linkage. More...
 
enum  ChannelType { LeftChannel = 0, RightChannel = 1, MonoChannel = 2 }
 
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...
 
- 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 void FinishCopy (const Track *n, Track *dest)
 
- 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...
 
- Public Attributes inherited from Track
wxSize vrulerSize
 
- Protected Member Functions inherited from Track
void SetLinkType (LinkType linkType)
 
void DoSetLinkType (LinkType linkType) noexcept
 
void SetChannel (ChannelType c) noexcept
 
- Protected Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
template<typename Function >
void ForEach (const Function &function)
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
void ForEach (const Function &function) const
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
ClientData * FindIf (const Function &function)
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
template<typename Function >
const ClientData * FindIf (const Function &function) const
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
void BuildAll ()
 For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it. More...
 
- Protected Attributes inherited from Track
std::weak_ptr< TrackListmList
 
TrackNodePointer mNode {}
 Holds iterator to self, so that TrackList::Find can be constant-time. More...
 
int mIndex
 0-based position of this track in its TrackList More...
 
wxString mName
 
wxString mDefaultName
 
ChannelType mChannel
 
double mOffset
 
std::shared_ptr< CommonTrackCellmpView
 
std::shared_ptr< CommonTrackCellmpControls
 

Detailed Description

A kind of Track used to 'warp time'.

Definition at line 24 of file TimeTrack.h.

Member Typedef Documentation

◆ Holder

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

Definition at line 116 of file TimeTrack.h.

Constructor & Destructor Documentation

◆ TimeTrack() [1/2]

TimeTrack::TimeTrack ( const ZoomInfo zoomInfo)
explicit

Definition at line 50 of file TimeTrack.cpp.

50  :
51  Track()
52  , mZoomInfo(zoomInfo)
53 {
54  CleanState();
55 }

References CleanState().

Here is the call graph for this function:

◆ TimeTrack() [2/2]

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

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

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

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

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

Definition at line 77 of file TimeTrack.cpp.

78  : Track(orig)
79  , mZoomInfo(orig.mZoomInfo)
80 {
81  Init(orig); // this copies the TimeTrack metadata (name, range, etc)
82 
83  auto len = DBL_MAX;
84  if (pT0 && pT1) {
85  len = *pT1 - *pT0;
86  mEnvelope = std::make_unique<BoundedEnvelope>( *orig.mEnvelope, *pT0, *pT1 );
87  }
88  else
89  mEnvelope = std::make_unique<BoundedEnvelope>( *orig.mEnvelope );
90 
93 
94  mEnvelope->SetTrackLen( len );
95  mEnvelope->SetOffset(0);
96 
98  mRuler = std::make_unique<Ruler>();
99  mRuler->SetUseZoomInfo(0, mZoomInfo);
100  mRuler->SetLabelEdges(false);
101  mRuler->SetFormat(Ruler::TimeFormat);
102 }

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

Here is the call graph for this function:

◆ ~TimeTrack()

TimeTrack::~TimeTrack ( )
virtual

Definition at line 113 of file TimeTrack.cpp.

114 {
115 }

Member Function Documentation

◆ CleanState()

void TimeTrack::CleanState ( )
private

Definition at line 57 of file TimeTrack.cpp.

58 {
59  mEnvelope = std::make_unique<BoundedEnvelope>(true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0);
60 
61  SetRangeLower( 0.9 );
62  SetRangeUpper( 1.1 );
63  mDisplayLog = false;
64 
65  mEnvelope->SetTrackLen(DBL_MAX);
66  mEnvelope->SetOffset(0);
67 
68  SetDefaultName(_("Time Track"));
70 
71  mRuler = std::make_unique<Ruler>();
72  mRuler->SetUseZoomInfo(0, mZoomInfo);
73  mRuler->SetLabelEdges(false);
74  mRuler->SetFormat(Ruler::TimeFormat);
75 }

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

Referenced by PasteInto(), and 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 183 of file TimeTrack.cpp.

184 {
185  auto sampleTime = 1.0 / GetRate();
186  mEnvelope->CollapseRegion( t0, t1, sampleTime );
187 }

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

213 {
214  return std::make_shared<TimeTrack>(*this);
215 }

◆ Copy()

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

Definition at line 169 of file TimeTrack.cpp.

170 {
171  return std::make_shared<TimeTrack>( *this, &t0, &t1 );
172 }

Referenced by Cut().

Here is the caller graph for this function:

◆ Cut()

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

Definition at line 162 of file TimeTrack.cpp.

163 {
164  auto result = Copy( t0, t1, false );
165  Clear( t0, t1 );
166  return result;
167 }

References Clear(), and Copy().

Here is the call graph for this function:

◆ GetDisplayLog()

bool TimeTrack::GetDisplayLog ( ) const
inline

Definition at line 88 of file TimeTrack.h.

88 { 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 60 of file TimeTrack.h.

60 { return 0.0; }

◆ GetEnvelope() [1/2]

BoundedEnvelope* TimeTrack::GetEnvelope ( )
inline

Definition at line 77 of file TimeTrack.h.

77 { return mEnvelope.get(); }

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

Here is the caller graph for this function:

◆ GetEnvelope() [2/2]

const BoundedEnvelope* TimeTrack::GetEnvelope ( ) const
inline

Definition at line 78 of file TimeTrack.h.

78 { return mEnvelope.get(); }

◆ GetInterpolateLog()

bool TimeTrack::GetInterpolateLog ( ) const

Definition at line 217 of file TimeTrack.cpp.

218 {
219  return mEnvelope->GetExponential();
220 }

References mEnvelope.

Referenced by TimeTrackMenuTable::OnTimeTrackLogInt().

Here is the caller graph for this function:

◆ GetKind()

TrackKind TimeTrack::GetKind ( ) const
inlineoverrideprivatevirtual

Reimplemented from Track.

Definition at line 101 of file TimeTrack.h.

101 { return TrackKind::Time; }

References Time.

◆ GetOffset()

double TimeTrack::GetOffset ( ) const
inlineoverridevirtual

Implements Track.

Definition at line 56 of file TimeTrack.h.

56 { return 0.0; }

◆ GetRangeLower()

double TimeTrack::GetRangeLower ( ) const

Definition at line 117 of file TimeTrack.cpp.

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

References mEnvelope.

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

Here is the caller graph for this function:

◆ GetRangeUpper()

double TimeTrack::GetRangeUpper ( ) const

Definition at line 122 of file TimeTrack.cpp.

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

References mEnvelope.

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

Here is the caller graph for this function:

◆ GetRuler()

Ruler& TimeTrack::GetRuler ( ) const
inline

Definition at line 95 of file TimeTrack.h.

95 { return *mRuler; }

◆ GetStartTime()

double TimeTrack::GetStartTime ( ) const
inlineoverridevirtual

Implements Track.

Definition at line 59 of file TimeTrack.h.

59 { return 0.0; }

◆ HandleXMLChild()

XMLTagHandler * TimeTrack::HandleXMLChild ( const wxChar *  tag)
overridevirtual

Implements XMLTagHandler.

Definition at line 283 of file TimeTrack.cpp.

284 {
285  if (!wxStrcmp(tag, wxT("envelope")))
286  return mEnvelope.get();
287 
288  return NULL;
289 }

References mEnvelope.

◆ HandleXMLEndTag()

void TimeTrack::HandleXMLEndTag ( const wxChar *  tag)
override

Definition at line 273 of file TimeTrack.cpp.

274 {
276  {
277  mRescaleXMLValues = false;
278  mEnvelope->RescaleValues(GetRangeLower(), GetRangeUpper());
280  }
281 }

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

Here is the call graph for this function:

◆ HandleXMLTag()

bool TimeTrack::HandleXMLTag ( const wxChar *  tag,
const wxChar **  attrs 
)
overridevirtual

Implements XMLTagHandler.

Definition at line 226 of file TimeTrack.cpp.

227 {
228  if (!wxStrcmp(tag, wxT("timetrack"))) {
229  mRescaleXMLValues = true; // will be set to false if upper/lower is found
230  long nValue;
231  while(*attrs) {
232  const wxChar *attr = *attrs++;
233  const wxChar *value = *attrs++;
234 
235  if (!value)
236  break;
237 
238  const wxString strValue = value;
239  if (this->Track::HandleCommonXMLAttribute(attr, strValue))
240  ;
241  else if (!wxStrcmp(attr, wxT("rangelower")))
242  {
244  mRescaleXMLValues = false;
245  }
246  else if (!wxStrcmp(attr, wxT("rangeupper")))
247  {
249  mRescaleXMLValues = false;
250  }
251  else if (!wxStrcmp(attr, wxT("displaylog")) &&
252  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
253  {
254  SetDisplayLog(nValue != 0);
255  //TODO-MB: This causes a graphical glitch, TrackPanel should probably be Refresh()ed after loading.
256  // I don't know where to do this though.
257  }
258  else if (!wxStrcmp(attr, wxT("interpolatelog")) &&
259  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
260  {
261  SetInterpolateLog(nValue != 0);
262  }
263 
264  } // while
266  mEnvelope->SetRange(0.0, 1.0); // this will be restored to the actual range later
267  return true;
268  }
269 
270  return false;
271 }

References Internat::CompatibleToDouble(), Track::HandleCommonXMLAttribute(), XMLValueChecker::IsGoodInt(), 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 105 of file TimeTrack.cpp.

106 {
107  Track::Init(orig);
109  SetName(orig.GetName());
111 }

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

Referenced by PasteInto(), and 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 207 of file TimeTrack.cpp.

208 {
209  mEnvelope->InsertSpace(t, len);
210 }

References mEnvelope.

◆ Paste()

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

Definition at line 189 of file TimeTrack.cpp.

190 {
191  bool bOk = src && src->TypeSwitch< bool >( [&] (const TimeTrack *tt) {
192  auto sampleTime = 1.0 / GetRate();
193  mEnvelope->PasteEnvelope
194  (t, tt->mEnvelope.get(), sampleTime);
195  return true;
196  } );
197 
198  if (! bOk )
199  // THROW_INCONSISTENCY_EXCEPTION // ?
200  (void)0;// intentionally do nothing.
201 }

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

Referenced by PasteInto().

Here is the call graph for this function:
Here is the caller 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 142 of file TimeTrack.cpp.

143 {
144  // Maintain uniqueness of the time track!
145  std::shared_ptr<TimeTrack> pNewTrack;
146  if( auto pTrack = *TrackList::Get( project ).Any<TimeTrack>().begin() )
147  pNewTrack = pTrack->SharedPointer<TimeTrack>();
148  else
149  pNewTrack = std::make_shared<TimeTrack>( &ViewInfo::Get( project ) );
150 
151  // Should come here only for .aup3 import, not for paste (because the
152  // track is skipped in cut/copy commands)
153  // And for import we agree to replace the track contents completely
154  pNewTrack->CleanState();
155  pNewTrack->Init(*this);
156  pNewTrack->Paste(0.0, this);
157  pNewTrack->SetRangeLower(this->GetRangeLower());
158  pNewTrack->SetRangeUpper(this->GetRangeUpper());
159  return pNewTrack;
160 }

References CleanState(), ViewInfo::Get(), TrackList::Get(), GetRangeLower(), GetRangeUpper(), Init(), Paste(), SetRangeLower(), SetRangeUpper(), and Track::SharedPointer().

Here is the call graph for this function:

◆ SetDisplayLog()

void TimeTrack::SetDisplayLog ( bool  displayLog)
inline

Definition at line 89 of file TimeTrack.h.

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

222  {
223  mEnvelope->SetExponential(interpolateLog);
224 }

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

57 {}

◆ SetRangeLower()

void TimeTrack::SetRangeLower ( double  lower)

Definition at line 127 of file TimeTrack.cpp.

128 {
129  mEnvelope->SetRangeLower( lower );
130 }

References mEnvelope.

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

Here is the caller graph for this function:

◆ SetRangeUpper()

void TimeTrack::SetRangeUpper ( double  upper)

Definition at line 132 of file TimeTrack.cpp.

133 {
134  mEnvelope->SetRangeUpper( upper );
135 }

References mEnvelope.

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

Here is the caller graph for this function:

◆ Silence()

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

Definition at line 203 of file TimeTrack.cpp.

204 {
205 }

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

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

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

293 {
294  xmlFile.StartTag(wxT("timetrack"));
295  this->Track::WriteCommonXMLAttributes( xmlFile );
296 
297  //xmlFile.WriteAttr(wxT("channel"), mChannel);
298  //xmlFile.WriteAttr(wxT("offset"), mOffset, 8);
299  xmlFile.WriteAttr(wxT("rangelower"), GetRangeLower(), 12);
300  xmlFile.WriteAttr(wxT("rangeupper"), GetRangeUpper(), 12);
301  xmlFile.WriteAttr(wxT("displaylog"), GetDisplayLog());
302  xmlFile.WriteAttr(wxT("interpolatelog"), GetInterpolateLog());
303 
304  mEnvelope->WriteXML(xmlFile);
305 
306  xmlFile.EndTag(wxT("timetrack"));
307 }

References Track::WriteCommonXMLAttributes().

Here is the call graph for this function:

Member Data Documentation

◆ mDisplayLog

bool TimeTrack::mDisplayLog
private

Definition at line 106 of file TimeTrack.h.

Referenced by CleanState().

◆ mEnvelope

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

◆ mRescaleXMLValues

bool TimeTrack::mRescaleXMLValues
private

Definition at line 107 of file TimeTrack.h.

Referenced by HandleXMLEndTag(), and HandleXMLTag().

◆ mRuler

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

Definition at line 105 of file TimeTrack.h.

Referenced by CleanState(), and TimeTrack().

◆ mZoomInfo

const ZoomInfo* const TimeTrack::mZoomInfo
private

Definition at line 103 of file TimeTrack.h.

Referenced by CleanState(), and TimeTrack().


The documentation for this class was generated from the following files:
XMLWriter::EndTag
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:99
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:161
TimeTrack::GetRangeLower
double GetRangeLower() const
Definition: TimeTrack.cpp:117
Track::GetDefaultName
wxString GetDefaultName() const
Definition: Track.h:428
Track::WriteCommonXMLAttributes
void WriteCommonXMLAttributes(XMLWriter &xmlFile, bool includeNameAndSelected=true) const
Definition: Track.cpp:1255
TIMETRACK_MAX
#define TIMETRACK_MAX
Definition: TimeTrack.cpp:36
XMLValueChecker::IsGoodInt
static bool IsGoodInt(const wxString &strInt)
Check that the supplied string can be converted to a long (32bit) integer.
Definition: XMLTagHandler.cpp:157
Track::GetName
wxString GetName() const
Definition: Track.h:426
TimeTrack::GetRangeUpper
double GetRangeUpper() const
Definition: TimeTrack.cpp:122
Track::SharedPointer
std::shared_ptr< Subclass > SharedPointer()
Definition: Track.h:291
TimeTrack::mDisplayLog
bool mDisplayLog
Definition: TimeTrack.h:106
Track::HandleCommonXMLAttribute
bool HandleCommonXMLAttribute(const wxChar *attr, const wxChar *value)
Definition: Track.cpp:1269
Envelope::IntegralOfInverse
double IntegralOfInverse(double t0, double t1) const
Definition: Envelope.cpp:1233
TimeTrack::Paste
void Paste(double t, const Track *src) override
Definition: TimeTrack.cpp:189
TimeTrack::GetDisplayLog
bool GetDisplayLog() const
Definition: TimeTrack.h:88
Ruler::TimeFormat
@ TimeFormat
Definition: Ruler.h:33
TimeTrack::CleanState
void CleanState()
Definition: TimeTrack.cpp:57
TimeTrack::Clear
void Clear(double t0, double t1) override
Definition: TimeTrack.cpp:183
TimeTrack::GetInterpolateLog
bool GetInterpolateLog() const
Definition: TimeTrack.cpp:217
TimeTrack::SetDisplayLog
void SetDisplayLog(bool displayLog)
Definition: TimeTrack.h:89
Track::Track
Track()
Definition: Track.cpp:49
TrackKind::Time
@ Time
Track::SetDefaultName
void SetDefaultName(const wxString &n)
Definition: Track.h:429
anonymous_namespace{TimeTrack.cpp}::GetRate
double GetRate()
Definition: TimeTrack.cpp:175
TimeTrack::GetEnvelope
BoundedEnvelope * GetEnvelope()
Definition: TimeTrack.h:77
TimeTrack::mZoomInfo
const ZoomInfo *const mZoomInfo
Definition: TimeTrack.h:103
Envelope::InsertOrReplace
int InsertOrReplace(double when, double value)
Add a point at a particular absolute time coordinate.
Definition: Envelope.h:181
TIMETRACK_MIN
#define TIMETRACK_MIN
Definition: TimeTrack.cpp:35
Track::TypeSwitch
R TypeSwitch(const Functions &...functions)
Use this function rather than testing track type explicitly and making down-casts.
Definition: Track.h:709
TimeTrack::mRescaleXMLValues
bool mRescaleXMLValues
Definition: TimeTrack.h:107
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
TimeTrack::mEnvelope
std::unique_ptr< BoundedEnvelope > mEnvelope
Definition: TimeTrack.h:104
Track::SetName
void SetName(const wxString &n)
Definition: Track.cpp:82
_
#define _(s)
Definition: Internat.h:75
Track::Init
void Init(const Track &orig)
Definition: Track.cpp:70
XMLWriter::WriteAttr
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:34
TimeTrack::Copy
Holder Copy(double t0, double t1, bool forClipboard) const override
Definition: TimeTrack.cpp:169
TimeTrack::SetInterpolateLog
void SetInterpolateLog(bool interpolateLog)
Definition: TimeTrack.cpp:222
Envelope::Flatten
void Flatten(double value)
Definition: Envelope.cpp:134
TimeTrack::SetRangeLower
void SetRangeLower(double lower)
Definition: TimeTrack.cpp:127
Envelope::Integral
double Integral(double t0, double t1) const
Definition: Envelope.cpp:1170
TimeTrack::mRuler
std::unique_ptr< Ruler > mRuler
Definition: TimeTrack.h:105
TimeTrack::Init
void Init(const TimeTrack &orig)
Copy the metadata from another track but not the points.
Definition: TimeTrack.cpp:105
TimeTrack::SetRangeUpper
void SetRangeUpper(double upper)
Definition: TimeTrack.cpp:132
XMLWriter::StartTag
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:76
TimeTrack
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:24
Internat::CompatibleToDouble
static bool CompatibleToDouble(const wxString &stringToConvert, double *result)
Convert a string to a number.
Definition: Internat.cpp:134