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...
 
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 ()
 
virtual bool LinkConsistencyFix (bool doFix=true, bool completeList=true)
 Check consistency of channel groups, and maybe fix it. More...
 
bool LinkConsistencyCheck (bool completeList)
 Do the non-mutating part of consistency fix only and return status. More...
 
bool HasOwner () const
 
std::shared_ptr< TrackListGetOwner () const
 
LinkType GetLinkType () const noexcept
 
bool IsAlignedWithLeader () const
 Returns true if the leader track has link type LinkType::Aligned. More...
 
ChannelGroupDataGetGroupData ()
 
const ChannelGroupDataGetGroupData () const
 
 Track ()
 
 Track (const Track &orig, ProtectedCreationArg &&)
 
Trackoperator= (const Track &orig)=delete
 
virtual ~Track ()
 
void Init (const Track &orig)
 
virtual Holder Duplicate () const
 
const wxString & GetName () const
 Name is always the same for all channels of a group. More...
 
void SetName (const wxString &n)
 
bool GetSelected () const
 Selectedness is always the same for all channels of a group. More...
 
virtual void SetSelected (bool s)
 
void EnsureVisible (bool modifyState=false)
 
virtual double GetOffset () const =0
 
void Offset (double t)
 
virtual void SetOffset (double o)
 
virtual Holder Cut (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual Holder Copy (double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard=true) const =0
 
virtual void Clear (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void Paste (double WXUNUSED(t), const Track *WXUNUSED(src))=0
 
virtual void SyncLockAdjust (double oldT1, double newT1)
 
virtual void Silence (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void InsertSilence (double WXUNUSED(t), double WXUNUSED(len))=0
 
bool SameKindAs (const Track &track) const
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions)
 Use this function rather than testing track type explicitly and making down-casts. More...
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions) const
 Use this function rather than testing track type explicitly and making down-casts. More...
 
virtual void WriteXML (XMLWriter &xmlFile) const =0
 
virtual bool GetErrorOpening ()
 
virtual double GetStartTime () const =0
 
virtual double GetEndTime () const =0
 
void Notify (bool allChannels, int code=-1)
 
bool Any () const
 
bool IsSelected () const
 
bool IsLeader () const
 
bool IsSelectedLeader () const
 
void AdjustPositions ()
 
void WriteCommonXMLAttributes (XMLWriter &xmlFile, bool includeNameAndSelected=true) const
 
bool HandleCommonXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView)
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual bool HandleXMLTag (const std::string_view &tag, const AttributesList &attrs)=0
 
virtual void HandleXMLEndTag (const std::string_view &WXUNUSED(tag))
 
virtual void HandleXMLContent (const std::string_view &WXUNUSED(content))
 
virtual XMLTagHandlerHandleXMLChild (const std::string_view &tag)=0
 
void ReadXMLEndTag (const char *tag)
 
void ReadXMLContent (const char *s, int len)
 
XMLTagHandlerReadXMLChild (const char *tag)
 
- Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
 ~Site ()
 
 Site ()
 
 Site (const Site &other)
 
Siteoperator= (const Site &other)
 
 Site (Site &&other)
 
Siteoperator= (Site &&other)
 
size_t size () const
 How many attachment pointers are in the Site. More...
 
template<typename Subclass = ClientData>
Subclass & Get (const RegisteredFactory &key)
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = const ClientData>
auto Get (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass & >
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = ClientData>
Subclass * Find (const RegisteredFactory &key)
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename Subclass = const ClientData>
auto Find (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass * >
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename ReplacementPointer >
void Assign (const RegisteredFactory &key, ReplacementPointer &&replacement)
 Reassign Site's pointer to ClientData. More...
 

Static Public Member Functions

template<typename Subclass = Track>
static std::shared_ptr< Subclass > SharedPointer (Track *pTrack)
 
template<typename Subclass = const Track>
static std::shared_ptr< Subclass > SharedPointer (const Track *pTrack)
 
static const TypeInfoClassTypeInfo ()
 
static void FinishCopy (const Track *n, Track *dest)
 
template<typename TrackType >
static void checkTrackType ()
 
template<typename R , typename TrackType , typename... Functions>
static R CallExecutor (R *, std::tuple<> *, TrackType &, const Functions &...)
 
template<typename R , typename TrackType , typename... Functions, typename Executor , typename... Executors>
static R CallExecutor (R *, std::tuple< Executor, Executors... > *, TrackType &track, const Functions &...functions)
 
template<typename ... Executors>
static constexpr unsigned UsedCases (std::tuple< Executors... > *)
 
template<typename Tag , bool IsConst, typename R , typename ... TrackTypes, typename ... Functions>
static R DoTypeSwitch (std::conditional_t< IsConst, const Track, Track > &track, TypeList::List< TrackTypes... >, const Functions &...functions)
 Deduce two packs from arguments. More...
 
- Static Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
static size_t slots ()
 How many static factories have been registered with this specialization of Site. More...
 

Public Attributes

std::pair< int, int > vrulerSize
 

Protected Member Functions

void SetLinkType (LinkType linkType, bool completeList=true)
 
- Protected Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
template<typename Function >
void ForEach (const Function &function)
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
void ForEach (const Function &function) const
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
ClientData * FindIf (const Function &function)
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
template<typename Function >
const ClientData * FindIf (const Function &function) const
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
void BuildAll ()
 For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it. More...
 

Protected Attributes

std::weak_ptr< TrackListmList
 
TrackNodePointer mNode {}
 Holds iterator to self, so that TrackList::Find can be constant-time. More...
 
int mIndex
 0-based position of this track in its TrackList More...
 
double mOffset
 

Private Member Functions

void SetId (TrackId id)
 
int GetIndex () const
 
void SetIndex (int index)
 
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
 

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

Member Typedef Documentation

◆ AttachedObjects

Alias for my base type.

Definition at line 212 of file Track.h.

◆ ChannelGroupAttachments

Hosting of objects attached by higher level code.

Definition at line 181 of file Track.h.

◆ ConstInterval

Definition at line 263 of file Track.h.

◆ ConstIntervals

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

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

◆ Fallthrough

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

Definition at line 459 of file Track.h.

◆ Holder

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

Definition at line 295 of file Track.h.

◆ Interval

Definition at line 261 of file Track.h.

◆ IntervalData

Definition at line 260 of file Track.h.

◆ Intervals

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

Definition at line 262 of file Track.h.

Member Enumeration Documentation

◆ LinkType

enum class Track::LinkType : int
strong

For two tracks describes the type of the linkage.

Enumerator
None 
Group 
Aligned 

Definition at line 172 of file Track.h.

172 : int {
173 None = 0, //< No linkage
174 Group = 2, //< Tracks are grouped together
175 Aligned, //< Tracks are grouped and changes should be synchronized
176 };

Constructor & Destructor Documentation

◆ Track() [1/2]

Track::Track ( )

Definition at line 39 of file Track.cpp.

40: vrulerSize(36,0)
41{
42 mIndex = 0;
43
44 mOffset = 0.0;
45}
double mOffset
Definition: Track.h:372
std::pair< int, int > vrulerSize
Definition: Track.h:313
int mIndex
0-based position of this track in its TrackList
Definition: Track.h:207

References mIndex, and mOffset.

◆ Track() [2/2]

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

Definition at line 47 of file Track.cpp.

48: vrulerSize( orig.vrulerSize )
49{
50 mIndex = 0;
51 mOffset = orig.mOffset;
52}

References mIndex, and mOffset.

◆ ~Track()

Track::~Track ( )
virtual

Definition at line 114 of file Track.cpp.

115{
116}

Member Function Documentation

◆ AdjustPositions()

void Track::AdjustPositions ( )

Definition at line 1190 of file Track.cpp.

1191{
1192 auto pList = mList.lock();
1193 if (pList) {
1194 pList->RecalcPositions(mNode);
1195 pList->ResizingEvent(mNode);
1196 }
1197}
std::weak_ptr< TrackList > mList
Definition: Track.h:203
TrackNodePointer mNode
Holds iterator to self, so that TrackList::Find can be constant-time.
Definition: Track.h:206

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

678 {
679 checkTrackType<TrackType>();
680 const auto &info = Executor::NominalType::ClassTypeInfo();
681 // Dynamic type test of track
682 // Assumes Executor classes are sequenced with more specific accepted
683 // types earlier
684 if ( info.IsBaseOf(track.GetTypeInfo()) )
685 // Dispatch to an Executor that knows which of functions applies
686 return Executor{}(&track, functions...);
687 else
688 // Recur, with fewer candidate Executors and all of functions
689 return CallExecutor( (R*)nullptr,
690 (std::tuple<Executors...>*)nullptr, track, functions...);
691 }
static R CallExecutor(R *, std::tuple<> *, TrackType &, const Functions &...)
Definition: Track.h:660

◆ CallExecutor() [2/2]

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

Definition at line 660 of file Track.h.

661 {
662 // This overload is needed so that the other overload of CallExecutor
663 // compiles, but it should never be reached at run-time, because an
664 // Executor generated for (const) Track should have been the catch-all.
665 wxASSERT(false);
666 checkTrackType<TrackType>();
667 if constexpr (std::is_void_v<R>)
668 return;
669 else
670 return R{};
671 }

◆ checkTrackType()

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

Definition at line 653 of file Track.h.

654 {
655 static_assert(
656 std::is_same_v<Track, TrackType> ||
657 std::is_same_v<const Track, TrackType>, "Error" );
658 }

◆ ClassTypeInfo()

auto Track::ClassTypeInfo ( )
static

Definition at line 1126 of file Track.cpp.

1127{
1128 static Track::TypeInfo info{
1129 { "generic", "generic", XO("Generic Track") }, false };
1130 return info;
1131}
XO("Cut/Copy/Paste")

References XO().

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

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

◆ Clear()

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

Referenced by anonymous_namespace{LabelMenus.cpp}::OnDeleteLabels(), and SyncLockAdjust().

Here is the caller graph for this function:

◆ Clone()

virtual Holder Track::Clone ( ) const
privatepure virtual

Implemented in TimeTrack, WaveTrack, LabelTrack, and NoteTrack.

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

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

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,
TypeList::List< TrackTypes... >  ,
const Functions &...  functions 
)
inlinestatic

Deduce two packs from arguments.

Definition at line 707 of file Track.h.

711 {
712 // Generate Executor classes, for each of TrackTypes,
713 // each zero-sized and with an operator () that calls the correct
714 // one of functions, assuming the track is of the corresponding type
715 using Executors = std::tuple< Executor<
716 Tag, R,
717 std::conditional_t<IsConst, const TrackTypes, TrackTypes>,
718 Functions...
719 >... >;
720 // Don't even construct the tuple of zero-sized types, just point
721 constexpr Executors *executors = nullptr;
722
723 // Compile time reachability check of the given functions
724 enum { All = sizeof...( functions ) };
725 static_assert( (1u << All) - 1u == UsedCases(executors),
726 "Uncallable case in Track::TypeSwitch");
727
728 // Do dynamic dispatch to one of the Executors
729 return CallExecutor((R *)nullptr, executors, track, functions...);
730 }
static constexpr unsigned UsedCases(std::tuple< Executors... > *)
Definition: Track.h:694

◆ Duplicate()

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

Definition at line 101 of file Track.cpp.

102{
103 // invoke "virtual constructor" to copy track object proper:
104 auto result = Clone();
105
106 AttachedTrackObjects::ForEach([&](auto &attachment){
107 // Copy view state that might be important to undo/redo
108 attachment.CopyTo( *result );
109 });
110
111 return result;
112}
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 304 of file Track.cpp.

306{
307 if (dest) {
308 dest->mpGroupData = n->mpGroupData ?
309 std::make_unique<ChannelGroupData>(*n->mpGroupData) : nullptr;
310 }
311}

References mpGroupData.

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

787{ return false; }

◆ GetGroupData() [1/2]

Track::ChannelGroupData & Track::GetGroupData ( )

Definition at line 171 of file Track.cpp.

172{
173 auto pTrack = this;
174 if (auto pList = GetOwner())
175 if (auto pLeader = *pList->FindLeader(pTrack))
176 pTrack = pLeader;
177 // May make on demand
178 return pTrack->MakeGroupData();
179}
std::shared_ptr< TrackList > GetOwner() const
Definition: Track.h:333

References GetOwner().

Referenced by SpectrogramSettings::Get(), WaveformSettings::Get(), WaveformScale::Get(), anonymous_namespace{PlayableTrack.cpp}::MuteAndSolo::Get(), RealtimeEffectList::Get(), anonymous_namespace{WaveTrackView.cpp}::PlacementArray::Get(), anonymous_namespace{WaveTrack.cpp}::GainAndPan::Get(), SpectrogramBounds::Get(), GetGroupData(), GetName(), GetSelected(), SpectrogramSettings::Own(), SpectrogramSettings::Reset(), WaveformSettings::Set(), SetName(), and SetSelected().

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

182{
183 // May make group data on demand, but consider that logically const
184 return const_cast<Track *>(this)->GetGroupData();
185}
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:161
ChannelGroupData & GetGroupData()
Definition: Track.cpp:171

References GetGroupData().

Here is the call graph for this function:

◆ GetId()

TrackId Track::GetId ( ) const
inline

Definition at line 214 of file Track.h.

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

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

Here is the caller graph for this function:

◆ GetIndex()

int Track::GetIndex ( ) const
private

Definition at line 134 of file Track.cpp.

135{
136 return mIndex;
137}

References mIndex.

Referenced by TrackList::RecalcPositions().

Here is the caller graph for this function:

◆ GetIntervals() [1/2]

auto Track::GetIntervals ( )
virtual

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

Reimplemented in WaveTrack, LabelTrack, and NoteTrack.

Definition at line 1143 of file Track.cpp.

1144{
1145 return {};
1146}

◆ GetIntervals() [2/2]

auto Track::GetIntervals ( ) const
virtual

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

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

Reimplemented in WaveTrack, LabelTrack, and NoteTrack.

Definition at line 1138 of file Track.cpp.

1139{
1140 return {};
1141}

Referenced by TrackShifter::InitIntervals().

Here is the caller graph for this function:

◆ GetLinkedTrack()

Track * Track::GetLinkedTrack ( ) const
private

Definition at line 234 of file Track.cpp.

235{
236 auto pList = mList.lock();
237 if (!pList)
238 return nullptr;
239
240 if (!pList->isNull(mNode)) {
241 if (HasLinkedTrack()) {
242 auto next = pList->getNext( mNode );
243 if ( !pList->isNull( next ) )
244 return next.first->get();
245 }
246
247 if (mNode.first != mNode.second->begin()) {
248 auto prev = pList->getPrev( mNode );
249 if ( !pList->isNull( prev ) ) {
250 auto track = prev.first->get();
251 if (track && track->HasLinkedTrack())
252 return track;
253 }
254 }
255 }
256
257 return nullptr;
258}

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

1213{
1214 return mpGroupData ? mpGroupData->mLinkType : LinkType::None;
1215}

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()

const wxString & Track::GetName ( ) const

◆ GetNode()

TrackNodePointer Track::GetNode ( ) const
private

Retrieve mNode with debug checks.

Definition at line 119 of file Track.cpp.

120{
121 wxASSERT(mList.lock() == NULL || this == mNode.first->get());
122 return mNode;
123}

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

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

◆ GetSelected()

bool Track::GetSelected ( ) const

◆ GetStartTime()

virtual double Track::GetStartTime ( ) const
pure virtual

Implemented in TimeTrack, WaveTrack, LabelTrack, and NoteTrack.

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

Referenced by SameKindAs().

Here is the caller graph for this function:

◆ GetTypeNames()

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

Definition at line 289 of file Track.h.

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

◆ HandleCommonXMLAttribute()

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

Definition at line 1165 of file Track.cpp.

1167{
1168 long nValue = -1;
1169
1170 bool handled = false;
1171 AttachedTrackObjects::ForEach([&](auto &attachment){
1172 handled = handled || attachment.HandleXMLAttribute( attr, valueView );
1173 });
1174 if (handled)
1175 ;
1176 // Note that the per-group properties of name and selectedness may have
1177 // been written redundantly for each channel, and values for the last
1178 // channel will be the last ones assigned
1179 else if (attr == "name") {
1180 SetName(valueView.ToWString());
1181 return true;
1182 }
1183 else if (attr == "isSelected" && valueView.TryGet(nValue)) {
1184 this->SetSelected(nValue != 0);
1185 return true;
1186 }
1187 return false;
1188}
virtual void SetSelected(bool s)
Definition: Track.cpp:83
void SetName(const wxString &n)
Definition: Track.cpp:69
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 TimeTrack::HandleXMLTag(), WaveTrack::HandleXMLTag(), LabelTrack::HandleXMLTag(), and NoteTrack::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 260 of file Track.cpp.

261{
262 return mpGroupData && mpGroupData->mLinkType != LinkType::None;
263}

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

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

◆ Init()

void Track::Init ( const Track orig)

Definition at line 55 of file Track.cpp.

56{
57 mId = orig.mId;
58
59 // Deep copy of any group data
61 std::make_unique<ChannelGroupData>(*orig.mpGroupData) : nullptr;
62}

References mId, and mpGroupData.

Referenced by TimeTrack::Init(), and WaveTrack::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 1217 of file Track.cpp.

1218{
1219 if (auto owner = GetOwner())
1220 {
1221 auto leader = *owner->FindLeader(this);
1222 return leader != this && leader->GetLinkType() == Track::LinkType::Aligned;
1223 }
1224 return false;
1225}

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

297{
298 return !GetLinkedTrack() || HasLinkedTrack();
299}

References GetLinkedTrack(), and HasLinkedTrack().

Referenced by anonymous_namespace{FileMenus.cpp}::DoExport(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), anonymous_namespace{TrackPanel.cpp}::DrawTrackName(), TrackList::FindLeader(), SampleTrack::GetChannelType(), IsSelectedLeader(), TrackList::Leaders(), EffectLoudness::Process(), EffectNormalize::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 293 of file Track.cpp.

294 { return GetSelected(); }
bool GetSelected() const
Selectedness is always the same for all channels of a group.
Definition: Track.cpp:78

References GetSelected().

Referenced by ProjectAudioManager::ChooseExistingRecordingTracks(), ExportPlugin::CreateMixer(), anonymous_namespace{TrackMenus.cpp}::DoPanTracks(), Exporter::ExamineTracks(), ExportMixerDialog::ExportMixerDialog(), IsSelectedLeader(), SyncLock::IsSelectedOrSyncLockSelected(), SyncLock::IsSyncLockSelected(), MakeTransportTracks(), ProjectAudioManager::OnRecord(), SelectActions::Handler::OnSelectSyncLockSel(), EffectPaulstretch::Process(), 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 301 of file Track.cpp.

302 { return IsSelected() && IsLeader(); }
bool IsSelected() const
Definition: Track.cpp:293
bool IsLeader() const
Definition: Track.cpp:296

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

329 { 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:313

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

314{
315 // Sanity checks for linked tracks; unsetting the linked property
316 // doesn't fix the problem, but it likely leaves us with orphaned
317 // sample blocks instead of much worse problems.
318 bool err = false;
319 if (completeList && HasLinkedTrack()) {
320 if (auto link = GetLinkedTrack()) {
321 // A linked track's partner should never itself be linked
322 if (link->HasLinkedTrack()) {
323 err = true;
324 if (doFix) {
325 wxLogWarning(
326 L"Left track %s had linked right track %s with extra right "
327 "track link.\n Removing extra link from right track.",
328 GetName(), link->GetName());
329 link->SetLinkType(LinkType::None);
330 }
331 }
332 }
333 else {
334 err = true;
335 if (doFix) {
336 wxLogWarning(
337 L"Track %s had link to NULL track. Setting it to not be linked.",
338 GetName());
340 }
341 }
342 }
343 return ! err;
344}
void SetLinkType(LinkType linkType, bool completeList=true)
Definition: Track.cpp:144
const wxString & GetName() const
Name is always the same for all channels of a group.
Definition: Track.cpp:64

References GetLinkedTrack(), GetName(), HasLinkedTrack(), None, 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 163 of file Track.cpp.

164{
165 if (!mpGroupData)
166 // Make on demand
167 mpGroupData = std::make_unique<ChannelGroupData>();
168 return *mpGroupData;
169}

References mpGroupData.

Referenced by DoSetLinkType().

Here is the caller graph for this function:

◆ Notify()

void Track::Notify ( bool  allChannels,
int  code = -1 
)

Definition at line 265 of file Track.cpp.

266{
267 auto pList = mList.lock();
268 if (pList)
269 pList->DataEvent(SharedPointer(), allChannels, code);
270}

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

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

Referenced by TrackShifter::DoHorizontalOffset(), EffectPreview(), 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 TimeTrack, WaveTrack, LabelTrack, and NoteTrack.

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

453 { 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:

◆ SetId()

void Track::SetId ( TrackId  id)
inlineprivate

Definition at line 216 of file Track.h.

216{ 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)
private

Definition at line 139 of file Track.cpp.

140{
141 mIndex = index;
142}

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

145{
146 auto pList = mList.lock();
147 if (pList && !pList->mPendingUpdates.empty()) {
148 auto orig = pList->FindById( GetId() );
149 if (orig && orig != this) {
150 orig->SetLinkType(linkType);
151 return;
152 }
153 }
154
155 DoSetLinkType(linkType, completeList);
156
157 if (pList) {
158 pList->RecalcPositions(mNode);
159 pList->ResizingEvent(mNode);
160 }
161}
TrackId GetId() const
Definition: Track.h:214
void DoSetLinkType(LinkType linkType, bool completeList=true)
Definition: Track.cpp:187

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

70{
71 auto &name = GetGroupData().mName;
72 if (name != n) {
73 name = n;
74 Notify(true);
75 }
76}
const TranslatableString name
Definition: Distortion.cpp:76
void Notify(bool allChannels, int code=-1)
Definition: Track.cpp:265

References GetGroupData(), Track::ChannelGroupData::mName, name, and Notify().

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

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

404{ 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 125 of file Track.cpp.

127{
128 // BUG: When using this function to clear an owner, we may need to clear
129 // focused track too. Otherwise focus could remain on an invisible (or deleted) track.
130 mList = list;
131 mNode = node;
132}

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:

◆ SetSelected()

void Track::SetSelected ( bool  s)
virtual

Reimplemented in LabelTrack.

Definition at line 83 of file Track.cpp.

84{
85 auto &selected = GetGroupData().mSelected;
86 if (selected != s) {
87 selected = s;
88 auto pList = mList.lock();
89 if (pList)
90 pList->SelectionEvent(*this);
91 }
92}

References GetGroupData(), mList, and Track::ChannelGroupData::mSelected.

Referenced by SetTrackStatusCommand::ApplyInner(), anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), HandleCommonXMLAttribute(), anonymous_namespace{LabelMenus.cpp}::OnPasteNewLabel(), SelectionState::SelectTrack(), 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 224 of file Track.h.

225 {
226 // shared_from_this is injected into class scope by base class
227 // std::enable_shared_from_this<Track>
228 return std::static_pointer_cast<Subclass>( shared_from_this() );
229 }

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(), 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 232 of file Track.h.

236 {
237 // shared_from_this is injected into class scope by base class
238 // std::enable_shared_from_this<Track>
239 return std::static_pointer_cast<Subclass>( shared_from_this() );
240 }

◆ SharedPointer() [3/4]

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

Definition at line 248 of file Track.h.

249 { 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 244 of file Track.h.

245 { 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 1106 of file Track.cpp.

1107{
1108 auto pList = mList.lock();
1109 if (pList) {
1110 const auto id = GetId();
1111 const auto pred = [=]( const ListOfTracks::value_type &ptr ) {
1112 return ptr->GetId() == id; };
1113 const auto end = pList->mPendingUpdates.end();
1114 const auto it = std::find_if( pList->mPendingUpdates.begin(), end, pred );
1115 if (it != end) {
1116 const auto &list2 = (const ListOfTracks &) *pList;
1117 const auto end2 = list2.end();
1118 const auto it2 = std::find_if( list2.begin(), end2, pred );
1119 if ( it2 != end2 )
1120 return *it2;
1121 }
1122 }
1123 return SharedPointer();
1124}
std::list< std::shared_ptr< Track > > ListOfTracks
Definition: Track.h:43
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 1085 of file Track.cpp.

1086{
1087 // Linear search. Tracks in a project are usually very few.
1088 auto pList = mList.lock();
1089 if (pList) {
1090 const auto id = GetId();
1091 const auto end = pList->mPendingUpdates.end();
1092 auto it = std::find_if(
1093 pList->mPendingUpdates.begin(), end,
1094 [=](const ListOfTracks::value_type &ptr){ return ptr->GetId() == id; } );
1095 if (it != end)
1096 return *it;
1097 }
1098 return SharedPointer();
1099}

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

1102{
1103 return const_cast<Track*>(this)->SubstitutePendingChangedTrack();
1104}
std::shared_ptr< Track > SubstitutePendingChangedTrack()
Definition: Track.cpp:1085

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

1134{
1135 return true;
1136}

Referenced by SelectActions::Handler::OnCursorTrackEnd(), SelectActions::Handler::OnCursorTrackStart(), anonymous_namespace{EditMenus.cpp}::OnCut(), SelectActions::Handler::OnSelectSyncLockSel(), and anonymous_namespace{EditMenus.cpp}::OnSplitCut().

Here is the caller graph for this function:

◆ SyncLockAdjust()

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

Reimplemented in WaveTrack, and LabelTrack.

Definition at line 272 of file Track.cpp.

273{
274 if (newT1 > oldT1) {
275 // Insert space within the track
276
277 if (oldT1 > GetEndTime())
278 return;
279
280 auto tmp = Cut(oldT1, GetEndTime());
281
282 Paste(newT1, tmp.get());
283 }
284 else if (newT1 < oldT1) {
285 // Remove from the track
286 Clear(newT1, oldT1);
287 }
288}
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 anonymous_namespace{EditMenus.cpp}::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 755 of file Track.h.

756 {
757 struct Tag : TrackTypeTag {};
758 // Collect all concrete and abstract track types known at compile time
759 using TrackTypes = TypeList::Reverse_t<
761 // Generate a function that dispatches dynamically on track type
762 return DoTypeSwitch<Tag, false, R>(*this, TrackTypes{}, functions...);
763 }
typename Accumulate< 0 >::type type
typename Reverse< TypeList >::type Reverse_t
Definition: TypeList.h:284

Referenced by SetClipCommand::ApplyInner(), SetEnvelopeCommand::ApplyInner(), WaveTrack::Merge(), anonymous_namespace{LabelMenus.cpp}::OnCopyLabels(), anonymous_namespace{LabelMenus.cpp}::OnCutLabels(), anonymous_namespace{LabelMenus.cpp}::OnDisjoinLabels(), anonymous_namespace{LabelMenus.cpp}::OnJoinLabels(), anonymous_namespace{LabelMenus.cpp}::OnSilenceLabels(), anonymous_namespace{LabelMenus.cpp}::OnSplitCutLabels(), anonymous_namespace{LabelMenus.cpp}::OnSplitDeleteLabels(), anonymous_namespace{LabelMenus.cpp}::OnSplitLabels(), TimeTrack::Paste(), LabelTrack::Paste(), NoteTrack::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 772 of file Track.h.

773 {
774 struct Tag : TrackTypeTag {};
775 // Collect all concrete and abstract track types known at compile time
776 using TrackTypes = TypeList::Reverse_t<
778 // Generate a function that dispatches dynamically on track type
779 return DoTypeSwitch<Tag, true, R>(*this, TrackTypes{}, functions...);
780 }

◆ UsedCases()

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

Definition at line 694 of file Track.h.

695 {
696 return (Executors::SetUsed | ...); // My very first fold expression :-)
697 }

◆ WriteCommonXMLAttributes()

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

Definition at line 1149 of file Track.cpp.

1151{
1152 if (includeNameAndSelected) {
1153 // May write name and selectedness redundantly for right channels,
1154 // but continue doing that in case the file is opened in Audacity 3.1.x
1155 // which does not have unique ChannelGroupData for the track
1156 xmlFile.WriteAttr(wxT("name"), GetName());
1157 xmlFile.WriteAttr(wxT("isSelected"), this->GetSelected());
1158 }
1159 AttachedTrackObjects::ForEach([&](auto &attachment){
1160 attachment.WriteXMLAttributes( xmlFile );
1161 });
1162}
wxT("CloseDown"))
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:36

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

Referenced by TimeTrack::WriteXML(), WaveTrack::WriteXML(), and LabelTrack::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 TimeTrack, WaveTrack, LabelTrack, and NoteTrack.

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

846{
847 using BareType = std::remove_pointer_t< T >;
848 if (track &&
849 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
850 return reinterpret_cast<T>(track);
851 else
852 return nullptr;
853}

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

829{
830 using BareType = std::remove_pointer_t< T >;
831 if (track &&
832 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
833 return reinterpret_cast<T>(track);
834 else
835 return nullptr;
836}

◆ TrackList

friend class TrackList
friend

Definition at line 195 of file Track.h.

Member Data Documentation

◆ mId

TrackId Track::mId
private

Identifies the track only in-session, not persistently.

Definition at line 198 of file Track.h.

Referenced by Init().

◆ mIndex

int Track::mIndex
protected

0-based position of this track in its TrackList

Definition at line 207 of file Track.h.

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

◆ mList

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

◆ 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 206 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

◆ vrulerSize

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

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