Audacity 3.2.0
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
ChannelGroup Class Referenceabstract

#include <Channel.h>

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

Classes

struct  ChannelGroupData
 
class  ChannelIterator
 
class  IntervalIterator
 

Public Types

enum class  LinkType : int { None = 0 , Group = 2 , Aligned }
 For two tracks describes the type of the linkage. More...
 
using Attachments = ClientData::Site< ChannelGroupData, ClientData::Cloneable<>, ClientData::DeepCopying >
 

Public Member Functions

virtual ~ChannelGroup ()
 
double GetStartTime () const
 Get the minimum of Start() values of intervals, or 0 when none. More...
 
double GetEndTime () const
 Get the maximum of End() values of intervals, or 0 when none. More...
 
void ShiftBy (double t)
 Change start time by given duration. More...
 
virtual void MoveTo (double o)=0
 Change start time to given time point. More...
 
virtual bool IsLeader () const =0
 
ChannelGroupDataGetGroupData ()
 Make attachment site on demand as needed. More...
 
const ChannelGroupDataGetGroupData () const
 
ChannelGroupDataFindGroupData ()
 Do not make attachment site on demand if absent. More...
 
const ChannelGroupDataFindGroupData () const
 Do not make attachment site on demand if absent. More...
 
void Init (const ChannelGroup &other)
 Copy, including cloning of attached objects. More...
 
void DestroyGroupData ()
 Leave all attachments null. More...
 
std::unique_ptr< ChannelGroupDataDetachGroupData ()
 Move attachments out. More...
 
void AssignGroupData (std::unique_ptr< ChannelGroupData > pGroupData)
 Replace any previous attachments. More...
 
Acesss to channels
virtual size_t NChannels () const =0
 Report the number of channels. More...
 
template<typename ChannelType = Channel>
std::shared_ptr< ChannelType > GetChannel (size_t iChannel)
 Retrieve a channel, cast to the given type. More...
 
template<typename ChannelType = const Channel>
auto GetChannel (size_t iChannel) const -> std::enable_if_t< std::is_const_v< ChannelType >, std::shared_ptr< ChannelType > >
 
template<typename ChannelType = Channel>
IteratorRange< ChannelIterator< ChannelType > > Channels ()
 Get range of channels with mutative access. More...
 
template<typename ChannelType = const Channel>
auto Channels () const -> std::enable_if_t< std::is_const_v< ChannelType >, IteratorRange< ChannelIterator< ChannelType > > >
 Get range of channels with read-only access. More...
 

Protected Member Functions

virtual std::shared_ptr< ChannelDoGetChannel (size_t iChannel)=0
 Retrieve a channel. More...
 
virtual std::shared_ptr< IntervalDoGetInterval (size_t iInterval)=0
 Retrieve an interval. More...
 

Private Attributes

std::unique_ptr< ChannelGroupDatampGroupData
 

Acesss to intervals

using Interval = WideChannelGroupInterval
 
virtual size_t NIntervals () const =0
 Report the number of intervals. More...
 
template<typename IntervalType = Interval>
std::shared_ptr< IntervalType > GetInterval (size_t iInterval)
 Retrieve an interval, cast to the given type. More...
 
template<typename IntervalType = const Interval>
auto GetInterval (size_t iInterval) const -> std::enable_if_t< std::is_const_v< IntervalType >, std::shared_ptr< IntervalType > >
 
template<typename IntervalType = Interval>
IteratorRange< IntervalIterator< IntervalType > > Intervals ()
 Get range of intervals with mutative access. More...
 
template<typename IntervalType = const Interval>
auto Intervals () const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< IntervalIterator< IntervalType > > >
 Get range of intervals with read-only access. More...
 

Detailed Description

Definition at line 303 of file Channel.h.

Member Typedef Documentation

◆ Attachments

Definition at line 542 of file Channel.h.

◆ Interval

Definition at line 434 of file Channel.h.

Member Enumeration Documentation

◆ LinkType

enum class ChannelGroup::LinkType : int
strong

For two tracks describes the type of the linkage.

Enumerator
None 

No linkage.

Group 

compatibility with projects that were generated by older versions of Audacity

Tracks are grouped together, currently used to provide backward

Aligned 

Tracks are grouped and changes should be synchronized.

Definition at line 571 of file Channel.h.

571 : int {
572 None = 0,
573 // 1 - reserved for backward compatibility with projects generated by
574 // older versions of Audacity
575 Group = 2,
577 Aligned,
578 };
MenuRegistry::GroupItem< MenuRegistry::Traits > Group
Definition: MenuHelper.h:11

Constructor & Destructor Documentation

◆ ~ChannelGroup()

ChannelGroup::~ChannelGroup ( )
virtualdefault

Member Function Documentation

◆ AssignGroupData()

void ChannelGroup::AssignGroupData ( std::unique_ptr< ChannelGroupData pGroupData)

Replace any previous attachments.

Definition at line 106 of file Channel.cpp.

107{
108 mpGroupData = move(pGroupData);
109}
std::unique_ptr< ChannelGroupData > mpGroupData
Definition: Channel.h:605

References mpGroupData.

◆ Channels() [1/2]

template<typename ChannelType = Channel>
IteratorRange< ChannelIterator< ChannelType > > ChannelGroup::Channels ( )
inline

Get range of channels with mutative access.

Precondition
IsLeader()

Definition at line 408 of file Channel.h.

409 {
410 assert(IsLeader());
411 return { { this, 0 }, { this, NChannels() } };
412 }
virtual bool IsLeader() const =0
virtual size_t NChannels() const =0
Report the number of channels.

Referenced by SetTrackVisualsCommand::ApplyInner(), TrackPanelResizeHandle::Click(), TrackShifter::CommonMayMigrateTo(), TrackPanelResizeHandle::Drag(), anonymous_namespace{TrackPanel.cpp}::FindAdjustedChannelHeights(), TrackList::NChannels(), TrackPanelResizeHandle::NextChannel(), TrackPanelResizeHandle::PrevChannel(), ProjectWindow::SetChannelHeights(), ProjectWindow::SetMinimized(), TrackPanelResizeHandle::TrackPanelResizeHandle(), and TrackPanel::UpdateTrackVRuler().

Here is the caller graph for this function:

◆ Channels() [2/2]

template<typename ChannelType = const Channel>
auto ChannelGroup::Channels ( ) const -> std::enable_if_t<std::is_const_v<ChannelType>, IteratorRange<ChannelIterator<ChannelType>> >
inline

Get range of channels with read-only access.

Precondition
IsLeader()

Definition at line 419 of file Channel.h.

423 {
424 assert(IsLeader());
425 return { { this, 0 }, { this, NChannels() } };
426 }

◆ DestroyGroupData()

void ChannelGroup::DestroyGroupData ( )

Leave all attachments null.

Definition at line 96 of file Channel.cpp.

97{
98 mpGroupData.reset();
99}

References mpGroupData.

◆ DetachGroupData()

auto ChannelGroup::DetachGroupData ( )

Move attachments out.

Definition at line 101 of file Channel.cpp.

102{
103 return move(mpGroupData);
104}

Referenced by TrackList::SwapChannels().

Here is the caller graph for this function:

◆ DoGetChannel()

virtual std::shared_ptr< Channel > ChannelGroup::DoGetChannel ( size_t  iChannel)
protectedpure virtual

Retrieve a channel.

Postcondition
result: !(iChannel < NChannels()) || result

Implemented in UniqueChannelTrack< Base >, UniqueChannelTrack< NoteTrackBase >, and WaveTrack.

◆ DoGetInterval()

virtual std::shared_ptr< Interval > ChannelGroup::DoGetInterval ( size_t  iInterval)
protectedpure virtual

Retrieve an interval.

Postcondition
result: !(iInterval < NIntervals()) || result

Implemented in NoteTrack, TimeTrack, WaveTrack, and LabelTrack.

◆ FindGroupData() [1/2]

ChannelGroupData * ChannelGroup::FindGroupData ( )
inline

Do not make attachment site on demand if absent.

Definition at line 553 of file Channel.h.

553{ return mpGroupData.get(); }

Referenced by Track::DoSetLinkType(), Track::GetLinkType(), and Track::HasLinkedTrack().

Here is the caller graph for this function:

◆ FindGroupData() [2/2]

const ChannelGroupData * ChannelGroup::FindGroupData ( ) const
inline

Do not make attachment site on demand if absent.

Definition at line 555 of file Channel.h.

555{ return mpGroupData.get(); }

◆ GetChannel() [1/2]

template<typename ChannelType = Channel>
std::shared_ptr< ChannelType > ChannelGroup::GetChannel ( size_t  iChannel)
inline

Retrieve a channel, cast to the given type.

Postconditions imply that GetChannel(0) is always non-null

Postcondition
if ChannelType is default, then: result: !(iChannel < NChannels()) || result

Definition at line 344 of file Channel.h.

345 {
346 return
347 std::dynamic_pointer_cast<ChannelType>(DoGetChannel(iChannel));
348 }
virtual std::shared_ptr< Channel > DoGetChannel(size_t iChannel)=0
Retrieve a channel.

References anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel.

Referenced by LabelTrackView::CopyTo(), WaveChannelView::CopyTo(), ProjectWindow::IsTrackMinimized(), anonymous_namespace{NoteTrackControls.cpp}::MidiControlsDrawFunction(), CommonTrackInfo::MinimizeSyncLockDrawFunction(), TrackPanel::OnTrackMenu(), and TrackPanel::RefreshTrack().

Here is the caller graph for this function:

◆ GetChannel() [2/2]

template<typename ChannelType = const Channel>
auto ChannelGroup::GetChannel ( size_t  iChannel) const -> std::enable_if_t<std::is_const_v<ChannelType>, std::shared_ptr<ChannelType>>
inline

Postconditions imply that GetChannel(0) is always non-null

Postcondition
if ChannelType is default, then: result: !(iChannel < NChannels()) || result

Definition at line 354 of file Channel.h.

357 {
358 return std::dynamic_pointer_cast<ChannelType>(
359 const_cast<ChannelGroup*>(this)->DoGetChannel(iChannel));
360 }

References anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel.

◆ GetEndTime()

double ChannelGroup::GetEndTime ( ) const

Get the maximum of End() values of intervals, or 0 when none.

Definition at line 135 of file Channel.cpp.

136{
137 auto range = Intervals();
138 if (range.empty())
139 return 0;
140 return std::accumulate(range.first, range.second,
141 std::numeric_limits<double>::lowest(),
142 [](double acc, const auto &pInterval){
143 return std::max(acc, pInterval->End()); });
144}
IteratorRange< IntervalIterator< IntervalType > > Intervals()
Get range of intervals with mutative access.
Definition: Channel.h:513

References Intervals().

Referenced by anonymous_namespace{TrackMenus.cpp}::DoAlign(), TrackList::GetEndTime(), WaveTrack::GetEndTime(), StretchHandle::GetT1(), ModifiedAnalysisTrack::ModifiedAnalysisTrack(), SelectActions::Handler::OnCursorTrackEnd(), ProjectAudioManager::OnRecord(), SelectActions::Handler::OnSelectCursorEnd(), SelectActions::Handler::OnSelectTrackStartToEnd(), NoteTrack::Paste(), SelectionState::SelectTrackLength(), Track::SyncLockAdjust(), and LabelTrack::SyncLockAdjust().

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

◆ GetGroupData() [1/2]

auto ChannelGroup::GetGroupData ( )

Make attachment site on demand as needed.

Definition at line 111 of file Channel.cpp.

112{
113 if (!mpGroupData)
114 // Make on demand
115 mpGroupData = std::make_unique<ChannelGroupData>();
116 return *mpGroupData;
117}

Referenced by RealtimeEffectList::Get(), and GetGroupData().

Here is the caller graph for this function:

◆ GetGroupData() [2/2]

auto ChannelGroup::GetGroupData ( ) const

Make attachment site on demand as needed May make new group data on demand, but consider that logically const

Definition at line 119 of file Channel.cpp.

120{
121 return const_cast<ChannelGroup *>(this)->GetGroupData();
122}
ChannelGroupData & GetGroupData()
Make attachment site on demand as needed.
Definition: Channel.cpp:111

References GetGroupData().

Here is the call graph for this function:

◆ GetInterval() [1/2]

template<typename IntervalType = Interval>
std::shared_ptr< IntervalType > ChannelGroup::GetInterval ( size_t  iInterval)
inline

Retrieve an interval, cast to the given type.

Postcondition
if IntervalType is default, then: result: !(iInterval < NIntervals()) || result

Definition at line 445 of file Channel.h.

446 {
447 return
448 std::dynamic_pointer_cast<IntervalType>(DoGetInterval(iInterval));
449 }
virtual std::shared_ptr< Interval > DoGetInterval(size_t iInterval)=0
Retrieve an interval.

Referenced by Channel::GetInterval().

Here is the caller graph for this function:

◆ GetInterval() [2/2]

template<typename IntervalType = const Interval>
auto ChannelGroup::GetInterval ( size_t  iInterval) const -> std::enable_if_t<std::is_const_v<IntervalType>, std::shared_ptr<IntervalType>>
inline
Postcondition
if IntervalType is default, then: result: !(iInterval < NIntervals()) || result

Definition at line 455 of file Channel.h.

458 {
459 return std::dynamic_pointer_cast<IntervalType>(
460 const_cast<ChannelGroup*>(this)->DoGetInterval(iInterval));
461 }

◆ GetStartTime()

double ChannelGroup::GetStartTime ( ) const

Get the minimum of Start() values of intervals, or 0 when none.

Definition at line 124 of file Channel.cpp.

125{
126 auto range = Intervals();
127 if (range.empty())
128 return 0;
129 return std::accumulate(range.first, range.second,
130 std::numeric_limits<double>::max(),
131 [](double acc, const auto &pInterval){
132 return std::min(acc, pInterval->Start()); });
133}

References Intervals().

Referenced by anonymous_namespace{TrackMenus.cpp}::DoAlign(), anonymous_namespace{NoteTrackView.cpp}::DrawNoteBackground(), anonymous_namespace{NoteTrackView.cpp}::DrawNoteTrack(), TrackList::GetStartTime(), WaveTrack::GetStartTime(), StretchHandle::GetT0(), ModifiedAnalysisTrack::ModifiedAnalysisTrack(), SelectActions::Handler::OnCursorTrackStart(), ExportAudioDialog::OnExport(), SelectActions::Handler::OnSelectStartCursor(), SelectActions::Handler::OnSelectTrackStartToEnd(), and SelectionState::SelectTrackLength().

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

◆ Init()

void ChannelGroup::Init ( const ChannelGroup other)

Copy, including cloning of attached objects.

Definition at line 89 of file Channel.cpp.

90{
91 // Deep copy of any group data
92 mpGroupData = orig.mpGroupData ?
93 std::make_unique<ChannelGroupData>(*orig.mpGroupData) : nullptr;
94}

References mpGroupData.

Referenced by Track::Init().

Here is the caller graph for this function:

◆ Intervals() [1/2]

template<typename IntervalType = Interval>
IteratorRange< IntervalIterator< IntervalType > > ChannelGroup::Intervals ( )
inline

Get range of intervals with mutative access.

Definition at line 513 of file Channel.h.

514 {
515 assert(IsLeader());
516 return { { this, 0 }, { this, NIntervals() } };
517 }
virtual size_t NIntervals() const =0
Report the number of intervals.

Referenced by GetEndTime(), and GetStartTime().

Here is the caller graph for this function:

◆ Intervals() [2/2]

template<typename IntervalType = const Interval>
auto ChannelGroup::Intervals ( ) const -> std::enable_if_t<std::is_const_v<IntervalType>, IteratorRange<IntervalIterator<IntervalType>> >
inline

Get range of intervals with read-only access.

Definition at line 524 of file Channel.h.

528 {
529 assert(IsLeader());
530 return { { this, 0 }, { this, NIntervals() } };
531 }

◆ IsLeader()

virtual bool ChannelGroup::IsLeader ( ) const
pure virtual

◆ MoveTo()

virtual void ChannelGroup::MoveTo ( double  o)
pure virtual

Change start time to given time point.

Implemented in LabelTrack, WaveTrack, NoteTrack, and TimeTrack.

◆ NChannels()

virtual size_t ChannelGroup::NChannels ( ) const
pure virtual

Report the number of channels.

Postcondition
result: result >= 1

Implemented in UniqueChannelTrack< Base >, UniqueChannelTrack< NoteTrackBase >, WaveTrack, and WritableSampleTrack.

Referenced by anonymous_namespace{FileMenus.cpp}::DoExport(), ProjectAudioManager::DoRecord(), ChannelAttachmentsBase::Get(), TrackList::RegisterPendingChangedTrack(), TrackList::ReplaceOne(), Track::SyncLockAdjust(), and Viewport::ZoomFitVertically().

Here is the caller graph for this function:

◆ NIntervals()

virtual size_t ChannelGroup::NIntervals ( ) const
pure virtual

Report the number of intervals.

Implemented in NoteTrack, TimeTrack, WaveTrack, and LabelTrack.

Referenced by Channel::NIntervals().

Here is the caller graph for this function:

◆ ShiftBy()

void ChannelGroup::ShiftBy ( double  t)
inline

Change start time by given duration.

Definition at line 317 of file Channel.h.

317{ MoveTo(GetStartTime() + t); }
double GetStartTime() const
Get the minimum of Start() values of intervals, or 0 when none.
Definition: Channel.cpp:124
virtual void MoveTo(double o)=0
Change start time to given time point.

Referenced by TrackShifter::DoHorizontalOffset(), and StretchHandle::Stretch().

Here is the caller graph for this function:

Member Data Documentation

◆ mpGroupData

std::unique_ptr<ChannelGroupData> ChannelGroup::mpGroupData
private

Definition at line 605 of file Channel.h.

Referenced by AssignGroupData(), DestroyGroupData(), and Init().


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