Audacity 3.2.0
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
TrackList Class Referencefinal

A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list of tracks, event notifications. More...

#include <Track.h>

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

Public Types

using iterator = TrackIter< Track >
 
using const_iterator = TrackIter< const Track >
 
using value_type = Track *
 
using Updater = std::function< void(Track &dest, const Track &src) >
 
- Public Types inherited from Observer::Publisher< TrackListEvent >
using message_type = TrackListEvent
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const TrackListEvent &) >
 Type of functions that can be connected to the Publisher. More...
 

Public Member Functions

 TrackList (AudacityProject *pOwner)
 
void Swap (TrackList &that)
 
virtual ~TrackList ()
 
AudacityProjectGetOwner ()
 
const AudacityProjectGetOwner () const
 
wxString MakeUniqueTrackName (const wxString &baseTrackName) const
 Returns string that contains baseTrackName, but is guaranteed to be unique among other tracks in that list. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
template<typename TrackType = Track>
auto Find (Track *pTrack) -> TrackIter< TrackType >
 Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track. More...
 
template<typename TrackType = const Track>
auto Find (const Track *pTrack) const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIter< TrackType > >
 Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track. More...
 
TrackIter< TrackFindLeader (Track *pTrack)
 
TrackIter< const TrackFindLeader (const Track *pTrack) const
 
template<typename TrackType = Track>
auto Any () -> TrackIterRange< TrackType >
 
template<typename TrackType = const Track>
auto Any () const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
 
template<typename TrackType = Track>
auto Selected () -> TrackIterRange< TrackType >
 
template<typename TrackType = const Track>
auto Selected () const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
 
template<typename TrackType = Track>
auto Leaders () -> TrackIterRange< TrackType >
 
template<typename TrackType = const Track>
auto Leaders () const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
 
template<typename TrackType = Track>
auto SelectedLeaders () -> TrackIterRange< TrackType >
 
template<typename TrackType = const Track>
auto SelectedLeaders () const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
 
void Permute (const std::vector< TrackNodePointer > &permutation)
 For use in sorting: assume each iterator points into this list, no duplications. More...
 
TrackFindById (TrackId id)
 
template<typename TrackKind >
TrackKind * AddToHead (const std::shared_ptr< TrackKind > &t)
 Add a Track, giving it a fresh id. More...
 
template<typename TrackKind >
TrackKind * Add (const std::shared_ptr< TrackKind > &t)
 
void UnlinkChannels (Track &track)
 Removes linkage if track belongs to a group. More...
 
bool MakeMultiChannelTrack (Track &first, int nChannels, bool aligned)
 Converts channels to a multichannel track. More...
 
ListOfTracks::value_type Replace (Track *t, const ListOfTracks::value_type &with)
 
TrackNodePointer Remove (Track *t)
 Remove the Track and return an iterator to what followed it. More...
 
void Clear (bool sendEvent=true)
 Make the list empty. More...
 
bool CanMoveUp (Track *t) const
 
bool CanMoveDown (Track *t) const
 
bool MoveUp (Track *t)
 
bool MoveDown (Track *t)
 
bool Move (Track *t, bool up)
 
bool Contains (const Track *t) const
 Mainly a test function. Uses a linear search, so could be slow. More...
 
template<typename Subclass >
std::shared_ptr< Subclass > Lock (const std::weak_ptr< Subclass > &wTrack)
 
bool empty () const
 
size_t size () const
 
double GetStartTime () const
 
double GetEndTime () const
 
double GetMinOffset () const
 
std::shared_ptr< TrackRegisterPendingChangedTrack (Updater updater, Track *src)
 
void RegisterPendingNewTrack (const std::shared_ptr< Track > &pTrack)
 
void UpdatePendingTracks ()
 
void ClearPendingTracks (ListOfTracks *pAdded=nullptr)
 
bool ApplyPendingTracks ()
 
bool HasPendingTracks () const
 
- Public Member Functions inherited from Observer::Publisher< TrackListEvent >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Static Public Member Functions

static TrackListGet (AudacityProject &project)
 
static const TrackListGet (const AudacityProject &project)
 
static TrackListFindUndoTracks (const UndoStackElem &state)
 
static std::shared_ptr< TrackListCreate (AudacityProject *pOwner)
 
template<typename TrackType >
static auto SingletonRange (TrackType *pTrack) -> TrackIterRange< TrackType >
 
template<typename TrackType >
static auto Channels (TrackType *pTrack) -> TrackIterRange< TrackType >
 
static bool SwapChannels (Track &track)
 If the given track is one of a pair of channels, swap them. More...
 

Private Member Functions

 TrackList (const TrackList &that)=delete
 
TrackListoperator= (const TrackList &)=delete
 
 TrackList (TrackList &&that)=delete
 
TrackListoperator= (TrackList &&)=delete
 
void clear ()=delete
 
TrackDoAddToHead (const std::shared_ptr< Track > &t)
 
TrackDoAdd (const std::shared_ptr< Track > &t)
 
template<typename TrackType = Track, typename Pred = typename TrackIterRange< TrackType >::iterator::FunctionType>
auto Tracks (const Pred &pred={}) -> TrackIterRange< TrackType >
 
template<typename TrackType = const Track, typename Pred = typename TrackIterRange< TrackType >::iterator::FunctionType>
auto Tracks (const Pred &pred={}) const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
 
TrackGetPrev (Track *t, bool linked=false) const
 
TrackGetNext (Track *t, bool linked=false) const
 Return a track in the list that comes after Track t. More...
 
template<typename TrackType >
TrackIter< TrackType > MakeTrackIterator (TrackNodePointer iter) const
 
template<typename TrackType >
TrackIter< TrackType > EndIterator () const
 
TrackIterRange< TrackEmptyRange () const
 
bool isNull (TrackNodePointer p) const
 
TrackNodePointer getEnd () const
 
TrackNodePointer getBegin () const
 
TrackNodePointer getNext (TrackNodePointer p) const
 Move an iterator to the next node, if any; else stay at end. More...
 
TrackNodePointer getPrev (TrackNodePointer p) const
 Move an iterator to the previous node, if any; else wrap to end. More...
 
void RecalcPositions (TrackNodePointer node)
 
void QueueEvent (TrackListEvent event)
 
void SelectionEvent (const std::shared_ptr< Track > &pTrack)
 
void PermutationEvent (TrackNodePointer node)
 
void DataEvent (const std::shared_ptr< Track > &pTrack, int code)
 
void EnsureVisibleEvent (const std::shared_ptr< Track > &pTrack, bool modifyState)
 
void DeletionEvent (std::weak_ptr< Track > node, bool duringReplace)
 
void AdditionEvent (TrackNodePointer node)
 
void ResizingEvent (TrackNodePointer node)
 
void SwapNodes (TrackNodePointer s1, TrackNodePointer s2)
 

Static Private Member Functions

template<typename TrackType , typename InTrackType >
static TrackIterRange< TrackType > Channels_ (TrackIter< InTrackType > iter1)
 

Private Attributes

AudacityProjectmOwner
 
ListOfTracks mPendingUpdates
 Shadow tracks holding append-recording in progress; need to put them into a list so that GetLink() works. More...
 
std::vector< UpdatermUpdaters
 This is in correspondence with mPendingUpdates. More...
 

Static Private Attributes

static long sCounter = -1
 

Friends

class Track
 

Additional Inherited Members

- Static Public Attributes inherited from Observer::Publisher< TrackListEvent >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from Observer::Publisher< TrackListEvent >
CallbackReturn Publish (const TrackListEvent &message)
 Send a message to connected callbacks. More...
 

Detailed Description

A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list of tracks, event notifications.

Definition at line 1334 of file Track.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 1391 of file Track.h.

◆ iterator

Definition at line 1390 of file Track.h.

◆ Updater

using TrackList::Updater = std::function< void(Track &dest, const Track &src) >

Definition at line 1729 of file Track.h.

◆ value_type

Definition at line 1392 of file Track.h.

Constructor & Destructor Documentation

◆ TrackList() [1/3]

TrackList::TrackList ( const TrackList that)
privatedelete

◆ TrackList() [2/3]

TrackList::TrackList ( TrackList &&  that)
privatedelete

◆ TrackList() [3/3]

TrackList::TrackList ( AudacityProject pOwner)
explicit

Definition at line 497 of file Track.cpp.

498 : mOwner{ pOwner }
499{
500}
AudacityProject * mOwner
Definition: Track.h:1774

◆ ~TrackList()

TrackList::~TrackList ( )
virtual

Definition at line 539 of file Track.cpp.

540{
541 Clear(false);
542}
void Clear(bool sendEvent=true)
Make the list empty.
Definition: Track.cpp:820

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ Add()

template<typename TrackKind >
TrackKind * TrackList::Add ( const std::shared_ptr< TrackKind > &  t)
inline

Definition at line 1567 of file Track.h.

1568 { return static_cast< TrackKind* >( DoAdd( t ) ); }
Track * DoAdd(const std::shared_ptr< Track > &t)
Definition: Track.cpp:712

Referenced by ApplyPendingTracks(), LabelTrack::Create(), EffectBase::DoEffect(), anonymous_namespace{EditMenus.cpp}::FinishCopy(), AUPImportFileHandle::HandleLabelTrack(), AUPImportFileHandle::HandleNoteTrack(), AUPImportFileHandle::HandleTimeTrack(), AUPImportFileHandle::HandleWaveTrack(), EffectBase::Preview(), EffectBase::ReplaceProcessedTracks(), anonymous_namespace{Track.cpp}::TrackListRestorer::TrackListRestorer(), and LabelDialog::TransferDataFromWindow().

Here is the caller graph for this function:

◆ AdditionEvent()

void TrackList::AdditionEvent ( TrackNodePointer  node)
private

Definition at line 625 of file Track.cpp.

626{
627 QueueEvent({ TrackListEvent::ADDITION, *node.first });
628}
void QueueEvent(TrackListEvent event)
Definition: Track.cpp:588
@ ADDITION
Posted when a track has been added to a tracklist. Also posted when one track replaces another.
Definition: Track.h:1308

References TrackListEvent::ADDITION, and QueueEvent().

Referenced by ApplyPendingTracks(), DoAdd(), and DoAddToHead().

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

◆ AddToHead()

template<typename TrackKind >
TrackKind * TrackList::AddToHead ( const std::shared_ptr< TrackKind > &  t)
inline

Add a Track, giving it a fresh id.

Definition at line 1563 of file Track.h.

1564 { return static_cast< TrackKind* >( DoAddToHead( t ) ); }
Track * DoAddToHead(const std::shared_ptr< Track > &t)
Definition: Track.cpp:700

◆ Any() [1/2]

template<typename TrackType = Track>
auto TrackList::Any ( ) -> TrackIterRange< TrackType >
inline

Definition at line 1440 of file Track.h.

1442 {
1443 return Tracks< TrackType >();
1444 }

Referenced by anonymous_namespace{Track.cpp}::Accumulate(), ImportCommand::Apply(), LabelDefaultClickHandle::Click(), Effect::CopyInputTracks(), ExportMultipleDialog::CountTracksAndLabels(), ExportPlugin::CreateMixer(), anonymous_namespace{EditMenus.cpp}::CutCopyAvailableFlag(), LabelTrackView::DoKeyDown(), LyricsPanel::DoUpdateLyrics(), TrackPanel::DrawTracks(), anonymous_namespace{LabelMenus.cpp}::EditByLabel(), anonymous_namespace{LabelMenus.cpp}::EditClipboardByLabel(), ControlToolBar::EnableDisableButtons(), TranscriptionToolBar::EnableDisableButtons(), GetInfoCommand::ExploreTrackPanel(), ExportMultipleDialog::ExportMultipleByTrack(), LabelDialog::FindAllLabels(), anonymous_namespace{Snap.cpp}::FindCandidates(), anonymous_namespace{TimeShiftHandle.cpp}::FindCorrespondence(), anonymous_namespace{EditMenus.cpp}::ForEachCopiedWaveTrack(), GetAllSeqBlocks(), GetNumExportChannels(), TrackView::GetTotalHeight(), anonymous_namespace{EditMenus.cpp}::HasHiddenData(), MixerBoard::HasSolo(), ClipMoveState::Init(), LabelTracksExistFlag(), MakeUniqueTrackName(), anonymous_namespace{ExportMIDI.cpp}::NoteTracksExistFlag(), ProjectAudioManager::OnRecord(), LabelDialog::OnSelectCell(), ScreenshotBigDialog::OnShortTracks(), anonymous_namespace{TimerRecordDialog.cpp}::OnTimerRecord(), TranscriptionToolBar::PlayAtSpeed(), EffectBase::Preview(), EffectFindClipping::Process(), RealtimeEffectPanel::RealtimeEffectPanel(), SelectionStateChanger::SelectionStateChanger(), SelectionState::SelectNone(), SelectionState::SelectRangeOfTracks(), TracksExistFlag(), LabelDialog::TransferDataFromWindow(), TransportTracks::TransportTracks(), TrackPanel::UpdateVRulerSize(), VisitBlocks(), WaveTracksExistFlag(), ZoomInAvailableFlag(), ZoomOutAvailableFlag(), and SelectionStateChanger::~SelectionStateChanger().

Here is the caller graph for this function:

◆ Any() [2/2]

template<typename TrackType = const Track>
auto TrackList::Any ( ) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIterRange< TrackType > >
inline

Definition at line 1447 of file Track.h.

1451 {
1452 return Tracks< TrackType >();
1453 }

◆ ApplyPendingTracks()

bool TrackList::ApplyPendingTracks ( )
Exception safety guarantee:
Strong

Definition at line 1145 of file Track.cpp.

1146{
1147 bool result = false;
1148
1149 ListOfTracks additions;
1150 ListOfTracks updates;
1151 {
1152 // Always clear, even if one of the update functions throws
1153 auto cleanup = finally( [&] { ClearPendingTracks( &additions ); } );
1155 updates.swap( mPendingUpdates );
1156 }
1157
1158 // Remaining steps must be No-fail-guarantee so that this function
1159 // gives Strong-guarantee
1160
1161 std::vector< std::shared_ptr<Track> > reinstated;
1162
1163 for (auto &pendingTrack : updates) {
1164 if (pendingTrack) {
1165 pendingTrack->AttachedTrackObjects::ForEach([&](auto &attachment){
1166 attachment.Reparent( pendingTrack );
1167 });
1168 auto src = FindById( pendingTrack->GetId() );
1169 if (src)
1170 this->Replace(src, pendingTrack), result = true;
1171 else
1172 // Perhaps a track marked for pending changes got deleted by
1173 // some other action. Recreate it so we don't lose the
1174 // accumulated changes.
1175 reinstated.push_back(pendingTrack);
1176 }
1177 }
1178
1179 // If there are tracks to reinstate, append them to the list.
1180 for (auto &pendingTrack : reinstated)
1181 if (pendingTrack)
1182 this->Add( pendingTrack ), result = true;
1183
1184 // Put the pending added tracks back into the list, preserving their
1185 // positions.
1186 bool inserted = false;
1187 ListOfTracks::iterator first;
1188 for (auto &pendingTrack : additions) {
1189 if (pendingTrack) {
1190 auto iter = ListOfTracks::begin();
1191 std::advance( iter, pendingTrack->GetIndex() );
1192 iter = ListOfTracks::insert( iter, pendingTrack );
1193 pendingTrack->SetOwner( shared_from_this(), {iter, this} );
1194 pendingTrack->SetId( TrackId{ ++sCounter } );
1195 if (!inserted) {
1196 first = iter;
1197 inserted = true;
1198 }
1199 }
1200 }
1201 if (inserted) {
1202 TrackNodePointer node{first, this};
1203 RecalcPositions(node);
1204 AdditionEvent(node);
1205 result = true;
1206 }
1207
1208 return result;
1209}
std::pair< ListOfTracks::iterator, ListOfTracks * > TrackNodePointer
Pairs a std::list iterator and a pointer to a list, for comparison purposes.
Definition: Track.h:49
std::list< std::shared_ptr< Track > > ListOfTracks
Definition: Track.h:43
An in-session identifier of track objects across undo states. It does not persist between sessions.
Definition: Track.h:152
static long sCounter
Definition: Track.h:1726
ListOfTracks::value_type Replace(Track *t, const ListOfTracks::value_type &with)
Definition: Track.cpp:725
TrackKind * Add(const std::shared_ptr< TrackKind > &t)
Definition: Track.h:1567
void AdditionEvent(TrackNodePointer node)
Definition: Track.cpp:625
void RecalcPositions(TrackNodePointer node)
Definition: Track.cpp:565
void ClearPendingTracks(ListOfTracks *pAdded=nullptr)
Definition: Track.cpp:1104
void UpdatePendingTracks()
Definition: Track.cpp:1086
Track * FindById(TrackId id)
Definition: Track.cpp:689
ListOfTracks mPendingUpdates
Shadow tracks holding append-recording in progress; need to put them into a list so that GetLink() wo...
Definition: Track.h:1778
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150

References Add(), AdditionEvent(), PackedArray::begin(), ClearPendingTracks(), FindById(), mPendingUpdates, RecalcPositions(), Replace(), sCounter, and UpdatePendingTracks().

Referenced by ProjectAudioManager::OnCommitRecording().

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

◆ begin() [1/2]

iterator TrackList::begin ( )
inline

Definition at line 1393 of file Track.h.

1393{ return Any().begin(); }
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1440

Referenced by TimeShiftHandle::DoSlideVertical(), empty(), HasPendingTracks(), and EffectTruncSilence::ProcessAll().

Here is the caller graph for this function:

◆ begin() [2/2]

const_iterator TrackList::begin ( ) const
inline

Definition at line 1395 of file Track.h.

1395{ return Any().begin(); }

◆ CanMoveDown()

bool TrackList::CanMoveDown ( Track t) const

Definition at line 911 of file Track.cpp.

912{
913 return GetNext(t, true) != NULL;
914}
Track * GetNext(Track *t, bool linked=false) const
Return a track in the list that comes after Track t.
Definition: Track.cpp:851

References GetNext().

Here is the call graph for this function:

◆ CanMoveUp()

bool TrackList::CanMoveUp ( Track t) const

Definition at line 906 of file Track.cpp.

907{
908 return GetPrev(t, true) != NULL;
909}
Track * GetPrev(Track *t, bool linked=false) const
Definition: Track.cpp:870

References GetPrev().

Here is the call graph for this function:

◆ cbegin()

const_iterator TrackList::cbegin ( ) const
inline

Definition at line 1397 of file Track.h.

1397{ return begin(); }
iterator begin()
Definition: Track.h:1393

References PackedArray::begin().

Here is the call graph for this function:

◆ cend()

const_iterator TrackList::cend ( ) const
inline

Definition at line 1398 of file Track.h.

1398{ return end(); }
iterator end()
Definition: Track.h:1394

References PackedArray::end().

Here is the call graph for this function:

◆ Channels()

template<typename TrackType >
static auto TrackList::Channels ( TrackType *  pTrack) -> TrackIterRange< TrackType >
inlinestatic

Definition at line 1544 of file Track.h.

1546 {
1547 return Channels_<TrackType>( pTrack->GetOwner()->FindLeader(pTrack) );
1548 }

Referenced by AppendItem(), SelectTracksCommand::Apply(), SetTrackBase::Apply(), WaveTrackView::CaptureKey(), anonymous_namespace{ClipMenus.cpp}::ChannelsHaveDifferentClipBoundaries(), anonymous_namespace{TrackPanel.cpp}::ResizingChannelGroup::Children(), anonymous_namespace{TrackPanel.cpp}::Subgroup::Children(), anonymous_namespace{TrackPanel.cpp}::ChannelGroup::Children(), ProjectAudioManager::ChooseExistingRecordingTracks(), TrackPanelResizeHandle::Click(), CutlineHandle::Click(), EnvelopeHandle::Click(), WaveformPrefs::Commit(), MinimizeButtonHandle::CommitChanges(), TrackShifter::CommonMayMigrateTo(), WaveTrackView::CopySelectedText(), WaveTrackView::CutSelectedText(), anonymous_namespace{TrackMenus.cpp}::DoAlign(), anonymous_namespace{ClipMenus.cpp}::DoClipMove(), WaveTrackSubView::DoDetailedHitTest(), WaveformVRulerControls::DoHandleWheelRotation(), SpectrumVRulerControls::DoHandleWheelRotation(), ClipMoveState::DoHorizontalOffset(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), TrackUtilities::DoRemoveTrack(), anonymous_namespace{TrackMenus.cpp}::DoSortTracks(), TrackUtilities::DoTrackMute(), TrackUtilities::DoTrackSolo(), SpectrumVZoomHandle::DoZoom(), WaveformVZoomHandle::DoZoom(), TrackPanelResizeHandle::Drag(), anonymous_namespace{TrackPanel.cpp}::ChannelGroup::Draw(), TrackPanelResizerCell::Draw(), SpectrumView::Draw(), WaveformView::Draw(), ExportMultipleDialog::ExportMultipleByTrack(), anonymous_namespace{TrackPanel.cpp}::FindAdjustedChannelHeights(), anonymous_namespace{Mix.cpp}::FindBufferSize(), anonymous_namespace{ClipMenus.cpp}::FindClipBoundaries(), anonymous_namespace{ClipMenus.cpp}::FindClips(), anonymous_namespace{WaveClipTrimHandle.cpp}::FindClipsInChannels(), anonymous_namespace{RealtimeEffectManager.cpp}::FindStates(), anonymous_namespace{EditMenus.cpp}::ForEachCopiedWaveTrack(), MixerSource::GetChannel(), TrackView::GetChannelGroupHeight(), ContrastDialog::GetDB(), CommonTrackView::GetMinimizedHeight(), MixerTrackCluster::GetRight(), VampEffect::Init(), ClipMoveState::Init(), TrackPanelAx::IsFocused(), LOFImportFileHandle::lofOpenFiles(), AudioGraph::MakeChannelMap(), anonymous_namespace{EffectStage.cpp}::MakeInstances(), MixAndRender(), MixerSource::MixerSource(), TrackPanel::OnEnsureVisible(), FormatMenuTable::OnFormatChange(), WaveTrackMenuTable::OnMultiView(), anonymous_namespace{EditMenus.cpp}::OnPaste(), WaveTrackMenuTable::OnSetDisplay(), TrackMenuTable::OnSetName(), SpectrumVRulerMenuTable::OnSpectrumScaleType(), anonymous_namespace{EditMenus.cpp}::OnSplit(), WaveTrackMenuTable::OnSwapChannels(), WaveColorMenuTable::OnWaveColorChange(), WaveformVRulerMenuTable::OnWaveformScaleType(), WaveTrackView::PasteText(), SpectrumPrefs::Preview(), EffectLoudness::Process(), EffectNormalize::Process(), NyquistEffect::Process(), EffectSBSMS::Process(), EffectStereoToMono::Process(), VampEffect::Process(), EffectTruncSilence::ProcessIndependently(), NyquistEffect::ProcessOne(), PerTrackEffect::ProcessPass(), AudioIO::ProcessPlaybackSlices(), TrackPanel::RefreshTrack(), SpectrumPrefs::Rollback(), WaveTrackView::SelectAllText(), anonymous_namespace{WaveTrackAffordanceControls.cpp}::SelectedClipOfFocusedTrack(), SelectionState::SelectTrack(), SelectionState::SelectTrackLength(), GetInfoCommand::SendTracks(), TrackView::SetMinimized(), RateMenuTable::SetRate(), anonymous_namespace{TrackMenus.cpp}::SetTrackGain(), anonymous_namespace{TrackMenus.cpp}::SetTrackPan(), GainSliderHandle::SetValue(), PanSliderHandle::SetValue(), ScreenshotBigDialog::SizeTracks(), WaveTrackMenuTable::SplitStereo(), anonymous_namespace{WaveTrackControls.cpp}::Status1DrawFunction(), SwapNodes(), TrackPanelResizeHandle::TrackPanelResizeHandle(), AudioIO::TransformPlayBuffers(), AudioIoCallback::TransportState::TransportState(), UnlinkChannels(), and TrackPanel::UpdateTrackVRuler().

◆ Channels_()

template<typename TrackType , typename InTrackType >
static TrackIterRange< TrackType > TrackList::Channels_ ( TrackIter< InTrackType >  iter1)
inlinestaticprivate

Definition at line 1522 of file Track.h.

1523 {
1524 // Assume iterator filters leader tracks
1525 if (*iter1) {
1526 return {
1527 iter1.Filter( &Track::Any )
1528 .template Filter<TrackType>(),
1529 (++iter1).Filter( &Track::Any )
1530 .template Filter<TrackType>()
1531 };
1532 }
1533 else
1534 // empty range
1535 return {
1536 iter1.template Filter<TrackType>(),
1537 iter1.template Filter<TrackType>()
1538 };
1539 }
bool Any() const
Definition: Track.cpp:400
TrackIter Filter(const Predicate2 &pred2) const
Return an iterator that replaces the predicate.
Definition: Track.h:1033

References Track::Any(), and TrackIter< TrackType >::Filter().

Here is the call graph for this function:

◆ clear()

void TrackList::clear ( )
privatedelete

◆ Clear()

void TrackList::Clear ( bool  sendEvent = true)

Make the list empty.

Definition at line 820 of file Track.cpp.

821{
822 // Null out the back-pointers to this in tracks, in case there
823 // are outstanding shared_ptrs to those tracks, making them outlive
824 // the temporary ListOfTracks below.
825 for ( auto pTrack: *this )
826 {
827 pTrack->SetOwner({}, {});
828
829 if (sendEvent)
830 DeletionEvent(pTrack->shared_from_this(), false);
831 }
832
833 for ( auto pTrack: mPendingUpdates )
834 {
835 pTrack->SetOwner({}, {});
836
837 if (sendEvent)
838 DeletionEvent(pTrack, false);
839 }
840
841 ListOfTracks tempList;
842 tempList.swap( *this );
843
844 ListOfTracks updating;
845 updating.swap( mPendingUpdates );
846
847 mUpdaters.clear();
848}
std::vector< Updater > mUpdaters
This is in correspondence with mPendingUpdates.
Definition: Track.h:1780
void DeletionEvent(std::weak_ptr< Track > node, bool duringReplace)
Definition: Track.cpp:619

References DeletionEvent(), mPendingUpdates, and mUpdaters.

Referenced by ~TrackList().

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

◆ ClearPendingTracks()

void TrackList::ClearPendingTracks ( ListOfTracks pAdded = nullptr)
Exception safety guarantee:
No-fail

Definition at line 1104 of file Track.cpp.

1105{
1106 for (const auto &pTrack: mPendingUpdates)
1107 pTrack->SetOwner( {}, {} );
1108 mPendingUpdates.clear();
1109 mUpdaters.clear();
1110
1111 if (pAdded)
1112 pAdded->clear();
1113
1114 // To find the first node that remains after the first deleted one
1115 TrackNodePointer node;
1116 bool foundNode = false;
1117
1118 for (auto it = ListOfTracks::begin(), stop = ListOfTracks::end();
1119 it != stop;) {
1120 if (it->get()->GetId() == TrackId{}) {
1121 do {
1122 if (pAdded)
1123 pAdded->push_back( *it );
1124 (*it)->SetOwner( {}, {} );
1125 DeletionEvent(*it, false);
1126 it = erase( it );
1127 }
1128 while (it != stop && it->get()->GetId() == TrackId{});
1129
1130 if (!foundNode && it != stop) {
1131 node = (*it)->GetNode();
1132 foundNode = true;
1133 }
1134 }
1135 else
1136 ++it;
1137 }
1138
1139 if (!empty()) {
1141 }
1142}
bool empty() const
Definition: Track.cpp:1010
TrackNodePointer getBegin() const
Definition: Track.h:1684
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References PackedArray::begin(), DeletionEvent(), empty(), PackedArray::end(), getBegin(), mPendingUpdates, mUpdaters, and RecalcPositions().

Referenced by ApplyPendingTracks(), ProjectAudioManager::CancelRecording(), and AudacityApp::OnExceptionInMainLoop().

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

◆ Contains()

bool TrackList::Contains ( const Track t) const

Mainly a test function. Uses a linear search, so could be slow.

Definition at line 1005 of file Track.cpp.

1006{
1007 return make_iterator_range( *this ).contains( t );
1008}
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:448

References make_iterator_range().

Here is the call graph for this function:

◆ Create()

std::shared_ptr< TrackList > TrackList::Create ( AudacityProject pOwner)
static

◆ DataEvent()

void TrackList::DataEvent ( const std::shared_ptr< Track > &  pTrack,
int  code 
)
private

Definition at line 601 of file Track.cpp.

602{
603 QueueEvent({
604 TrackListEvent::TRACK_DATA_CHANGE, pTrack, code });
605}
@ TRACK_DATA_CHANGE
Posted when certain fields of a track change.
Definition: Track.h:1295

References QueueEvent(), and TrackListEvent::TRACK_DATA_CHANGE.

Here is the call graph for this function:

◆ DeletionEvent()

void TrackList::DeletionEvent ( std::weak_ptr< Track node,
bool  duringReplace 
)
private

Definition at line 619 of file Track.cpp.

620{
622 { TrackListEvent::DELETION, std::move(node), duringReplace ? 1 : 0 });
623}
@ DELETION
Posted when a track has been deleted from a tracklist. Also posted when one track replaces another.
Definition: Track.h:1314

References TrackListEvent::DELETION, and QueueEvent().

Referenced by Clear(), ClearPendingTracks(), and Remove().

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

◆ DoAdd()

Track * TrackList::DoAdd ( const std::shared_ptr< Track > &  t)
private

Definition at line 712 of file Track.cpp.

713{
714 push_back(t);
715
716 auto n = getPrev( getEnd() );
717
718 t->SetOwner(shared_from_this(), n);
719 t->SetId( TrackId{ ++sCounter } );
721 AdditionEvent(n);
722 return back().get();
723}
TrackNodePointer getEnd() const
Definition: Track.h:1681
TrackNodePointer getPrev(TrackNodePointer p) const
Move an iterator to the previous node, if any; else wrap to end.
Definition: Track.h:1699

References AdditionEvent(), getEnd(), getPrev(), RecalcPositions(), and sCounter.

Here is the call graph for this function:

◆ DoAddToHead()

Track * TrackList::DoAddToHead ( const std::shared_ptr< Track > &  t)
private

Definition at line 700 of file Track.cpp.

701{
702 Track *pTrack = t.get();
703 push_front(ListOfTracks::value_type(t));
704 auto n = getBegin();
705 pTrack->SetOwner(shared_from_this(), n);
706 pTrack->SetId( TrackId{ ++sCounter } );
708 AdditionEvent(n);
709 return front().get();
710}
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:226
void SetOwner(const std::weak_ptr< TrackList > &list, TrackNodePointer node)
Update mNode when Track is added to TrackList, or removed from it.
Definition: Track.cpp:135
void SetId(TrackId id)
Definition: Track.h:290

References AdditionEvent(), getBegin(), RecalcPositions(), sCounter, Track::SetId(), and Track::SetOwner().

Here is the call graph for this function:

◆ empty()

bool TrackList::empty ( ) const

Definition at line 1010 of file Track.cpp.

1011{
1012 return begin() == end();
1013}

References begin(), and end().

Referenced by anonymous_namespace{Track.cpp}::Accumulate(), ClearPendingTracks(), ProjectFileManager::Import(), ApplyMacroDialog::OnApplyToFiles(), and size().

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

◆ EmptyRange()

auto TrackList::EmptyRange ( ) const
private

Definition at line 635 of file Track.cpp.

637{
638 auto it = const_cast<TrackList*>(this)->getEnd();
639 return {
640 { it, it, it, &Track::Any },
641 { it, it, it, &Track::Any }
642 };
643}
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1339

References Track::Any(), and getEnd().

Here is the call graph for this function:

◆ end() [1/2]

iterator TrackList::end ( )
inline

Definition at line 1394 of file Track.h.

1394{ return Any().end(); }

Referenced by TimeShiftHandle::DoSlideVertical(), empty(), FindUndoTracks(), HasPendingTracks(), MakeMultiChannelTrack(), and RecalcPositions().

Here is the caller graph for this function:

◆ end() [2/2]

const_iterator TrackList::end ( ) const
inline

Definition at line 1396 of file Track.h.

1396{ return Any().end(); }

◆ EndIterator()

template<typename TrackType >
TrackIter< TrackType > TrackList::EndIterator ( ) const
inlineprivate

Definition at line 1670 of file Track.h.

1671 {
1672 auto e = const_cast<TrackList*>(this)->getEnd();
1673 return { e, e, e };
1674 }

◆ EnsureVisibleEvent()

void TrackList::EnsureVisibleEvent ( const std::shared_ptr< Track > &  pTrack,
bool  modifyState 
)
private

Definition at line 607 of file Track.cpp.

609{
611 pTrack, static_cast<int>(modifyState) });
612}
@ TRACK_REQUEST_VISIBLE
Posted when a track needs to be scrolled into view.
Definition: Track.h:1298

References QueueEvent(), and TrackListEvent::TRACK_REQUEST_VISIBLE.

Here is the call graph for this function:

◆ Find() [1/2]

template<typename TrackType = const Track>
auto TrackList::Find ( const Track pTrack) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIter< TrackType > >
inline

Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track.

const overload will only produce iterators over const TrackType

Definition at line 1414 of file Track.h.

1418 {
1419 if (!pTrack || pTrack->GetOwner().get() != this)
1420 return EndIterator<TrackType>();
1421 else
1422 return MakeTrackIterator<TrackType>( pTrack->GetNode() );
1423 }
TrackNodePointer GetNode() const
Retrieve mNode with debug checks.
Definition: Track.cpp:128
std::shared_ptr< TrackList > GetOwner() const
Definition: Track.h:410

◆ Find() [2/2]

template<typename TrackType = Track>
auto TrackList::Find ( Track pTrack) -> TrackIter< TrackType >
inline

Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track.

Definition at line 1402 of file Track.h.

1404 {
1405 if (!pTrack || pTrack->GetOwner().get() != this)
1406 return EndIterator<TrackType>();
1407 else
1408 return MakeTrackIterator<TrackType>( pTrack->GetNode() );
1409 }

Referenced by TimeShiftHandle::DoSlideVertical(), anonymous_namespace{TimeShiftHandle.cpp}::FindCorrespondence(), anonymous_namespace{TrackView.cpp}::TrackPositioner::OnUpdate(), and RecalcPositions().

Here is the caller graph for this function:

◆ FindById()

Track * TrackList::FindById ( TrackId  id)

Definition at line 689 of file Track.cpp.

690{
691 // Linear search. Tracks in a project are usually very few.
692 // Search only the non-pending tracks.
693 auto it = std::find_if( ListOfTracks::begin(), ListOfTracks::end(),
694 [=](const ListOfTracks::value_type &ptr){ return ptr->GetId() == id; } );
695 if (it == ListOfTracks::end())
696 return {};
697 return it->get();
698}

References PackedArray::begin(), and PackedArray::end().

Referenced by ApplyPendingTracks(), TrackPanelAx::IsFocused(), and UpdatePendingTracks().

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

◆ FindLeader() [1/2]

TrackIter< const Track > TrackList::FindLeader ( const Track pTrack) const
inline

Definition at line 1432 of file Track.h.

1433 {
1434 return const_cast<TrackList*>(this)->
1435 FindLeader( const_cast<Track*>(pTrack) ).Filter< const Track >();
1436 }
TrackIter< Track > FindLeader(Track *pTrack)
Definition: Track.cpp:645

◆ FindLeader() [2/2]

auto TrackList::FindLeader ( Track pTrack)

Definition at line 645 of file Track.cpp.

647{
648 auto iter = Find(pTrack);
649 while( *iter && ! ( *iter )->IsLeader() )
650 --iter;
651 return iter.Filter( &Track::IsLeader );
652}
bool IsLeader() const
Definition: Track.cpp:406
auto Find(Track *pTrack) -> TrackIter< TrackType >
Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track.
Definition: Track.h:1402

References ActiveProjects::Find(), and Track::IsLeader().

Referenced by TrackPanel::FindTrackRect(), TrackPanel::RefreshTrack(), TrackFocus::Set(), and SwapNodes().

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

◆ FindUndoTracks()

TrackList * TrackList::FindUndoTracks ( const UndoStackElem state)
static

Definition at line 1395 of file Track.cpp.

1396{
1397 auto &exts = state.state.extensions;
1398 auto end = exts.end(),
1399 iter = std::find_if(exts.begin(), end, [](auto &pExt){
1400 return dynamic_cast<TrackListRestorer*>(pExt.get());
1401 });
1402 if (iter != end)
1403 return static_cast<TrackListRestorer*>(iter->get())->mpTracks.get();
1404 return nullptr;
1405}
static const auto exts
Definition: ImportAUP.cpp:56
UndoState state
Definition: UndoManager.h:128
Extensions extensions
Definition: UndoManager.h:114

References end(), UndoState::extensions, exts, and UndoStackElem::state.

Referenced by anonymous_namespace{HistoryWindow.cpp}::SpaceUsageCalculator::Calculate(), ProjectFileManager::Compact(), and EstimateRemovedBlocks().

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

◆ Get() [1/2]

TrackList & TrackList::Get ( AudacityProject project)
static

Definition at line 487 of file Track.cpp.

488{
489 return project.AttachedObjects::Get< TrackList >( key );
490}
static const AudacityProject::AttachedObjects::RegisteredFactory key
Definition: Track.cpp:483

References key.

Referenced by SelectUtilities::ActivatePlayRegion(), ProjectFileManager::AddImportedTracks(), SelectHandle::AdjustSelection(), AdornedRulerPanel::AdornedRulerPanel(), AnyTracksSelectedPred(), AppendItem(), ImportCommand::Apply(), ScreenshotCommand::Apply(), SelectTimeCommand::Apply(), SelectTracksCommand::Apply(), SetLabelCommand::Apply(), SetTrackBase::Apply(), BrushHandleHitTest(), TrackSelectHandle::CalculateRearrangingThresholds(), TrackPanelResizeHandle::Cancel(), ProjectAudioManager::CancelRecording(), anonymous_namespace{Track.cpp}::TrackListRestorer::CanUndoOrRedo(), Exporter::CheckMix(), ProjectAudioManager::ChooseExistingRecordingTracks(), ButtonHandle::Click(), TrackPanelResizeHandle::Click(), LabelDefaultClickHandle::Click(), LabelGlyphHandle::Click(), BrushHandle::Click(), SelectHandle::Click(), TimeShiftHandle::Click(), BackgroundHandle::Click(), anonymous_namespace{EditMenus.cpp}::CutCopyAvailableFlag(), ProjectAudioIO::DefaultOptionsFactory(), anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), anonymous_namespace{TrackMenus.cpp}::DoAlign(), anonymous_namespace{SelectMenus.cpp}::DoBoundaryMove(), anonymous_namespace{ClipMenus.cpp}::DoClipLeftOrRight(), LOFImportFileHandle::doDurationAndScrollOffset(), LabelTrackView::DoEditLabels(), EffectUI::DoEffect(), anonymous_namespace{FileMenus.cpp}::DoExport(), DoImportMIDI(), LabelTrackView::DoKeyDown(), SelectUtilities::DoListSelection(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel(), TrackUtilities::DoMoveTrack(), anonymous_namespace{NavigationMenus.cpp}::DoNextTrack(), anonymous_namespace{TrackMenus.cpp}::DoPanTracks(), anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), anonymous_namespace{EditMenus.cpp}::DoPasteText(), anonymous_namespace{NavigationMenus.cpp}::DoPrevTrack(), ProjectAudioManager::DoRecord(), TrackUtilities::DoRemoveTrack(), TrackUtilities::DoRemoveTracks(), ProjectFileManager::DoSave(), SelectUtilities::DoSelectSomething(), anonymous_namespace{SelectUtilities.cpp}::DoSelectTimeAndAudioTracks(), SelectUtilities::DoSelectTimeAndTracks(), anonymous_namespace{TrackMenus.cpp}::DoSortTracks(), TrackUtilities::DoTrackMute(), TrackUtilities::DoTrackSolo(), LyricsPanel::DoUpdateLyrics(), ProjectWindow::DoZoomFit(), anonymous_namespace{ViewMenus.cpp}::DoZoomFitV(), ButtonHandle::Drag(), TrackPanelResizeHandle::Drag(), LabelTextHandle::Drag(), NoteTrackVZoomHandle::Drag(), SpectrumVZoomHandle::Drag(), WaveformVZoomHandle::Drag(), TimeTrackVZoomHandle::Drag(), BrushHandle::Drag(), SelectHandle::Drag(), TimeShiftHandle::Drag(), TrackSelectHandle::Drag(), anonymous_namespace{DropoutDetector.cpp}::DropoutSubscription::DropoutSubscription(), EditableTracksSelectedPred(), cloud::ShareAudioToolbar::EnableDisableButtons(), ControlToolBar::EnableDisableButtons(), TranscriptionToolBar::EnableDisableButtons(), EstimateRemovedBlocks(), Exporter::ExamineTracks(), TimerRecordDialog::ExecutePostRecordActions(), GetInfoCommand::ExploreTrackPanel(), ExportCL::Export(), ExportFFmpeg::Export(), ExportFLAC::Export(), ExportMP3::Export(), ExportOGG::Export(), ExportPCM::Export(), ExportWavPack::Export(), cloud::audiocom::ShareAudioDialog::ExportProject(), anonymous_namespace{ClipMenus.cpp}::FindClipBoundaries(), anonymous_namespace{ClipMenus.cpp}::FindClips(), ProjectWindow::FixScrollbars(), SpectrumView::ForAll(), ProjectFileIO::GenerateDoc(), Get(), GetAllSeqBlocks(), FrequencyPlotDialog::GetAudio(), ContrastDialog::GetDB(), GetPropertiesOfSelected(), CompareAudioCommand::GetSelection(), SliderHandle::GetSlider(), ScreenshotCommand::GetTrackRect(), TrackPanelAx::GetTracks(), ProjectWindow::GetZoomOfToFit(), LabelGlyphHandle::HandleGlyphDragRelease(), AUPImportFileHandle::HandleImport(), AUPImportFileHandle::HandleLabelTrack(), AUPImportFileHandle::HandleNoteTrack(), AUPImportFileHandle::HandleTimeTrack(), AUPImportFileHandle::HandleWaveTrack(), SelectHandle::HitTest(), ProjectFileManager::Import(), AUPImportFileHandle::Import(), anonymous_namespace{ProjectFileManager.cpp}::ImportProject(), EffectEqualization::Init(), NyquistEffect::Init(), anonymous_namespace{LabelMenus.cpp}::LabelsSelectedFlag(), LabelTracksExistFlag(), LOFImportFileHandle::lofOpenFiles(), MixerBoard::MixerBoard(), anonymous_namespace{SelectMenus.cpp}::MoveWhenAudioInactive(), anonymous_namespace{TrackMenus.cpp}::MuteTracks(), anonymous_namespace{SelectMenus.cpp}::NearestZeroCrossing(), WaveTrack::New(), LabelTrack::New(), NoteTrack::New(), TimeTrack::New(), anonymous_namespace{ExportMIDI.cpp}::NoteTracksExistFlag(), ApplyMacroDialog::OnApplyToFiles(), ProjectManager::OnCloseWindow(), ViewActions::Handler::OnCollapseAllTracks(), ProjectAudioManager::OnCommitRecording(), anonymous_namespace{EditMenus.cpp}::OnCopy(), anonymous_namespace{LabelMenus.cpp}::OnCopyLabels(), SelectActions::Handler::OnCursorTrackEnd(), SelectActions::Handler::OnCursorTrackStart(), anonymous_namespace{EditMenus.cpp}::OnCut(), anonymous_namespace{LabelMenus.cpp}::OnCutLabels(), anonymous_namespace{EditMenus.cpp}::OnDelete(), anonymous_namespace{LabelMenus.cpp}::OnDeleteLabels(), anonymous_namespace{EditMenus.cpp}::OnDisjoin(), anonymous_namespace{LabelMenus.cpp}::OnDisjoinLabels(), anonymous_namespace{EditMenus.cpp}::OnDuplicate(), AudacityApp::OnExceptionInMainLoop(), ViewActions::Handler::OnExpandAllTracks(), anonymous_namespace{FileMenus.cpp}::OnExportLabels(), anonymous_namespace{ExportMIDI.cpp}::OnExportMIDI(), NavigationActions::Handler::OnFirstTrack(), ContrastDialog::OnGetBackground(), ContrastDialog::OnGetForeground(), anonymous_namespace{FileMenus.cpp}::OnImportLabels(), anonymous_namespace{EditMenus.cpp}::OnJoin(), anonymous_namespace{LabelMenus.cpp}::OnJoinLabels(), NavigationActions::Handler::OnLastTrack(), WaveTrackMenuTable::OnMergeStereo(), anonymous_namespace{LabelMenus.cpp}::OnNewLabelTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::OnNewStereoTrack(), anonymous_namespace{TimeTrackMenuItems.cpp}::OnNewTimeTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::OnNewWaveTrack(), anonymous_namespace{FileMenus.cpp}::OnOpen(), anonymous_namespace{EditMenus.cpp}::OnPaste(), anonymous_namespace{LabelMenus.cpp}::OnPasteNewLabel(), anonymous_namespace{Printing.cpp}::OnPrint(), ProjectAudioManager::OnRecord(), anonymous_namespace{EditMenus.cpp}::OnRedo(), anonymous_namespace{TrackMenus.cpp}::OnResample(), SelectActions::Handler::OnSelectAll(), SelectActions::Handler::OnSelectCursorEnd(), SelectActions::Handler::OnSelectStartCursor(), SelectActions::Handler::OnSelectSyncLockSel(), SelectActions::Handler::OnSelectTrackStartToEnd(), ScreenshotBigDialog::OnShortTracks(), anonymous_namespace{EditMenus.cpp}::OnSilence(), anonymous_namespace{LabelMenus.cpp}::OnSilenceLabels(), anonymous_namespace{EditMenus.cpp}::OnSplit(), anonymous_namespace{EditMenus.cpp}::OnSplitCut(), anonymous_namespace{LabelMenus.cpp}::OnSplitCutLabels(), anonymous_namespace{EditMenus.cpp}::OnSplitDelete(), anonymous_namespace{LabelMenus.cpp}::OnSplitDeleteLabels(), anonymous_namespace{LabelMenus.cpp}::OnSplitLabels(), anonymous_namespace{EditMenus.cpp}::OnSplitNew(), WaveTrackMenuTable::OnSwapChannels(), anonymous_namespace{TimerRecordDialog.cpp}::OnTimerRecord(), anonymous_namespace{TrackMenus.cpp}::OnTrackMoveBottom(), anonymous_namespace{TrackMenus.cpp}::OnTrackMoveDown(), anonymous_namespace{TrackMenus.cpp}::OnTrackMoveTop(), anonymous_namespace{TrackMenus.cpp}::OnTrackMoveUp(), anonymous_namespace{EditMenus.cpp}::OnTrim(), anonymous_namespace{EditMenus.cpp}::OnUndo(), anonymous_namespace{TrackView.cpp}::TrackPositioner::OnUpdate(), ProjectFileManager::OpenProjectFile(), TimeTrack::PasteInto(), anonymous_namespace{MixerBoard.cpp}::PlayableTracksExistFlag(), TranscriptionToolBar::PlayAtSpeed(), ProjectAudioManager::PlayPlayRegion(), TrackSelectHandle::Preview(), NyquistEffect::Process(), SpectralDataManager::ProcessTracks(), TrackPanel::ProcessUIHandleResult(), ProjectFileManager::ReadProjectFile(), RealtimeEffectPanel::RealtimeEffectPanel(), ProjectWindow::RedrawProject(), ButtonHandle::Release(), LabelTextHandle::Release(), NoteTrackButtonHandle::Release(), NoteTrackVZoomHandle::Release(), SpectrumVZoomHandle::Release(), WaveformVZoomHandle::Release(), TimeTrackVZoomHandle::Release(), AffordanceHandle::Release(), LabelDefaultClickHandle::RestoreState(), anonymous_namespace{Track.cpp}::TrackListRestorer::RestoreUndoRedoState(), ProjectManager::SafeToOpenProjectInto(), ProjectFileIO::SaveCopy(), LabelDefaultClickHandle::SaveState(), ProjectWindow::ScrollingLowerBoundTime(), anonymous_namespace{SelectMenus.cpp}::SeekWhenAudioInactive(), NoteTrackAffordanceHandle::SelectAt(), SelectUtilities::SelectNone(), GetInfoCommand::SendClips(), GetInfoCommand::SendEnvelopes(), GetInfoCommand::SendLabels(), GetInfoCommand::SendTracks(), TrackFocus::Set(), ScreenshotBigDialog::SizeTracks(), ProjectWindow::SkipEnd(), WaveTrackMenuTable::SplitStereo(), ProjectSelectionManager::SSBL_GetRate(), StereoRequiredFlag(), anonymous_namespace{Track.cpp}::TrackListRestorer::TrackListRestorer(), anonymous_namespace{TrackView.cpp}::TrackPositioner::TrackPositioner(), TracksExistFlag(), ProjectSettings::UpdatePrefs(), RealtimeEffectPanel::PrefsListenerHelper::UpdatePrefs(), WaveTracksExistFlag(), WaveTracksSelectedFlag(), ProjectFileIO::WriteXML(), ProjectWindow::ZoomAfterImport(), ZoomInAvailableFlag(), and ZoomOutAvailableFlag().

◆ Get() [2/2]

const TrackList & TrackList::Get ( const AudacityProject project)
static

Definition at line 492 of file Track.cpp.

493{
494 return Get( const_cast< AudacityProject & >( project ) );
495}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:487

References Get().

Here is the call graph for this function:

◆ getBegin()

TrackNodePointer TrackList::getBegin ( ) const
inlineprivate

Definition at line 1684 of file Track.h.

1685 { return { const_cast<TrackList*>(this)->ListOfTracks::begin(),
1686 const_cast<TrackList*>(this)}; }

References PackedArray::begin().

Referenced by ClearPendingTracks(), DoAddToHead(), and Permute().

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

◆ getEnd()

TrackNodePointer TrackList::getEnd ( ) const
inlineprivate

Definition at line 1681 of file Track.h.

1682 { return { const_cast<TrackList*>(this)->ListOfTracks::end(),
1683 const_cast<TrackList*>(this)}; }

References PackedArray::end().

Referenced by DoAdd(), EmptyRange(), Remove(), and size().

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

◆ GetEndTime()

double TrackList::GetEndTime ( ) const

Definition at line 1053 of file Track.cpp.

1054{
1055 return Accumulate(*this, &Track::GetEndTime, -DBL_MAX, std::max);
1056}
virtual double GetEndTime() const =0
double Accumulate(const TrackList &list, double(Track::*memfn)() const, double ident, const double &(*combine)(const double &, const double &))
Definition: Track.cpp:1028

References anonymous_namespace{Track.cpp}::Accumulate(), and Track::GetEndTime().

Referenced by SelectTimeCommand::Apply(), LOFImportFileHandle::doDurationAndScrollOffset(), ExportMultipleDialog::ExportMultipleByLabel(), and AdornedRulerPanel::StartQPPlay().

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

◆ GetMinOffset()

double TrackList::GetMinOffset ( ) const

Definition at line 1043 of file Track.cpp.

1044{
1045 return Accumulate(*this, &Track::GetOffset, DBL_MAX, std::min);
1046}
int min(int a, int b)
virtual double GetOffset() const =0

References anonymous_namespace{Track.cpp}::Accumulate(), Track::GetOffset(), and min().

Here is the call graph for this function:

◆ GetNext()

Track * TrackList::GetNext ( Track t,
bool  linked = false 
) const
private

Return a track in the list that comes after Track t.

Definition at line 851 of file Track.cpp.

852{
853 if (t) {
854 auto node = t->GetNode();
855 if ( !isNull( node ) ) {
856 if ( linked && t->HasLinkedTrack() )
857 node = getNext( node );
858
859 if ( !isNull( node ) )
860 node = getNext( node );
861
862 if ( !isNull( node ) )
863 return node.first->get();
864 }
865 }
866
867 return nullptr;
868}
bool HasLinkedTrack() const noexcept
Returns true for leaders of multichannel groups.
Definition: Track.cpp:274
bool isNull(TrackNodePointer p) const
Definition: Track.h:1678
TrackNodePointer getNext(TrackNodePointer p) const
Move an iterator to the next node, if any; else stay at end.
Definition: Track.h:1689

References getNext(), Track::GetNode(), Track::HasLinkedTrack(), and isNull().

Referenced by CanMoveDown(), and MoveDown().

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

◆ getNext()

TrackNodePointer TrackList::getNext ( TrackNodePointer  p) const
inlineprivate

Move an iterator to the next node, if any; else stay at end.

Definition at line 1689 of file Track.h.

1690 {
1691 if ( isNull(p) )
1692 return p;
1693 auto q = p;
1694 ++q.first;
1695 return q;
1696 }

Referenced by GetNext(), and Remove().

Here is the caller graph for this function:

◆ GetOwner() [1/2]

AudacityProject * TrackList::GetOwner ( )
inline

Definition at line 1376 of file Track.h.

1376{ return mOwner; }

Referenced by EffectBase::FindProject(), and EffectBase::Preview().

Here is the caller graph for this function:

◆ GetOwner() [2/2]

const AudacityProject * TrackList::GetOwner ( ) const
inline

Definition at line 1377 of file Track.h.

1377{ return mOwner; }

◆ GetPrev()

Track * TrackList::GetPrev ( Track t,
bool  linked = false 
) const
private

Definition at line 870 of file Track.cpp.

871{
872 if (t) {
873 TrackNodePointer prev;
874 auto node = t->GetNode();
875 if ( !isNull( node ) ) {
876 // linked is true and input track second in team?
877 if (linked) {
878 prev = getPrev( node );
879 if( !isNull( prev ) &&
880 !t->HasLinkedTrack() && t->GetLinkedTrack() )
881 // Make it the first
882 node = prev;
883 }
884
885 prev = getPrev( node );
886 if ( !isNull( prev ) ) {
887 // Back up once
888 node = prev;
889
890 // Back up twice sometimes when linked is true
891 if (linked) {
892 prev = getPrev( node );
893 if( !isNull( prev ) &&
894 !(*node.first)->HasLinkedTrack() && (*node.first)->GetLinkedTrack() )
895 node = prev;
896 }
897
898 return node.first->get();
899 }
900 }
901 }
902
903 return nullptr;
904}
Track * GetLinkedTrack() const
Definition: Track.cpp:248

References Track::GetLinkedTrack(), Track::GetNode(), getPrev(), Track::HasLinkedTrack(), and isNull().

Referenced by CanMoveUp(), and MoveUp().

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

◆ getPrev()

TrackNodePointer TrackList::getPrev ( TrackNodePointer  p) const
inlineprivate

Move an iterator to the previous node, if any; else wrap to end.

Definition at line 1699 of file Track.h.

1700 {
1701 if (p == getBegin())
1702 return getEnd();
1703 else {
1704 auto q = p;
1705 --q.first;
1706 return q;
1707 }
1708 }

Referenced by DoAdd(), GetPrev(), RecalcPositions(), and size().

Here is the caller graph for this function:

◆ GetStartTime()

double TrackList::GetStartTime ( ) const

Definition at line 1048 of file Track.cpp.

1049{
1050 return Accumulate(*this, &Track::GetStartTime, DBL_MAX, std::min);
1051}
virtual double GetStartTime() const =0

References anonymous_namespace{Track.cpp}::Accumulate(), Track::GetStartTime(), and min().

Referenced by AdornedRulerPanel::StartQPPlay().

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

◆ HasPendingTracks()

bool TrackList::HasPendingTracks ( ) const

Definition at line 1337 of file Track.cpp.

1338{
1339 if ( !mPendingUpdates.empty() )
1340 return true;
1341 if (end() != std::find_if(begin(), end(), [](const Track *t){
1342 return t->GetId() == TrackId{};
1343 }))
1344 return true;
1345 return false;
1346}
TrackId GetId() const
Definition: Track.h:288

References begin(), end(), Track::GetId(), and mPendingUpdates.

Referenced by anonymous_namespace{Track.cpp}::TrackListRestorer::CanUndoOrRedo().

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

◆ isNull()

bool TrackList::isNull ( TrackNodePointer  p) const
inlineprivate

Definition at line 1678 of file Track.h.

1679 { return (p.second == this && p.first == ListOfTracks::end())
1680 || (p.second == &mPendingUpdates && p.first == mPendingUpdates.end()); }

References PackedArray::end().

Referenced by GetNext(), GetPrev(), RecalcPositions(), Remove(), and SwapNodes().

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

◆ Leaders() [1/2]

template<typename TrackType = Track>
auto TrackList::Leaders ( ) -> TrackIterRange< TrackType >
inline

Definition at line 1474 of file Track.h.

1476 {
1477 return Tracks< TrackType >( &Track::IsLeader );
1478 }

References Track::IsLeader().

Referenced by ExportMultipleDialog::CountTracksAndLabels(), ExportMultipleDialog::ExportMultipleByTrack(), ScreenshotCommand::GetTrackRect(), TrackSelectHandle::Preview(), NyquistEffect::Process(), and MixerBoard::UpdateTrackClusters().

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

◆ Leaders() [2/2]

template<typename TrackType = const Track>
auto TrackList::Leaders ( ) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIterRange< TrackType > >
inline

Definition at line 1481 of file Track.h.

1485 {
1486 return Tracks< TrackType >( &Track::IsLeader );
1487 }

References Track::IsLeader().

Here is the call graph for this function:

◆ Lock()

template<typename Subclass >
std::shared_ptr< Subclass > TrackList::Lock ( const std::weak_ptr< Subclass > &  wTrack)
inline

◆ MakeMultiChannelTrack()

bool TrackList::MakeMultiChannelTrack ( Track first,
int  nChannels,
bool  aligned 
)

Converts channels to a multichannel track.

Parameters
firstand the following must be in this list. Tracks should not be a part of another group (not linked)
nChannelsnumber of channels, for now only 2 channels supported
alignedif true, the link type will be set to Track::LinkType::Aligned, or Track::LinkType::Group otherwise
Returns
true on success, false if some prerequisites do not met

Definition at line 763 of file Track.cpp.

764{
765 if (nChannels != 2)
766 return false;
767
768 auto list = track.mList.lock();
769 if (list.get() == this)
770 {
771 if (*list->FindLeader(&track) != &track)
772 return false;
773
774 auto first = list->Find(&track);
775 auto canLink = [&]() -> bool {
776 int count = nChannels;
777 for (auto it = first, end = TrackList::end(); it != end && count; ++it)
778 {
779 if ((*it)->HasLinkedTrack())
780 return false;
781 --count;
782 }
783 return count == 0;
784 }();
785
786 if (!canLink)
787 return false;
788
789 (*first)->SetChannel(Track::LeftChannel);
790 auto second = std::next(first);
791 (*second)->SetChannel(Track::RightChannel);
792 (*first)->SetLinkType(aligned ? Track::LinkType::Aligned : Track::LinkType::Group);
793 }
794 else
796 return true;
797}
#define THROW_INCONSISTENCY_EXCEPTION
Throw InconsistencyException, using C++ preprocessor to identify the source code location.
Subclass * Find(const RegisteredFactory &key)
Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand...
Definition: ClientData.h:333
@ LeftChannel
Definition: Track.h:283
@ RightChannel
Definition: Track.h:284

References Track::Aligned, end(), Track::Group, Track::LeftChannel, Track::mList, Track::RightChannel, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by ProjectAudioManager::DoRecord(), and EffectBase::Preview().

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

◆ MakeTrackIterator()

template<typename TrackType >
TrackIter< TrackType > TrackList::MakeTrackIterator ( TrackNodePointer  iter) const
inlineprivate

Definition at line 1661 of file Track.h.

1662 {
1663 auto b = const_cast<TrackList*>(this)->getBegin();
1664 auto e = const_cast<TrackList*>(this)->getEnd();
1665 return { b, iter, e };
1666 }

◆ MakeUniqueTrackName()

wxString TrackList::MakeUniqueTrackName ( const wxString &  baseTrackName) const

Returns string that contains baseTrackName, but is guaranteed to be unique among other tracks in that list.

Parameters
baseTrackNameString to be put into the template
Returns
Formatted string: "[baseTrackName] [N]"

Definition at line 544 of file Track.cpp.

545{
546 int n = 1;
547 while(true)
548 {
549 auto name = wxString::Format("%s %d", baseTrackName, n++);
550
551 bool found {false};
552 for(const auto track : Any())
553 {
554 if(track->GetName() == name)
555 {
556 found = true;
557 break;
558 }
559 }
560 if(!found)
561 return name;
562 }
563}
const TranslatableString name
Definition: Distortion.cpp:76

References Any(), and name.

Referenced by LabelTrack::Create(), and EffectBase::DoEffect().

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

◆ Move()

bool TrackList::Move ( Track t,
bool  up 
)
inline

Definition at line 1598 of file Track.h.

1598{ return up ? MoveUp(t) : MoveDown(t); }
bool MoveUp(Track *t)
Definition: Track.cpp:979
bool MoveDown(Track *t)
Definition: Track.cpp:992

◆ MoveDown()

bool TrackList::MoveDown ( Track t)

Definition at line 992 of file Track.cpp.

993{
994 if (t) {
995 Track *n = GetNext(t, true);
996 if (n) {
997 SwapNodes(t->GetNode(), n->GetNode());
998 return true;
999 }
1000 }
1001
1002 return false;
1003}
void SwapNodes(TrackNodePointer s1, TrackNodePointer s2)
Definition: Track.cpp:920

References GetNext(), Track::GetNode(), and SwapNodes().

Here is the call graph for this function:

◆ MoveUp()

bool TrackList::MoveUp ( Track t)

Definition at line 979 of file Track.cpp.

980{
981 if (t) {
982 Track *p = GetPrev(t, true);
983 if (p) {
984 SwapNodes(p->GetNode(), t->GetNode());
985 return true;
986 }
987 }
988
989 return false;
990}

References Track::GetNode(), GetPrev(), and SwapNodes().

Here is the call graph for this function:

◆ operator=() [1/2]

TrackList & TrackList::operator= ( const TrackList )
privatedelete

◆ operator=() [2/2]

TrackList & TrackList::operator= ( TrackList &&  )
privatedelete

◆ PermutationEvent()

void TrackList::PermutationEvent ( TrackNodePointer  node)
private

Definition at line 614 of file Track.cpp.

615{
616 QueueEvent({ TrackListEvent::PERMUTED, *node.first });
617}
@ PERMUTED
Posted when tracks are reordered but otherwise unchanged.
Definition: Track.h:1302

References TrackListEvent::PERMUTED, and QueueEvent().

Referenced by Permute(), and SwapNodes().

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

◆ Permute()

void TrackList::Permute ( const std::vector< TrackNodePointer > &  permutation)

For use in sorting: assume each iterator points into this list, no duplications.

Definition at line 675 of file Track.cpp.

676{
677 for (const auto iter : permutation) {
678 ListOfTracks::value_type track = *iter.first;
679 erase(iter.first);
680 Track *pTrack = track.get();
681 pTrack->SetOwner(shared_from_this(),
682 { insert(ListOfTracks::end(), track), this });
683 }
684 auto n = getBegin();
687}
void PermutationEvent(TrackNodePointer node)
Definition: Track.cpp:614

References PackedArray::end(), getBegin(), PermutationEvent(), RecalcPositions(), and Track::SetOwner().

Here is the call graph for this function:

◆ QueueEvent()

void TrackList::QueueEvent ( TrackListEvent  event)
private

Definition at line 588 of file Track.cpp.

589{
590 BasicUI::CallAfter( [wThis = weak_from_this(), event = std::move(event)]{
591 if (auto pThis = wThis.lock())
592 pThis->Publish(event);
593 } );
594}
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:208

References BasicUI::CallAfter().

Referenced by AdditionEvent(), DataEvent(), DeletionEvent(), EnsureVisibleEvent(), PermutationEvent(), ResizingEvent(), and SelectionEvent().

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

◆ RecalcPositions()

void TrackList::RecalcPositions ( TrackNodePointer  node)
private

Definition at line 565 of file Track.cpp.

566{
567 if ( isNull( node ) )
568 return;
569
570 Track *t;
571 int i = 0;
572
573 auto prev = getPrev( node );
574 if ( !isNull( prev ) ) {
575 t = prev.first->get();
576 i = t->GetIndex() + 1;
577 }
578
579 const auto theEnd = end();
580 for (auto n = Find( node.first->get() ); n != theEnd; ++n) {
581 t = *n;
582 t->SetIndex(i++);
583 }
584
586}
void SetIndex(int index)
Definition: Track.cpp:148
int GetIndex() const
Definition: Track.cpp:143

References end(), Find(), Track::GetIndex(), getPrev(), isNull(), Track::SetIndex(), and UpdatePendingTracks().

Referenced by ApplyPendingTracks(), ClearPendingTracks(), DoAdd(), DoAddToHead(), Permute(), Remove(), and SwapNodes().

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

◆ RegisterPendingChangedTrack()

std::shared_ptr< Track > TrackList::RegisterPendingChangedTrack ( Updater  updater,
Track src 
)

Definition at line 1059 of file Track.cpp.

1060{
1061 std::shared_ptr<Track> pTrack;
1062 if (src) {
1063 pTrack = src->Clone(); // not duplicate
1064 // Share the satellites with the original, though they do not point back
1065 // to the pending track
1066 ((AttachedTrackObjects&)*pTrack) = *src; // shallow copy
1067 }
1068
1069 if (pTrack) {
1070 mUpdaters.push_back( updater );
1071 mPendingUpdates.push_back( pTrack );
1072 auto n = mPendingUpdates.end();
1073 --n;
1074 pTrack->SetOwner(shared_from_this(), {n, &mPendingUpdates});
1075 }
1076
1077 return pTrack;
1078}
static CustomUpdaterValue updater
Utility to register hooks into a host class that attach client data.
Definition: ClientData.h:220
virtual Holder Clone() const =0

References Track::Clone(), mPendingUpdates, mUpdaters, and updater.

Referenced by ProjectAudioManager::DoRecord().

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

◆ RegisterPendingNewTrack()

void TrackList::RegisterPendingNewTrack ( const std::shared_ptr< Track > &  pTrack)

Definition at line 1080 of file Track.cpp.

1081{
1082 Add<Track>( pTrack );
1083 pTrack->SetId( TrackId{} );
1084}

Referenced by ProjectAudioManager::DoRecord().

Here is the caller graph for this function:

◆ Remove()

TrackNodePointer TrackList::Remove ( Track t)

Remove the Track and return an iterator to what followed it.

Definition at line 799 of file Track.cpp.

800{
801 auto result = getEnd();
802 if (t) {
803 auto node = t->GetNode();
804 t->SetOwner({}, {});
805
806 if ( !isNull( node ) ) {
807 ListOfTracks::value_type holder = *node.first;
808
809 result = getNext( node );
810 erase(node.first);
811 if ( !isNull( result ) )
812 RecalcPositions(result);
813
814 DeletionEvent(t->shared_from_this(), false);
815 }
816 }
817 return result;
818}

References DeletionEvent(), getEnd(), getNext(), Track::GetNode(), isNull(), RecalcPositions(), and Track::SetOwner().

Referenced by EffectBase::DoEffect(), EffectBase::ReplaceProcessedTracks(), and AddedAnalysisTrack::~AddedAnalysisTrack().

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

◆ Replace()

auto TrackList::Replace ( Track t,
const ListOfTracks::value_type &  with 
)

Replace first track with second track, give back a holder Give the replacement the same id as the replaced

Definition at line 725 of file Track.cpp.

727{
728 ListOfTracks::value_type holder;
729 if (t && with) {
730 auto node = t->GetNode();
731 t->SetOwner({}, {});
732
733 holder = *node.first;
734
735 Track *pTrack = with.get();
736 *node.first = with;
737 pTrack->SetOwner(shared_from_this(), node);
738 pTrack->SetId( t->GetId() );
739 RecalcPositions(node);
740
741 DeletionEvent(t->shared_from_this(), true);
742 AdditionEvent(node);
743 }
744 return holder;
745}

References Track::SetId(), and Track::SetOwner().

Referenced by ApplyPendingTracks(), ModifiedAnalysisTrack::ModifiedAnalysisTrack(), EffectBase::ReplaceProcessedTracks(), and ModifiedAnalysisTrack::~ModifiedAnalysisTrack().

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

◆ ResizingEvent()

void TrackList::ResizingEvent ( TrackNodePointer  node)
private

Definition at line 630 of file Track.cpp.

631{
632 QueueEvent({ TrackListEvent::RESIZING, *node.first });
633}
@ RESIZING
Posted when some track changed its height.
Definition: Track.h:1305

References QueueEvent(), and TrackListEvent::RESIZING.

Here is the call graph for this function:

◆ Selected() [1/2]

template<typename TrackType = Track>
auto TrackList::Selected ( ) -> TrackIterRange< TrackType >
inline

Definition at line 1457 of file Track.h.

1459 {
1460 return Tracks< TrackType >( &Track::IsSelected );
1461 }
bool IsSelected() const
Definition: Track.cpp:403

References Track::IsSelected().

Referenced by AnyTracksSelectedPred(), SelectionState::ChangeSelectionOnShiftClick(), EffectBase::CountWaveTracks(), EditableTracksSelectedPred(), anonymous_namespace{LabelMenus.cpp}::EditByLabel(), anonymous_namespace{LabelMenus.cpp}::EditClipboardByLabel(), TranscriptionToolBar::EnableDisableButtons(), ExportMultipleDialog::ExportMultipleByTrack(), EffectTruncSilence::FindSilences(), anonymous_namespace{EditMenus.cpp}::ForEachCopiedWaveTrack(), FrequencyPlotDialog::GetAudio(), GetPropertiesOfSelected(), anonymous_namespace{LabelMenus.cpp}::GetRegionsByLabel(), CompareAudioCommand::GetSelection(), EffectEqualization::Init(), NyquistEffect::Init(), EffectScienFilter::Init(), EffectCompressor::InitPass1(), anonymous_namespace{LabelMenus.cpp}::LabelsSelectedFlag(), ContrastDialog::OnGetBackground(), ContrastDialog::OnGetForeground(), EffectBase::Preview(), EffectFindClipping::Process(), EffectNoiseReduction::Worker::Process(), EffectTruncSilence::ProcessAll(), StereoRequiredFlag(), and WaveTracksSelectedFlag().

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

◆ Selected() [2/2]

template<typename TrackType = const Track>
auto TrackList::Selected ( ) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIterRange< TrackType > >
inline

Definition at line 1464 of file Track.h.

1468 {
1469 return Tracks< TrackType >( &Track::IsSelected );
1470 }

References Track::IsSelected().

Here is the call graph for this function:

◆ SelectedLeaders() [1/2]

template<typename TrackType = Track>
auto TrackList::SelectedLeaders ( ) -> TrackIterRange< TrackType >
inline

Definition at line 1491 of file Track.h.

1493 {
1494 return Tracks< TrackType >( &Track::IsSelectedLeader );
1495 }
bool IsSelectedLeader() const
Definition: Track.cpp:411

References Track::IsSelectedLeader().

Referenced by EffectBase::CountWaveTracks(), ContrastDialog::GetDB(), and TrackPanel::GetSelectedTrackCount().

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

◆ SelectedLeaders() [2/2]

template<typename TrackType = const Track>
auto TrackList::SelectedLeaders ( ) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIterRange< TrackType > >
inline

Definition at line 1498 of file Track.h.

1502 {
1503 return Tracks< TrackType >( &Track::IsSelectedLeader );
1504 }

References Track::IsSelectedLeader().

Here is the call graph for this function:

◆ SelectionEvent()

void TrackList::SelectionEvent ( const std::shared_ptr< Track > &  pTrack)
private

Definition at line 596 of file Track.cpp.

597{
599}
@ SELECTION_CHANGE
Posted when the set of selected tracks changes.
Definition: Track.h:1292

References QueueEvent(), and TrackListEvent::SELECTION_CHANGE.

Here is the call graph for this function:

◆ SingletonRange()

template<typename TrackType >
static auto TrackList::SingletonRange ( TrackType *  pTrack) -> TrackIterRange< TrackType >
inlinestatic

Definition at line 1508 of file Track.h.

1510 {
1511 return pTrack->GetOwner()->template Any<TrackType>()
1512 .StartingWith( pTrack ).EndingAfter( pTrack );
1513 }

References TrackIterRange< TrackType >::EndingAfter(), and TrackIterRange< TrackType >::StartingWith().

Referenced by anonymous_namespace{ClipMenus.cpp}::FindClipBoundaries(), anonymous_namespace{ClipMenus.cpp}::FindClips(), EffectLoudness::Process(), and EffectNormalize::Process().

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

◆ size()

size_t TrackList::size ( ) const

Definition at line 1015 of file Track.cpp.

1016{
1017 int cnt = 0;
1018
1019 if (!empty())
1020 cnt = getPrev( getEnd() ).first->get()->GetIndex() + 1;
1021
1022 return cnt;
1023}

References empty(), getEnd(), and getPrev().

Referenced by ScreenshotCommand::Apply(), anonymous_namespace{EditMenus.cpp}::EstimateCopiedBlocks(), and ProjectSettings::UpdatePrefs().

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

◆ Swap()

void TrackList::Swap ( TrackList that)

Definition at line 519 of file Track.cpp.

520{
521 auto SwapLOTs = [](
522 ListOfTracks &a, const std::weak_ptr< TrackList > &aSelf,
523 ListOfTracks &b, const std::weak_ptr< TrackList > &bSelf )
524 {
525 a.swap(b);
526 for (auto it = a.begin(), last = a.end(); it != last; ++it)
527 (*it)->SetOwner(aSelf, {it, &a});
528 for (auto it = b.begin(), last = b.end(); it != last; ++it)
529 (*it)->SetOwner(bSelf, {it, &b});
530 };
531
532 const auto self = shared_from_this();
533 const auto otherSelf = that.shared_from_this();
534 SwapLOTs( *this, self, that, otherSelf );
535 SwapLOTs( this->mPendingUpdates, self, that.mPendingUpdates, otherSelf );
536 mUpdaters.swap(that.mUpdaters);
537}

◆ SwapChannels()

bool TrackList::SwapChannels ( Track track)
static

If the given track is one of a pair of channels, swap them.

Returns
success

Definition at line 654 of file Track.cpp.

655{
656 if (!track.HasLinkedTrack())
657 return false;
658 auto pOwner = track.GetOwner();
659 if (!pOwner)
660 return false;
661 auto pPartner = pOwner->GetNext(&track, false);
662 if (!pPartner)
663 return false;
664
665 // Swap channels, avoiding copying of GroupData
666 auto pData = move(track.mpGroupData);
667 assert(pData);
668 pOwner->MoveUp(pPartner);
669 pPartner->mpGroupData = move(pData);
670 pPartner->SetChannel(Track::LeftChannel);
672 return true;
673}
void SetChannel(ChannelType c) noexcept
Definition: Track.cpp:243
std::unique_ptr< ChannelGroupData > mpGroupData
Definition: Track.h:263

References Track::GetOwner(), Track::HasLinkedTrack(), Track::LeftChannel, Track::mpGroupData, Track::RightChannel, and Track::SetChannel().

Referenced by WaveTrackMenuTable::OnSwapChannels().

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

◆ SwapNodes()

void TrackList::SwapNodes ( TrackNodePointer  s1,
TrackNodePointer  s2 
)
private

Definition at line 920 of file Track.cpp.

921{
922 // if a null pointer is passed in, we want to know about it
923 wxASSERT(!isNull(s1));
924 wxASSERT(!isNull(s2));
925
926 // Deal with first track in each team
927 s1 = ( * FindLeader( s1.first->get() ) )->GetNode();
928 s2 = ( * FindLeader( s2.first->get() ) )->GetNode();
929
930 // Safety check...
931 if (s1 == s2)
932 return;
933
934 // Be sure s1 is the earlier iterator
935 if ((*s1.first)->GetIndex() >= (*s2.first)->GetIndex())
936 std::swap(s1, s2);
937
938 // For saving the removed tracks
939 using Saved = std::vector< ListOfTracks::value_type >;
940 Saved saved1, saved2;
941
942 auto doSave = [&] ( Saved &saved, TrackNodePointer &s ) {
943 size_t nn = Channels( s.first->get() ).size();
944 saved.resize( nn );
945 // Save them in backwards order
946 while( nn-- )
947 saved[nn] = *s.first, s.first = erase(s.first);
948 };
949
950 doSave( saved1, s1 );
951 // The two ranges are assumed to be disjoint but might abut
952 const bool same = (s1 == s2);
953 doSave( saved2, s2 );
954 if (same)
955 // Careful, we invalidated s1 in the second doSave!
956 s1 = s2;
957
958 // Reinsert them
959 auto doInsert = [&] ( Saved &saved, TrackNodePointer &s ) {
960 Track *pTrack;
961 for (auto & pointer : saved)
962 pTrack = pointer.get(),
963 // Insert before s, and reassign s to point at the new node before
964 // old s; which is why we saved pointers in backwards order
965 pTrack->SetOwner(shared_from_this(),
966 s = { insert(s.first, pointer), this } );
967 };
968 // This does not invalidate s2 even when it equals s1:
969 doInsert( saved2, s1 );
970 // Even if s2 was same as s1, this correctly inserts the saved1 range
971 // after the saved2 range, when done after:
972 doInsert( saved1, s2 );
973
974 // Now correct the Index in the tracks, and other things
975 RecalcPositions(s1);
977}
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1544
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:752

References Channels(), FindLeader(), isNull(), PermutationEvent(), RecalcPositions(), Track::SetOwner(), and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by MoveDown(), and MoveUp().

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

◆ Tracks() [1/2]

template<typename TrackType = Track, typename Pred = typename TrackIterRange< TrackType >::iterator::FunctionType>
auto TrackList::Tracks ( const Pred &  pred = {}) -> TrackIterRange< TrackType >
inlineprivate

Definition at line 1633 of file Track.h.

1633 {} )
1635 {
1636 auto b = getBegin(), e = getEnd();
1637 return { { b, b, e, pred }, { b, e, e, pred } };
1638 }
Range between two TrackIters, usable in range-for statements, and with Visit member functions.
Definition: Track.h:1168

◆ Tracks() [2/2]

template<typename TrackType = const Track, typename Pred = typename TrackIterRange< TrackType >::iterator::FunctionType>
auto TrackList::Tracks ( const Pred &  pred = {}) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIterRange< TrackType > >
inlineprivate

Definition at line 1646 of file Track.h.

1646 {} ) const
1647 -> std::enable_if_t< std::is_const_v<TrackType>,
1649 >
1650 {
1651 auto b = const_cast<TrackList*>(this)->getBegin();
1652 auto e = const_cast<TrackList*>(this)->getEnd();
1653 return { { b, b, e, pred }, { b, e, e, pred } };
1654 }

◆ UnlinkChannels()

void TrackList::UnlinkChannels ( Track track)

Removes linkage if track belongs to a group.

Definition at line 747 of file Track.cpp.

748{
749 auto list = track.mList.lock();
750 if (list.get() == this)
751 {
752 auto channels = TrackList::Channels(&track);
753 for (auto c : channels)
754 {
755 c->SetLinkType(Track::LinkType::None);
756 c->SetChannel(Track::ChannelType::MonoChannel);
757 }
758 }
759 else
761}
std::weak_ptr< TrackList > mList
Definition: Track.h:266

References Channels(), Track::mList, Track::None, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by WaveTrackMenuTable::SplitStereo().

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

◆ UpdatePendingTracks()

void TrackList::UpdatePendingTracks ( )

Definition at line 1086 of file Track.cpp.

1087{
1088 auto pUpdater = mUpdaters.begin();
1089 for (const auto &pendingTrack : mPendingUpdates) {
1090 // Copy just a part of the track state, according to the update
1091 // function
1092 const auto &updater = *pUpdater;
1093 auto src = FindById( pendingTrack->GetId() );
1094 if (pendingTrack && src) {
1095 if (updater)
1096 updater( *pendingTrack, *src );
1097 pendingTrack->DoSetLinkType(src->GetLinkType());
1098 }
1099 ++pUpdater;
1100 }
1101}
std::optional< LogWindowUpdater > pUpdater
Definition: LogWindow.cpp:53

References FindById(), mPendingUpdates, mUpdaters, anonymous_namespace{LogWindow.cpp}::pUpdater, and updater.

Referenced by ApplyPendingTracks(), ProjectAudioManager::DoRecord(), TrackPanel::ProcessUIHandleResult(), and RecalcPositions().

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

Friends And Related Function Documentation

◆ Track

friend class Track
friend

Definition at line 1554 of file Track.h.

Member Data Documentation

◆ mOwner

AudacityProject* TrackList::mOwner
private

Definition at line 1774 of file Track.h.

◆ mPendingUpdates

ListOfTracks TrackList::mPendingUpdates
private

Shadow tracks holding append-recording in progress; need to put them into a list so that GetLink() works.

Beware, they are in a disjoint iteration sequence from ordinary tracks

Definition at line 1778 of file Track.h.

Referenced by ApplyPendingTracks(), Clear(), ClearPendingTracks(), HasPendingTracks(), RegisterPendingChangedTrack(), and UpdatePendingTracks().

◆ mUpdaters

std::vector< Updater > TrackList::mUpdaters
private

This is in correspondence with mPendingUpdates.

Definition at line 1780 of file Track.h.

Referenced by Clear(), ClearPendingTracks(), RegisterPendingChangedTrack(), and UpdatePendingTracks().

◆ sCounter

long TrackList::sCounter = -1
staticprivate

Definition at line 1726 of file Track.h.

Referenced by ApplyPendingTracks(), DoAdd(), and DoAddToHead().


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