Audacity  3.0.3
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
Track Class Referenceabstract

Abstract base class for an object holding data associated with points on a time axis. More...

#include <Track.h>

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

Classes

struct  Dispatcher
 Helper for recursive case of metafunction implementing Track::TypeSwitch. More...
 
struct  Executor
 Variadic template implements metafunction with specializations, to dispatch Track::TypeSwitch. More...
 
struct  Executor< R, ConcreteType >
 Base case of metafunction implementing Track::TypeSwitch generates operator () with nonvoid return. More...
 
struct  Executor< R, ConcreteType, Function, Functions... >
 Implements Track::TypeSwitch, its operator() invokes the first function that can accept ConcreteType*. More...
 
struct  Executor< R, const ConcreteType, Function, Functions... >
 Implements const overload of Track::TypeSwitch, its operator() invokes the first function that can accept ConcreteType*. More...
 
struct  Executor< void, ConcreteType >
 Base case of metafunction implementing Track::TypeSwitch generates operator () with void return. More...
 

Public Types

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

Public Member Functions

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 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 ()
 
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
 
virtual double GetOffset () const =0
 
void Offset (double t)
 
virtual void SetOffset (double o)
 
virtual void SetPan (float)
 
virtual void SetPanFromChannelType ()
 
virtual Holder Cut (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual Holder Copy (double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard=true) const =0
 
virtual void Clear (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void Paste (double WXUNUSED(t), const Track *WXUNUSED(src))=0
 
virtual void SyncLockAdjust (double oldT1, double newT1)
 
virtual void Silence (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void InsertSilence (double WXUNUSED(t), double WXUNUSED(len))=0
 
bool SameKindAs (const Track &track) const
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions)
 Use this function rather than testing track type explicitly and making down-casts. More...
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions) const
 Use this function rather than testing track type explicitly and making down-casts. More...
 
virtual void WriteXML (XMLWriter &xmlFile) const =0
 
virtual bool GetErrorOpening ()
 
virtual double GetStartTime () const =0
 
virtual double GetEndTime () const =0
 
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 bool HandleXMLTag (const wxChar *tag, const wxChar **attrs)=0
 
virtual void HandleXMLEndTag (const wxChar *WXUNUSED(tag))
 
virtual void HandleXMLContent (const wxString &WXUNUSED(content))
 
virtual XMLTagHandlerHandleXMLChild (const wxChar *tag)=0
 
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...
 

Static Public Member Functions

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

wxSize vrulerSize
 

Protected Member Functions

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

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
 

Private Member Functions

void SetId (TrackId id)
 
TrackGetLinkedTrack () const
 
bool HasLinkedTrack () const noexcept
 Returns true for leaders of multichannel groups. More...
 
TrackNodePointer GetNode () const
 Retrieve mNode with debug checks. More...
 
void SetOwner (const std::weak_ptr< TrackList > &list, TrackNodePointer node)
 Update mNode when Track is added to TrackList, or removed from it. More...
 
virtual Holder Clone () const =0
 
virtual TrackKind GetKind () const
 

Private Attributes

TrackId mId
 Identifies the track only in-session, not persistently. More...
 
LinkType mLinkType { LinkType::None }
 
bool mSelected
 

Friends

class TrackList
 
template<typename T >
std::enable_if< std::is_pointer< T >::value, T >::type track_cast (Track *track)
 Encapsulate the checked down-casting of track pointers. More...
 
template<typename T >
std::enable_if< std::is_pointer< T >::value &&std::is_const< typename std::remove_pointer< T >::type >::value, T >::type track_cast (const Track *track)
 Encapsulate the checked down-casting of track pointers. More...
 

Detailed Description

Abstract base class for an object holding data associated with points on a time axis.

Fundamental data object of Audacity, displayed in the TrackPanel. Classes derived form it include the WaveTrack, NoteTrack, LabelTrack and TimeTrack.

Definition at line 235 of file Track.h.

Member Typedef Documentation

◆ AttachedObjects

Alias for my base type.

Definition at line 272 of file Track.h.

◆ ConstInterval

Definition at line 330 of file Track.h.

◆ ConstIntervals

using Track::ConstIntervals = std::vector< ConstInterval >

Definition at line 331 of file Track.h.

◆ Continuation

template<typename R = void>
using Track::Continuation = std::function< R() >

Type of arguments passed as optional second parameter to TypeSwitch() cases.

Definition at line 502 of file Track.h.

◆ Fallthrough

Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.

Definition at line 504 of file Track.h.

◆ Holder

using Track::Holder = std::shared_ptr<Track>

Definition at line 336 of file Track.h.

◆ Interval

Definition at line 328 of file Track.h.

◆ IntervalData

Definition at line 327 of file Track.h.

◆ Intervals

using Track::Intervals = std::vector< Interval >

Definition at line 329 of file Track.h.

Member Enumeration Documentation

◆ ChannelType

Enumerator
LeftChannel 
RightChannel 
MonoChannel 

Definition at line 274 of file Track.h.

275  {
276  LeftChannel = 0,
277  RightChannel = 1,
278  MonoChannel = 2
279  };

◆ LinkType

enum Track::LinkType : int
strong

For two tracks describes the type of the linkage.

Enumerator
None 
Group 
Aligned 

Definition at line 243 of file Track.h.

243  : int {
244  None = 0, //< No linkage
245  Group = 2, //< Tracks are grouped together
246  Aligned, //< Tracks are grouped and changes should be synchronized
247  };

Constructor & Destructor Documentation

◆ Track() [1/2]

Track::Track ( )

Definition at line 49 of file Track.cpp.

50 : vrulerSize(36,0)
51 {
52  mSelected = false;
53 
54  mIndex = 0;
55 
56  mOffset = 0.0;
57 
59 }

References mChannel, mIndex, mOffset, MonoChannel, and mSelected.

◆ Track() [2/2]

Track::Track ( const Track orig)

Definition at line 61 of file Track.cpp.

62 : vrulerSize( orig.vrulerSize )
63 {
64  mIndex = 0;
65  Init(orig);
66  mOffset = orig.mOffset;
67 }

References Init(), mIndex, and mOffset.

Here is the call graph for this function:

◆ ~ Track()

virtual Track::~ Track ( )
virtual

Member Function Documentation

◆ AdjustPositions()

void Track::AdjustPositions ( )

Definition at line 1290 of file Track.cpp.

1291 {
1292  auto pList = mList.lock();
1293  if (pList) {
1294  pList->RecalcPositions(mNode);
1295  pList->ResizingEvent(mNode);
1296  }
1297 }

References mList, and mNode.

◆ Any()

bool Track::Any ( ) const

◆ Clear()

virtual void Track::Clear ( double   WXUNUSEDt0,
double   WXUNUSEDt1 
)
pure virtual

Referenced by LabelEditActions::Handler::OnDeleteLabels(), and SyncLockAdjust().

Here is the caller graph for this function:

◆ Clone()

virtual Holder Track::Clone ( ) const
privatepure virtual

Implemented in WaveTrack, TimeTrack, NoteTrack, and LabelTrack.

Referenced by Duplicate(), and TrackList::RegisterPendingChangedTrack().

Here is the caller graph for this function:

◆ Copy()

virtual Holder Track::Copy ( double   WXUNUSEDt0,
double   WXUNUSEDt1,
bool  forClipboard = true 
) const
pure virtual

◆ Cut()

virtual Holder Track::Cut ( double   WXUNUSEDt0,
double   WXUNUSEDt1 
)
pure virtual

Referenced by SyncLockAdjust().

Here is the caller graph for this function:

◆ DoSetLinkType()

void Track::DoSetLinkType ( LinkType  linkType)
protectednoexcept

Definition at line 193 of file Track.cpp.

194 {
195  mLinkType = linkType;
196 }

Referenced by SetLinkType().

Here is the caller graph for this function:

◆ Duplicate()

Track::Holder Track::Duplicate ( ) const
virtual

Definition at line 112 of file Track.cpp.

113 {
114  // invoke "virtual constructor" to copy track object proper:
115  auto result = Clone();
116 
117  if (mpView)
118  // Copy view state that might be important to undo/redo
119  mpView->CopyTo( *result );
120 
121  return result;
122 }

References Clone(), and mpView.

Referenced by WaveTrackFactory::DuplicateWaveTrack().

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

◆ EnsureVisible()

void Track::EnsureVisible ( bool  modifyState = false)

Definition at line 100 of file Track.cpp.

101 {
102  auto pList = mList.lock();
103  if (pList)
104  pList->EnsureVisibleEvent( SharedPointer(), modifyState );
105 }

References mList, and SharedPointer().

Referenced by anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), EffectUI::DoEffect(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), anonymous_namespace{NavigationMenus.cpp}::DoPrevTrack(), TrackUtilities::DoRemoveTracks(), TrackPanel::OnMouseEvent(), TrackActions::Handler::OnNewLabelTrack(), TrackActions::Handler::OnNewStereoTrack(), TrackActions::Handler::OnNewTimeTrack(), TrackActions::Handler::OnNewWaveTrack(), LabelEditActions::Handler::OnPasteNewLabel(), EditActions::Handler::OnRedo(), NavigationActions::Handler::OnToggle(), EditActions::Handler::OnUndo(), TrackPanel::ProcessUIHandleResult(), and ProjectWindow::ZoomAfterImport().

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

◆ FinishCopy()

void Track::FinishCopy ( const Track n,
Track dest 
)
static

Definition at line 387 of file Track.cpp.

389 {
390  if (dest) {
391  dest->SetChannel(n->GetChannel());
392  dest->SetLinkType(n->GetLinkType());
393  dest->SetName(n->GetName());
394  }
395 }

References GetChannel(), GetLinkType(), GetName(), SetChannel(), SetLinkType(), and SetName().

Referenced by anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), anonymous_namespace{LabelMenus.cpp}::EditClipboardByLabel(), anonymous_namespace{EditMenus.cpp}::FinishCopy(), and anonymous_namespace{ProjectFileManager.cpp}::ImportProject().

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

◆ GetChannel()

virtual ChannelType Track::GetChannel ( ) const
inlinevirtual

Reimplemented in WaveTrack.

Definition at line 441 of file Track.h.

441 { return mChannel;}

Referenced by FinishCopy(), LinkConsistencyCheck(), and anonymous_namespace{NoteTrackControls.cpp}::MidiControlsDrawFunction().

Here is the caller graph for this function:

◆ GetDefaultName()

wxString Track::GetDefaultName ( ) const
inline

Definition at line 428 of file Track.h.

428 { return mDefaultName; }

Referenced by TimeTrack::CleanState(), TimeTrack::Init(), WaveTrack::Init(), LabelTrack::LabelTrack(), NoteTrack::NoteTrack(), and WaveTrack::WaveTrack().

Here is the caller graph for this function:

◆ GetEndTime()

virtual double Track::GetEndTime ( ) const
pure virtual

◆ GetErrorOpening()

virtual bool Track::GetErrorOpening ( )
inlinevirtual

Reimplemented in WaveTrack.

Definition at line 799 of file Track.h.

799 { return false; }

◆ GetId()

TrackId Track::GetId ( ) const
inline

Definition at line 281 of file Track.h.

281 { return mId; }

Referenced by TrackList::HasPendingTracks(), TrackPanelAx::IsFocused(), SetLinkType(), SubstituteOriginalTrack(), and SubstitutePendingChangedTrack().

Here is the caller graph for this function:

◆ GetIndex()

int Track::GetIndex ( ) const

Definition at line 164 of file Track.cpp.

165 {
166  return mIndex;
167 }

References mIndex.

Referenced by SelectionState::ChangeSelectionOnShiftClick(), TrackList::RecalcPositions(), and SelectionState::SelectRangeOfTracks().

Here is the caller graph for this function:

◆ GetIntervals() [1/2]

auto Track::GetIntervals ( )
virtual

This overload exposes the extra data of the intervals as non-const This overload exposes the extra data of the intervals as non-const

Reimplemented in WaveTrack, NoteTrack, and LabelTrack.

Definition at line 1249 of file Track.cpp.

1250 {
1251  return {};
1252 }

◆ GetIntervals() [2/2]

auto Track::GetIntervals ( ) const
virtual

Report times on the track where important intervals begin and end, for UI to snap to.

Some intervals may be empty, and no ordering of the intervals is assumed.

Reimplemented in WaveTrack, NoteTrack, and LabelTrack.

Definition at line 1244 of file Track.cpp.

1245 {
1246  return {};
1247 }

Referenced by TrackShifter::InitIntervals().

Here is the caller graph for this function:

◆ GetKind()

virtual TrackKind Track::GetKind ( ) const
inlineprivatevirtual

Reimplemented in WaveTrack, TimeTrack, NoteTrack, and LabelTrack.

Definition at line 483 of file Track.h.

483 { return TrackKind::None; }

References None.

Referenced by SameKindAs(), and track_cast().

Here is the caller graph for this function:

◆ GetLinkedTrack()

Track * Track::GetLinkedTrack ( ) const
private

Definition at line 203 of file Track.cpp.

204 {
205  auto pList = mList.lock();
206  if (!pList)
207  return nullptr;
208 
209  if (!pList->isNull(mNode)) {
210  if (HasLinkedTrack()) {
211  auto next = pList->getNext( mNode );
212  if ( !pList->isNull( next ) )
213  return next.first->get();
214  }
215 
216  if (mNode.first != mNode.second->begin()) {
217  auto prev = pList->getPrev( mNode );
218  if ( !pList->isNull( prev ) ) {
219  auto track = prev.first->get();
220  if (track && track->HasLinkedTrack())
221  return track;
222  }
223  }
224  }
225 
226  return nullptr;
227 }

References HasLinkedTrack(), mList, and mNode.

Referenced by TrackList::GetPrev(), IsLeader(), and LinkConsistencyCheck().

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

◆ GetLinkType()

Track::LinkType Track::GetLinkType ( ) const
noexcept

Definition at line 1312 of file Track.cpp.

1313 {
1314  return mLinkType;
1315 }

References mLinkType.

Referenced by FinishCopy(), WaveClipTrimHandle::HitAnywhere(), WaveTrack::LinkConsistencyCheck(), and WaveTrackMenuTable::OnSwapChannels().

Here is the caller graph for this function:

◆ GetName()

wxString Track::GetName ( ) const
inline

◆ GetNode()

TrackNodePointer Track::GetNode ( ) const
private

Retrieve mNode with debug checks.

Definition at line 129 of file Track.cpp.

130 {
131  wxASSERT(mList.lock() == NULL || this == mNode.first->get());
132  return mNode;
133 }

References mList, and mNode.

Referenced by TrackList::GetNext(), TrackList::GetPrev(), TrackList::MoveDown(), TrackList::MoveUp(), and TrackList::Remove().

Here is the caller graph for this function:

◆ GetOffset()

virtual double Track::GetOffset ( ) const
pure virtual

Implemented in WaveTrack, TimeTrack, NoteTrack, and LabelTrack.

Referenced by anonymous_namespace{TrackMenus.cpp}::DoAlign(), TrackList::GetMinOffset(), SelectActions::Handler::OnCursorTrackStart(), and SelectionState::SelectTrackLength().

Here is the caller graph for this function:

◆ GetOwner()

std::shared_ptr<TrackList> Track::GetOwner ( ) const
inline

Definition at line 379 of file Track.h.

379 { return mList.lock(); }

Referenced by TrackShifter::CommonMayMigrateTo(), IsAlignedWithLeader(), WaveTrack::LinkConsistencyCheck(), WaveTrack::PasteWaveTrack(), and WaveTrackAffordanceControls::WaveTrackAffordanceControls().

Here is the caller graph for this function:

◆ GetSelected()

bool Track::GetSelected ( ) const
inline

◆ GetStartTime()

virtual double Track::GetStartTime ( ) const
pure virtual

Implemented in WaveTrack, TimeTrack, NoteTrack, and LabelTrack.

Referenced by anonymous_namespace{TrackMenus.cpp}::DoAlign(), ExportMultipleDialog::ExportMultipleByTrack(), TrackList::GetStartTime(), StretchHandle::GetT0(), SelectActions::Handler::OnSelectStartCursor(), SelectActions::Handler::OnSelectTrackStartToEnd(), and NyquistEffect::ProcessOne().

Here is the caller graph for this function:

◆ GetTrackControls()

const std::shared_ptr< CommonTrackCell > & Track::GetTrackControls ( )

Definition at line 154 of file Track.cpp.

155 {
156  return mpControls;
157 }

References mpControls.

Referenced by CommonTrackControls::TrackControls().

Here is the caller graph for this function:

◆ GetTrackView()

const std::shared_ptr< CommonTrackCell > & Track::GetTrackView ( )

Definition at line 144 of file Track.cpp.

145 {
146  return mpView;
147 }

References mpView.

Referenced by TrackView::Get().

Here is the caller graph for this function:

◆ HandleCommonXMLAttribute()

bool Track::HandleCommonXMLAttribute ( const wxChar *  attr,
const wxChar *  value 
)

Definition at line 1269 of file Track.cpp.

1270 {
1271  long nValue = -1;
1272  wxString strValue( value );
1273  if ( mpView && mpView->HandleXMLAttribute( attr, value ) )
1274  ;
1275  else if ( mpControls && mpControls->HandleXMLAttribute( attr, value ) )
1276  ;
1277  else if (!wxStrcmp(attr, wxT("name")) &&
1278  XMLValueChecker::IsGoodString(strValue)) {
1279  SetName( strValue );
1280  return true;
1281  }
1282  else if (!wxStrcmp(attr, wxT("isSelected")) &&
1283  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
1284  this->SetSelected(nValue != 0);
1285  return true;
1286  }
1287  return false;
1288 }

References XMLValueChecker::IsGoodInt(), XMLValueChecker::IsGoodString(), mpControls, mpView, SetName(), and SetSelected().

Referenced by LabelTrack::HandleXMLTag(), NoteTrack::HandleXMLTag(), TimeTrack::HandleXMLTag(), and WaveTrack::HandleXMLTag().

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

◆ HasLinkedTrack()

bool Track::HasLinkedTrack ( ) const
privatenoexcept

Returns true for leaders of multichannel groups.

Definition at line 229 of file Track.cpp.

230 {
231  return mLinkType != LinkType::None;
232 }

References mLinkType, and None.

Referenced by GetLinkedTrack(), TrackList::GetNext(), TrackList::GetPrev(), IsLeader(), and LinkConsistencyCheck().

Here is the caller graph for this function:

◆ HasOwner()

bool Track::HasOwner ( ) const
inline

Definition at line 377 of file Track.h.

377 { return static_cast<bool>(GetOwner());}

References TrackList::GetOwner().

Here is the call graph for this function:

◆ Init()

void Track::Init ( const Track orig)

Definition at line 70 of file Track.cpp.

71 {
72  mId = orig.mId;
73 
75  mName = orig.mName;
76 
77  mSelected = orig.mSelected;
78  mLinkType = orig.mLinkType;
79  mChannel = orig.mChannel;
80 }

References mChannel, mDefaultName, mId, mLinkType, mName, and mSelected.

Referenced by PlayableTrack::Init(), TimeTrack::Init(), and Track().

Here is the caller graph for this function:

◆ InsertSilence()

virtual void Track::InsertSilence ( double   WXUNUSEDt,
double   WXUNUSEDlen 
)
pure virtual

◆ IsAlignedWithLeader()

bool Track::IsAlignedWithLeader ( ) const

Returns true if the leader track has link type LinkType::Aligned.

Definition at line 1317 of file Track.cpp.

1318 {
1319  if (auto owner = GetOwner())
1320  {
1321  auto leader = *owner->FindLeader(this);
1322  return leader != this && leader->GetLinkType() == Track::LinkType::Aligned;
1323  }
1324  return false;
1325 }

References Aligned, and GetOwner().

Referenced by WaveClipTrimHandle::HitAnywhere().

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

◆ IsLeader()

bool Track::IsLeader ( ) const

Definition at line 379 of file Track.cpp.

380 {
381  return !GetLinkedTrack() || HasLinkedTrack();
382 }

References GetLinkedTrack(), and HasLinkedTrack().

Referenced by anonymous_namespace{FileMenus.cpp}::DoExport(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), anonymous_namespace{TrackPanel.cpp}::DrawTrackName(), AudioIoCallback::FillOutputBuffers(), TrackList::FindLeader(), IsSelectedLeader(), TrackList::Leaders(), EffectLoudness::Process(), EffectNormalize::Process(), NyquistEffect::Process(), and StereoRequiredFlag().

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

◆ IsSelected()

bool Track::IsSelected ( ) const

Definition at line 373 of file Track.cpp.

374  { return GetSelected(); }

References GetSelected().

Referenced by ProjectAudioManager::ChooseExistingRecordingTracks(), ExportPlugin::CreateMixer(), anonymous_namespace{TrackMenus.cpp}::DoPanTracks(), Exporter::ExamineTracks(), ExportMixerDialog::ExportMixerDialog(), ProjectAudioManager::GetAllPlaybackTracks(), IsSelectedLeader(), IsSyncLockSelected(), ProjectAudioManager::OnRecord(), SelectActions::Handler::OnSelectSyncLockSel(), EffectTruncSilence::ProcessIndependently(), and TrackList::Selected().

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

◆ IsSelectedLeader()

bool Track::IsSelectedLeader ( ) const

Definition at line 384 of file Track.cpp.

385  { return IsSelected() && IsLeader(); }

References IsLeader(), and IsSelected().

Referenced by TrackList::SelectedLeaders().

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

◆ IsSelectedOrSyncLockSelected()

bool Track::IsSelectedOrSyncLockSelected ( ) const

Definition at line 376 of file Track.cpp.

377  { return GetSelected() || IsSyncLockSelected(); }

References GetSelected(), and IsSyncLockSelected().

Referenced by anonymous_namespace{TrackMenus.cpp}::DoAlign(), EffectTruncSilence::DoRemoval(), EditActions::Handler::OnCut(), and EffectReverse::Process().

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

◆ IsSyncLockSelected()

bool Track::IsSyncLockSelected ( ) const

Definition at line 254 of file Track.cpp.

255 {
256 #ifdef EXPERIMENTAL_SYNC_LOCK
257  auto pList = mList.lock();
258  if (!pList)
259  return false;
260 
261  auto p = pList->GetOwner();
262  if (!p || !ProjectSettings::Get( *p ).IsSyncLocked())
263  return false;
264 
265  auto shTrack = this->SubstituteOriginalTrack();
266  if (!shTrack)
267  return false;
268 
269  const auto pTrack = shTrack.get();
270  auto trackRange = TrackList::SyncLockGroup( pTrack );
271 
272  if (trackRange.size() <= 1) {
273  // Not in a sync-locked group.
274  // Return true iff selected and of a sync-lockable type.
275  return (IsSyncLockableNonLabelTrack( pTrack ) ||
276  track_cast<const LabelTrack*>( pTrack )) && GetSelected();
277  }
278 
279  // Return true iff any track in the group is selected.
280  return *(trackRange + &Track::IsSelected).begin();
281 #endif
282 
283  return false;
284 }

References ProjectSettings::Get(), GetSelected(), IsSelected(), anonymous_namespace{Track.cpp}::IsSyncLockableNonLabelTrack(), ProjectSettings::IsSyncLocked(), mList, SubstituteOriginalTrack(), and TrackList::SyncLockGroup().

Referenced by ClipParameters::ClipParameters(), TrackArt::DrawBackgroundWithSelection(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), IsSelectedOrSyncLockSelected(), TrackInfo::MinimizeSyncLockDrawFunction(), EditActions::Handler::OnPaste(), SelectActions::Handler::OnSelectSyncLockSel(), EffectChangeSpeed::Process(), EffectRepeat::Process(), and EffectSBSMS::Process().

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

◆ LinkConsistencyCheck()

bool Track::LinkConsistencyCheck ( )
virtual

Reimplemented in WaveTrack.

Definition at line 397 of file Track.cpp.

398 {
399  // Sanity checks for linked tracks; unsetting the linked property
400  // doesn't fix the problem, but it likely leaves us with orphaned
401  // sample blocks instead of much worse problems.
402  bool err = false;
403  if (HasLinkedTrack())
404  {
405  auto link = GetLinkedTrack();
406  if (link)
407  {
408  // A linked track's partner should never itself be linked
409  if (link->HasLinkedTrack())
410  {
411  wxLogWarning(
412  wxT("Left track %s had linked right track %s with extra right track link.\n Removing extra link from right track."),
413  GetName(), link->GetName());
414  err = true;
415  link->SetLinkType(LinkType::None);
416  }
417 
418  // Channels should be left and right
419  if ( !( (GetChannel() == Track::LeftChannel &&
420  link->GetChannel() == Track::RightChannel) ||
422  link->GetChannel() == Track::LeftChannel) ) )
423  {
424  wxLogWarning(
425  wxT("Track %s and %s had left/right track links out of order. Setting tracks to not be linked."),
426  GetName(), link->GetName());
427  err = true;
429  }
430  }
431  else
432  {
433  wxLogWarning(
434  wxT("Track %s had link to NULL track. Setting it to not be linked."),
435  GetName());
436  err = true;
438  }
439  }
440 
441  return ! err;
442 }

References GetChannel(), GetLinkedTrack(), GetName(), HasLinkedTrack(), LeftChannel, None, RightChannel, and SetLinkType().

Referenced by WaveTrack::LinkConsistencyCheck().

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

◆ Merge()

void Track::Merge ( const Track orig)
virtual

Reimplemented in WaveTrack, and PlayableTrack.

Definition at line 107 of file Track.cpp.

108 {
109  mSelected = orig.mSelected;
110 }

References mSelected.

Referenced by PlayableTrack::Merge().

Here is the caller graph for this function:

◆ Notify()

void Track::Notify ( int  code = -1)

Definition at line 286 of file Track.cpp.

287 {
288  auto pList = mList.lock();
289  if (pList)
290  pList->DataEvent( SharedPointer(), code );
291 }

References mList, and SharedPointer().

Referenced by WaveTrack::SetGain(), PlayableTrack::SetMute(), SetName(), WaveTrack::SetPan(), and PlayableTrack::SetSolo().

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

◆ Offset()

void Track::Offset ( double  t)
inline

Definition at line 444 of file Track.h.

444 { SetOffset(GetOffset() + t); }

Referenced by TrackShifter::DoHorizontalOffset(), Effect::Preview(), and StretchHandle::Stretch().

Here is the caller graph for this function:

◆ Paste()

virtual void Track::Paste ( double   WXUNUSEDt,
const Track WXUNUSEDsrc 
)
pure virtual

Referenced by SyncLockAdjust().

Here is the caller graph for this function:

◆ PasteInto()

virtual Holder Track::PasteInto ( AudacityProject ) const
pure virtual

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

Implemented in WaveTrack, TimeTrack, NoteTrack, and LabelTrack.

Referenced by anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected().

Here is the caller graph for this function:

◆ SameKindAs()

bool Track::SameKindAs ( const Track track) const
inline

Definition at line 497 of file Track.h.

498  { return GetKind() == track.GetKind(); }

References GetKind().

Referenced by TrackShifter::CommonMayMigrateTo(), and anonymous_namespace{TimeShiftHandle.cpp}::FindCorrespondence().

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

◆ SetChannel()

void Track::SetChannel ( ChannelType  c)
protectednoexcept

Definition at line 198 of file Track.cpp.

199 {
200  mChannel = c;
201 }

Referenced by FinishCopy(), and WaveTrack::LinkConsistencyCheck().

Here is the caller graph for this function:

◆ SetDefaultName()

void Track::SetDefaultName ( const wxString &  n)
inline

Definition at line 429 of file Track.h.

429 { mDefaultName = n; }

Referenced by TimeTrack::CleanState(), TimeTrack::Init(), WaveTrack::Init(), LabelTrack::LabelTrack(), NoteTrack::NoteTrack(), and WaveTrack::WaveTrack().

Here is the caller graph for this function:

◆ SetId()

void Track::SetId ( TrackId  id)
inlineprivate

Definition at line 283 of file Track.h.

283 { mId = id; }

References id.

Referenced by TrackList::DoAdd(), TrackList::DoAddToHead(), TrackList::RegisterPendingNewTrack(), and TrackList::Replace().

Here is the caller graph for this function:

◆ SetIndex()

void Track::SetIndex ( int  index)

Definition at line 169 of file Track.cpp.

170 {
171  mIndex = index;
172 }

References mIndex.

Referenced by TrackList::RecalcPositions().

Here is the caller graph for this function:

◆ SetLinkType()

void Track::SetLinkType ( LinkType  linkType)
protected

Definition at line 174 of file Track.cpp.

175 {
176  auto pList = mList.lock();
177  if (pList && !pList->mPendingUpdates.empty()) {
178  auto orig = pList->FindById( GetId() );
179  if (orig && orig != this) {
180  orig->SetLinkType(linkType);
181  return;
182  }
183  }
184 
185  DoSetLinkType(linkType);
186 
187  if (pList) {
188  pList->RecalcPositions(mNode);
189  pList->ResizingEvent(mNode);
190  }
191 }

References DoSetLinkType(), GetId(), mList, and mNode.

Referenced by FinishCopy(), WaveTrack::HandleXMLTag(), LinkConsistencyCheck(), and WaveTrack::LinkConsistencyCheck().

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

◆ SetName()

void Track::SetName ( const wxString &  n)

Definition at line 82 of file Track.cpp.

83 {
84  if ( mName != n ) {
85  mName = n;
86  Notify();
87  }
88 }

References mName, and Notify().

Referenced by Effect::AddedAnalysisTrack::AddedAnalysisTrack(), SetTrackStatusCommand::ApplyInner(), TimeTrack::CleanState(), FinishCopy(), HandleCommonXMLAttribute(), ImportMIDI(), TimeTrack::Init(), WaveTrack::Init(), LabelTrack::LabelTrack(), Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack(), NoteTrack::NoteTrack(), and WaveTrack::WaveTrack().

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

◆ SetOffset()

virtual void Track::SetOffset ( double  o)
inlinevirtual

Reimplemented in TimeTrack, WaveTrack, and LabelTrack.

Definition at line 445 of file Track.h.

445 { mOffset = o; }

Referenced by NoteTrack::Clear(), NoteTrack::HandleXMLTag(), ImportMIDI(), NoteTrack::Paste(), and NoteTrack::Trim().

Here is the caller graph for this function:

◆ SetOwner()

void Track::SetOwner ( const std::weak_ptr< TrackList > &  list,
TrackNodePointer  node 
)
private

Update mNode when Track is added to TrackList, or removed from it.

Definition at line 135 of file Track.cpp.

137 {
138  // BUG: When using this function to clear an owner, we may need to clear
139  // focused track too. Otherwise focus could remain on an invisible (or deleted) track.
140  mList = list;
141  mNode = node;
142 }

References mList, and mNode.

Referenced by TrackList::DoAdd(), TrackList::DoAddToHead(), TrackList::Permute(), TrackList::RegisterPendingChangedTrack(), TrackList::Remove(), TrackList::Replace(), and TrackList::SwapNodes().

Here is the caller graph for this function:

◆ SetPan()

virtual void Track::SetPan ( float  )
inlinevirtual

Reimplemented in WaveTrack.

Definition at line 447 of file Track.h.

447 { ;}

Referenced by SetTrackAudioCommand::ApplyInner().

Here is the caller graph for this function:

◆ SetPanFromChannelType()

virtual void Track::SetPanFromChannelType ( )
inlinevirtual

Reimplemented in WaveTrack.

Definition at line 448 of file Track.h.

448 { ;};

◆ SetSelected()

void Track::SetSelected ( bool  s)
virtual

Reimplemented in LabelTrack.

Definition at line 90 of file Track.cpp.

91 {
92  if (mSelected != s) {
93  mSelected = s;
94  auto pList = mList.lock();
95  if (pList)
96  pList->SelectionEvent( SharedPointer() );
97  }
98 }

References mList, mSelected, and SharedPointer().

Referenced by SetTrackStatusCommand::ApplyInner(), anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), HandleCommonXMLAttribute(), LabelEditActions::Handler::OnPasteNewLabel(), and LabelTrack::SetSelected().

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

◆ SetTrackControls()

void Track::SetTrackControls ( const std::shared_ptr< CommonTrackCell > &  pControls)

Definition at line 159 of file Track.cpp.

160 {
161  mpControls = pControls;
162 }

References mpControls.

Referenced by CommonTrackControls::TrackControls().

Here is the caller graph for this function:

◆ SetTrackView()

void Track::SetTrackView ( const std::shared_ptr< CommonTrackCell > &  pView)

Definition at line 149 of file Track.cpp.

150 {
151  mpView = pView;
152 }

References mpView.

Referenced by TrackView::Get().

Here is the caller graph for this function:

◆ SharedPointer() [1/4]

template<typename Subclass = Track>
std::shared_ptr<Subclass> Track::SharedPointer ( )
inline

◆ SharedPointer() [2/4]

template<typename Subclass = const Track>
auto Track::SharedPointer ( ) const -> typename std::enable_if< std::is_const<Subclass>::value, std::shared_ptr<Subclass> >::type
inline

Definition at line 299 of file Track.h.

303  {
304  // shared_from_this is injected into class scope by base class
305  // std::enable_shared_from_this<Track>
306  return std::static_pointer_cast<Subclass>( shared_from_this() );
307  }

◆ SharedPointer() [3/4]

template<typename Subclass = const Track>
static std::shared_ptr<Subclass> Track::SharedPointer ( const Track pTrack)
inlinestatic

Definition at line 315 of file Track.h.

316  { return pTrack ? pTrack->SharedPointer<Subclass>() : nullptr; }

References SharedPointer().

Here is the call graph for this function:

◆ SharedPointer() [4/4]

template<typename Subclass = Track>
static std::shared_ptr<Subclass> Track::SharedPointer ( Track pTrack)
inlinestatic

Definition at line 311 of file Track.h.

312  { return pTrack ? pTrack->SharedPointer<Subclass>() : nullptr; }

References SharedPointer().

Here is the call graph for this function:

◆ Silence()

virtual void Track::Silence ( double   WXUNUSEDt0,
double   WXUNUSEDt1 
)
pure virtual

◆ SubstituteOriginalTrack()

std::shared_ptr< const Track > Track::SubstituteOriginalTrack ( ) const

Definition at line 1219 of file Track.cpp.

1220 {
1221  auto pList = mList.lock();
1222  if (pList) {
1223  const auto id = GetId();
1224  const auto pred = [=]( const ListOfTracks::value_type &ptr ) {
1225  return ptr->GetId() == id; };
1226  const auto end = pList->mPendingUpdates.end();
1227  const auto it = std::find_if( pList->mPendingUpdates.begin(), end, pred );
1228  if (it != end) {
1229  const auto &list2 = (const ListOfTracks &) *pList;
1230  const auto end2 = list2.end();
1231  const auto it2 = std::find_if( list2.begin(), end2, pred );
1232  if ( it2 != end2 )
1233  return *it2;
1234  }
1235  }
1236  return SharedPointer();
1237 }

References GetId(), id, mList, and SharedPointer().

Referenced by IsSyncLockSelected().

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

◆ SubstitutePendingChangedTrack() [1/2]

std::shared_ptr< Track > Track::SubstitutePendingChangedTrack ( )

Definition at line 1198 of file Track.cpp.

1199 {
1200  // Linear search. Tracks in a project are usually very few.
1201  auto pList = mList.lock();
1202  if (pList) {
1203  const auto id = GetId();
1204  const auto end = pList->mPendingUpdates.end();
1205  auto it = std::find_if(
1206  pList->mPendingUpdates.begin(), end,
1207  [=](const ListOfTracks::value_type &ptr){ return ptr->GetId() == id; } );
1208  if (it != end)
1209  return *it;
1210  }
1211  return SharedPointer();
1212 }

References GetId(), mList, and SharedPointer().

Referenced by TrackPanel::DrawTracks(), SubstitutePendingChangedTrack(), and ProjectFileIO::WriteXML().

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

◆ SubstitutePendingChangedTrack() [2/2]

std::shared_ptr< const Track > Track::SubstitutePendingChangedTrack ( ) const

Definition at line 1214 of file Track.cpp.

1215 {
1216  return const_cast<Track*>(this)->SubstitutePendingChangedTrack();
1217 }

References SubstitutePendingChangedTrack().

Here is the call graph for this function:

◆ SupportsBasicEditing()

bool Track::SupportsBasicEditing ( ) const
virtual

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

Reimplemented in TimeTrack.

Definition at line 1239 of file Track.cpp.

1240 {
1241  return true;
1242 }

Referenced by SelectActions::Handler::OnCursorTrackEnd(), SelectActions::Handler::OnCursorTrackStart(), EditActions::Handler::OnCut(), SelectActions::Handler::OnSelectSyncLockSel(), and EditActions::Handler::OnSplitCut().

Here is the caller graph for this function:

◆ SyncLockAdjust()

void Track::SyncLockAdjust ( double  oldT1,
double  newT1 
)
virtual

Reimplemented in WaveTrack, and LabelTrack.

Definition at line 293 of file Track.cpp.

294 {
295  if (newT1 > oldT1) {
296  // Insert space within the track
297 
298  if (oldT1 > GetEndTime())
299  return;
300 
301  auto tmp = Cut(oldT1, GetEndTime());
302 
303  Paste(newT1, tmp.get());
304  }
305  else if (newT1 < oldT1) {
306  // Remove from the track
307  Clear(newT1, oldT1);
308  }
309 }

References Clear(), Cut(), GetEndTime(), and Paste().

Referenced by EditActions::Handler::OnPaste().

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

◆ TypeSwitch() [1/2]

template<typename R = void, typename ... Functions>
R Track::TypeSwitch ( const Functions &...  functions)
inline

Use this function rather than testing track type explicitly and making down-casts.

A variadic function taking any number of function objects, each taking a pointer to Track or a subclass, maybe const-qualified, and maybe a second argument which is a fall-through continuation.

Each of the function objects (and supplied continuations) returns R (or a type convertible to R). Calls the first in the sequence that accepts the actual type of the track.

If no function accepts the track, do nothing and return R{} if R is not void.

If one of the functions invokes the call-through, then the next following applicable function is called.

Template Parameters
RReturn type of this function and each function argument
Functionscallable types deduced from arguments
Parameters
functionstypically lambdas, taking a pointer to a track subclass, and optionally a fall-through call-back

Definition at line 709 of file Track.h.

710  {
711  using WaveExecutor =
712  Executor< R, WaveTrack, Functions... >;
713  using NoteExecutor =
714  Executor< R, NoteTrack, Functions... >;
715  using LabelExecutor =
716  Executor< R, LabelTrack, Functions... >;
717  using TimeExecutor =
718  Executor< R, TimeTrack, Functions... >;
719  using DefaultExecutor =
720  Executor< R, Track >;
721  enum { All = sizeof...( functions ) };
722 
723  static_assert(
724  (1u << All) - 1u ==
725  (WaveExecutor::SetUsed |
726  NoteExecutor::SetUsed |
727  LabelExecutor::SetUsed |
728  TimeExecutor::SetUsed),
729  "Uncallable case in Track::TypeSwitch"
730  );
731 
732  switch (GetKind()) {
733  case TrackKind::Wave:
734  return WaveExecutor{} (this, functions...);
735 #if defined(USE_MIDI)
736  case TrackKind::Note:
737  return NoteExecutor{} (this, functions...);
738 #endif
739  case TrackKind::Label:
740  return LabelExecutor{}(this, functions...);
741  case TrackKind::Time:
742  return TimeExecutor{} (this, functions...);
743  default:
744  return DefaultExecutor{} (this);
745  }
746  }

References All, Label, Note, Time, and Wave.

Referenced by SetClipCommand::ApplyInner(), SetEnvelopeCommand::ApplyInner(), WaveTrack::Merge(), LabelEditActions::Handler::OnCopyLabels(), LabelEditActions::Handler::OnCutLabels(), LabelEditActions::Handler::OnDisjoinLabels(), LabelEditActions::Handler::OnJoinLabels(), LabelEditActions::Handler::OnSilenceLabels(), LabelEditActions::Handler::OnSplitCutLabels(), LabelEditActions::Handler::OnSplitDeleteLabels(), LabelEditActions::Handler::OnSplitLabels(), LabelTrack::Paste(), NoteTrack::Paste(), TimeTrack::Paste(), LabelTrack::PasteOver(), NyquistEffect::ProcessOne(), and StretchHandle::Stretch().

Here is the caller graph for this function:

◆ TypeSwitch() [2/2]

template<typename R = void, typename ... Functions>
R Track::TypeSwitch ( const Functions &...  functions) const
inline

Use this function rather than testing track type explicitly and making down-casts.

A variadic function taking any number of function objects, each taking a pointer to Track or a subclass, maybe const-qualified, and maybe a second argument which is a fall-through continuation.

Each of the function objects (and supplied continuations) returns R (or a type convertible to R). Calls the first in the sequence that accepts the actual type of the track.

If no function accepts the track, do nothing and return R{} if R is not void.

If one of the functions invokes the call-through, then the next following applicable function is called.

Template Parameters
RReturn type of this function and each function argument
Functionscallable types deduced from arguments
Parameters
functionstypically lambdas, taking a pointer to a track subclass, and optionally a fall-through call-back

This is the overload for const tracks, only taking callable arguments that accept first arguments that are pointers to const.

Definition at line 755 of file Track.h.

756  {
757  using WaveExecutor =
758  Executor< R, const WaveTrack, Functions... >;
759  using NoteExecutor =
760  Executor< R, const NoteTrack, Functions... >;
761  using LabelExecutor =
762  Executor< R, const LabelTrack, Functions... >;
763  using TimeExecutor =
764  Executor< R, const TimeTrack, Functions... >;
765  using DefaultExecutor =
766  Executor< R, const Track >;
767  enum { All = sizeof...( functions ) };
768 
769  static_assert(
770  (1u << All) - 1u ==
771  (WaveExecutor::SetUsed |
772  NoteExecutor::SetUsed |
773  LabelExecutor::SetUsed |
774  TimeExecutor::SetUsed),
775  "Uncallable case in Track::TypeSwitch"
776  );
777 
778  switch (GetKind()) {
779  case TrackKind::Wave:
780  return WaveExecutor{} (this, functions...);
781 #if defined(USE_MIDI)
782  case TrackKind::Note:
783  return NoteExecutor{} (this, functions...);
784 #endif
785  case TrackKind::Label:
786  return LabelExecutor{}(this, functions...);
787  case TrackKind::Time:
788  return TimeExecutor{} (this, functions...);
789  default:
790  return DefaultExecutor{} (this);
791  }
792  }

References All, Label, Note, Time, and Wave.

◆ WriteCommonXMLAttributes()

void Track::WriteCommonXMLAttributes ( XMLWriter xmlFile,
bool  includeNameAndSelected = true 
) const

Definition at line 1255 of file Track.cpp.

1257 {
1258  if (includeNameAndSelected) {
1259  xmlFile.WriteAttr(wxT("name"), GetName());
1260  xmlFile.WriteAttr(wxT("isSelected"), this->GetSelected());
1261  }
1262  if ( mpView )
1263  mpView->WriteXMLAttributes( xmlFile );
1264  if ( mpControls )
1265  mpControls->WriteXMLAttributes( xmlFile );
1266 }

References GetName(), GetSelected(), mpControls, mpView, and XMLWriter::WriteAttr().

Referenced by LabelTrack::WriteXML(), TimeTrack::WriteXML(), and WaveTrack::WriteXML().

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

◆ WriteXML()

virtual void Track::WriteXML ( XMLWriter xmlFile) const
pure virtual

Implemented in WaveTrack, TimeTrack, NoteTrack, and LabelTrack.

Friends And Related Function Documentation

◆ track_cast [1/2]

template<typename T >
std::enable_if< std::is_pointer<T>::value && std::is_const< typename std::remove_pointer< T >::type >::value, T >::type track_cast ( const Track track)
friend

Encapsulate the checked down-casting of track pointers.

Eliminates possibility of error – and not quietly casting away const

Typical usage:

if (auto wt = track_cast<const WaveTrack*>(track)) { ... }

This overload for const pointers can cast only to other const pointer types.

Definition at line 909 of file Track.h.

910 {
911  using BareType = typename std::remove_pointer< T >::type;
912  if (track &&
913  CompatibleTrackKinds( track_kind<BareType>(), track->GetKind() ))
914  return reinterpret_cast<T>(track);
915  else
916  return nullptr;
917 }

◆ track_cast [2/2]

template<typename T >
std::enable_if< std::is_pointer<T>::value, T >::type track_cast ( Track track)
friend

Encapsulate the checked down-casting of track pointers.

Eliminates possibility of error – and not quietly casting away const

Typical usage:

if (auto wt = track_cast<const WaveTrack*>(track)) { ... }

Definition at line 891 of file Track.h.

892 {
893  using BareType = typename std::remove_pointer< T >::type;
894  if (track &&
895  CompatibleTrackKinds( track_kind<BareType>(), track->GetKind() ))
896  return reinterpret_cast<T>(track);
897  else
898  return nullptr;
899 }

◆ TrackList

friend class TrackList
friend

Definition at line 251 of file Track.h.

Member Data Documentation

◆ mChannel

ChannelType Track::mChannel
protected

◆ mDefaultName

wxString Track::mDefaultName
protected

Definition at line 264 of file Track.h.

Referenced by Init().

◆ mId

TrackId Track::mId
private

Identifies the track only in-session, not persistently.

Definition at line 254 of file Track.h.

Referenced by Init().

◆ mIndex

int Track::mIndex
protected

0-based position of this track in its TrackList

Definition at line 262 of file Track.h.

Referenced by GetIndex(), SetIndex(), and Track().

◆ mLinkType

LinkType Track::mLinkType { LinkType::None }
private

Definition at line 255 of file Track.h.

Referenced by GetLinkType(), HasLinkedTrack(), and Init().

◆ mList

std::weak_ptr<TrackList> Track::mList
protected

◆ mName

wxString Track::mName
protected

Definition at line 263 of file Track.h.

Referenced by Init(), and SetName().

◆ mNode

TrackNodePointer Track::mNode {}
protected

Holds iterator to self, so that TrackList::Find can be constant-time.

mNode's pointer to std::list might not be this TrackList, if it's a pending update track

Definition at line 261 of file Track.h.

Referenced by AdjustPositions(), GetLinkedTrack(), GetNode(), SetLinkType(), and SetOwner().

◆ mOffset

double Track::mOffset
protected

◆ mpControls

std::shared_ptr<CommonTrackCell> Track::mpControls
protected

◆ mpView

std::shared_ptr<CommonTrackCell> Track::mpView
protected

◆ mSelected

bool Track::mSelected
private

Definition at line 267 of file Track.h.

Referenced by Init(), Merge(), SetSelected(), and Track().

◆ vrulerSize

wxSize Track::vrulerSize
mutable

The documentation for this class was generated from the following files:
Track::SubstituteOriginalTrack
std::shared_ptr< const Track > SubstituteOriginalTrack() const
Definition: Track.cpp:1219
Track::mChannel
ChannelType mChannel
Definition: Track.h:407
Track::LinkType::Aligned
@ Aligned
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
Track::mOffset
double mOffset
Definition: Track.h:408
Track::mSelected
bool mSelected
Definition: Track.h:267
Track::GetLinkType
LinkType GetLinkType() const noexcept
Definition: Track.cpp:1312
TrackKind::None
@ None
no class
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::GetEndTime
virtual double GetEndTime() const =0
Track::GetName
wxString GetName() const
Definition: Track.h:426
Track::SetLinkType
void SetLinkType(LinkType linkType)
Definition: Track.cpp:174
Track::SharedPointer
std::shared_ptr< Subclass > SharedPointer()
Definition: Track.h:291
Track::Cut
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1))=0
anonymous_namespace{Track.cpp}::IsSyncLockableNonLabelTrack
bool IsSyncLockableNonLabelTrack(const Track *pTrack)
Definition: Track.cpp:235
Track::GetOwner
std::shared_ptr< TrackList > GetOwner() const
Definition: Track.h:379
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:44
LabelTrack
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:88
Track::mNode
TrackNodePointer mNode
Holds iterator to self, so that TrackList::Find can be constant-time.
Definition: Track.h:261
Track::Paste
virtual void Paste(double WXUNUSED(t), const Track *WXUNUSED(src))=0
Track::SetOffset
virtual void SetOffset(double o)
Definition: Track.h:445
Track::mLinkType
LinkType mLinkType
Definition: Track.h:255
Track::IsSyncLockSelected
bool IsSyncLockSelected() const
Definition: Track.cpp:254
Track::mDefaultName
wxString mDefaultName
Definition: Track.h:264
Track::mpControls
std::shared_ptr< CommonTrackCell > mpControls
Definition: Track.h:833
XMLValueChecker::IsGoodString
static bool IsGoodString(const wxString &str)
Definition: XMLTagHandler.cpp:38
TrackKind::All
@ All
the root class
Track::mName
wxString mName
Definition: Track.h:263
Track::SetSelected
virtual void SetSelected(bool s)
Definition: Track.cpp:90
ProjectSettings::IsSyncLocked
bool IsSyncLocked() const
Definition: ProjectSettings.cpp:179
Track::mList
std::weak_ptr< TrackList > mList
Definition: Track.h:258
Track::SubstitutePendingChangedTrack
std::shared_ptr< Track > SubstitutePendingChangedTrack()
Definition: Track.cpp:1198
Track::mId
TrackId mId
Identifies the track only in-session, not persistently.
Definition: Track.h:254
Track::GetId
TrackId GetId() const
Definition: Track.h:281
TrackKind::Time
@ Time
ListOfTracks
std::list< std::shared_ptr< Track > > ListOfTracks
Definition: Track.h:53
Track::DoSetLinkType
void DoSetLinkType(LinkType linkType) noexcept
Definition: Track.cpp:193
Track::GetOffset
virtual double GetOffset() const =0
Track::mpView
std::shared_ptr< CommonTrackCell > mpView
Definition: Track.h:832
Track::GetKind
virtual TrackKind GetKind() const
Definition: Track.h:483
Track::Clone
virtual Holder Clone() const =0
CompatibleTrackKinds
constexpr bool CompatibleTrackKinds(TrackKind desired, TrackKind actual)
Compile-time function on enum values.
Definition: Track.h:83
Track::RightChannel
@ RightChannel
Definition: Track.h:277
Track::IsSelected
bool IsSelected() const
Definition: Track.cpp:373
Track::HasLinkedTrack
bool HasLinkedTrack() const noexcept
Returns true for leaders of multichannel groups.
Definition: Track.cpp:229
Track::LinkType::None
@ None
Track::GetSelected
bool GetSelected() const
Definition: Track.h:431
Track::mIndex
int mIndex
0-based position of this track in its TrackList
Definition: Track.h:262
id
int id
Definition: WaveTrackControls.cpp:577
Track::SetName
void SetName(const wxString &n)
Definition: Track.cpp:82
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
Track::IsLeader
bool IsLeader() const
Definition: Track.cpp:379
Track::Notify
void Notify(int code=-1)
Definition: Track.cpp:286
Track::Init
void Init(const Track &orig)
Definition: Track.cpp:70
TrackKind::Wave
@ Wave
Track::MonoChannel
@ MonoChannel
Definition: Track.h:278
Track::GetChannel
virtual ChannelType GetChannel() const
Definition: Track.h:441
XMLWriter::WriteAttr
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:34
Track::GetLinkedTrack
Track * GetLinkedTrack() const
Definition: Track.cpp:203
Track::Clear
virtual void Clear(double WXUNUSED(t0), double WXUNUSED(t1))=0
TrackKind::Label
@ Label
Track::SetChannel
void SetChannel(ChannelType c) noexcept
Definition: Track.cpp:198
TrackList::SyncLockGroup
static TrackIterRange< Track > SyncLockGroup(Track *pTrack)
Definition: Track.cpp:650
Track::LeftChannel
@ LeftChannel
Definition: Track.h:276
TimeTrack
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:24
NoteTrack
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:67
TrackKind::Note
@ Note
Track::vrulerSize
wxSize vrulerSize
Definition: Track.h:354