15#ifndef __AUDACITY_CHANNEL__
16#define __AUDACITY_CHANNEL__
34 : mStart{ start }, mEnd{
end }
41 double Start()
const {
return mStart; }
42 double End()
const {
return mEnd; }
89 template<
typename IntervalType = ChannelInterval>
93 std::dynamic_pointer_cast<IntervalType>(DoGetChannel(
iChannel));
99 template<
typename IntervalType = const ChannelInterval>
101 -> std::enable_if_t<std::is_const_v<IntervalType>,
102 std::shared_ptr<IntervalType>>
104 return std::dynamic_pointer_cast<IntervalType>(
110 template<
typename IntervalType>
113 std::shared_ptr<IntervalType>, std::bidirectional_iterator_tag
116 using GroupType = std::conditional_t<std::is_const_v<IntervalType>,
121 : mpGroup{ pGroup }, mIndex{ index }
126 if (!mpGroup || mIndex >= mpGroup->NChannels())
128 return mpGroup->template GetChannel<IntervalType>(mIndex);
133 {
auto copy{ *
this }; operator ++();
return copy; }
137 {
auto copy{ *
this }; operator --();
return copy; }
142 {
return !(a == b); }
150 template<
typename IntervalType = ChannelInterval>
153 return { {
this, 0 }, {
this, NChannels() } };
157 template<
typename IntervalType = const ChannelInterval>
159 ->
std::enable_if_t<
std::is_const_v<IntervalType>,
163 return { {
this, 0 }, {
this, NChannels() } };
192 size_t GetChannelIndex()
const;
194 size_t ReallyGetChannelIndex()
const;
204 size_t NIntervals()
const;
211 template<
typename IntervalType = Interval>
212 std::shared_ptr<IntervalType> GetInterval(
size_t iInterval);
217 template<
typename IntervalType = const Interval>
218 auto GetInterval(
size_t iInterval)
const
219 -> std::enable_if_t<std::is_const_v<IntervalType>,
220 std::shared_ptr<IntervalType>>;
228 template<
typename IntervalType>
231 std::shared_ptr<IntervalType>, std::bidirectional_iterator_tag
234 using ChannelType = std::conditional_t<std::is_const_v<IntervalType>,
239 : mpChannel{ pChannel }, mIndex{ index }
244 if (!mpChannel || mIndex >= mpChannel->NIntervals())
246 return mpChannel->template GetInterval<IntervalType>(mIndex);
251 {
auto copy{ *
this }; operator ++();
return copy; }
255 {
auto copy{ *
this }; operator --();
return copy; }
260 {
return !(a == b); }
268 template<
typename IntervalType = Interval>
271 return { {
this, 0 }, {
this, NIntervals() } };
275 template<
typename IntervalType = const Interval>
277 ->
std::enable_if_t<
std::is_const_v<IntervalType>,
281 return { {
this, 0 }, {
this, NIntervals() } };
300 int FindChannelIndex()
const;
309 double GetStartTime()
const;
311 double GetEndTime()
const;
317 void ShiftBy(
double t) { MoveTo(GetStartTime() + t); }
343 template<
typename ChannelType = Channel>
347 std::dynamic_pointer_cast<ChannelType>(DoGetChannel(
iChannel));
353 template<
typename ChannelType = const Channel>
355 -> std::enable_if_t<std::is_const_v<ChannelType>,
356 std::shared_ptr<ChannelType>>
358 return std::dynamic_pointer_cast<ChannelType>(
364 template<
typename ChannelType>
367 std::shared_ptr<ChannelType>, std::bidirectional_iterator_tag
370 using GroupType = std::conditional_t<std::is_const_v<ChannelType>,
375 : mpGroup{ pGroup }, mIndex{ index }
380 if (!mpGroup || mIndex >= mpGroup->NChannels())
382 return mpGroup->template GetChannel<ChannelType>(mIndex);
387 {
auto copy{ *
this }; operator ++();
return copy; }
391 {
auto copy{ *
this }; operator --();
return copy; }
396 {
return !(a == b); }
407 template<
typename ChannelType = Channel>
411 return { {
this, 0 }, {
this, NChannels() } };
418 template<
typename ChannelType = const Channel>
425 return { {
this, 0 }, {
this, NChannels() } };
444 template<
typename IntervalType = Interval>
448 std::dynamic_pointer_cast<IntervalType>(DoGetInterval(iInterval));
454 template<
typename IntervalType = const Interval>
456 -> std::enable_if_t<std::is_const_v<IntervalType>,
457 std::shared_ptr<IntervalType>>
459 return std::dynamic_pointer_cast<IntervalType>(
460 const_cast<ChannelGroup*
>(
this)->DoGetInterval(iInterval));
469 template<
typename IntervalType>
472 std::shared_ptr<IntervalType>, std::bidirectional_iterator_tag
475 using GroupType = std::conditional_t<std::is_const_v<IntervalType>,
480 : mpGroup{ pGroup }, mIndex{ index }
485 if (!mpGroup || mIndex >= mpGroup->NIntervals())
487 return mpGroup->template GetInterval<IntervalType>(mIndex);
492 {
auto copy{ *
this }; operator ++();
return copy; }
496 {
auto copy{ *
this }; operator --();
return copy; }
501 {
return !(a == b); }
512 template<
typename IntervalType = Interval>
516 return { {
this, 0 }, {
this, NIntervals() } };
523 template<
typename IntervalType = const Interval>
525 ->
std::enable_if_t<
std::is_const_v<IntervalType>,
530 return { {
this, 0 }, {
this, NIntervals() } };
561 void DestroyGroupData();
564 std::unique_ptr<ChannelGroupData> DetachGroupData();
567 void AssignGroupData(std::unique_ptr<ChannelGroupData> pGroupData);
587 bool mSelected{
false };
613template<
typename IntervalType>
620template<
typename IntervalType>
622 -> std::enable_if_t<std::is_const_v<IntervalType>,
623 std::shared_ptr<IntervalType>>
625 return ReallyDoGetChannelGroup().GetInterval(iInterval)
626 ->template GetChannel<IntervalType>(ReallyGetChannelIndex());
Utility ClientData::Site to register hooks into a host class that attach client data.
Vector operator*(const Vector &left, const Vector &right)
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.
ClientData::Site< ChannelGroupData, ClientData::Cloneable<>, ClientData::DeepCopying > Attachments
virtual void MoveTo(double o)=0
Change start time to given time point.
ChannelGroupData * FindGroupData()
Do not make attachment site on demand if absent.
virtual bool IsLeader() const =0
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::unique_ptr< ChannelGroupData > mpGroupData
std::shared_ptr< IntervalType > GetInterval(size_t iInterval)
Retrieve an interval, cast to the given type.
const ChannelGroupData * FindGroupData() const
Do not make attachment site on demand if absent.
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
Retrieve a channel.
A start and an end time, and whatever else subclasses associate with them.
virtual ~ChannelGroupInterval()
ChannelGroupInterval(double start, double end)
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.
virtual ChannelGroup & ReallyDoGetChannelGroup() const
This is temporary! It defaults to call the above.
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 ReallyGetChannelIndex() 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.
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.
size_t NChannels() const
Report the number of channels.
ChannelType
Mutually exclusive channel classifications.
@ DeepCopying
point to new sub-objects; these must define a Clone() member; won't compile for std::weak_ptr
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
void copy(const T *src, T *dst, int32_t n)
std::optional< double > mProjectTempo
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 ...