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

#include <Channel.h>

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

Classes

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 = ChannelGroupAttachments
 
- Public Types inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
using DataType = ClientData
 
using DataPointer = Pointer< ClientData >
 
using DataFactory = std::function< DataPointer(Host &) >
 Type of function from which RegisteredFactory is constructed; it builds attachments. More...
 

Public 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...
 
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...
 
std::shared_ptr< ChannelNthChannel (size_t nChannel)
 
std::shared_ptr< const ChannelNthChannel (size_t nChannel) const
 
- Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
 ~Site ()
 
 Site ()
 
 Site (const Site &other)
 
Siteoperator= (const Site &other)
 
 Site (Site &&other)
 
Siteoperator= (Site &&other)
 
size_t size () const
 How many attachment pointers are in the Site. More...
 
template<typename Subclass = ClientData>
Subclass & Get (const RegisteredFactory &key)
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = const ClientData>
auto Get (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass & >
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = ClientData>
Subclass * Find (const RegisteredFactory &key)
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename Subclass = const ClientData>
auto Find (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass * >
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename ReplacementPointer >
void Assign (const RegisteredFactory &key, ReplacementPointer &&replacement)
 Reassign Site's pointer to ClientData. More...
 

Protected Member Functions

virtual std::shared_ptr< ChannelDoGetChannel (size_t iChannel)=0
 
virtual std::shared_ptr< IntervalDoGetInterval (size_t iInterval)=0
 Retrieve an interval. More...
 
- Protected Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
template<typename Function >
void ForEach (const Function &function)
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
void ForEach (const Function &function) const
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
void ForCorresponding (Site &other, const Function &function, bool create=true)
 
template<typename Function >
ClientData * FindIf (const Function &function)
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
template<typename Function >
const ClientData * FindIf (const Function &function) const
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
template<typename Function >
void EraseIf (const Function &function)
 Erase attached objects satisfying a predicate. More...
 
void BuildAll ()
 For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it. More...
 

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...
 

Additional Inherited Members

- Static Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
static size_t numFactories ()
 How many static factories have been registered with this specialization of Site. More...
 

Detailed Description

Definition at line 283 of file Channel.h.

Member Typedef Documentation

◆ Attachments

Definition at line 286 of file Channel.h.

◆ Interval

Definition at line 416 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 512 of file Channel.h.

512 : int {
513 None = 0,
514 // 1 - reserved for backward compatibility with projects generated by
515 // older versions of Audacity
516 Group = 2,
518 Aligned,
519 };
MenuRegistry::GroupItem< MenuRegistry::Traits > Group
Definition: MenuHelper.h:11

Constructor & Destructor Documentation

◆ ~ChannelGroup()

ChannelGroup::~ChannelGroup ( )
virtualdefault

Member Function Documentation

◆ Channels() [1/2]

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

Get range of channels with mutative access.

Definition at line 381 of file Channel.h.

382 {
383 return { { this, 0 }, { this, NChannels() } };
384 }
virtual size_t NChannels() const =0
Report the number of channels.

Referenced by SetTrackVisualsCommand::ApplyInner(), TrackPanelResizeHandle::Click(), CommonTrackInfo::CloseTitleDrawFunction(), TrackShifter::CommonMayMigrateTo(), TrackPanelResizeHandle::Drag(), anonymous_namespace{TrackPanel.cpp}::FindAdjustedChannelHeights(), ChannelView::GetChannelGroupHeight(), ChannelView::GetCumulativeHeight(), 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.

Definition at line 388 of file Channel.h.

392 {
393 return { { this, 0 }, { this, NChannels() } };
394 }

◆ DoGetChannel()

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

Retrieve a channel For fixed iChannel, resulting address must be unchanging, if there has been no other mutation of this ChannelGroup

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

Implemented in UniqueChannelTrack< Base >, UniqueChannelTrack< PlayableTrack >, 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.

◆ 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 320 of file Channel.h.

321 {
322 return
323 std::dynamic_pointer_cast<ChannelType>(DoGetChannel(iChannel));
324 }
virtual std::shared_ptr< Channel > DoGetChannel(size_t iChannel)=0

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 330 of file Channel.h.

333 {
334 return std::dynamic_pointer_cast<ChannelType>(
335 const_cast<ChannelGroup*>(this)->DoGetChannel(iChannel));
336 }

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 61 of file Channel.cpp.

62{
63 const auto &range = Intervals();
64 if (range.empty())
65 return 0;
66 return std::accumulate(range.first, range.second,
67 std::numeric_limits<double>::lowest(),
68 [](double acc, const auto &pInterval){
69 return std::max(acc, pInterval->End()); });
70}
IteratorRange< IntervalIterator< IntervalType > > Intervals()
Get range of intervals with mutative access.
Definition: Channel.h:492

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:

◆ 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 427 of file Channel.h.

428 {
429 return
430 std::dynamic_pointer_cast<IntervalType>(DoGetInterval(iInterval));
431 }
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 437 of file Channel.h.

440 {
441 return std::dynamic_pointer_cast<IntervalType>(
442 const_cast<ChannelGroup*>(this)->DoGetInterval(iInterval));
443 }

◆ GetStartTime()

double ChannelGroup::GetStartTime ( ) const

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

Definition at line 50 of file Channel.cpp.

51{
52 const auto &range = Intervals();
53 if (range.empty())
54 return 0;
55 return std::accumulate(range.first, range.second,
56 std::numeric_limits<double>::max(),
57 [](double acc, const auto &pInterval){
58 return std::min(acc, pInterval->Start()); });
59}

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:

◆ Intervals() [1/2]

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

Get range of intervals with mutative access.

Definition at line 492 of file Channel.h.

493 {
494 return { { this, 0 }, { this, NIntervals() } };
495 }
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 499 of file Channel.h.

503 {
504 return { { this, 0 }, { this, NIntervals() } };
505 }

◆ 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

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

◆ NthChannel() [1/2]

std::shared_ptr< Channel > ChannelGroup::NthChannel ( size_t  nChannel)
inline

Definition at line 396 of file Channel.h.

397 {
398 auto iter = Channels().begin();
399 std::advance(iter, nChannel);
400 return *iter;
401 }
IteratorRange< ChannelIterator< ChannelType > > Channels()
Get range of channels with mutative access.
Definition: Channel.h:381

◆ NthChannel() [2/2]

std::shared_ptr< const Channel > ChannelGroup::NthChannel ( size_t  nChannel) const
inline

Definition at line 403 of file Channel.h.

404 {
405 auto iter = Channels().begin();
406 std::advance(iter, nChannel);
407 return *iter;
408 }

◆ ShiftBy()

void ChannelGroup::ShiftBy ( double  t)
inline

Change start time by given duration.

Definition at line 296 of file Channel.h.

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

Referenced by TrackShifter::DoHorizontalOffset().

Here is the caller graph for this function:

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