Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
PlayableTrack Class Reference

AudioTrack subclass that can also be audibly replayed by the program. More...

#include <PlayableTrack.h>

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

Public Member Functions

 PlayableTrack ()
 
 PlayableTrack (const PlayableTrack &orig, ProtectedCreationArg &&)
 
bool GetMute () const
 
bool GetSolo () const
 
bool GetNotMute () const
 
bool GetNotSolo () const
 
void SetMute (bool m)
 
void SetSolo (bool s)
 
void WriteXMLAttributes (XMLWriter &xmlFile) const
 
bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &value)
 
- Public Member Functions inherited from AudioTrack
 AudioTrack ()
 
 AudioTrack (const Track &orig, ProtectedCreationArg &&a)
 
void WriteXMLAttributes (XMLWriter &WXUNUSED(xmlFile)) const
 
bool HandleXMLAttribute (const std::string_view &, const XMLAttributeValueView &)
 
- Public Member Functions inherited from Track
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

static const TypeInfoClassTypeInfo ()
 
- Static Public Member Functions inherited from AudioTrack
static const TypeInfoClassTypeInfo ()
 
- Static Public Member Functions inherited from Track
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

bool DoGetMute () const
 
void DoSetMute (bool value)
 
bool DoGetSolo () const
 
void DoSetSolo (bool value)
 
- Protected Member Functions inherited from Track
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...
 

Additional Inherited Members

- Public Types inherited from Track
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
 
- Protected Attributes inherited from Track
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...
 

Detailed Description

AudioTrack subclass that can also be audibly replayed by the program.

An AudioTrack that can be played and stopped.

Definition at line 39 of file PlayableTrack.h.

Constructor & Destructor Documentation

◆ PlayableTrack() [1/2]

PlayableTrack::PlayableTrack ( )

Definition at line 101 of file PlayableTrack.cpp.

101 : AudioTrack{}
102{
103}
Track subclass holding data representing sound (as notes, or samples, or ...)
Definition: PlayableTrack.h:21

◆ PlayableTrack() [2/2]

PlayableTrack::PlayableTrack ( const PlayableTrack orig,
ProtectedCreationArg &&  a 
)

Definition at line 105 of file PlayableTrack.cpp.

107 : AudioTrack{ orig, std::move(a) }
108{
109}

Member Function Documentation

◆ ClassTypeInfo()

auto PlayableTrack::ClassTypeInfo ( )
static

Definition at line 180 of file PlayableTrack.cpp.

181{
182 static Track::TypeInfo info{
183 { "playable", "playable", XO("Playable Track") },
184 false, &AudioTrack::ClassTypeInfo() };
185 return info;
186}
XO("Cut/Copy/Paste")
static const TypeInfo & ClassTypeInfo()

References AudioTrack::ClassTypeInfo(), and XO().

Referenced by typeInfo().

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

◆ DoGetMute()

bool PlayableTrack::DoGetMute ( ) const
protected

Definition at line 127 of file PlayableTrack.cpp.

128{
129 return MuteAndSolo::Get(*this).GetMute();
130}
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:196

References BasicUI::Get().

Referenced by SetMute(), and WriteXMLAttributes().

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

◆ DoGetSolo()

bool PlayableTrack::DoGetSolo ( ) const
protected

Definition at line 137 of file PlayableTrack.cpp.

138{
139 return MuteAndSolo::Get(*this).GetSolo();
140}

References BasicUI::Get().

Referenced by SetSolo(), and WriteXMLAttributes().

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

◆ DoSetMute()

void PlayableTrack::DoSetMute ( bool  value)
protected

Definition at line 132 of file PlayableTrack.cpp.

133{
134 MuteAndSolo::Get(*this).SetMute(value);
135}

References BasicUI::Get().

Referenced by HandleXMLAttribute(), and SetMute().

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

◆ DoSetSolo()

void PlayableTrack::DoSetSolo ( bool  value)
protected

Definition at line 142 of file PlayableTrack.cpp.

143{
144 MuteAndSolo::Get(*this).SetSolo(value);
145}

References BasicUI::Get().

Referenced by HandleXMLAttribute(), and SetSolo().

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

◆ GetMute()

bool PlayableTrack::GetMute ( ) const
inline

Definition at line 47 of file PlayableTrack.h.

47{ return DoGetMute(); }
bool DoGetMute() const

Referenced by TrackUtilities::DoTrackMute(), and WaveTrack::GetMute().

Here is the caller graph for this function:

◆ GetNotMute()

bool PlayableTrack::GetNotMute ( ) const
inline

Definition at line 49 of file PlayableTrack.h.

49{ return !DoGetMute(); }

◆ GetNotSolo()

bool PlayableTrack::GetNotSolo ( ) const
inline

Definition at line 50 of file PlayableTrack.h.

50{ return !DoGetSolo(); }
bool DoGetSolo() const

Referenced by ExportAudioDialog::DoExportSplitByTracks(), ExportUtils::FindExportWaveTracks(), anonymous_namespace{ExportAudioDialog.cpp}::GetNumExportChannels(), and ExportAudioDialog::UpdateTrackExportSettings().

Here is the caller graph for this function:

◆ GetSolo()

bool PlayableTrack::GetSolo ( ) const
inline

Definition at line 48 of file PlayableTrack.h.

48{ return DoGetSolo(); }

Referenced by ProjectFileManager::AddImportedTracks(), anonymous_namespace{ImportMIDI.cpp}::DoImportMIDI(), TrackUtilities::DoTrackSolo(), TrackPanel::DrawTracks(), WaveTrack::GetSolo(), and MixerBoard::HasSolo().

Here is the caller graph for this function:

◆ HandleXMLAttribute()

bool PlayableTrack::HandleXMLAttribute ( const std::string_view &  attr,
const XMLAttributeValueView value 
)

Definition at line 156 of file PlayableTrack.cpp.

157{
158 long nValue;
159
160 if (attr == "mute" && value.TryGet(nValue)) {
161 DoSetMute(nValue != 0);
162 return true;
163 }
164 else if (attr == "solo" && value.TryGet(nValue)) {
165 DoSetSolo(nValue != 0);
166 return true;
167 }
168
169 return AudioTrack::HandleXMLAttribute(attr, value);
170}
bool HandleXMLAttribute(const std::string_view &, const XMLAttributeValueView &)
Definition: PlayableTrack.h:32
void DoSetSolo(bool value)
void DoSetMute(bool value)
bool TryGet(bool &value) const noexcept
Try to get a boolean value from the view.

References DoSetMute(), DoSetSolo(), AudioTrack::HandleXMLAttribute(), and XMLAttributeValueView::TryGet().

Referenced by WaveTrack::HandleXMLTag().

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

◆ SetMute()

void PlayableTrack::SetMute ( bool  m)

Definition at line 111 of file PlayableTrack.cpp.

112{
113 if (DoGetMute() != m) {
114 DoSetMute(m);
115 Notify(true);
116 }
117}
void Notify(bool allChannels, int code=-1)
Definition: Track.cpp:257

References DoGetMute(), DoSetMute(), and Track::Notify().

Referenced by anonymous_namespace{TrackMenus.cpp}::MuteTracks().

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

◆ SetSolo()

void PlayableTrack::SetSolo ( bool  s)

Definition at line 119 of file PlayableTrack.cpp.

120{
121 if (DoGetSolo() != s) {
122 DoSetSolo(s);
123 Notify(true);
124 }
125}

References DoGetSolo(), DoSetSolo(), and Track::Notify().

Referenced by SetTrackAudioCommand::ApplyInner().

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

◆ WriteXMLAttributes()

void PlayableTrack::WriteXMLAttributes ( XMLWriter xmlFile) const

Definition at line 148 of file PlayableTrack.cpp.

149{
150 xmlFile.WriteAttr(wxT("mute"), DoGetMute());
151 xmlFile.WriteAttr(wxT("solo"), DoGetSolo());
153}
wxT("CloseDown"))
void WriteXMLAttributes(XMLWriter &WXUNUSED(xmlFile)) const
Definition: PlayableTrack.h:29
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:36

References DoGetMute(), DoGetSolo(), XMLWriter::WriteAttr(), AudioTrack::WriteXMLAttributes(), and wxT().

Here is the call graph for this function:

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