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

◆ ChannelGroupAttachments

Hosting of objects attached by higher level code.

Definition at line 238 of file Track.h.

◆ ConstInterval

Definition at line 329 of file Track.h.

◆ ConstIntervals

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

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

◆ Fallthrough

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

Definition at line 533 of file Track.h.

◆ Holder

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

Definition at line 361 of file Track.h.

◆ Interval

Definition at line 327 of file Track.h.

◆ IntervalData

Definition at line 326 of file Track.h.

◆ Intervals

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

Definition at line 328 of file Track.h.

Member Enumeration Documentation

◆ ChannelType

Enumerator
LeftChannel 
RightChannel 
MonoChannel 

Definition at line 273 of file Track.h.

274 {
275 LeftChannel = 0,
276 RightChannel = 1,
277 MonoChannel = 2
278 };
@ LeftChannel
Definition: Track.h:275
@ RightChannel
Definition: Track.h:276
@ MonoChannel
Definition: Track.h:277

◆ LinkType

enum class Track::LinkType : int
strong

For two tracks describes the type of the linkage.

Enumerator
None 
Group 
Aligned 

Definition at line 229 of file Track.h.

229 : int {
230 None = 0, //< No linkage
231 Group = 2, //< Tracks are grouped together
232 Aligned, //< Tracks are grouped and changes should be synchronized
233 };

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:440
std::pair< int, int > vrulerSize
Definition: Track.h:379
bool mSelected
Definition: Track.h:266
ChannelType mChannel
Definition: Track.h:439
int mIndex
0-based position of this track in its TrackList
Definition: Track.h:262

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

◆ Track() [2/2]

Track::Track ( const Track orig)

Definition at line 56 of file Track.cpp.

57: vrulerSize( orig.vrulerSize )
58{
59 mIndex = 0;
60 Init(orig);
61 mOffset = orig.mOffset;
62}
void Init(const Track &orig)
Definition: Track.cpp:65

References Init(), mIndex, and mOffset.

Here is the call graph for this function:

◆ ~Track()

Track::~Track ( )
virtual

Definition at line 123 of file Track.cpp.

124{
125}

Member Function Documentation

◆ AdjustPositions()

void Track::AdjustPositions ( )

Definition at line 1286 of file Track.cpp.

1287{
1288 auto pList = mList.lock();
1289 if (pList) {
1290 pList->RecalcPositions(mNode);
1291 pList->ResizingEvent(mNode);
1292 }
1293}
std::weak_ptr< TrackList > mList
Definition: Track.h:258
TrackNodePointer mNode
Holds iterator to self, so that TrackList::Find can be constant-time.
Definition: Track.h:261

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

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

◆ CallExecutor() [2/2]

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

Definition at line 730 of file Track.h.

731 {
732 // This overload is needed so that the other overload of CallExecutor
733 // compiles, but it should never be reached at run-time, because an
734 // Executor generated for (const) Track should have been the catch-all.
735 wxASSERT(false);
736 checkTrackType<TrackType>();
737 if constexpr (std::is_void_v<R>)
738 return;
739 else
740 return R{};
741 }

◆ checkTrackType()

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

Definition at line 723 of file Track.h.

724 {
725 static_assert(
726 std::is_same_v<Track, TrackType> ||
727 std::is_same_v<const Track, TrackType>, "Error" );
728 }

◆ ClassTypeInfo()

auto Track::ClassTypeInfo ( )
static

Definition at line 1228 of file Track.cpp.

1229{
1230 static Track::TypeInfo info{
1231 { "generic", "generic", XO("Generic Track") }, false };
1232 return info;
1233}
#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 196 of file Track.cpp.

197{
198 auto oldType = GetLinkType();
199 if (linkType == oldType)
200 // No change
201 return;
202
203 if (oldType == LinkType::None) {
204 // Becoming linked
205
206 // First ensure there is no partner
207 if (auto partner = GetLinkedTrack())
208 partner->mpGroupData.reset();
209 assert(!GetLinkedTrack());
210
211 // Change the link type
212 MakeGroupData().mLinkType = linkType;
213
214 // If this acquired a partner, it loses any old group data
215 if (auto partner = GetLinkedTrack())
216 partner->mpGroupData.reset();
217 }
218 else if (linkType == LinkType::None) {
219 // Becoming unlinked
220 assert(mpGroupData);
221 if (HasLinkedTrack()) {
222 // Make independent copy of group data in the partner, which should
223 // have had none
224 auto partner = GetLinkedTrack();
225 assert(!partner->mpGroupData);
226 partner->mpGroupData =
227 std::make_unique<ChannelGroupData>(*mpGroupData);
228 partner->mpGroupData->mLinkType = LinkType::None;
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:397
Track * GetLinkedTrack() const
Definition: Track.cpp:247
ChannelGroupData & MakeGroupData()
Definition: Track.cpp:172
LinkType GetLinkType() const noexcept
Definition: Track.cpp:1324
std::unique_ptr< ChannelGroupData > mpGroupData
Definition: Track.h:255
LinkType mLinkType
Definition: Track.h:245

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

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

◆ Duplicate()

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

Definition at line 110 of file Track.cpp.

111{
112 // invoke "virtual constructor" to copy track object proper:
113 auto result = Clone();
114
115 AttachedTrackObjects::ForEach([&](auto &attachment){
116 // Copy view state that might be important to undo/redo
117 attachment.CopyTo( *result );
118 });
119
120 return result;
121}
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 394 of file Track.cpp.

396{
397 if (dest) {
398 dest->SetChannel(n->GetChannel());
399 dest->mpGroupData = n->mpGroupData ?
400 std::make_unique<ChannelGroupData>(*n->mpGroupData) : nullptr;
401 dest->SetName(n->GetName());
402 }
403}
void SetChannel(ChannelType c) noexcept
Definition: Track.cpp:242
wxString GetName() const
Definition: Track.h:458
virtual ChannelType GetChannel() const
Definition: Track.h:471
void SetName(const wxString &n)
Definition: Track.cpp:80

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

471{ 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 856 of file Track.h.

856{ return false; }

◆ GetGroupData() [1/2]

Track::ChannelGroupData & Track::GetGroupData ( )

Definition at line 180 of file Track.cpp.

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

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

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

References GetGroupData().

Here is the call graph for this function:

◆ GetId()

TrackId Track::GetId ( ) const
inline

Definition at line 280 of file Track.h.

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

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

144{
145 return mIndex;
146}

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

1246{
1247 return {};
1248}

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

1241{
1242 return {};
1243}

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

1325{
1326 return mpGroupData ? mpGroupData->mLinkType : LinkType::None;
1327}

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

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

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

402{ 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 355 of file Track.h.

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

◆ HandleCommonXMLAttribute()

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

Definition at line 1264 of file Track.cpp.

1266{
1267 long nValue = -1;
1268
1269 bool handled = false;
1270 AttachedTrackObjects::ForEach([&](auto &attachment){
1271 handled = handled || attachment.HandleXMLAttribute( attr, valueView );
1272 });
1273 if (handled)
1274 ;
1275 else if (attr == "name") {
1276 SetName(valueView.ToWString());
1277 return true;
1278 }
1279 else if (attr == "isSelected" && valueView.TryGet(nValue)) {
1280 this->SetSelected(nValue != 0);
1281 return true;
1282 }
1283 return false;
1284}
virtual void SetSelected(bool s)
Definition: Track.cpp:88
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 400 of file Track.h.

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

◆ Init()

void Track::Init ( const Track orig)

Definition at line 65 of file Track.cpp.

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

References mChannel, mId, mName, mpGroupData, 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 1329 of file Track.cpp.

1330{
1331 if (auto owner = GetOwner())
1332 {
1333 auto leader = *owner->FindLeader(this);
1334 return leader != this && leader->GetLinkType() == Track::LinkType::Aligned;
1335 }
1336 return false;
1337}

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

387{
388 return !GetLinkedTrack() || HasLinkedTrack();
389}

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

384 { return GetSelected(); }
bool GetSelected() const
Definition: Track.h:461

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

392 { return IsSelected() && IsLeader(); }
bool IsSelected() const
Definition: Track.cpp:383
bool IsLeader() const
Definition: Track.cpp:386

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

398 { 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:405

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

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

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

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

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

106{
107 mSelected = orig.mSelected;
108}

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

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

Referenced by TrackShifter::DoHorizontalOffset(), EffectBase::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 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 526 of file Track.h.

527 { 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 282 of file Track.h.

282{ 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 148 of file Track.cpp.

149{
150 mIndex = index;
151}

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

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

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

81{
82 if ( mName != n ) {
83 mName = n;
84 Notify();
85 }
86}
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 475 of file Track.h.

475{ 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 134 of file Track.cpp.

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

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

477{ ;}

Referenced by SetTrackAudioCommand::ApplyInner().

Here is the caller graph for this function:

◆ SetPanFromChannelType()

virtual void Track::SetPanFromChannelType ( )
inlinevirtual

Reimplemented in WaveTrack.

Definition at line 478 of file Track.h.

478{ ;};

◆ SetSelected()

void Track::SetSelected ( bool  s)
virtual

Reimplemented in LabelTrack.

Definition at line 88 of file Track.cpp.

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

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

291 {
292 // shared_from_this is injected into class scope by base class
293 // std::enable_shared_from_this<Track>
294 return std::static_pointer_cast<Subclass>( shared_from_this() );
295 }

Referenced by SelectHandle::AdjustSelection(), SelectionState::ChangeSelectionOnShiftClick(), DEFINE_ATTACHED_VIRTUAL_OVERRIDE(), SpectrumView::DoDraw(), TimeShiftHandle::Drag(), EnsureVisible(), TrackPanelAx::GetFocus(), SelectHandle::HandleCenterFrequencyClick(), ClipMoveState::Init(), SelectHandle::MoveSnappingFreqSelection(), Notify(), EffectStereoToMono::ProcessOne(), 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 298 of file Track.h.

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

◆ SharedPointer() [3/4]

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

Definition at line 314 of file Track.h.

315 { 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 310 of file Track.h.

311 { 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 1208 of file Track.cpp.

1209{
1210 auto pList = mList.lock();
1211 if (pList) {
1212 const auto id = GetId();
1213 const auto pred = [=]( const ListOfTracks::value_type &ptr ) {
1214 return ptr->GetId() == id; };
1215 const auto end = pList->mPendingUpdates.end();
1216 const auto it = std::find_if( pList->mPendingUpdates.begin(), end, pred );
1217 if (it != end) {
1218 const auto &list2 = (const ListOfTracks &) *pList;
1219 const auto end2 = list2.end();
1220 const auto it2 = std::find_if( list2.begin(), end2, pred );
1221 if ( it2 != end2 )
1222 return *it2;
1223 }
1224 }
1225 return SharedPointer();
1226}
std::list< std::shared_ptr< Track > > ListOfTracks
Definition: Track.h:42
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for, if Traits<Type>::iterated_type is defined.
Definition: PackedArray.h:126

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

1188{
1189 // Linear search. Tracks in a project are usually very few.
1190 auto pList = mList.lock();
1191 if (pList) {
1192 const auto id = GetId();
1193 const auto end = pList->mPendingUpdates.end();
1194 auto it = std::find_if(
1195 pList->mPendingUpdates.begin(), end,
1196 [=](const ListOfTracks::value_type &ptr){ return ptr->GetId() == id; } );
1197 if (it != end)
1198 return *it;
1199 }
1200 return SharedPointer();
1201}

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

1204{
1205 return const_cast<Track*>(this)->SubstitutePendingChangedTrack();
1206}
std::shared_ptr< Track > SubstitutePendingChangedTrack()
Definition: Track.cpp:1187

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

1236{
1237 return true;
1238}

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

825 {
826 struct Tag : TrackTypeCountTag {};
827 // Collect all concrete and abstract track types known at compile time
828 using TrackTypes = typename CollectTrackTypes<Tag>::type;
829 TrackTypes *const trackTypes = nullptr;
830 // Generate a function that dispatches dynamically on track type
831 return DoTypeSwitch<Tag, false, R>(*this, trackTypes, functions...);
832 }

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

842 {
843 struct Tag : TrackTypeCountTag {};
844 // Collect all concrete and abstract track types known at compile time
845 using TrackTypes = typename CollectTrackTypes<Tag>::type;
846 TrackTypes *const trackTypes = nullptr;
847 // Generate a function that dispatches dynamically on track type
848 return DoTypeSwitch<Tag, true, R>(*this, trackTypes, functions...);
849 }

◆ UsedCases()

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

Definition at line 764 of file Track.h.

765 {
766 return (Executors::SetUsed | ...); // My very first fold expression :-)
767 }

◆ WriteCommonXMLAttributes()

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

Definition at line 1251 of file Track.cpp.

1253{
1254 if (includeNameAndSelected) {
1255 xmlFile.WriteAttr(wxT("name"), GetName());
1256 xmlFile.WriteAttr(wxT("isSelected"), this->GetSelected());
1257 }
1258 AttachedTrackObjects::ForEach([&](auto &attachment){
1259 attachment.WriteXMLAttributes( xmlFile );
1260 });
1261}
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:37

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::ForEach(), GetName(), GetSelected(), 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 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 976 of file Track.h.

977{
978 using BareType = std::remove_pointer_t< T >;
979 if (track &&
980 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
981 return reinterpret_cast<T>(track);
982 else
983 return nullptr;
984}

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

960{
961 using BareType = std::remove_pointer_t< T >;
962 if (track &&
963 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
964 return reinterpret_cast<T>(track);
965 else
966 return nullptr;
967}

◆ TrackList

friend class TrackList
friend

Definition at line 250 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 253 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().

◆ 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

◆ mpGroupData

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

◆ mSelected

bool Track::mSelected
private

Definition at line 266 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: