Audacity  3.2.0
SampleTrack.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 SampleTrack.cpp
6 
7 Paul Licameli split from WaveTrack.cpp
8 
9 **********************************************************************/
10 
11 #include "SampleTrack.h"
12 
13 #include <cmath>
14 
15 SampleTrack::~SampleTrack() = default;
16 
17 static const Track::TypeInfo &typeInfo()
18 {
19  static const Track::TypeInfo info{
20  { "sample", "sample", XO("Sample Track") },
22  return info;
23 }
24 
26 {
27  return typeInfo();
28 }
29 
30 auto SampleTrack::GetTypeInfo() const -> const TypeInfo &
31 {
32  return typeInfo();
33 }
34 
36 {
37  return sampleCount( floor(t0 * GetRate() + 0.5) );
38 }
39 
41 {
42  return pos.as_double() / GetRate();
43 }
44 
46 
47 static const Track::TypeInfo &typeInfo2()
48 {
49  static const Track::TypeInfo info{
50  { "writable-sample", "writable-sample", XO("Writable Sample Track") },
51  true, &SampleTrack::ClassTypeInfo() };
52  return info;
53 }
54 
56 {
57  return typeInfo2();
58 }
59 
61 {
62  return typeInfo2();
63 }
XO
#define XO(s)
Definition: Internat.h:31
WritableSampleTrack::ClassTypeInfo
static const TypeInfo & ClassTypeInfo()
Definition: SampleTrack.cpp:55
SampleTrack.h
typeInfo2
static const Track::TypeInfo & typeInfo2()
Definition: SampleTrack.cpp:47
sampleCount::as_double
double as_double() const
Definition: SampleCount.h:45
WritableSampleTrack::GetTypeInfo
const TypeInfo & GetTypeInfo() const override
Definition: SampleTrack.cpp:60
SampleTrack::GetRate
virtual double GetRate() const =0
WritableSampleTrack::~WritableSampleTrack
~WritableSampleTrack() override
PlayableTrack::ClassTypeInfo
static const TypeInfo & ClassTypeInfo()
Definition: Track.cpp:1171
typeInfo
static const Track::TypeInfo & typeInfo()
Definition: SampleTrack.cpp:17
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
SampleTrack::~SampleTrack
~SampleTrack() override
SampleTrack::TimeToLongSamples
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: SampleTrack.cpp:35
Track::TypeInfo
Definition: Track.h:325
SampleTrack::LongSamplesToTime
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: SampleTrack.cpp:40
SampleTrack::ClassTypeInfo
static const TypeInfo & ClassTypeInfo()
Definition: SampleTrack.cpp:25
SampleTrack::GetTypeInfo
const TypeInfo & GetTypeInfo() const override
Definition: SampleTrack.cpp:30