Audacity 3.2.0
Channel.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Channel.cpp
6
7 Dominic Mazzoni
8
9 Paul Licameli split from Track.h
10
11*//*******************************************************************/
12#include "Channel.h"
13
14#include <algorithm>
15#include <numeric>
16
18
20
22
23Channel::~Channel() = default;
24
26{
27 auto &group = DoGetChannelGroup();
28 int index = -1;
29 for (size_t ii = 0, nn = group.NChannels(); ii < nn; ++ii)
30 if (group.GetChannel(ii).get() == this) {
31 index = ii;
32 break;
33 }
34 assert(index >= 0);
35 return index;
36}
37
39{
40 return DoGetChannelGroup();
41}
42
44{
45 return DoGetChannelGroup();
46}
47
49
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}
60
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}
Abstract class ChannelGroup with two discrete iterable dimensions, channels and intervals; subclasses...
double GetEndTime() const
Get the maximum of End() values of intervals, or 0 when none.
Definition: Channel.cpp:61
double GetStartTime() const
Get the minimum of Start() values of intervals, or 0 when none.
Definition: Channel.cpp:50
IteratorRange< IntervalIterator< IntervalType > > Intervals()
Get range of intervals with mutative access.
Definition: Channel.h:492
virtual ~ChannelGroup()
virtual ~ChannelGroupInterval()
virtual ~Channel()
ChannelGroup & GetChannelGroup()
Channel object's lifetime is assumed to be nested in its Track's.
Definition: Channel.cpp:43
virtual ChannelGroup & DoGetChannelGroup() const =0
Subclass must override.
size_t GetChannelIndex() const
Definition: Channel.cpp:25
virtual ~ChannelInterval()
~WideChannelGroupInterval() override