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

Member Typedef Documentation

◆ const_iterator

Definition at line 1388 of file Track.h.

◆ iterator

Definition at line 1387 of file Track.h.

◆ Updater

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

Definition at line 1726 of file Track.h.

◆ value_type

Definition at line 1389 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 496 of file Track.cpp.

497 : mOwner{ pOwner }
498{
499}
AudacityProject * mOwner
Definition: Track.h:1771

◆ ~TrackList()

TrackList::~TrackList ( )
virtual

Definition at line 538 of file Track.cpp.

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

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

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

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

Here is the caller graph for this function:

◆ AdditionEvent()

void TrackList::AdditionEvent ( TrackNodePointer  node)
private

Definition at line 624 of file Track.cpp.

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

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

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

◆ Any() [1/2]

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

Definition at line 1437 of file Track.h.

1439 {
1440 return Tracks< TrackType >();
1441 }

Referenced by anonymous_namespace{Track.cpp}::Accumulate(), ImportCommand::Apply(), LabelDefaultClickHandle::Click(), Effect::CopyInputTracks(), ExportMultipleDialog::CountTracksAndLabels(), ExportPlugin::CreateMixer(), 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(), ProjectAudioManager::GetAllPlaybackTracks(), GetAllSeqBlocks(), GetNumExportChannels(), TrackView::GetTotalHeight(), MixerBoard::HasSolo(), ClipMoveState::Init(), LabelTracksExistFlag(), MakeUniqueTrackName(), anonymous_namespace{FileMenus.cpp}::NoteTracksExistFlag(), AudacityPrintout::OnPrintPage(), ProjectAudioManager::OnRecord(), LabelDialog::OnSelectCell(), ScreenshotBigDialog::OnShortTracks(), TransportActions::Handler::OnTimerRecord(), TranscriptionToolBar::PlayAtSpeed(), ProjectHistory::PopState(), EffectBase::Preview(), EffectFindClipping::Process(), RealtimeEffectPanel::RealtimeEffectPanel(), SelectionStateChanger::SelectionStateChanger(), SelectionState::SelectNone(), SelectionState::SelectRangeOfTracks(), TracksExistFlag(), LabelDialog::TransferDataFromWindow(), 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 1444 of file Track.h.

1448 {
1449 return Tracks< TrackType >();
1450 }

◆ ApplyPendingTracks()

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

Definition at line 1144 of file Track.cpp.

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

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

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

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

◆ CanMoveDown()

bool TrackList::CanMoveDown ( Track t) const

Definition at line 910 of file Track.cpp.

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

References GetNext().

Here is the call graph for this function:

◆ CanMoveUp()

bool TrackList::CanMoveUp ( Track t) const

Definition at line 905 of file Track.cpp.

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

References GetPrev().

Here is the call graph for this function:

◆ cbegin()

const_iterator TrackList::cbegin ( ) const
inline

Definition at line 1394 of file Track.h.

1394{ return begin(); }
iterator begin()
Definition: Track.h:1390

References PackedArray::begin().

Here is the call graph for this function:

◆ cend()

const_iterator TrackList::cend ( ) const
inline

Definition at line 1395 of file Track.h.

1395{ return end(); }
iterator end()
Definition: Track.h:1391

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

1543 {
1544 return Channels_<TrackType>( pTrack->GetOwner()->FindLeader(pTrack) );
1545 }

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(), 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(), EditActions::Handler::OnPaste(), WaveTrackMenuTable::OnSetDisplay(), TrackMenuTable::OnSetName(), SpectrumVRulerMenuTable::OnSpectrumScaleType(), EditActions::Handler::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 1519 of file Track.h.

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

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

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

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

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

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

References make_iterator_range().

Here is the call graph for this function:

◆ Create()

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

Definition at line 502 of file Track.cpp.

503{
504 return std::make_shared<TrackList>( pOwner );
505}

Referenced by Effect::CopyInputTracks(), ProjectFileManager::DoSave(), anonymous_namespace{LabelMenus.cpp}::EditClipboardByLabel(), UndoManager::ModifyState(), EditActions::Handler::OnCopy(), EditActions::Handler::OnCut(), EditActions::Handler::OnSplitCut(), EffectBase::Preview(), EffectTwoPassSimpleMono::Process(), EffectManager::PromptUser(), UndoManager::PushState(), ProjectFileManager::ReadProjectFile(), and ProjectFileIO::SaveProject().

Here is the caller graph for this function:

◆ DataEvent()

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

Definition at line 600 of file Track.cpp.

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

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

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

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

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

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

700{
701 Track *pTrack = t.get();
702 push_front(ListOfTracks::value_type(t));
703 auto n = getBegin();
704 pTrack->SetOwner(shared_from_this(), n);
705 pTrack->SetId( TrackId{ ++sCounter } );
707 AdditionEvent(n);
708 return front().get();
709}
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
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:134
void SetId(TrackId id)
Definition: Track.h:289

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

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

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

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

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

Here is the call graph for this function:

◆ end() [1/2]

iterator TrackList::end ( )
inline

Definition at line 1391 of file Track.h.

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

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

Here is the caller graph for this function:

◆ end() [2/2]

const_iterator TrackList::end ( ) const
inline

Definition at line 1393 of file Track.h.

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

◆ EndIterator()

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

Definition at line 1667 of file Track.h.

1668 {
1669 auto e = const_cast<TrackList*>(this)->getEnd();
1670 return { e, e, e };
1671 }

◆ EnsureVisibleEvent()

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

Definition at line 606 of file Track.cpp.

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

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

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

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

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

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

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

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

1430 {
1431 return const_cast<TrackList*>(this)->
1432 FindLeader( const_cast<Track*>(pTrack) ).Filter< const Track >();
1433 }
TrackIter< Track > FindLeader(Track *pTrack)
Definition: Track.cpp:644

◆ FindLeader() [2/2]

auto TrackList::FindLeader ( Track pTrack)

Definition at line 644 of file Track.cpp.

646{
647 auto iter = Find(pTrack);
648 while( *iter && ! ( *iter )->IsLeader() )
649 --iter;
650 return iter.Filter( &Track::IsLeader );
651}
bool IsLeader() const
Definition: Track.cpp:405
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:1399

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:

◆ Get() [1/2]

TrackList & TrackList::Get ( AudacityProject project)
static

Definition at line 486 of file Track.cpp.

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

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(), Exporter::CheckMix(), ProjectAudioManager::ChooseExistingRecordingTracks(), ButtonHandle::Click(), TrackPanelResizeHandle::Click(), LabelDefaultClickHandle::Click(), LabelGlyphHandle::Click(), BrushHandle::Click(), SelectHandle::Click(), TimeShiftHandle::Click(), BackgroundHandle::Click(), CutCopyAvailableFlag(), DefaultPlayOptions(), 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{SelectMenus.cpp}::DoNextPeakFrequency(), 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(), 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(), ProjectHistory::InitialState(), anonymous_namespace{LabelMenus.cpp}::LabelsSelectedFlag(), LabelTracksExistFlag(), LOFImportFileHandle::lofOpenFiles(), MixerBoard::MixerBoard(), ProjectHistory::ModifyState(), anonymous_namespace{SelectMenus.cpp}::MoveWhenAudioInactive(), TrackActions::Handler::MuteTracks(), anonymous_namespace{SelectMenus.cpp}::NearestZeroCrossing(), LabelTrack::New(), NoteTrack::New(), TimeTrack::New(), WaveTrack::New(), anonymous_namespace{FileMenus.cpp}::NoteTracksExistFlag(), ApplyMacroDialog::OnApplyToFiles(), ProjectManager::OnCloseWindow(), ViewActions::Handler::OnCollapseAllTracks(), ProjectAudioManager::OnCommitRecording(), EditActions::Handler::OnCopy(), LabelEditActions::Handler::OnCopyLabels(), SelectActions::Handler::OnCursorTrackEnd(), SelectActions::Handler::OnCursorTrackStart(), EditActions::Handler::OnCut(), LabelEditActions::Handler::OnCutLabels(), EditActions::Handler::OnDelete(), LabelEditActions::Handler::OnDeleteLabels(), EditActions::Handler::OnDisjoin(), LabelEditActions::Handler::OnDisjoinLabels(), EditActions::Handler::OnDuplicate(), AudacityApp::OnExceptionInMainLoop(), ViewActions::Handler::OnExpandAllTracks(), FileActions::Handler::OnExportLabels(), FileActions::Handler::OnExportMIDI(), NavigationActions::Handler::OnFirstTrack(), ContrastDialog::OnGetBackground(), ContrastDialog::OnGetForeground(), FileActions::Handler::OnImportLabels(), EditActions::Handler::OnJoin(), LabelEditActions::Handler::OnJoinLabels(), NavigationActions::Handler::OnLastTrack(), WaveTrackMenuTable::OnMergeStereo(), LabelEditActions::Handler::OnNewLabelTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::Handler::OnNewStereoTrack(), anonymous_namespace{TimeTrackMenuItems.cpp}::Handler::OnNewTimeTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::Handler::OnNewWaveTrack(), EditActions::Handler::OnPaste(), LabelEditActions::Handler::OnPasteNewLabel(), FileActions::Handler::OnPrint(), ProjectAudioManager::OnRecord(), EditActions::Handler::OnRedo(), TrackActions::Handler::OnResample(), SelectActions::Handler::OnSelectAll(), SelectActions::Handler::OnSelectCursorEnd(), SelectActions::Handler::OnSelectStartCursor(), SelectActions::Handler::OnSelectSyncLockSel(), SelectActions::Handler::OnSelectTrackStartToEnd(), ScreenshotBigDialog::OnShortTracks(), EditActions::Handler::OnSilence(), LabelEditActions::Handler::OnSilenceLabels(), EditActions::Handler::OnSplit(), EditActions::Handler::OnSplitCut(), LabelEditActions::Handler::OnSplitCutLabels(), EditActions::Handler::OnSplitDelete(), LabelEditActions::Handler::OnSplitDeleteLabels(), LabelEditActions::Handler::OnSplitLabels(), EditActions::Handler::OnSplitNew(), WaveTrackMenuTable::OnSwapChannels(), TransportActions::Handler::OnTimerRecord(), TrackActions::Handler::OnTrackMoveBottom(), TrackActions::Handler::OnTrackMoveDown(), TrackActions::Handler::OnTrackMoveTop(), TrackActions::Handler::OnTrackMoveUp(), EditActions::Handler::OnTrim(), EditActions::Handler::OnUndo(), anonymous_namespace{TrackView.cpp}::TrackPositioner::OnUpdate(), ProjectFileManager::OpenProjectFile(), TimeTrack::PasteInto(), anonymous_namespace{MixerBoard.cpp}::PlayableTracksExistFlag(), TranscriptionToolBar::PlayAtSpeed(), ProjectAudioManager::PlayPlayRegion(), ProjectHistory::PopState(), TrackSelectHandle::Preview(), NyquistEffect::Process(), SpectralDataManager::ProcessTracks(), TrackPanel::ProcessUIHandleResult(), ProjectHistory::PushState(), ProjectFileManager::ReadProjectFile(), RealtimeEffectPanel::RealtimeEffectPanel(), ProjectHistory::RedoAvailable(), ProjectWindow::RedrawProject(), ButtonHandle::Release(), LabelTextHandle::Release(), NoteTrackButtonHandle::Release(), NoteTrackVZoomHandle::Release(), SpectrumVZoomHandle::Release(), WaveformVZoomHandle::Release(), TimeTrackVZoomHandle::Release(), AffordanceHandle::Release(), LabelDefaultClickHandle::RestoreState(), 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{TrackView.cpp}::TrackPositioner::TrackPositioner(), TracksExistFlag(), ProjectHistory::UndoAvailable(), 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 491 of file Track.cpp.

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

References Get().

Here is the call graph for this function:

◆ getBegin()

TrackNodePointer TrackList::getBegin ( ) const
inlineprivate

Definition at line 1681 of file Track.h.

1682 { return { const_cast<TrackList*>(this)->ListOfTracks::begin(),
1683 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 1678 of file Track.h.

1679 { return { const_cast<TrackList*>(this)->ListOfTracks::end(),
1680 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 1052 of file Track.cpp.

1053{
1054 return Accumulate(*this, &Track::GetEndTime, -DBL_MAX, std::max);
1055}
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:1027

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

Referenced by SelectTimeCommand::Apply(), DefaultPlayOptions(), LOFImportFileHandle::doDurationAndScrollOffset(), ExportMultipleDialog::ExportMultipleByLabel(), AudacityPrintout::OnPrintPage(), 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 1042 of file Track.cpp.

1043{
1044 return Accumulate(*this, &Track::GetOffset, DBL_MAX, std::min);
1045}
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 850 of file Track.cpp.

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

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

1687 {
1688 if ( isNull(p) )
1689 return p;
1690 auto q = p;
1691 ++q.first;
1692 return q;
1693 }

Referenced by GetNext(), and Remove().

Here is the caller graph for this function:

◆ GetOwner() [1/2]

AudacityProject * TrackList::GetOwner ( )
inline

Definition at line 1373 of file Track.h.

1373{ 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 1374 of file Track.h.

1374{ return mOwner; }

◆ GetPrev()

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

Definition at line 869 of file Track.cpp.

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

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

1697 {
1698 if (p == getBegin())
1699 return getEnd();
1700 else {
1701 auto q = p;
1702 --q.first;
1703 return q;
1704 }
1705 }

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

Here is the caller graph for this function:

◆ GetStartTime()

double TrackList::GetStartTime ( ) const

Definition at line 1047 of file Track.cpp.

1048{
1049 return Accumulate(*this, &Track::GetStartTime, DBL_MAX, std::min);
1050}
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 1336 of file Track.cpp.

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

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

Here is the call graph for this function:

◆ isNull()

bool TrackList::isNull ( TrackNodePointer  p) const
inlineprivate

Definition at line 1675 of file Track.h.

1676 { return (p.second == this && p.first == ListOfTracks::end())
1677 || (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 1471 of file Track.h.

1473 {
1474 return Tracks< TrackType >( &Track::IsLeader );
1475 }

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

1482 {
1483 return Tracks< TrackType >( &Track::IsLeader );
1484 }

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

763{
764 if (nChannels != 2)
765 return false;
766
767 auto list = track.mList.lock();
768 if (list.get() == this)
769 {
770 if (*list->FindLeader(&track) != &track)
771 return false;
772
773 auto first = list->Find(&track);
774 auto canLink = [&]() -> bool {
775 int count = nChannels;
776 for (auto it = first, end = TrackList::end(); it != end && count; ++it)
777 {
778 if ((*it)->HasLinkedTrack())
779 return false;
780 --count;
781 }
782 return count == 0;
783 }();
784
785 if (!canLink)
786 return false;
787
788 (*first)->SetChannel(Track::LeftChannel);
789 auto second = std::next(first);
790 (*second)->SetChannel(Track::RightChannel);
791 (*first)->SetLinkType(aligned ? Track::LinkType::Aligned : Track::LinkType::Group);
792 }
793 else
795 return true;
796}
#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:282
@ RightChannel
Definition: Track.h:283

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

1659 {
1660 auto b = const_cast<TrackList*>(this)->getBegin();
1661 auto e = const_cast<TrackList*>(this)->getEnd();
1662 return { b, iter, e };
1663 }

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

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

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

1595{ return up ? MoveUp(t) : MoveDown(t); }
bool MoveUp(Track *t)
Definition: Track.cpp:978
bool MoveDown(Track *t)
Definition: Track.cpp:991

◆ MoveDown()

bool TrackList::MoveDown ( Track t)

Definition at line 991 of file Track.cpp.

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

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

Here is the call graph for this function:

◆ MoveUp()

bool TrackList::MoveUp ( Track t)

Definition at line 978 of file Track.cpp.

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

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

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

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

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

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

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

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

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

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

1059{
1060 std::shared_ptr<Track> pTrack;
1061 if (src) {
1062 pTrack = src->Clone(); // not duplicate
1063 // Share the satellites with the original, though they do not point back
1064 // to the pending track
1065 ((AttachedTrackObjects&)*pTrack) = *src; // shallow copy
1066 }
1067
1068 if (pTrack) {
1069 mUpdaters.push_back( updater );
1070 mPendingUpdates.push_back( pTrack );
1071 auto n = mPendingUpdates.end();
1072 --n;
1073 pTrack->SetOwner(shared_from_this(), {n, &mPendingUpdates});
1074 }
1075
1076 return pTrack;
1077}
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, and mUpdaters.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1465 {
1466 return Tracks< TrackType >( &Track::IsSelected );
1467 }

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

1490 {
1491 return Tracks< TrackType >( &Track::IsSelectedLeader );
1492 }
bool IsSelectedLeader() const
Definition: Track.cpp:410

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

1499 {
1500 return Tracks< TrackType >( &Track::IsSelectedLeader );
1501 }

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

596{
598}
@ SELECTION_CHANGE
Posted when the set of selected tracks changes.
Definition: Track.h:1291

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

1507 {
1508 return pTrack->GetOwner()->template Any<TrackType>()
1509 .StartingWith( pTrack ).EndingAfter( pTrack );
1510 }

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

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

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

Referenced by ScreenshotCommand::Apply(), 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 518 of file Track.cpp.

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

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

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

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

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

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

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

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

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

◆ UnlinkChannels()

void TrackList::UnlinkChannels ( Track track)

Removes linkage if track belongs to a group.

Definition at line 746 of file Track.cpp.

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

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

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

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

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

Member Data Documentation

◆ mOwner

AudacityProject* TrackList::mOwner
private

Definition at line 1771 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 1775 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 1777 of file Track.h.

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

◆ sCounter

long TrackList::sCounter = -1
staticprivate

Definition at line 1723 of file Track.h.

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


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