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 (TrackNodePointer node={})
 
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 1331 of file Track.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 1386 of file Track.h.

◆ iterator

Definition at line 1385 of file Track.h.

◆ Updater

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

Definition at line 1724 of file Track.h.

◆ value_type

Definition at line 1387 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:1769

◆ ~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:823

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

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

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

629{
630 QueueEvent({ TrackListEvent::ADDITION, *node.first });
631}
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 1558 of file Track.h.

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

◆ Any() [1/2]

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

Definition at line 1435 of file Track.h.

1437 {
1438 return Tracks< TrackType >();
1439 }

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

1446 {
1447 return Tracks< TrackType >();
1448 }

◆ ApplyPendingTracks()

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

Definition at line 1140 of file Track.cpp.

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

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

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

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

◆ CanMoveDown()

bool TrackList::CanMoveDown ( Track t) const

Definition at line 906 of file Track.cpp.

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

References GetNext().

Here is the call graph for this function:

◆ CanMoveUp()

bool TrackList::CanMoveUp ( Track t) const

Definition at line 901 of file Track.cpp.

902{
903 return GetPrev(t, true) != NULL;
904}
Track * GetPrev(Track *t, bool linked=false) const
Definition: Track.cpp:865

References GetPrev().

Here is the call graph for this function:

◆ cbegin()

const_iterator TrackList::cbegin ( ) const
inline

Definition at line 1392 of file Track.h.

1392{ return begin(); }
iterator begin()
Definition: Track.h:1388

References PackedArray::begin().

Here is the call graph for this function:

◆ cend()

const_iterator TrackList::cend ( ) const
inline

Definition at line 1393 of file Track.h.

1393{ return end(); }
iterator end()
Definition: Track.h:1389

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

1541 {
1542 return Channels_<TrackType>( pTrack->GetOwner()->FindLeader(pTrack) );
1543 }

Referenced by RealtimeEffectManager::AddState(), 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{ClipMenus.cpp}::FindClipBoundaries(), anonymous_namespace{ClipMenus.cpp}::FindClips(), anonymous_namespace{WaveClipTrimHandle.cpp}::FindClipsInChannels(), TrackView::GetChannelGroupHeight(), ContrastDialog::GetDB(), CommonTrackView::GetMinimizedHeight(), MixerTrackCluster::GetRight(), VampEffect::Init(), ClipMoveState::Init(), TrackPanelAx::IsFocused(), LOFImportFileHandle::lofOpenFiles(), MixAndRender(), 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(), TrackPanel::RefreshTrack(), RealtimeEffectManager::RemoveState(), 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 1517 of file Track.h.

1518 {
1519 // Assume iterator filters leader tracks
1520 if (*iter1) {
1521 return {
1522 iter1.Filter( &Track::Any )
1523 .template Filter<TrackType>(),
1524 (++iter1).Filter( &Track::Any )
1525 .template Filter<TrackType>()
1526 };
1527 }
1528 else
1529 // empty range
1530 return {
1531 iter1.template Filter<TrackType>(),
1532 iter1.template Filter<TrackType>()
1533 };
1534 }
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 823 of file Track.cpp.

824{
825 // Null out the back-pointers to this in tracks, in case there
826 // are outstanding shared_ptrs to those tracks, making them outlive
827 // the temporary ListOfTracks below.
828 for ( auto pTrack: *this )
829 pTrack->SetOwner( {}, {} );
830 for ( auto pTrack: mPendingUpdates )
831 pTrack->SetOwner( {}, {} );
832
833 ListOfTracks tempList;
834 tempList.swap( *this );
835
836 ListOfTracks updating;
837 updating.swap( mPendingUpdates );
838
839 mUpdaters.clear();
840
841 if (sendEvent)
843}
std::vector< Updater > mUpdaters
This is in correspondence with mPendingUpdates.
Definition: Track.h:1775
void DeletionEvent(TrackNodePointer node={})
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 1099 of file Track.cpp.

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

1001{
1002 return make_iterator_range( *this ).contains( t );
1003}
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:423

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(), 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 ( TrackNodePointer  node = {})
private

Definition at line 618 of file Track.cpp.

619{
620 QueueEvent({
622 node.second && node.first != node.second->end()
623 ? *node.first
624 : nullptr
625 });
626}
@ DELETION
Posted when a track has been deleted from a tracklist. Also posted when one track replaces another.
Definition: Track.h:1311

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

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

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

704{
705 Track *pTrack = t.get();
706 push_front(ListOfTracks::value_type(t));
707 auto n = getBegin();
708 pTrack->SetOwner(shared_from_this(), n);
709 pTrack->SetId( TrackId{ ++sCounter } );
711 AdditionEvent(n);
712 return front().get();
713}
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 1005 of file Track.cpp.

1006{
1007 return begin() == end();
1008}

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

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

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

Here is the call graph for this function:

◆ end() [1/2]

iterator TrackList::end ( )
inline

Definition at line 1389 of file Track.h.

1389{ 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 1391 of file Track.h.

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

◆ EndIterator()

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

Definition at line 1665 of file Track.h.

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

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

1413 {
1414 if (!pTrack || pTrack->GetOwner().get() != this)
1415 return EndIterator<TrackType>();
1416 else
1417 return MakeTrackIterator<TrackType>( pTrack->GetNode() );
1418 }
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 1397 of file Track.h.

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

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

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

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

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

◆ FindLeader() [2/2]

auto TrackList::FindLeader ( Track pTrack)

Definition at line 648 of file Track.cpp.

650{
651 auto iter = Find(pTrack);
652 while( *iter && ! ( *iter )->IsLeader() )
653 --iter;
654 return iter.Filter( &Track::IsLeader );
655}
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:1397

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

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

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

1049{
1050 return Accumulate(*this, &Track::GetEndTime, -DBL_MAX, std::max);
1051}
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:1023

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

1039{
1040 return Accumulate(*this, &Track::GetOffset, DBL_MAX, std::min);
1041}
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 846 of file Track.cpp.

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

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

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

Referenced by GetNext(), and Remove().

Here is the caller graph for this function:

◆ GetOwner() [1/2]

AudacityProject * TrackList::GetOwner ( )
inline

Definition at line 1371 of file Track.h.

1371{ 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 1372 of file Track.h.

1372{ return mOwner; }

◆ GetPrev()

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

Definition at line 865 of file Track.cpp.

866{
867 if (t) {
868 TrackNodePointer prev;
869 auto node = t->GetNode();
870 if ( !isNull( node ) ) {
871 // linked is true and input track second in team?
872 if (linked) {
873 prev = getPrev( node );
874 if( !isNull( prev ) &&
875 !t->HasLinkedTrack() && t->GetLinkedTrack() )
876 // Make it the first
877 node = prev;
878 }
879
880 prev = getPrev( node );
881 if ( !isNull( prev ) ) {
882 // Back up once
883 node = prev;
884
885 // Back up twice sometimes when linked is true
886 if (linked) {
887 prev = getPrev( node );
888 if( !isNull( prev ) &&
889 !(*node.first)->HasLinkedTrack() && (*node.first)->GetLinkedTrack() )
890 node = prev;
891 }
892
893 return node.first->get();
894 }
895 }
896 }
897
898 return nullptr;
899}
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 1694 of file Track.h.

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

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

Here is the caller graph for this function:

◆ GetStartTime()

double TrackList::GetStartTime ( ) const

Definition at line 1043 of file Track.cpp.

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

1333{
1334 if ( !mPendingUpdates.empty() )
1335 return true;
1336 if (end() != std::find_if(begin(), end(), [](const Track *t){
1337 return t->GetId() == TrackId{};
1338 }))
1339 return true;
1340 return false;
1341}
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 1673 of file Track.h.

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

1471 {
1472 return Tracks< TrackType >( &Track::IsLeader );
1473 }

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

1480 {
1481 return Tracks< TrackType >( &Track::IsLeader );
1482 }

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

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

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

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

1593{ return up ? MoveUp(t) : MoveDown(t); }
bool MoveUp(Track *t)
Definition: Track.cpp:974
bool MoveDown(Track *t)
Definition: Track.cpp:987

◆ MoveDown()

bool TrackList::MoveDown ( Track t)

Definition at line 987 of file Track.cpp.

988{
989 if (t) {
990 Track *n = GetNext(t, true);
991 if (n) {
992 SwapNodes(t->GetNode(), n->GetNode());
993 return true;
994 }
995 }
996
997 return false;
998}
void SwapNodes(TrackNodePointer s1, TrackNodePointer s2)
Definition: Track.cpp:915

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

Here is the call graph for this function:

◆ MoveUp()

bool TrackList::MoveUp ( Track t)

Definition at line 974 of file Track.cpp.

975{
976 if (t) {
977 Track *p = GetPrev(t, true);
978 if (p) {
979 SwapNodes(p->GetNode(), t->GetNode());
980 return true;
981 }
982 }
983
984 return false;
985}

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

679{
680 for (const auto iter : permutation) {
681 ListOfTracks::value_type track = *iter.first;
682 erase(iter.first);
683 Track *pTrack = track.get();
684 pTrack->SetOwner(shared_from_this(),
685 { insert(ListOfTracks::end(), track), this });
686 }
687 auto n = getBegin();
690}
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:38

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

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

1076{
1077 Add<Track>( pTrack );
1078 pTrack->SetId( TrackId{} );
1079}

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

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

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

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

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

634{
635 QueueEvent({ TrackListEvent::RESIZING, *node.first });
636}
@ 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 1459 of file Track.h.

1463 {
1464 return Tracks< TrackType >( &Track::IsSelected );
1465 }

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

1488 {
1489 return Tracks< TrackType >( &Track::IsSelectedLeader );
1490 }
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 1493 of file Track.h.

1497 {
1498 return Tracks< TrackType >( &Track::IsSelectedLeader );
1499 }

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

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

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

1011{
1012 int cnt = 0;
1013
1014 if (!empty())
1015 cnt = getPrev( getEnd() ).first->get()->GetIndex() + 1;
1016
1017 return cnt;
1018}

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

658{
659 if (!track.HasLinkedTrack())
660 return false;
661 auto pOwner = track.GetOwner();
662 if (!pOwner)
663 return false;
664 auto pPartner = pOwner->GetNext(&track, false);
665 if (!pPartner)
666 return false;
667
668 // Swap channels, avoiding copying of GroupData
669 auto pData = move(track.mpGroupData);
670 assert(pData);
671 pOwner->MoveUp(pPartner);
672 pPartner->mpGroupData = move(pData);
673 pPartner->SetChannel(Track::LeftChannel);
675 return true;
676}
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 915 of file Track.cpp.

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

1628 {} )
1630 {
1631 auto b = getBegin(), e = getEnd();
1632 return { { b, b, e, pred }, { b, e, e, pred } };
1633 }
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 1641 of file Track.h.

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

◆ UnlinkChannels()

void TrackList::UnlinkChannels ( Track track)

Removes linkage if track belongs to a group.

Definition at line 750 of file Track.cpp.

751{
752 auto list = track.mList.lock();
753 if (list.get() == this)
754 {
755 auto channels = TrackList::Channels(&track);
756 for (auto c : channels)
757 {
758 c->SetLinkType(Track::LinkType::None);
759 c->SetChannel(Track::ChannelType::MonoChannel);
760 }
761 }
762 else
764}
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 1081 of file Track.cpp.

1082{
1083 auto pUpdater = mUpdaters.begin();
1084 for (const auto &pendingTrack : mPendingUpdates) {
1085 // Copy just a part of the track state, according to the update
1086 // function
1087 const auto &updater = *pUpdater;
1088 auto src = FindById( pendingTrack->GetId() );
1089 if (pendingTrack && src) {
1090 if (updater)
1091 updater( *pendingTrack, *src );
1092 pendingTrack->DoSetLinkType(src->GetLinkType());
1093 }
1094 ++pUpdater;
1095 }
1096}
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 1549 of file Track.h.

Member Data Documentation

◆ mOwner

AudacityProject* TrackList::mOwner
private

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

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

◆ sCounter

long TrackList::sCounter = -1
staticprivate

Definition at line 1721 of file Track.h.

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


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