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 ShiftBy (double t0, double delta)=0
 Shift all intervals that starts after t0 by delta seconds. 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 419 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 515 of file Channel.h.

515 : int {
516 None = 0,
517 // 1 - reserved for backward compatibility with projects generated by
518 // older versions of Audacity
519 Group = 2,
521 Aligned,
522 };
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 384 of file Channel.h.

385 {
386 return { { this, 0 }, { this, NChannels() } };
387 }
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(), 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 391 of file Channel.h.

395 {
396 return { { this, 0 }, { this, NChannels() } };
397 }

◆ 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 LabelTrack, NoteTrack, TimeTrack, and WaveTrack.

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

324 {
325 return
326 std::dynamic_pointer_cast<ChannelType>(DoGetChannel(iChannel));
327 }
virtual std::shared_ptr< Channel > DoGetChannel(size_t iChannel)=0

References anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel.

Referenced by CommonTrackInfo::CloseTitleDrawFunction(), LabelTrackView::CopyTo(), WaveChannelView::CopyTo(), ProjectWindow::IsTrackMinimized(), anonymous_namespace{NoteTrackControls.cpp}::MidiControlsDrawFunction(), 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 333 of file Channel.h.

336 {
337 return std::dynamic_pointer_cast<ChannelType>(
338 const_cast<ChannelGroup*>(this)->DoGetChannel(iChannel));
339 }

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

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

431 {
432 return
433 std::dynamic_pointer_cast<IntervalType>(DoGetInterval(iInterval));
434 }
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 440 of file Channel.h.

443 {
444 return std::dynamic_pointer_cast<IntervalType>(
445 const_cast<ChannelGroup*>(this)->DoGetInterval(iInterval));
446 }

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

496 {
497 return { { this, 0 }, { this, NIntervals() } };
498 }
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 502 of file Channel.h.

506 {
507 return { { this, 0 }, { this, NIntervals() } };
508 }

◆ 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< PlayableTrack >, WaveTrack, and WritableSampleTrack.

Referenced by ChannelAttachmentsBase::ChannelAttachmentsBase(), ChannelAttachmentsBase::CopyTo(), anonymous_namespace{FileMenus.cpp}::DoExport(), ProjectAudioManager::DoRecord(), anonymous_namespace{EditMenus.cpp}::FitsInto(), ChannelAttachmentsBase::Get(), 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 LabelTrack, NoteTrack, TimeTrack, and WaveTrack.

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

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

◆ NthChannel() [2/2]

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

Definition at line 406 of file Channel.h.

407 {
408 auto iter = Channels().begin();
409 std::advance(iter, nChannel);
410 return *iter;
411 }

◆ ShiftBy() [1/2]

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:

◆ ShiftBy() [2/2]

virtual void ChannelGroup::ShiftBy ( double  t0,
double  delta 
)
pure virtual

Shift all intervals that starts after t0 by delta seconds.

Implemented in LabelTrack, NoteTrack, WaveTrack, and TimeTrack.


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