Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | 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  DuplicateOptions
 Choices when duplicating a track. 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

using AttachedObjects = ::AttachedTrackObjects
 Alias for my base type. More...
 
using Holder = std::shared_ptr< Track >
 
- 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 Types inherited from ChannelGroup
enum class  LinkType : int { None = 0 , Group = 2 , Aligned }
 For two tracks describes the type of the linkage. More...
 
using Attachments = ClientData::Site< ChannelGroupData, ClientData::Cloneable<>, ClientData::DeepCopying >
 
using Interval = WideChannelGroupInterval
 

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 &project, TrackList &list) const =0
 
virtual bool LinkConsistencyFix (bool doFix=true)
 Check consistency of channel groups, and maybe fix it. More...
 
bool LinkConsistencyCheck ()
 Do the non-mutating part of consistency fix only and return status. More...
 
bool HasOwner () const
 
std::shared_ptr< TrackListGetOwner () const
 
TrackListGetHolder () const
 
LinkType GetLinkType () const noexcept
 
ChannelGroupDataGetGroupData ()
 
const ChannelGroupDataGetGroupData () const
 May make group data on demand, but consider that logically const. More...
 
 Track ()
 
 Track (const Track &orig, ProtectedCreationArg &&)
 
Trackoperator= (const Track &orig)=delete
 
virtual ~Track ()
 
void Init (const Track &orig)
 
virtual TrackListHolder Duplicate (DuplicateOptions={}) const
 public nonvirtual duplication function that invokes Clone() More...
 
void ReparentAllAttachments ()
 
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 OnProjectTempoChange (double newTempo)
 method to set project tempo on track More...
 
virtual TrackListHolder Cut (double t0, double t1)=0
 Create tracks and modify this track. More...
 
virtual TrackListHolder Copy (double t0, double t1, bool forClipboard=true) const =0
 Create new tracks and don't modify this track. More...
 
virtual void Clear (double t0, double t1)=0
 
virtual void Paste (double t, const Track &src)=0
 Weak precondition allows overrides to replicate one channel into many. More...
 
void Paste (double t, const TrackList &src)
 
virtual void SyncLockAdjust (double oldT1, double newT1)
 
virtual void Silence (double t0, double t1, ProgressReporter reportProgress={})=0
 
virtual void InsertSilence (double t, double len)=0
 
bool SameKindAs (const Track &track) const
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions)
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions) const
 
virtual void WriteXML (XMLWriter &xmlFile) const =0
 
virtual std::optional< TranslatableStringGetErrorOpening () const
 
void Notify (bool allChannels, int code=-1)
 
bool Any () const
 
bool IsSelected () const
 
bool IsLeader () const override
 
bool IsSelectedLeader () const
 
void AdjustPositions ()
 
void WriteCommonXMLAttributes (XMLWriter &xmlFile, bool includeNameAndSelected=true) const
 
bool HandleCommonXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView)
 
const std::optional< double > & GetProjectTempo () const
 
- 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...
 
- Public Member Functions inherited from ChannelGroup
virtual ~ChannelGroup ()
 
double GetStartTime () const
 Get the minimum of Start() values of intervals, or 0 when none. More...
 
double GetEndTime () const
 Get the maximum of End() values of intervals, or 0 when none. More...
 
void ShiftBy (double t)
 Change start time by given duration. More...
 
virtual void MoveTo (double o)=0
 Change start time to given time point. More...
 
virtual bool IsLeader () const =0
 
ChannelGroupDataGetGroupData ()
 Make attachment site on demand as needed. More...
 
const ChannelGroupDataGetGroupData () const
 
ChannelGroupDataFindGroupData ()
 Do not make attachment site on demand if absent. More...
 
const ChannelGroupDataFindGroupData () const
 Do not make attachment site on demand if absent. More...
 
void Init (const ChannelGroup &other)
 Copy, including cloning of attached objects. More...
 
void DestroyGroupData ()
 Leave all attachments null. More...
 
std::unique_ptr< ChannelGroupDataDetachGroupData ()
 Move attachments out. More...
 
void AssignGroupData (std::unique_ptr< ChannelGroupData > pGroupData)
 Replace any previous attachments. More...
 
virtual size_t NChannels () const =0
 Report the number of channels. More...
 
template<typename ChannelType = Channel>
std::shared_ptr< ChannelType > GetChannel (size_t iChannel)
 Retrieve a channel, cast to the given type. More...
 
template<typename ChannelType = const Channel>
auto GetChannel (size_t iChannel) const -> std::enable_if_t< std::is_const_v< ChannelType >, std::shared_ptr< ChannelType > >
 
template<typename ChannelType = Channel>
IteratorRange< ChannelIterator< ChannelType > > Channels ()
 Get range of channels with mutative access. More...
 
template<typename ChannelType = const Channel>
auto Channels () const -> std::enable_if_t< std::is_const_v< ChannelType >, IteratorRange< ChannelIterator< ChannelType > > >
 Get range of channels with read-only access. More...
 
virtual size_t NIntervals () const =0
 Report the number of intervals. More...
 
template<typename IntervalType = Interval>
std::shared_ptr< IntervalType > GetInterval (size_t iInterval)
 Retrieve an interval, cast to the given type. More...
 
template<typename IntervalType = const Interval>
auto GetInterval (size_t iInterval) const -> std::enable_if_t< std::is_const_v< IntervalType >, std::shared_ptr< IntervalType > >
 
template<typename IntervalType = Interval>
IteratorRange< IntervalIterator< IntervalType > > Intervals ()
 Get range of intervals with mutative access. More...
 
template<typename IntervalType = const Interval>
auto Intervals () const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< IntervalIterator< IntervalType > > >
 Get range of intervals with read-only access. 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 Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
static size_t numFactories ()
 How many static factories have been registered with this specialization of Site. More...
 

Protected Member Functions

void SetLinkType (LinkType linkType, bool completeList=true)
 
virtual void DoOnProjectTempoChange (const std::optional< double > &oldTempo, double newTempo)=0
 
- 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 Member Functions inherited from ChannelGroup
virtual std::shared_ptr< ChannelDoGetChannel (size_t iChannel)=0
 Retrieve a channel. More...
 
virtual std::shared_ptr< IntervalDoGetInterval (size_t iInterval)=0
 Retrieve an interval. 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...
 

Private Member Functions

void SetId (TrackId id)
 
int GetIndex () const
 
void SetIndex (int index)
 
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 TrackListHolder Clone (bool backup) const =0
 

Private Attributes

TrackId mId
 Identifies the track only in-session, not persistently. More...
 

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

Member Typedef Documentation

◆ AttachedObjects

Alias for my base type.

Definition at line 148 of file Track.h.

◆ Holder

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

Definition at line 225 of file Track.h.

Constructor & Destructor Documentation

◆ Track() [1/2]

Track::Track ( )

Definition at line 39 of file Track.cpp.

40{
41 mIndex = 0;
42}
int mIndex
0-based position of this track in its TrackList
Definition: Track.h:143

References mIndex.

◆ Track() [2/2]

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

Definition at line 44 of file Track.cpp.

45{
46 mIndex = 0;
47}

References mIndex.

◆ ~Track()

Track::~Track ( )
virtual

Definition at line 110 of file Track.cpp.

111{
112}

Member Function Documentation

◆ AdjustPositions()

void Track::AdjustPositions ( )

Definition at line 1260 of file Track.cpp.

1261{
1262 auto pList = mList.lock();
1263 if (pList) {
1264 pList->RecalcPositions(mNode);
1265 pList->ResizingEvent(mNode);
1266 }
1267}
std::weak_ptr< TrackList > mList
Definition: Track.h:139
TrackNodePointer mNode
Holds iterator to self, so that TrackList::Find can be constant-time.
Definition: Track.h:142

References mList, and mNode.

◆ Any()

bool Track::Any ( ) const

Definition at line 285 of file Track.cpp.

286 { return true; }

Referenced by EffectLoudness::AllocBuffers(), TrackList::Channels_(), WaveTrack::DuplicateWithOtherTempo(), TrackList::EmptyRange(), ExportUtils::FindExportWaveTracks(), MakeTransportTracks(), anonymous_namespace{LabelMenus.cpp}::OnPasteNewLabel(), EffectNoiseReduction::Worker::Process(), and TrackList::Size().

Here is the caller graph for this function:

◆ ClassTypeInfo()

auto Track::ClassTypeInfo ( )
static

Definition at line 1206 of file Track.cpp.

1207{
1208 static Track::TypeInfo info{
1209 { "generic", "generic", XO("Generic Track") }, false };
1210 return info;
1211}
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  t0,
double  t1 
)
pure virtual

May assume precondition: t0 <= t1

Precondition
IsLeader()

Implemented in NoteTrack, TimeTrack, WaveTrack, and LabelTrack.

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

Here is the caller graph for this function:

◆ Clone()

virtual TrackListHolder Track::Clone ( bool  backup) const
privatepure virtual

Subclass responsibility implements only a part of Duplicate(), copying the track data proper (not associated data such as for groups and views)

Parameters
unstretchIntervalIf set, this time interval's stretching must be applied.
Precondition
!unstretchInterval.has_value() || unstretchInterval->first < unstretchInterval->second
IsLeader()
Parameters
backupwhether the duplication is for backup purposes while opening a project, instead of other editing operations
Postcondition
result: NChannels() == result->NChannels()

Implemented in NoteTrack, TimeTrack, WaveTrack, and LabelTrack.

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

Here is the caller graph for this function:

◆ Copy()

virtual TrackListHolder Track::Copy ( double  t0,
double  t1,
bool  forClipboard = true 
) const
pure virtual

Create new tracks and don't modify this track.

Returns
non-NULL or else throw Note that subclasses may want to distinguish tracks stored in a clipboard from those stored in a project May assume precondition: t0 <= t1 Should invoke Track::Init
Precondition
IsLeader
Postcondition
result: result->NChannels() == NChannels()

Implemented in TimeTrack, NoteTrack, WaveTrack, and LabelTrack.

◆ Cut()

virtual TrackListHolder Track::Cut ( double  t0,
double  t1 
)
pure virtual

Create tracks and modify this track.

Returns
non-NULL or else throw May assume precondition: t0 <= t1
Precondition
IsLeader()
Postcondition
result: result->NChannels() == NChannels()

Implemented in NoteTrack, TimeTrack, WaveTrack, and LabelTrack.

Referenced by SyncLockAdjust().

Here is the caller graph for this function:

◆ DoOnProjectTempoChange()

virtual void Track::DoOnProjectTempoChange ( const std::optional< double > &  oldTempo,
double  newTempo 
)
protectedpure virtual
Precondition
IsLeader()

Implemented in NoteTrack, TimeTrack, WaveTrack, and LabelTrack.

Referenced by OnProjectTempoChange().

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

175{
176 auto oldType = GetLinkType();
177 if (linkType == oldType)
178 // No change
179 return;
180
181 if (oldType == LinkType::None) {
182 // Becoming linked
183
184 // First ensure there is no partner
185 if (auto partner = GetLinkedTrack())
186 partner->DestroyGroupData();
187 assert(!GetLinkedTrack());
188
189 // Change the link type
190 GetGroupData().mLinkType = linkType;
191
192 // If this acquired a partner, it loses any old group data
193 if (auto partner = GetLinkedTrack())
194 partner->DestroyGroupData();
195 }
196 else if (linkType == LinkType::None) {
197 // Becoming unlinked
198 assert(FindGroupData());
199 if (HasLinkedTrack()) {
200 if (auto partner = GetLinkedTrack()) {
201 // Make independent copy of group data in the partner, which should
202 // have had none
203 assert(!partner->FindGroupData());
204 partner->ChannelGroup::Init(*this);
205 partner->GetGroupData().mLinkType = LinkType::None;
206 }
207 }
209 }
210 else {
211 // Remaining linked, changing the type
212 assert(FindGroupData());
213 GetGroupData().mLinkType = linkType;
214 }
215
216 // Assertion checks only in a debug build, does not have side effects!
217 assert(!completeList || LinkConsistencyCheck());
218}
ChannelGroupData * FindGroupData()
Do not make attachment site on demand if absent.
Definition: Channel.h:553
bool HasLinkedTrack() const noexcept
Returns true for leaders of multichannel groups.
Definition: Track.cpp:246
ChannelGroupData & GetGroupData()
Definition: Track.cpp:159
Track * GetLinkedTrack() const
Definition: Track.cpp:220
LinkType GetLinkType() const noexcept
Definition: Track.cpp:1280
bool LinkConsistencyCheck()
Do the non-mutating part of consistency fix only and return status.
Definition: Track.h:249

References ChannelGroup::FindGroupData(), GetGroupData(), GetLinkedTrack(), GetLinkType(), HasLinkedTrack(), LinkConsistencyCheck(), ChannelGroup::ChannelGroupData::mLinkType, and ChannelGroup::None.

Referenced by SetLinkType().

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

◆ Duplicate()

TrackListHolder Track::Duplicate ( DuplicateOptions  options = {}) const
virtual

public nonvirtual duplication function that invokes Clone()

Precondition
IsLeader()
Postcondition
result: NChannels() == result->NChannels()

Definition at line 86 of file Track.cpp.

87{
88 assert(IsLeader());
89 // invoke "virtual constructor" to copy track object proper:
90 auto result = Clone(options.backup);
91
92 auto iter = TrackList::Channels(*result->begin()).begin();
93 const auto copyOne = [&](const Track *pChannel){
94 pChannel->AttachedTrackObjects::ForEach([&](auto &attachment){
95 // Copy view state that might be important to undo/redo
96 attachment.CopyTo(**iter);
97 });
98 ++iter;
99 };
100
101 if (GetOwner())
102 for (const auto pChannel : TrackList::Channels(this))
103 copyOne(pChannel);
104 else
105 copyOne(this);
106
107 return result;
108}
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:122
std::shared_ptr< TrackList > GetOwner() const
Definition: Track.h:254
bool IsLeader() const override
Definition: Track.cpp:291
virtual TrackListHolder Clone(bool backup) const =0
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1164

References Track::DuplicateOptions::backup, TrackList::Channels(), Clone(), GetOwner(), and IsLeader().

Referenced by WaveTrack::DuplicateWithOtherTempo(), and WaveTrack::MonoToStereo().

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

◆ GetErrorOpening()

std::optional< TranslatableString > Track::GetErrorOpening ( ) const
virtual

Returns nonempty if an error was encountered while trying to open the track from XML

May assume consistency of stereo channel grouping and examine other channels

Precondition
IsLeader()

Reimplemented in WaveTrack.

Definition at line 252 of file Track.cpp.

253{
254 return {};
255}

◆ GetGroupData() [1/2]

ChannelGroup::ChannelGroupData & Track::GetGroupData ( )

Definition at line 159 of file Track.cpp.

160{
161 auto pTrack = this;
162 if (auto pList = GetHolder())
163 if (auto pLeader = *pList->Find(pTrack))
164 pTrack = pLeader;
165 // May make on demand
166 return pTrack->ChannelGroup::GetGroupData();
167}
TrackList * GetHolder() const
Definition: Track.h:1480

References GetHolder().

Referenced by DoSetLinkType(), SpectrogramSettings::Get(), WaveformSettings::Get(), WaveformScale::Get(), anonymous_namespace{PlayableTrack.cpp}::MuteAndSolo::Get(), anonymous_namespace{WaveChannelView.cpp}::PlacementArray::Get(), anonymous_namespace{WaveTrack.cpp}::WaveTrackData::Get(), SpectrogramBounds::Get(), GetGroupData(), GetName(), GetProjectTempo(), GetSelected(), OnProjectTempoChange(), 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 ChannelGroup::ChannelGroupData & Track::GetGroupData ( ) const

May make group data on demand, but consider that logically const.

Definition at line 169 of file Track.cpp.

170{
171 return const_cast<Track *>(this)->GetGroupData();
172}

References GetGroupData().

Here is the call graph for this function:

◆ GetHolder()

TrackList * Track::GetHolder ( ) const
inline

Definition at line 1480 of file Track.h.

1480 {
1481 return static_cast<TrackList*>(mNode.second); }
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:993

References mNode.

Referenced by SpectrumView::DoDraw(), WaveformView::DoDraw(), GetGroupData(), and WaveTrack::ReallyDoGetChannelGroup().

Here is the caller graph for this function:

◆ GetId()

TrackId Track::GetId ( ) const
inline

Definition at line 150 of file Track.h.

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

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

Here is the caller graph for this function:

◆ GetIndex()

int Track::GetIndex ( ) const
private

Definition at line 130 of file Track.cpp.

131{
132 return mIndex;
133}

References mIndex.

Referenced by TrackList::RecalcPositions().

Here is the caller graph for this function:

◆ GetLinkedTrack()

Track * Track::GetLinkedTrack ( ) const
private

Definition at line 220 of file Track.cpp.

221{
222 auto pList = static_cast<TrackList*>(mNode.second);
223 if (!pList)
224 return nullptr;
225
226 if (!pList->isNull(mNode)) {
227 if (HasLinkedTrack()) {
228 auto next = pList->getNext( mNode );
229 if ( !pList->isNull( next ) )
230 return next.first->get();
231 }
232
233 if (mNode.first != mNode.second->begin()) {
234 auto prev = pList->getPrev( mNode );
235 if ( !pList->isNull( prev ) ) {
236 auto track = prev.first->get();
237 if (track && track->HasLinkedTrack())
238 return track;
239 }
240 }
241 }
242
243 return nullptr;
244}
TrackNodePointer getNext(TrackNodePointer p) const
Move an iterator to the next node, if any; else stay at end.
Definition: Track.h:1381

References TrackList::getNext(), HasLinkedTrack(), 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 1280 of file Track.cpp.

1281{
1282 const auto pGroupData = FindGroupData();
1283 return pGroupData ? pGroupData->mLinkType : LinkType::None;
1284}

References ChannelGroup::FindGroupData(), and ChannelGroup::None.

Referenced by DoSetLinkType(), ProjectFileManager::FixTracks(), WaveTrack::LinkConsistencyFix(), and WaveTrack::WriteOneXML().

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

116{
117 wxASSERT(mList.lock() == NULL || this == mNode.first->get());
118 return mNode;
119}

References mList, and mNode.

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

Here is the caller graph for this function:

◆ GetOwner()

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

◆ GetProjectTempo()

const std::optional< double > & Track::GetProjectTempo ( ) const

Definition at line 1369 of file Track.cpp.

1370{
1371 return GetGroupData().mProjectTempo;
1372}
std::optional< double > mProjectTempo
Definition: Channel.h:586

References GetGroupData(), and ChannelGroup::ChannelGroupData::mProjectTempo.

Referenced by WaveTrack::ClearAndPaste(), WaveTrack::ClearAndPasteAtSameTempo(), WaveTrack::CreateClip(), anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), WaveTrack::InsertClip(), WaveTrack::PasteWaveTrack(), and WaveTrack::PasteWaveTrackAtSameTempo().

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

◆ GetSelected()

bool Track::GetSelected ( ) const

◆ GetTypeInfo()

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

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

Referenced by SameKindAs().

Here is the caller graph for this function:

◆ GetTypeNames()

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

Definition at line 219 of file Track.h.

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

◆ HandleCommonXMLAttribute()

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

Definition at line 1235 of file Track.cpp.

1237{
1238 long nValue = -1;
1239
1240 bool handled = false;
1241 AttachedTrackObjects::ForEach([&](auto &attachment){
1242 handled = handled || attachment.HandleXMLAttribute( attr, valueView );
1243 });
1244 if (handled)
1245 ;
1246 // Note that the per-group properties of name and selectedness may have
1247 // been written redundantly for each channel, and values for the last
1248 // channel will be the last ones assigned
1249 else if (attr == "name") {
1250 SetName(valueView.ToWString());
1251 return true;
1252 }
1253 else if (attr == "isSelected" && valueView.TryGet(nValue)) {
1254 this->SetSelected(nValue != 0);
1255 return true;
1256 }
1257 return false;
1258}
void ForEach(const Function &function)
Invoke function on each ClientData object that has been created in this.
Definition: ClientData.h:388
virtual void SetSelected(bool s)
Definition: Track.cpp:75
void SetName(const wxString &n)
Definition: Track.cpp:61
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 NoteTrack::HandleXMLTag(), TimeTrack::HandleXMLTag(), WaveTrack::HandleXMLTag(), and LabelTrack::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 246 of file Track.cpp.

247{
248 auto pGroupData = FindGroupData();
249 return pGroupData && pGroupData->mLinkType != LinkType::None;
250}

References ChannelGroup::FindGroupData(), and ChannelGroup::None.

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

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

◆ HasOwner()

bool Track::HasOwner ( ) const
inline

Definition at line 252 of file Track.h.

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

◆ Init()

void Track::Init ( const Track orig)

Definition at line 50 of file Track.cpp.

51{
53 mId = orig.mId;
54}
void Init(const ChannelGroup &other)
Copy, including cloning of attached objects.
Definition: Channel.cpp:89

References ChannelGroup::Init(), and mId.

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

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

◆ InsertSilence()

virtual void Track::InsertSilence ( double  t,
double  len 
)
pure virtual

May assume precondition: t0 <= t1

Precondition
IsLeader()

Implemented in NoteTrack, TimeTrack, WaveTrack, and LabelTrack.

◆ IsLeader()

bool Track::IsLeader ( ) const
overridevirtual

Implements ChannelGroup.

Reimplemented in SampleTrack, WritableSampleTrack, and WaveTrack.

Definition at line 291 of file Track.cpp.

292{
293 return !GetLinkedTrack() || HasLinkedTrack();
294}

References GetLinkedTrack(), and HasLinkedTrack().

Referenced by TrackList::Any(), NoteTrack::Clear(), TimeTrack::Clear(), LabelTrack::Clear(), TimeTrack::Clone(), LabelTrack::Clone(), CoarseTrackShifter::CoarseTrackShifter(), TrackShifter::CommonMayMigrateTo(), NoteTrack::Cut(), TimeTrack::Cut(), LabelTrack::Cut(), DEFINE_ATTACHED_VIRTUAL(), NoteTrack::DoOnProjectTempoChange(), TimeTrack::DoOnProjectTempoChange(), LabelTrack::DoOnProjectTempoChange(), ProjectAudioManager::DoRecord(), TimeShiftHandle::DoSlideVertical(), Duplicate(), TrackList::Find(), anonymous_namespace{TrackPanel.cpp}::FindAdjustedChannelHeights(), SelectionState::HandleListSelection(), ClipMoveState::Init(), TrackList::Insert(), NoteTrack::InsertSilence(), TimeTrack::InsertSilence(), LabelTrack::InsertSilence(), WaveTrack::IsLeader(), IsSelectedLeader(), LinkConsistencyFix(), anonymous_namespace{LabelMenus.cpp}::OnCopyLabels(), anonymous_namespace{LabelMenus.cpp}::OnCutLabels(), anonymous_namespace{LabelMenus.cpp}::OnDeleteLabels(), anonymous_namespace{LabelMenus.cpp}::OnDisjoinLabels(), anonymous_namespace{LabelMenus.cpp}::OnJoinLabels(), NavigationActions::Handler::OnLastTrack(), OnProjectTempoChange(), anonymous_namespace{LabelMenus.cpp}::OnSilenceLabels(), anonymous_namespace{LabelMenus.cpp}::OnSplitCutLabels(), anonymous_namespace{LabelMenus.cpp}::OnSplitDeleteLabels(), anonymous_namespace{LabelMenus.cpp}::OnSplitLabels(), NavigationActions::Handler::OnToggle(), NoteTrack::PasteInto(), TimeTrack::PasteInto(), LabelTrack::PasteInto(), TrackList::RegisterPendingChangedTrack(), TrackList::Remove(), TrackList::ReplaceOne(), SelectionState::SelectTrack(), SelectionState::SelectTrackLength(), Viewport::ShowTrack(), NoteTrack::Silence(), TimeTrack::Silence(), LabelTrack::Silence(), SyncLockAdjust(), LabelTrack::SyncLockAdjust(), TrackPanel::UpdateTrackVRuler(), and AddedAnalysisTrack::~AddedAnalysisTrack().

Here is the call graph for this function:

◆ IsSelected()

bool Track::IsSelected ( ) const

Definition at line 288 of file Track.cpp.

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

References GetSelected().

Referenced by ProjectAudioManager::ChooseExistingRecordingTracks(), anonymous_namespace{TrackMenus.cpp}::DoPanTracks(), ExportUtils::FindExportWaveTracks(), IsSelectedLeader(), SyncLock::IsSelectedOrSyncLockSelected(), SyncLock::IsSyncLockSelected(), MakeTransportTracks(), SelectActions::Handler::OnSelectSyncLockSel(), and EffectTruncSilence::ProcessIndependently().

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

◆ IsSelectedLeader()

bool Track::IsSelectedLeader ( ) const

Definition at line 296 of file Track.cpp.

297 { return IsSelected() && IsLeader(); }
bool IsSelected() const
Definition: Track.cpp:288

References IsLeader(), and IsSelected().

Referenced by TrackList::Selected().

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

◆ LinkConsistencyCheck()

bool Track::LinkConsistencyCheck ( )
inline

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

Definition at line 249 of file Track.h.

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

Referenced by DoSetLinkType().

Here is the caller graph for this function:

◆ LinkConsistencyFix()

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

Check consistency of channel groups, and maybe fix it.

Parameters
doFixwhether to make any changes to correct inconsistencies
Precondition
!doFix || IsLeader()
Returns
true if no inconsistencies were found

Reimplemented in WaveTrack.

Definition at line 299 of file Track.cpp.

300{
301 assert(!doFix || IsLeader());
302 // Sanity checks for linked tracks; unsetting the linked property
303 // doesn't fix the problem, but it likely leaves us with orphaned
304 // sample blocks instead of much worse problems.
305 bool err = false;
306 if (HasLinkedTrack()) /* which implies IsLeader() */ {
307 if (auto link = GetLinkedTrack()) {
308 // A linked track's partner should never itself be linked
309 if (link->HasLinkedTrack()) {
310 err = true;
311 if (doFix) {
312 wxLogWarning(
313 L"Left track %s had linked right track %s with extra right "
314 "track link.\n Removing extra link from right track.",
315 GetName(), link->GetName());
316 link->SetLinkType(LinkType::None);
317 }
318 }
319 }
320 else {
321 err = true;
322 if (doFix) {
323 wxLogWarning(
324 L"Track %s had link to NULL track. Setting it to not be linked.",
325 GetName());
327 }
328 }
329 }
330 return ! err;
331}
void SetLinkType(LinkType linkType, bool completeList=true)
Definition: Track.cpp:140
const wxString & GetName() const
Name is always the same for all channels of a group.
Definition: Track.cpp:56

References GetLinkedTrack(), GetName(), HasLinkedTrack(), IsLeader(), ChannelGroup::None, and SetLinkType().

Referenced by WaveTrack::LinkConsistencyFix().

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

◆ Notify()

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

Definition at line 257 of file Track.cpp.

258{
259 auto pList = mList.lock();
260 if (pList)
261 pList->DataEvent(SharedPointer(), allChannels, code);
262}
std::shared_ptr< Subclass > SharedPointer()
Definition: Track.h:160

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:

◆ OnProjectTempoChange()

void Track::OnProjectTempoChange ( double  newTempo)

method to set project tempo on track

Precondition
IsLeader()

Definition at line 1361 of file Track.cpp.

1362{
1363 assert(IsLeader());
1364 auto &mProjectTempo = GetGroupData().mProjectTempo;
1365 DoOnProjectTempoChange(mProjectTempo, newTempo);
1366 mProjectTempo = newTempo;
1367}
virtual void DoOnProjectTempoChange(const std::optional< double > &oldTempo, double newTempo)=0

References DoOnProjectTempoChange(), GetGroupData(), IsLeader(), and ChannelGroup::ChannelGroupData::mProjectTempo.

Referenced by WaveTrack::DuplicateWithOtherTempo().

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

◆ operator=()

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

◆ Paste() [1/2]

virtual void Track::Paste ( double  t,
const Track src 
)
pure virtual

Weak precondition allows overrides to replicate one channel into many.

Precondition
IsLeader()
SameKindAs(src)
src.NChannels() == 1 || src.NChannels() == NChannels()

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

Referenced by Paste(), and SyncLockAdjust().

Here is the caller graph for this function:

◆ Paste() [2/2]

void Track::Paste ( double  t,
const TrackList src 
)

Non-virtual overload that passes the first track of a given list

Precondition
IsLeader()
SameKindAs(**src.begin()).NChannels()
NChannels == (**src.begin()).NChannels()

Definition at line 264 of file Track.cpp.

265{
266 Paste(t, **src.begin());
267}
virtual void Paste(double t, const Track &src)=0
Weak precondition allows overrides to replicate one channel into many.
iterator begin()
Definition: Track.h:1050

References TrackList::begin(), and Paste().

Here is the call graph for this function:

◆ PasteInto()

virtual Holder Track::PasteInto ( AudacityProject project,
TrackList list 
) const
pure virtual

Find or create the destination track for a paste, maybe in a different project

Precondition
IsLeader()
Parameters
listto which any newly created tracks are added; but left unchanged if an existing track is found in the project instead
Returns
A smart pointer to a leader track

Implemented in NoteTrack, TimeTrack, WaveTrack, and LabelTrack.

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

Here is the caller graph for this function:

◆ ReparentAllAttachments()

void Track::ReparentAllAttachments ( )

◆ SameKindAs()

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

Definition at line 428 of file Track.h.

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

References GetTypeInfo().

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

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

152{ mId = id; }
int id

References id.

Referenced by TrackList::DoAddToHead().

Here is the caller graph for this function:

◆ SetIndex()

void Track::SetIndex ( int  index)
private

Definition at line 135 of file Track.cpp.

136{
137 mIndex = index;
138}

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

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

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

62{
63 auto &name = GetGroupData().mName;
64 if (name != n) {
65 name = n;
66 Notify(true);
67 }
68}
const TranslatableString name
Definition: Distortion.cpp:76
void Notify(bool allChannels, int code=-1)
Definition: Track.cpp:257

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

Referenced by SetTrackStatusCommand::ApplyInner(), TimeTrack::CleanState(), HandleCommonXMLAttribute(), anonymous_namespace{ImportMIDI.cpp}::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:

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

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

References mList, and mNode.

Referenced by TrackList::DoAddToHead(), TrackList::Permute(), and TrackList::SwapNodes().

Here is the caller graph for this function:

◆ SetSelected()

void Track::SetSelected ( bool  s)
virtual

Reimplemented in LabelTrack.

Definition at line 75 of file Track.cpp.

76{
77 auto &selected = GetGroupData().mSelected;
78 if (selected != s) {
79 selected = s;
80 auto pList = mList.lock();
81 if (pList)
82 pList->SelectionEvent(*this);
83 }
84}

References GetGroupData(), mList, and ChannelGroup::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 160 of file Track.h.

161 {
162 // shared_from_this is injected into class scope by base class
163 // std::enable_shared_from_this<Track>
164 return std::static_pointer_cast<Subclass>( shared_from_this() );
165 }

Referenced by SelectHandle::AdjustSelection(), SelectionState::ChangeSelectionOnShiftClick(), WaveTrack::CopyOne(), DEFINE_ATTACHED_VIRTUAL_OVERRIDE(), TimeShiftHandle::DoSlideVertical(), TimeShiftHandle::Drag(), TrackFocus::GetFocus(), SelectHandle::HandleCenterFrequencyClick(), ClipMoveState::Init(), SelectHandle::MoveSnappingFreqSelection(), Notify(), EffectStereoToMono::ProcessOne(), SelectionState::SelectTrack(), TrackFocus::Set(), TrackFocus::SetFocus(), SharedPointer(), RealtimeEffectPanel::ShowPanel(), 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 168 of file Track.h.

172 {
173 // shared_from_this is injected into class scope by base class
174 // std::enable_shared_from_this<Track>
175 return std::static_pointer_cast<Subclass>( shared_from_this() );
176 }

◆ SharedPointer() [3/4]

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

Definition at line 184 of file Track.h.

185 { 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 180 of file Track.h.

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

References SharedPointer().

Here is the call graph for this function:

◆ Silence()

virtual void Track::Silence ( double  t0,
double  t1,
ProgressReporter  reportProgress = {} 
)
pure virtual
Precondition
IsLeader()

Implemented in WaveTrack, NoteTrack, TimeTrack, and LabelTrack.

◆ SubstituteOriginalTrack()

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

Definition at line 1185 of file Track.cpp.

1186{
1187 auto pList = mList.lock();
1188 if (pList && pList->mPendingUpdates) {
1189 const auto id = GetId();
1190 const auto pred = [=]( const ListOfTracks::value_type &ptr ) {
1191 return ptr->GetId() == id; };
1192 const auto end = pList->mPendingUpdates->ListOfTracks::end();
1193 const auto it =
1194 std::find_if(pList->mPendingUpdates->ListOfTracks::begin(), end, pred);
1195 if (it != end) {
1196 const auto &list2 = (const ListOfTracks &) *pList;
1197 const auto end2 = list2.end();
1198 const auto it2 = std::find_if( list2.begin(), end2, pred );
1199 if ( it2 != end2 )
1200 return *it2;
1201 }
1202 }
1203 return SharedPointer();
1204}
std::list< std::shared_ptr< Track > > ListOfTracks
Definition: Track.h:45
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 1164 of file Track.cpp.

1165{
1166 // Linear search. Tracks in a project are usually very few.
1167 auto pList = mList.lock();
1168 if (pList && pList->mPendingUpdates) {
1169 const auto id = GetId();
1170 const auto end = pList->mPendingUpdates->ListOfTracks::end();
1171 auto it = std::find_if(
1172 pList->mPendingUpdates->ListOfTracks::begin(), end,
1173 [=](const ListOfTracks::value_type &ptr){ return ptr->GetId() == id; } );
1174 if (it != end)
1175 return *it;
1176 }
1177 return SharedPointer();
1178}

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

Referenced by anonymous_namespace{TrackPanel.cpp}::DrawTrackName(), 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 1180 of file Track.cpp.

1181{
1182 return const_cast<Track*>(this)->SubstitutePendingChangedTrack();
1183}
std::shared_ptr< Track > SubstitutePendingChangedTrack()
Definition: Track.cpp:1164

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

1214{
1215 return true;
1216}

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

This can be used to adjust a sync-lock selected track when the selection is replaced by one of a different length.

Precondition
IsLeader()

Reimplemented in WaveTrack, and LabelTrack.

Definition at line 269 of file Track.cpp.

270{
271 assert(IsLeader());
272 const auto endTime = GetEndTime();
273 if (newT1 > oldT1 && oldT1 > endTime)
274 return;
275 if (newT1 > oldT1) {
276 auto cutChannels = Cut(oldT1, endTime);
277 assert(NChannels() == cutChannels->NChannels());
278 Paste(newT1, *cutChannels);
279 }
280 else if (newT1 < oldT1)
281 // Remove from the track
282 Clear(newT1, oldT1);
283}
double GetEndTime() const
Get the maximum of End() values of intervals, or 0 when none.
Definition: Channel.cpp:135
virtual size_t NChannels() const =0
Report the number of channels.
virtual void Clear(double t0, double t1)=0
virtual TrackListHolder Cut(double t0, double t1)=0
Create tracks and modify this track.

References Clear(), Cut(), ChannelGroup::GetEndTime(), IsLeader(), ChannelGroup::NChannels(), and Paste().

Here is the call graph for this function:

◆ TypeSwitch() [1/2]

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

◆ TypeSwitch() [2/2]

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

Do a TypeSwitch on this track, among all subtypes enumerated up to the point of the call

Definition at line 447 of file Track.h.

448 {
449 struct Here : TrackTypeTag {};
450 // List more derived classes later
451 using namespace TypeList;
452 using TrackTypes = Map_t<Fn<std::add_const_t>,
454 return TypeSwitch::VDispatch<R, TrackTypes>(*this, functions...);
455 }
Utilities for compile-time type manipulation. Some terminology as in Lisp.
Definition: TypeList.h:22
typename Map< Metafunction, TypeList >::type Map_t
Definition: TypeList.h:262

◆ WriteCommonXMLAttributes()

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

Definition at line 1219 of file Track.cpp.

1221{
1222 if (includeNameAndSelected) {
1223 // May write name and selectedness redundantly for right channels,
1224 // but continue doing that in case the file is opened in Audacity 3.1.x
1225 // which does not have unique ChannelGroupData for the track
1226 xmlFile.WriteAttr(wxT("name"), GetName());
1227 xmlFile.WriteAttr(wxT("isSelected"), this->GetSelected());
1228 }
1229 AttachedTrackObjects::ForEach([&](auto &attachment){
1230 attachment.WriteXMLAttributes( xmlFile );
1231 });
1232}
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(), 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 NoteTrack, TimeTrack, WaveTrack, and LabelTrack.

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

641{
642 using BareType = std::remove_pointer_t< T >;
643 if (track &&
644 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
645 return reinterpret_cast<T>(track);
646 else
647 return nullptr;
648}

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

624{
625 using BareType = std::remove_pointer_t< T >;
626 if (track &&
627 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
628 return reinterpret_cast<T>(track);
629 else
630 return nullptr;
631}

◆ TrackList

friend class TrackList
friend

Definition at line 133 of file Track.h.

Member Data Documentation

◆ mId

TrackId Track::mId
private

Identifies the track only in-session, not persistently.

Definition at line 136 of file Track.h.

Referenced by Init().

◆ mIndex

int Track::mIndex
protected

0-based position of this track in its TrackList

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

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


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