15#ifndef __AUDACITY_CHANNEL__
16#define __AUDACITY_CHANNEL__
36 virtual double Start()
const = 0;
38 virtual double End()
const = 0;
73 template<
typename IntervalType = ChannelInterval>
77 std::dynamic_pointer_cast<IntervalType>(DoGetChannel(
iChannel));
83 template<
typename IntervalType = const ChannelInterval>
85 -> std::enable_if_t<std::is_const_v<IntervalType>,
86 std::shared_ptr<IntervalType>>
88 return std::dynamic_pointer_cast<IntervalType>(
94 template<
typename IntervalType>
97 std::shared_ptr<IntervalType>, std::bidirectional_iterator_tag
100 using GroupType = std::conditional_t<std::is_const_v<IntervalType>,
105 : mpGroup{ pGroup }, mIndex{ index }
110 if (!mpGroup || mIndex >= mpGroup->NChannels())
112 return mpGroup->template GetChannel<IntervalType>(mIndex);
117 {
auto copy{ *
this }; operator ++();
return copy; }
121 {
auto copy{ *
this }; operator --();
return copy; }
126 {
return !(a == b); }
134 template<
typename IntervalType = ChannelInterval>
137 return { {
this, 0 }, {
this, NChannels() } };
141 template<
typename IntervalType = const ChannelInterval>
143 ->
std::enable_if_t<
std::is_const_v<IntervalType>,
147 return { {
this, 0 }, {
this, NChannels() } };
173 size_t GetChannelIndex()
const;
183 size_t NIntervals()
const;
190 template<
typename IntervalType = Interval>
191 std::shared_ptr<IntervalType> GetInterval(
size_t iInterval);
196 template<
typename IntervalType = const Interval>
197 auto GetInterval(
size_t iInterval)
const
198 -> std::enable_if_t<std::is_const_v<IntervalType>,
199 std::shared_ptr<IntervalType>>;
207 template<
typename IntervalType>
210 std::shared_ptr<IntervalType>, std::bidirectional_iterator_tag
213 using ChannelType = std::conditional_t<std::is_const_v<IntervalType>,
218 : mpChannel{ pChannel }, mIndex{ index }
223 if (!mpChannel || mIndex >= mpChannel->NIntervals())
225 return mpChannel->template GetInterval<IntervalType>(mIndex);
230 {
auto copy{ *
this }; operator ++();
return copy; }
234 {
auto copy{ *
this }; operator --();
return copy; }
239 {
return !(a == b); }
247 template<
typename IntervalType = Interval>
250 return { {
this, 0 }, {
this, NIntervals() } };
254 template<
typename IntervalType = const Interval>
256 ->
std::enable_if_t<
std::is_const_v<IntervalType>,
260 return { {
this, 0 }, {
this, NIntervals() } };
291 double GetStartTime()
const;
293 double GetEndTime()
const;
296 void ShiftBy(
double t) { MoveTo(GetStartTime() + t); }
319 template<
typename ChannelType = Channel>
323 std::dynamic_pointer_cast<ChannelType>(DoGetChannel(
iChannel));
329 template<
typename ChannelType = const Channel>
331 -> std::enable_if_t<std::is_const_v<ChannelType>,
332 std::shared_ptr<ChannelType>>
334 return std::dynamic_pointer_cast<ChannelType>(
340 template<
typename ChannelType>
343 std::shared_ptr<ChannelType>, std::bidirectional_iterator_tag
346 using GroupType = std::conditional_t<std::is_const_v<ChannelType>,
351 : mpGroup{ pGroup }, mIndex{ index }
356 if (!mpGroup || mIndex >= mpGroup->NChannels())
358 return mpGroup->template GetChannel<ChannelType>(mIndex);
363 {
auto copy{ *
this }; operator ++();
return copy; }
367 {
auto copy{ *
this }; operator --();
return copy; }
372 {
return !(a == b); }
380 template<
typename ChannelType = Channel>
383 return { {
this, 0 }, {
this, NChannels() } };
387 template<
typename ChannelType = const Channel>
393 return { {
this, 0 }, {
this, NChannels() } };
398 auto iter = Channels().begin();
399 std::advance(iter, nChannel);
403 std::shared_ptr<const Channel>
NthChannel(
size_t nChannel)
const
405 auto iter = Channels().begin();
406 std::advance(iter, nChannel);
426 template<
typename IntervalType = Interval>
430 std::dynamic_pointer_cast<IntervalType>(DoGetInterval(iInterval));
436 template<
typename IntervalType = const Interval>
438 -> std::enable_if_t<std::is_const_v<IntervalType>,
439 std::shared_ptr<IntervalType>>
441 return std::dynamic_pointer_cast<IntervalType>(
442 const_cast<ChannelGroup*
>(
this)->DoGetInterval(iInterval));
451 template<
typename IntervalType>
454 std::shared_ptr<IntervalType>, std::bidirectional_iterator_tag
457 using GroupType = std::conditional_t<std::is_const_v<IntervalType>,
462 : mpGroup{ pGroup }, mIndex{ index }
467 if (!mpGroup || mIndex >= mpGroup->NIntervals())
469 return mpGroup->template GetInterval<IntervalType>(mIndex);
474 {
auto copy{ *
this }; operator ++();
return copy; }
478 {
auto copy{ *
this }; operator --();
return copy; }
483 {
return !(a == b); }
491 template<
typename IntervalType = Interval>
494 return { {
this, 0 }, {
this, NIntervals() } };
498 template<
typename IntervalType = const Interval>
500 ->
std::enable_if_t<
std::is_const_v<IntervalType>,
504 return { {
this, 0 }, {
this, NIntervals() } };
542template<
typename IntervalType>
549template<
typename IntervalType>
551 -> std::enable_if_t<std::is_const_v<IntervalType>,
552 std::shared_ptr<IntervalType>>
554 return DoGetChannelGroup().GetInterval(iInterval)
555 ->template GetChannel<IntervalType>(GetChannelIndex());
ClientData::Site< ChannelGroup, ClientData::Cloneable<>, ClientData::DeepCopying > ChannelGroupAttachments
Hosting of objects attached by higher level code.
Utility ClientData::Site to register hooks into a host class that attach client data.
auto operator*(PffftAlignedCount x, Integral y) -> std::enable_if_t< std::is_unsigned_v< Integral > &&sizeof(Integral)<=sizeof(size_t), PffftAlignedCount >
bool operator==(const EffectReverbSettings &a, const EffectReverbSettings &b)
bool operator!=(const WaveTrackLocation &a, const WaveTrackLocation &b)
IntervalIterator(ChannelType *pChannel, size_t index)
IntervalIterator()=default
std::conditional_t< std::is_const_v< IntervalType >, const Channel, Channel > ChannelType
std::conditional_t< std::is_const_v< ChannelType >, const ChannelGroup, ChannelGroup > GroupType
ChannelIterator(GroupType *pGroup, size_t index)
ChannelIterator()=default
std::conditional_t< std::is_const_v< IntervalType >, const ChannelGroup, ChannelGroup > GroupType
IntervalIterator(GroupType *pGroup, size_t index)
IntervalIterator()=default
auto Channels() const -> std::enable_if_t< std::is_const_v< ChannelType >, IteratorRange< ChannelIterator< ChannelType > > >
Get range of channels with read-only access.
auto Intervals() const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< IntervalIterator< IntervalType > > >
Get range of intervals with read-only access.
virtual void MoveTo(double o)=0
Change start time to given time point.
LinkType
For two tracks describes the type of the linkage.
virtual size_t NIntervals() const =0
Report the number of intervals.
IteratorRange< ChannelIterator< ChannelType > > Channels()
Get range of channels with mutative access.
auto GetChannel(size_t iChannel) const -> std::enable_if_t< std::is_const_v< ChannelType >, std::shared_ptr< ChannelType > >
void ShiftBy(double t)
Change start time by given duration.
virtual std::shared_ptr< Interval > DoGetInterval(size_t iInterval)=0
Retrieve an interval.
auto GetInterval(size_t iInterval) const -> std::enable_if_t< std::is_const_v< IntervalType >, std::shared_ptr< IntervalType > >
IteratorRange< IntervalIterator< IntervalType > > Intervals()
Get range of intervals with mutative access.
std::shared_ptr< IntervalType > GetInterval(size_t iInterval)
Retrieve an interval, cast to the given type.
std::shared_ptr< const Channel > NthChannel(size_t nChannel) const
virtual size_t NChannels() const =0
Report the number of channels.
std::shared_ptr< ChannelType > GetChannel(size_t iChannel)
Retrieve a channel, cast to the given type.
virtual std::shared_ptr< Channel > DoGetChannel(size_t iChannel)=0
std::shared_ptr< Channel > NthChannel(size_t nChannel)
A start and an end time, and whatever else subclasses associate with them.
virtual ~ChannelGroupInterval()
virtual double Start() const =0
ChannelGroupInterval()=default
virtual double End() const =0
auto Intervals() const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< IntervalIterator< IntervalType > > >
Get range of intervals with read-only access.
size_t NIntervals() const
Report the number of intervals.
std::shared_ptr< IntervalType > GetInterval(size_t iInterval)
Retrieve an interval, cast to the given type.
IteratorRange< IntervalIterator< IntervalType > > Intervals()
Get range of intervals with mutative access.
ChannelGroup & GetChannelGroup()
Channel object's lifetime is assumed to be nested in its Track's.
virtual ChannelGroup & DoGetChannelGroup() const =0
Subclass must override.
size_t GetChannelIndex() const
The intersection of a Channel and a WideChannelGroupInterval.
virtual ~ChannelInterval()
Utility to register hooks into a host class that attach client data.
ChannelIterator()=default
std::conditional_t< std::is_const_v< IntervalType >, const WideChannelGroupInterval, WideChannelGroupInterval > GroupType
ChannelIterator(GroupType *pGroup, size_t index)
IteratorRange< ChannelIterator< IntervalType > > Channels()
Get range of ChannelInterval objects with mutative access.
virtual size_t NChannels() const =0
Report the number of channels.
auto GetChannel(size_t iChannel) const -> std::enable_if_t< std::is_const_v< IntervalType >, std::shared_ptr< IntervalType > >
~WideChannelGroupInterval() override
auto Channels() const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< ChannelIterator< IntervalType > > >
Get range of channels with read-only access.
std::shared_ptr< IntervalType > GetChannel(size_t iChannel)
Retrieve a channel, cast to the given type.
virtual std::shared_ptr< ChannelInterval > DoGetChannel(size_t iChannel)=0
Retrieve a channel.
ChannelType
Mutually exclusive channel classifications.
@ DeepCopying
point to new sub-objects; these must define a Clone() member; won't compile for std::weak_ptr
void copy(const T *src, T *dst, int32_t n)
A convenient base class defining abstract virtual Clone() for a given kind of pointer.
A convenience for use with range-for.
A convenience for defining iterators that return rvalue types, so that they cooperate correctly with ...