Audacity 3.2.0
TimeTrack.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 TimeTrack.h
6
7 Dr William Bland
8
9**********************************************************************/
10
11#ifndef __AUDACITY_TIMETRACK__
12#define __AUDACITY_TIMETRACK__
13
14#include "Track.h"
15
16#include <algorithm>
17
18class wxRect;
19class BoundedEnvelope;
20class Ruler;
21class ZoomInfo;
23
24class AUDACITY_DLL_API TimeTrack final : public Track {
25
26 public:
27
28 static wxString GetDefaultName();
29
30 // Construct and also build all attachments
31 static TimeTrack *New(AudacityProject &project);
32
33 explicit TimeTrack(const ZoomInfo *zoomInfo);
44 double *pT0 = nullptr, double *pT1 = nullptr);
45
46 virtual ~TimeTrack();
47
48 const TypeInfo &GetTypeInfo() const override;
49 static const TypeInfo &ClassTypeInfo();
50
51 bool SupportsBasicEditing() const override;
52
53 Holder PasteInto( AudacityProject & ) const override;
54
55 Holder Cut( double t0, double t1 ) override;
56 Holder Copy( double t0, double t1, bool forClipboard ) const override;
57 void Clear(double t0, double t1) override;
58 void Paste(double t, const Track * src) override;
59 void Silence(double t0, double t1) override;
60 void InsertSilence(double t, double len) override;
61
62 // TimeTrack parameters
63
64 double GetOffset() const override { return 0.0; }
65 void SetOffset(double /* t */) override {}
66
67 double GetStartTime() const override { return 0.0; }
68 double GetEndTime() const override { return 0.0; }
69
70 // XMLTagHandler callback methods for loading and saving
71
72 bool HandleXMLTag(const std::string_view& tag, const AttributesList& attrs) override;
73 void HandleXMLEndTag(const std::string_view& tag) override;
74 XMLTagHandler *HandleXMLChild(const std::string_view& tag) override;
75 void WriteXML(XMLWriter &xmlFile) const override;
76
77 // Lock and unlock the track: you must lock the track before
78 // doing a copy and paste between projects.
79
80 // bool Lock();
81 // bool Unlock();
82
83 // Access the track's speed envelope
84
85 BoundedEnvelope *GetEnvelope() { return mEnvelope.get(); }
86 const BoundedEnvelope *GetEnvelope() const { return mEnvelope.get(); }
87
88 // Get/Set the speed-warping range, as percentage of original speed (e.g. 90%-110%)
89
90 double GetRangeLower() const;
91 double GetRangeUpper() const;
92
93 void SetRangeLower(double lower);
94 void SetRangeUpper(double upper);
95
96 bool GetDisplayLog() const { return mDisplayLog; }
97 void SetDisplayLog(bool displayLog) { mDisplayLog = displayLog; }
98 bool GetInterpolateLog() const;
99 void SetInterpolateLog(bool interpolateLog);
100
101 void testMe();
102
103 Ruler &GetRuler() const { return *mRuler; }
104
105 private:
106 void CleanState();
107
108 const ZoomInfo *const mZoomInfo;
109 std::unique_ptr<BoundedEnvelope> mEnvelope;
110 std::unique_ptr<Ruler> mRuler;
112 bool mRescaleXMLValues; // needed for backward-compatibility with older project files
113
119 void Init(const TimeTrack &orig);
120
121 using Holder = std::unique_ptr<TimeTrack>;
122
123private:
124 Track::Holder Clone() const override;
125};
126
128
129
130#endif // __AUDACITY_TIMETRACK__
131
ENUMERATE_TRACK_TYPE(TimeTrack)
declares abstract base class Track, TrackList, and iterators over TrackList
std::vector< Attribute > AttributesList
Definition: XMLTagHandler.h:40
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Used to display a Ruler.
Definition: Ruler.h:26
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:24
bool mRescaleXMLValues
Definition: TimeTrack.h:112
void SetDisplayLog(bool displayLog)
Definition: TimeTrack.h:97
const ZoomInfo *const mZoomInfo
Definition: TimeTrack.h:108
std::unique_ptr< TimeTrack > Holder
Definition: TimeTrack.h:121
std::unique_ptr< BoundedEnvelope > mEnvelope
Definition: TimeTrack.h:109
const BoundedEnvelope * GetEnvelope() const
Definition: TimeTrack.h:86
double GetStartTime() const override
Definition: TimeTrack.h:67
double GetEndTime() const override
Definition: TimeTrack.h:68
std::unique_ptr< Ruler > mRuler
Definition: TimeTrack.h:110
BoundedEnvelope * GetEnvelope()
Definition: TimeTrack.h:85
bool GetDisplayLog() const
Definition: TimeTrack.h:96
double GetOffset() const override
Definition: TimeTrack.h:64
bool mDisplayLog
Definition: TimeTrack.h:111
Ruler & GetRuler() const
Definition: TimeTrack.h:103
void SetOffset(double) override
Definition: TimeTrack.h:65
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
virtual void Paste(double WXUNUSED(t), const Track *WXUNUSED(src))=0
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1))=0
virtual Holder PasteInto(AudacityProject &) const =0
Find or create the destination track for a paste, maybe in a different project.
virtual void Clear(double WXUNUSED(t0), double WXUNUSED(t1))=0
virtual const TypeInfo & GetTypeInfo() const =0
virtual bool SupportsBasicEditing() const
Whether this track type implements cut-copy-paste; by default, true.
Definition: Track.cpp:1258
static const TypeInfo & ClassTypeInfo()
Definition: Track.cpp:1251
virtual Holder Clone() const =0
virtual Holder Copy(double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard=true) const =0
std::shared_ptr< Track > Holder
Definition: Track.h:368
void Init(const Track &orig)
Definition: Track.cpp:64
virtual void WriteXML(XMLWriter &xmlFile) const =0
virtual void Silence(double WXUNUSED(t0), double WXUNUSED(t1))=0
virtual void InsertSilence(double WXUNUSED(t), double WXUNUSED(len))=0
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:42
virtual XMLTagHandler * HandleXMLChild(const std::string_view &tag)=0
virtual void HandleXMLEndTag(const std::string_view &WXUNUSED(tag))
Definition: XMLTagHandler.h:59
virtual bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs)=0
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:26
Empty argument passed to some public constructors.
Definition: Track.h:232