Audacity 3.2.0
SampleTrack.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5SampleTrack.cpp
6
7Paul Licameli split from WaveTrack.cpp
8
9**********************************************************************/
10
11#include "SampleTrack.h"
12
13#include <cmath>
14
15SampleTrack::SampleTrack() = default;
16
18 : PlayableTrack(other, std::move(a))
20{
21}
22
24
26{
27 if (TrackList::NChannels(*this) == 1)
29 else if (IsLeader())
31 else
32 // TODO more-than-two-channels
34}
35
37{
38 static const Track::TypeInfo info{
39 { "sample", "sample", XO("Sample Track") },
41 return info;
42}
43
45{
46 return typeInfo();
47}
48
49auto SampleTrack::GetTypeInfo() const -> const TypeInfo &
50{
51 return typeInfo();
52}
53
55{
56 return sampleCount( floor(t0 * GetRate() + 0.5) );
57}
58
60{
61 return pos.as_double() / GetRate();
62}
63
65
68) : SampleTrack(other, std::move(a))
69{
70}
71
73
75{
76 static const Track::TypeInfo info{
77 { "writable-sample", "writable-sample", XO("Writable Sample Track") },
79 return info;
80}
81
83{
84 return typeInfo2();
85}
86
88{
89 return typeInfo2();
90}
XO("Cut/Copy/Paste")
static const Track::TypeInfo & typeInfo2()
Definition: SampleTrack.cpp:74
static const Track::TypeInfo & typeInfo()
Definition: SampleTrack.cpp:36
Utility to register hooks into a host class that attach client data.
Definition: ClientData.h:220
AudioTrack subclass that can also be audibly replayed by the program.
Definition: PlayableTrack.h:40
static const TypeInfo & ClassTypeInfo()
AudioGraph::ChannelType GetChannelType() const final
Classify this channel.
Definition: SampleTrack.cpp:25
virtual double GetRate() const =0
~SampleTrack() override
const TypeInfo & GetTypeInfo() const override
Definition: SampleTrack.cpp:49
static const TypeInfo & ClassTypeInfo()
Definition: SampleTrack.cpp:44
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: SampleTrack.cpp:59
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: SampleTrack.cpp:54
bool IsLeader() const
Definition: Track.cpp:296
size_t NChannels() const
Definition: Track.cpp:889
static const TypeInfo & ClassTypeInfo()
Definition: SampleTrack.cpp:82
const TypeInfo & GetTypeInfo() const override
Definition: SampleTrack.cpp:87
~WritableSampleTrack() override
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
double as_double() const
Definition: SampleCount.h:46
ChannelType
Mutually exclusive channel classifications.
STL namespace.
Empty argument passed to some public constructors.
Definition: Track.h:168