Audacity 3.2.0
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  ChannelGroupData
 
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< Tag, R, ArgumentType >
 Base case of metafunction implementing Track::TypeSwitch. More...
 
struct  Executor< Tag, R, ArgumentType, Function, Functions... >
 Implements Track::TypeSwitch, its operator() invokes the first function that can accept ArgumentType*. More...
 
struct  ProtectedCreationArg
 Empty argument passed to some public constructors. More...
 
struct  TypeInfo
 
struct  TypeNames
 Names of a track type for various purposes. More...
 

Public Types

enum class  LinkType : int { None = 0 , Group = 2 , Aligned }
 For two tracks describes the type of the linkage. More...
 
enum  ChannelType { LeftChannel = 0 , RightChannel = 1 , MonoChannel = 2 }
 
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 Member Functions

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 ()
 
int GetIndex () const
 
void SetIndex (int index)
 
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
 
virtual void Merge (const Track &orig)
 
wxString GetName () const
 
void SetName (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
 
void Notify (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

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, std::tuple< TrackTypes... > *, const Functions &...functions)
 
- 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

std::pair< int, int > vrulerSize
 

Protected Member Functions

void SetLinkType (LinkType linkType, bool completeList=true)
 
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
 
ChannelType mChannel
 
double mOffset
 

Private Member Functions

void SetId (TrackId id)
 
ChannelGroupDataMakeGroupData ()
 
void DoSetLinkType (LinkType linkType, bool completeList=true)
 
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
 

Private Attributes

TrackId mId
 Identifies the track only in-session, not persistently. More...
 
std::unique_ptr< ChannelGroupDatampGroupData
 
bool mSelected
 

Friends

class TrackList
 
template<typename T >
std::enable_if_t< std::is_pointer_v< T >, T > track_cast (Track *track)
 Encapsulate the checked down-casting of track pointers. More...
 
template<typename T >
std::enable_if_t< std::is_pointer_v< T > &&std::is_const_v< std::remove_pointer_t< T > >, T > 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 221 of file Track.h.

Member Typedef Documentation

◆ AttachedObjects

Alias for my base type.

Definition at line 278 of file Track.h.

◆ ChannelGroupAttachments

Hosting of objects attached by higher level code.

Definition at line 245 of file Track.h.

◆ ConstInterval

Definition at line 336 of file Track.h.

◆ ConstIntervals

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

Definition at line 337 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 539 of file Track.h.

◆ Fallthrough

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

Definition at line 541 of file Track.h.

◆ Holder

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

Definition at line 368 of file Track.h.

◆ Interval

Definition at line 334 of file Track.h.

◆ IntervalData

Definition at line 333 of file Track.h.

◆ Intervals

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

Definition at line 335 of file Track.h.

Member Enumeration Documentation

◆ ChannelType

Enumerator
LeftChannel 
RightChannel 
MonoChannel 

Definition at line 280 of file Track.h.

281 {
282 LeftChannel = 0,
283 RightChannel = 1,
284 MonoChannel = 2
285 };
@ LeftChannel
Definition: Track.h:282
@ RightChannel
Definition: Track.h:283
@ MonoChannel
Definition: Track.h:284

◆ LinkType

enum class Track::LinkType : int
strong

For two tracks describes the type of the linkage.

Enumerator
None 
Group 
Aligned 

Definition at line 236 of file Track.h.

236 : int {
237 None = 0, //< No linkage
238 Group = 2, //< Tracks are grouped together
239 Aligned, //< Tracks are grouped and changes should be synchronized
240 };

Constructor & Destructor Documentation

◆ Track() [1/2]

Track::Track ( )

Definition at line 44 of file Track.cpp.

45: vrulerSize(36,0)
46{
47 mSelected = false;
48
49 mIndex = 0;
50
51 mOffset = 0.0;
52
54}
double mOffset
Definition: Track.h:447
std::pair< int, int > vrulerSize
Definition: Track.h:386
bool mSelected
Definition: Track.h:273
ChannelType mChannel
Definition: Track.h:446
int mIndex
0-based position of this track in its TrackList
Definition: Track.h:269

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

◆ Track() [2/2]

Track::Track ( const Track orig,
ProtectedCreationArg &&   
)

Definition at line 56 of file Track.cpp.

57: vrulerSize( orig.vrulerSize )
58{
59 mIndex = 0;
60 mOffset = orig.mOffset;
61}

References mIndex, and mOffset.

◆ ~Track()

Track::~Track ( )
virtual

Definition at line 122 of file Track.cpp.

123{
124}

Member Function Documentation

◆ AdjustPositions()

void Track::AdjustPositions ( )

Definition at line 1309 of file Track.cpp.

1310{
1311 auto pList = mList.lock();
1312 if (pList) {
1313 pList->RecalcPositions(mNode);
1314 pList->ResizingEvent(mNode);
1315 }
1316}
std::weak_ptr< TrackList > mList
Definition: Track.h:265
TrackNodePointer mNode
Holds iterator to self, so that TrackList::Find can be constant-time.
Definition: Track.h:268

References mList, and mNode.

◆ Any()

bool Track::Any ( ) const

◆ CallExecutor() [1/2]

template<typename R , typename TrackType , typename... Functions, typename Executor , typename... Executors>
static R Track::CallExecutor ( R *  ,
std::tuple< Executor, Executors... > *  ,
TrackType &  track,
const Functions &...  functions 
)
inlinestatic

Definition at line 753 of file Track.h.

756 {
757 checkTrackType<TrackType>();
758 const auto &info = Executor::NominalType::ClassTypeInfo();
759 // Dynamic type test of track
760 // Assumes Executor classes are sequenced with more specific accepted
761 // types earlier
762 if ( info.IsBaseOf(track.GetTypeInfo()) )
763 // Dispatch to an Executor that knows which of functions applies
764 return Executor{}(&track, functions...);
765 else
766 // Recur, with fewer candidate Executors and all of functions
767 return CallExecutor( (R*)nullptr,
768 (std::tuple<Executors...>*)nullptr, track, functions...);
769 }
static R CallExecutor(R *, std::tuple<> *, TrackType &, const Functions &...)
Definition: Track.h:738

◆ CallExecutor() [2/2]

template<typename R , typename TrackType , typename... Functions>
static R Track::CallExecutor ( R *  ,
std::tuple<> *  ,
TrackType &  ,
const Functions &  ... 
)
inlinestatic

Definition at line 738 of file Track.h.

739 {
740 // This overload is needed so that the other overload of CallExecutor
741 // compiles, but it should never be reached at run-time, because an
742 // Executor generated for (const) Track should have been the catch-all.
743 wxASSERT(false);
744 checkTrackType<TrackType>();
745 if constexpr (std::is_void_v<R>)
746 return;
747 else
748 return R{};
749 }

◆ checkTrackType()

template<typename TrackType >
static void Track::checkTrackType ( )
inlinestatic

Definition at line 731 of file Track.h.

732 {
733 static_assert(
734 std::is_same_v<Track, TrackType> ||
735 std::is_same_v<const Track, TrackType>, "Error" );
736 }

◆ ClassTypeInfo()

auto Track::ClassTypeInfo ( )
static

Definition at line 1251 of file Track.cpp.

1252{
1253 static Track::TypeInfo info{
1254 { "generic", "generic", XO("Generic Track") }, false };
1255 return info;
1256}
#define XO(s)
Definition: Internat.h:31

References XO.

Referenced by AudioTrack::ClassTypeInfo(), and typeInfo().

Here is the caller graph for this function:

◆ 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 LabelTrack, NoteTrack, TimeTrack, and WaveTrack.

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,
bool  completeList = true 
)
private
Parameters
completeListonly influences debug build consistency checking

Definition at line 195 of file Track.cpp.

196{
197 auto oldType = GetLinkType();
198 if (linkType == oldType)
199 // No change
200 return;
201
202 if (oldType == LinkType::None) {
203 // Becoming linked
204
205 // First ensure there is no partner
206 if (auto partner = GetLinkedTrack())
207 partner->mpGroupData.reset();
208 assert(!GetLinkedTrack());
209
210 // Change the link type
211 MakeGroupData().mLinkType = linkType;
212
213 // If this acquired a partner, it loses any old group data
214 if (auto partner = GetLinkedTrack())
215 partner->mpGroupData.reset();
216 }
217 else if (linkType == LinkType::None) {
218 // Becoming unlinked
219 assert(mpGroupData);
220 if (HasLinkedTrack()) {
221 if (auto partner = GetLinkedTrack()) {
222 // Make independent copy of group data in the partner, which should
223 // have had none
224 assert(!partner->mpGroupData);
225 partner->mpGroupData =
226 std::make_unique<ChannelGroupData>(*mpGroupData);
227 partner->mpGroupData->mLinkType = LinkType::None;
228 }
229 }
230 mpGroupData->mLinkType = LinkType::None;
231 }
232 else {
233 // Remaining linked, changing the type
234 assert(mpGroupData);
235 MakeGroupData().mLinkType = linkType;
236 }
237
238 // Assertion checks only in a debug build, does not have side effects!
239 assert(LinkConsistencyCheck(completeList));
240}
bool HasLinkedTrack() const noexcept
Returns true for leaders of multichannel groups.
Definition: Track.cpp:273
bool LinkConsistencyCheck(bool completeList)
Do the non-mutating part of consistency fix only and return status.
Definition: Track.h:404
Track * GetLinkedTrack() const
Definition: Track.cpp:247
ChannelGroupData & MakeGroupData()
Definition: Track.cpp:171
LinkType GetLinkType() const noexcept
Definition: Track.cpp:1347
std::unique_ptr< ChannelGroupData > mpGroupData
Definition: Track.h:262
LinkType mLinkType
Definition: Track.h:252

References GetLinkedTrack(), GetLinkType(), HasLinkedTrack(), LinkConsistencyCheck(), MakeGroupData(), Track::ChannelGroupData::mLinkType, mpGroupData, and None.

Referenced by SetLinkType().

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

◆ DoTypeSwitch()

template<typename Tag , bool IsConst, typename R , typename ... TrackTypes, typename ... Functions>
static R Track::DoTypeSwitch ( std::conditional_t< IsConst, const Track, Track > &  track,
std::tuple< TrackTypes... > *  ,
const Functions &...  functions 
)
inlinestatic

Definition at line 784 of file Track.h.

788 {
789 // Generate Executor classes, for each of TrackTypes,
790 // each zero-sized and with an operator () that calls the correct
791 // one of functions, assuming the track is of the corresponding type
792 using Executors = std::tuple< Executor<
793 Tag, R,
794 std::conditional_t<IsConst, const TrackTypes, TrackTypes>,
795 Functions...
796 >... >;
797 // Don't even construct the tuple of zero-sized types, just point
798 constexpr Executors *executors = nullptr;
799
800 // Compile time reachability check of the given functions
801 enum { All = sizeof...( functions ) };
802 static_assert( (1u << All) - 1u == UsedCases(executors),
803 "Uncallable case in Track::TypeSwitch");
804
805 // Do dynamic dispatch to one of the Executors
806 return CallExecutor((R *)nullptr, executors, track, functions...);
807 }
static constexpr unsigned UsedCases(std::tuple< Executors... > *)
Definition: Track.h:772

◆ Duplicate()

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

Definition at line 109 of file Track.cpp.

110{
111 // invoke "virtual constructor" to copy track object proper:
112 auto result = Clone();
113
114 AttachedTrackObjects::ForEach([&](auto &attachment){
115 // Copy view state that might be important to undo/redo
116 attachment.CopyTo( *result );
117 });
118
119 return result;
120}
void ForEach(const Function &function)
Invoke function on each ClientData object that has been created in this.
Definition: ClientData.h:380
virtual Holder Clone() const =0

References Clone(), and ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::ForEach().

Here is the call graph for this function:

◆ EnsureVisible()

void Track::EnsureVisible ( bool  modifyState = false)

◆ FinishCopy()

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

Definition at line 413 of file Track.cpp.

415{
416 if (dest) {
417 dest->SetChannel(n->GetChannel());
418 dest->mpGroupData = n->mpGroupData ?
419 std::make_unique<ChannelGroupData>(*n->mpGroupData) : nullptr;
420 dest->SetName(n->GetName());
421 }
422}
void SetChannel(ChannelType c) noexcept
Definition: Track.cpp:242
wxString GetName() const
Definition: Track.h:466
virtual ChannelType GetChannel() const
Definition: Track.h:479
void SetName(const wxString &n)
Definition: Track.cpp:79

References GetChannel(), GetName(), mpGroupData, SetChannel(), 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 479 of file Track.h.

479{ return mChannel;}

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

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 864 of file Track.h.

864{ return false; }

◆ GetGroupData() [1/2]

Track::ChannelGroupData & Track::GetGroupData ( )

Definition at line 179 of file Track.cpp.

180{
181 auto pTrack = this;
182 if (auto pList = GetOwner())
183 if (auto pLeader = *pList->FindLeader(pTrack))
184 pTrack = pLeader;
185 // May make on demand
186 return pTrack->MakeGroupData();
187}
std::shared_ptr< TrackList > GetOwner() const
Definition: Track.h:409

References GetOwner().

Referenced by RealtimeEffectList::Get(), and GetGroupData().

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

◆ GetGroupData() [2/2]

const Track::ChannelGroupData & Track::GetGroupData ( ) const

Definition at line 189 of file Track.cpp.

190{
191 // May make group data on demand, but consider that logically const
192 return const_cast<Track *>(this)->GetGroupData();
193}
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
ChannelGroupData & GetGroupData()
Definition: Track.cpp:179

References GetGroupData().

Here is the call graph for this function:

◆ GetId()

TrackId Track::GetId ( ) const
inline

Definition at line 287 of file Track.h.

287{ return mId; }
TrackId mId
Identifies the track only in-session, not persistently.
Definition: Track.h:260

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 142 of file Track.cpp.

143{
144 return mIndex;
145}

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 LabelTrack, NoteTrack, and WaveTrack.

Definition at line 1268 of file Track.cpp.

1269{
1270 return {};
1271}

◆ 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 LabelTrack, NoteTrack, and WaveTrack.

Definition at line 1263 of file Track.cpp.

1264{
1265 return {};
1266}

Referenced by TrackShifter::InitIntervals().

Here is the caller graph for this function:

◆ GetLinkedTrack()

Track * Track::GetLinkedTrack ( ) const
private

Definition at line 247 of file Track.cpp.

248{
249 auto pList = mList.lock();
250 if (!pList)
251 return nullptr;
252
253 if (!pList->isNull(mNode)) {
254 if (HasLinkedTrack()) {
255 auto next = pList->getNext( mNode );
256 if ( !pList->isNull( next ) )
257 return next.first->get();
258 }
259
260 if (mNode.first != mNode.second->begin()) {
261 auto prev = pList->getPrev( mNode );
262 if ( !pList->isNull( prev ) ) {
263 auto track = prev.first->get();
264 if (track && track->HasLinkedTrack())
265 return track;
266 }
267 }
268 }
269
270 return nullptr;
271}

References HasLinkedTrack(), mList, and mNode.

Referenced by DoSetLinkType(), TrackList::GetPrev(), IsLeader(), and LinkConsistencyFix().

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 1347 of file Track.cpp.

1348{
1349 return mpGroupData ? mpGroupData->mLinkType : LinkType::None;
1350}

References mpGroupData, and None.

Referenced by WaveClipTrimHandle::AdjustBetweenBorders::AdjustBetweenBorders(), DoSetLinkType(), WaveClipTrimHandle::AdjustBorder::FindSnapPoints(), ClipMoveState::Init(), and WaveTrack::LinkConsistencyFix().

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

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

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 LabelTrack, NoteTrack, TimeTrack, and WaveTrack.

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 409 of file Track.h.

409{ return mList.lock(); }

Referenced by RealtimeEffectManager::AddTrack(), TrackShifter::CommonMayMigrateTo(), WaveClipTrimHandle::AdjustBorder::FindSnapPoints(), anonymous_namespace{SyncLock.cpp}::FindSyncLockGroup(), GetGroupData(), SyncLock::Group(), IsAlignedWithLeader(), SyncLock::IsSyncLockSelected(), WaveTrack::LinkConsistencyFix(), WaveTrack::PasteWaveTrack(), and TrackList::SwapChannels().

Here is the caller graph for this function:

◆ GetSelected()

bool Track::GetSelected ( ) const
inline

◆ GetStartTime()

virtual double Track::GetStartTime ( ) const
pure virtual

Implemented in LabelTrack, NoteTrack, TimeTrack, and WaveTrack.

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:

◆ GetTypeInfo()

virtual const TypeInfo & Track::GetTypeInfo ( ) const
pure virtual

Implemented in SampleTrack, WritableSampleTrack, LabelTrack, NoteTrack, TimeTrack, and WaveTrack.

Referenced by SameKindAs().

Here is the caller graph for this function:

◆ GetTypeNames()

virtual const TypeNames & Track::GetTypeNames ( ) const
inlinevirtual

Definition at line 362 of file Track.h.

363 { return GetTypeInfo().names; }
virtual const TypeInfo & GetTypeInfo() const =0
TypeNames names
Definition: Track.h:347

◆ HandleCommonXMLAttribute()

bool Track::HandleCommonXMLAttribute ( const std::string_view &  attr,
const XMLAttributeValueView valueView 
)

Definition at line 1287 of file Track.cpp.

1289{
1290 long nValue = -1;
1291
1292 bool handled = false;
1293 AttachedTrackObjects::ForEach([&](auto &attachment){
1294 handled = handled || attachment.HandleXMLAttribute( attr, valueView );
1295 });
1296 if (handled)
1297 ;
1298 else if (attr == "name") {
1299 SetName(valueView.ToWString());
1300 return true;
1301 }
1302 else if (attr == "isSelected" && valueView.TryGet(nValue)) {
1303 this->SetSelected(nValue != 0);
1304 return true;
1305 }
1306 return false;
1307}
virtual void SetSelected(bool s)
Definition: Track.cpp:87
wxString ToWString() const
Convert the view value to wxString.
bool TryGet(bool &value) const noexcept
Try to get a boolean value from the view.

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::ForEach(), SetName(), SetSelected(), XMLAttributeValueView::ToWString(), and XMLAttributeValueView::TryGet().

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 273 of file Track.cpp.

274{
275 return mpGroupData && mpGroupData->mLinkType != LinkType::None;
276}

References mpGroupData, and None.

Referenced by DoSetLinkType(), GetLinkedTrack(), TrackList::GetNext(), TrackList::GetPrev(), IsLeader(), LinkConsistencyFix(), and TrackList::SwapChannels().

Here is the caller graph for this function:

◆ HasOwner()

bool Track::HasOwner ( ) const
inline

Definition at line 407 of file Track.h.

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

◆ Init()

void Track::Init ( const Track orig)

Definition at line 64 of file Track.cpp.

65{
66 mId = orig.mId;
67
68 mName = orig.mName;
69
70 mSelected = orig.mSelected;
71
72 // Deep copy of any group data
74 std::make_unique<ChannelGroupData>(*orig.mpGroupData) : nullptr;
75
76 mChannel = orig.mChannel;
77}

References mChannel, mId, mName, mpGroupData, and mSelected.

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

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 1352 of file Track.cpp.

1353{
1354 if (auto owner = GetOwner())
1355 {
1356 auto leader = *owner->FindLeader(this);
1357 return leader != this && leader->GetLinkType() == Track::LinkType::Aligned;
1358 }
1359 return false;
1360}

References Aligned, and GetOwner().

Referenced by WaveClipTrimHandle::AdjustBetweenBorders::AdjustBetweenBorders(), and ClipMoveState::Init().

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

◆ IsLeader()

bool Track::IsLeader ( ) const

Definition at line 405 of file Track.cpp.

406{
407 return !GetLinkedTrack() || HasLinkedTrack();
408}

References GetLinkedTrack(), and HasLinkedTrack().

Referenced by anonymous_namespace{FileMenus.cpp}::DoExport(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), anonymous_namespace{TrackPanel.cpp}::DrawTrackName(), cloud::audiocom::ShareAudioDialog::ExportProject(), 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 402 of file Track.cpp.

403 { return GetSelected(); }
bool GetSelected() const
Definition: Track.h:469

References GetSelected().

Referenced by ProjectAudioManager::ChooseExistingRecordingTracks(), ExportPlugin::CreateMixer(), anonymous_namespace{TrackMenus.cpp}::DoPanTracks(), Exporter::ExamineTracks(), ExportMixerDialog::ExportMixerDialog(), ProjectAudioManager::GetAllPlaybackTracks(), IsSelectedLeader(), SyncLock::IsSelectedOrSyncLockSelected(), SyncLock::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 410 of file Track.cpp.

411 { return IsSelected() && IsLeader(); }
bool IsSelected() const
Definition: Track.cpp:402
bool IsLeader() const
Definition: Track.cpp:405

References IsLeader(), and IsSelected().

Referenced by TrackList::SelectedLeaders().

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

◆ LinkConsistencyCheck()

bool Track::LinkConsistencyCheck ( bool  completeList)
inline

Do the non-mutating part of consistency fix only and return status.

Definition at line 404 of file Track.h.

405 { return const_cast<Track*>(this)->LinkConsistencyFix(false, completeList); }
virtual bool LinkConsistencyFix(bool doFix=true, bool completeList=true)
Check consistency of channel groups, and maybe fix it.
Definition: Track.cpp:424

Referenced by DoSetLinkType().

Here is the caller graph for this function:

◆ LinkConsistencyFix()

bool Track::LinkConsistencyFix ( bool  doFix = true,
bool  completeList = true 
)
virtual

Check consistency of channel groups, and maybe fix it.

Parameters
doFixwhether to make any changes to correct inconsistencies
completeListwhether to assume that the TrackList containing this is completely loaded; if false, skip some of the checks
Returns
true if no inconsistencies were found

Reimplemented in WaveTrack.

Definition at line 424 of file Track.cpp.

425{
426 // Sanity checks for linked tracks; unsetting the linked property
427 // doesn't fix the problem, but it likely leaves us with orphaned
428 // sample blocks instead of much worse problems.
429 bool err = false;
430 if (completeList && HasLinkedTrack()) {
431 if (auto link = GetLinkedTrack()) {
432 // A linked track's partner should never itself be linked
433 if (link->HasLinkedTrack()) {
434 err = true;
435 if (doFix) {
436 wxLogWarning(
437 L"Left track %s had linked right track %s with extra right "
438 "track link.\n Removing extra link from right track.",
439 GetName(), link->GetName());
440 link->SetLinkType(LinkType::None);
441 }
442 }
443
444 // Channels should be left and right
445 if ( !( (GetChannel() == Track::LeftChannel &&
446 link->GetChannel() == Track::RightChannel) ||
448 link->GetChannel() == Track::LeftChannel) ) ) {
449 err = true;
450 if (doFix) {
451 wxLogWarning(
452 L"Track %s and %s had left/right track links out of order. "
453 "Setting tracks to not be linked.",
454 GetName(), link->GetName());
456 }
457 }
458 }
459 else {
460 err = true;
461 if (doFix) {
462 wxLogWarning(
463 L"Track %s had link to NULL track. Setting it to not be linked.",
464 GetName());
466 }
467 }
468 }
469 return ! err;
470}
void SetLinkType(LinkType linkType, bool completeList=true)
Definition: Track.cpp:152

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

Referenced by WaveTrack::LinkConsistencyFix().

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

◆ MakeGroupData()

Track::ChannelGroupData & Track::MakeGroupData ( )
private

Definition at line 171 of file Track.cpp.

172{
173 if (!mpGroupData)
174 // Make on demand
175 mpGroupData = std::make_unique<ChannelGroupData>();
176 return *mpGroupData;
177}

References mpGroupData.

Referenced by DoSetLinkType().

Here is the caller graph for this function:

◆ Merge()

void Track::Merge ( const Track orig)
virtual

Reimplemented in PlayableTrack, and WaveTrack.

Definition at line 104 of file Track.cpp.

105{
106 mSelected = orig.mSelected;
107}

References mSelected.

Referenced by PlayableTrack::Merge().

Here is the caller graph for this function:

◆ Notify()

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

Definition at line 278 of file Track.cpp.

279{
280 auto pList = mList.lock();
281 if (pList)
282 pList->DataEvent( SharedPointer(), code );
283}

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 482 of file Track.h.

482{ SetOffset(GetOffset() + t); }
virtual void SetOffset(double o)
Definition: Track.h:483
virtual double GetOffset() const =0

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

Here is the caller graph for this function:

◆ operator=()

Track & Track::operator= ( const Track orig)
delete

◆ 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 LabelTrack, NoteTrack, TimeTrack, and WaveTrack.

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 534 of file Track.h.

535 { return &GetTypeInfo() == &track.GetTypeInfo(); }

References GetTypeInfo().

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 242 of file Track.cpp.

243{
244 mChannel = c;
245}

Referenced by FinishCopy(), WaveTrack::LinkConsistencyFix(), and TrackList::SwapChannels().

Here is the caller graph for this function:

◆ SetId()

void Track::SetId ( TrackId  id)
inlineprivate

Definition at line 289 of file Track.h.

289{ mId = id; }
int id

References id.

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

Here is the caller graph for this function:

◆ SetIndex()

void Track::SetIndex ( int  index)

Definition at line 147 of file Track.cpp.

148{
149 mIndex = index;
150}

References mIndex.

Referenced by TrackList::RecalcPositions().

Here is the caller graph for this function:

◆ SetLinkType()

void Track::SetLinkType ( LinkType  linkType,
bool  completeList = true 
)
protected
Parameters
completeListonly influences debug build consistency checking

Definition at line 152 of file Track.cpp.

153{
154 auto pList = mList.lock();
155 if (pList && !pList->mPendingUpdates.empty()) {
156 auto orig = pList->FindById( GetId() );
157 if (orig && orig != this) {
158 orig->SetLinkType(linkType);
159 return;
160 }
161 }
162
163 DoSetLinkType(linkType, completeList);
164
165 if (pList) {
166 pList->RecalcPositions(mNode);
167 pList->ResizingEvent(mNode);
168 }
169}
TrackId GetId() const
Definition: Track.h:287
void DoSetLinkType(LinkType linkType, bool completeList=true)
Definition: Track.cpp:195

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

Referenced by WaveTrack::HandleXMLTag(), WaveTrack::LinkConsistencyFix(), and LinkConsistencyFix().

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

80{
81 if ( mName != n ) {
82 mName = n;
83 Notify();
84 }
85}
void Notify(int code=-1)
Definition: Track.cpp:278

References mName, and Notify().

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

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 LabelTrack, WaveTrack, and TimeTrack.

Definition at line 483 of file Track.h.

483{ 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 133 of file Track.cpp.

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

References mList, and mNode.

Referenced by TrackList::DoAddToHead(), TrackList::Permute(), 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 485 of file Track.h.

485{ ;}

Referenced by SetTrackAudioCommand::ApplyInner().

Here is the caller graph for this function:

◆ SetPanFromChannelType()

virtual void Track::SetPanFromChannelType ( )
inlinevirtual

Reimplemented in WaveTrack.

Definition at line 486 of file Track.h.

486{ ;};

◆ SetSelected()

void Track::SetSelected ( bool  s)
virtual

Reimplemented in LabelTrack.

Definition at line 87 of file Track.cpp.

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

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:

◆ SharedPointer() [1/4]

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

Definition at line 297 of file Track.h.

298 {
299 // shared_from_this is injected into class scope by base class
300 // std::enable_shared_from_this<Track>
301 return std::static_pointer_cast<Subclass>( shared_from_this() );
302 }

Referenced by SelectHandle::AdjustSelection(), SelectionState::ChangeSelectionOnShiftClick(), DEFINE_ATTACHED_VIRTUAL_OVERRIDE(), SpectrumView::DoDraw(), TimeShiftHandle::Drag(), EnsureVisible(), TrackPanelAx::GetFocus(), SelectHandle::HandleCenterFrequencyClick(), ClipMoveState::Init(), SelectHandle::MoveSnappingFreqSelection(), Notify(), SelectionState::SelectTrack(), TrackFocus::Set(), TrackPanelAx::SetFocus(), SetSelected(), SharedPointer(), anonymous_namespace{MIDIPlay.h}::MIDIPlay::StartOtherStream(), SubstituteOriginalTrack(), and SubstitutePendingChangedTrack().

Here is the caller graph for this function:

◆ SharedPointer() [2/4]

template<typename Subclass = const Track>
auto Track::SharedPointer ( ) const -> std::enable_if_t< std::is_const_v<Subclass>, std::shared_ptr<Subclass> >
inline

Definition at line 305 of file Track.h.

309 {
310 // shared_from_this is injected into class scope by base class
311 // std::enable_shared_from_this<Track>
312 return std::static_pointer_cast<Subclass>( shared_from_this() );
313 }

◆ SharedPointer() [3/4]

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

Definition at line 321 of file Track.h.

322 { 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 317 of file Track.h.

318 { 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 1231 of file Track.cpp.

1232{
1233 auto pList = mList.lock();
1234 if (pList) {
1235 const auto id = GetId();
1236 const auto pred = [=]( const ListOfTracks::value_type &ptr ) {
1237 return ptr->GetId() == id; };
1238 const auto end = pList->mPendingUpdates.end();
1239 const auto it = std::find_if( pList->mPendingUpdates.begin(), end, pred );
1240 if (it != end) {
1241 const auto &list2 = (const ListOfTracks &) *pList;
1242 const auto end2 = list2.end();
1243 const auto it2 = std::find_if( list2.begin(), end2, pred );
1244 if ( it2 != end2 )
1245 return *it2;
1246 }
1247 }
1248 return SharedPointer();
1249}
std::list< std::shared_ptr< Track > > ListOfTracks
Definition: Track.h:42
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References PackedArray::end(), GetId(), id, mList, and SharedPointer().

Referenced by SyncLock::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 1210 of file Track.cpp.

1211{
1212 // Linear search. Tracks in a project are usually very few.
1213 auto pList = mList.lock();
1214 if (pList) {
1215 const auto id = GetId();
1216 const auto end = pList->mPendingUpdates.end();
1217 auto it = std::find_if(
1218 pList->mPendingUpdates.begin(), end,
1219 [=](const ListOfTracks::value_type &ptr){ return ptr->GetId() == id; } );
1220 if (it != end)
1221 return *it;
1222 }
1223 return SharedPointer();
1224}

References PackedArray::end(), 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 1226 of file Track.cpp.

1227{
1228 return const_cast<Track*>(this)->SubstitutePendingChangedTrack();
1229}
std::shared_ptr< Track > SubstitutePendingChangedTrack()
Definition: Track.cpp:1210

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 1258 of file Track.cpp.

1259{
1260 return true;
1261}

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 LabelTrack, and WaveTrack.

Definition at line 285 of file Track.cpp.

286{
287 if (newT1 > oldT1) {
288 // Insert space within the track
289
290 if (oldT1 > GetEndTime())
291 return;
292
293 auto tmp = Cut(oldT1, GetEndTime());
294
295 Paste(newT1, tmp.get());
296 }
297 else if (newT1 < oldT1) {
298 // Remove from the track
299 Clear(newT1, oldT1);
300 }
301}
virtual void Paste(double WXUNUSED(t), const Track *WXUNUSED(src))=0
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1))=0
virtual void Clear(double WXUNUSED(t0), double WXUNUSED(t1))=0
virtual double GetEndTime() const =0

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 fall-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 832 of file Track.h.

833 {
834 struct Tag : TrackTypeCountTag {};
835 // Collect all concrete and abstract track types known at compile time
836 using TrackTypes = typename CollectTrackTypes<Tag>::type;
837 TrackTypes *const trackTypes = nullptr;
838 // Generate a function that dispatches dynamically on track type
839 return DoTypeSwitch<Tag, false, R>(*this, trackTypes, functions...);
840 }

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 fall-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 849 of file Track.h.

850 {
851 struct Tag : TrackTypeCountTag {};
852 // Collect all concrete and abstract track types known at compile time
853 using TrackTypes = typename CollectTrackTypes<Tag>::type;
854 TrackTypes *const trackTypes = nullptr;
855 // Generate a function that dispatches dynamically on track type
856 return DoTypeSwitch<Tag, true, R>(*this, trackTypes, functions...);
857 }

◆ UsedCases()

template<typename ... Executors>
static constexpr unsigned Track::UsedCases ( std::tuple< Executors... > *  )
inlinestaticconstexpr

Definition at line 772 of file Track.h.

773 {
774 return (Executors::SetUsed | ...); // My very first fold expression :-)
775 }

◆ WriteCommonXMLAttributes()

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

Definition at line 1274 of file Track.cpp.

1276{
1277 if (includeNameAndSelected) {
1278 xmlFile.WriteAttr(wxT("name"), GetName());
1279 xmlFile.WriteAttr(wxT("isSelected"), this->GetSelected());
1280 }
1281 AttachedTrackObjects::ForEach([&](auto &attachment){
1282 attachment.WriteXMLAttributes( xmlFile );
1283 });
1284}
wxT("CloseDown"))
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:37

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::ForEach(), GetName(), GetSelected(), XMLWriter::WriteAttr(), and wxT().

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 LabelTrack, NoteTrack, TimeTrack, and WaveTrack.

Friends And Related Function Documentation

◆ track_cast [1/2]

template<typename T >
std::enable_if_t< std::is_pointer_v< T > && std::is_const_v< std::remove_pointer_t< T > >, T > 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 982 of file Track.h.

983{
984 using BareType = std::remove_pointer_t< T >;
985 if (track &&
986 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
987 return reinterpret_cast<T>(track);
988 else
989 return nullptr;
990}

◆ track_cast [2/2]

template<typename T >
std::enable_if_t< std::is_pointer_v< T >, T > 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 965 of file Track.h.

966{
967 using BareType = std::remove_pointer_t< T >;
968 if (track &&
969 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
970 return reinterpret_cast<T>(track);
971 else
972 return nullptr;
973}

◆ TrackList

friend class TrackList
friend

Definition at line 257 of file Track.h.

Member Data Documentation

◆ mChannel

ChannelType Track::mChannel
protected

◆ mId

TrackId Track::mId
private

Identifies the track only in-session, not persistently.

Definition at line 260 of file Track.h.

Referenced by Init().

◆ mIndex

int Track::mIndex
protected

0-based position of this track in its TrackList

Definition at line 269 of file Track.h.

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

◆ mList

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

◆ mName

wxString Track::mName
protected

Definition at line 270 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 268 of file Track.h.

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

◆ mOffset

double Track::mOffset
protected

◆ mpGroupData

std::unique_ptr<ChannelGroupData> Track::mpGroupData
private

◆ mSelected

bool Track::mSelected
private

Definition at line 273 of file Track.h.

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

◆ vrulerSize

std::pair<int, int> Track::vrulerSize
mutable

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