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);
43 TimeTrack(const TimeTrack &orig, double *pT0 = nullptr, double *pT1 = nullptr);
44
45 virtual ~TimeTrack();
46
47 const TypeInfo &GetTypeInfo() const override;
48 static const TypeInfo &ClassTypeInfo();
49
50 bool SupportsBasicEditing() const override;
51
52 Holder PasteInto( AudacityProject & ) const override;
53
54 Holder Cut( double t0, double t1 ) override;
55 Holder Copy( double t0, double t1, bool forClipboard ) const override;
56 void Clear(double t0, double t1) override;
57 void Paste(double t, const Track * src) override;
58 void Silence(double t0, double t1) override;
59 void InsertSilence(double t, double len) override;
60
61 // TimeTrack parameters
62
63 double GetOffset() const override { return 0.0; }
64 void SetOffset(double /* t */) override {}
65
66 double GetStartTime() const override { return 0.0; }
67 double GetEndTime() const override { return 0.0; }
68
69 // XMLTagHandler callback methods for loading and saving
70
71 bool HandleXMLTag(const std::string_view& tag, const AttributesList& attrs) override;
72 void HandleXMLEndTag(const std::string_view& tag) override;
73 XMLTagHandler *HandleXMLChild(const std::string_view& tag) override;
74 void WriteXML(XMLWriter &xmlFile) const override;
75
76 // Lock and unlock the track: you must lock the track before
77 // doing a copy and paste between projects.
78
79 // bool Lock();
80 // bool Unlock();
81
82 // Access the track's speed envelope
83
84 BoundedEnvelope *GetEnvelope() { return mEnvelope.get(); }
85 const BoundedEnvelope *GetEnvelope() const { return mEnvelope.get(); }
86
87 // Get/Set the speed-warping range, as percentage of original speed (e.g. 90%-110%)
88
89 double GetRangeLower() const;
90 double GetRangeUpper() const;
91
92 void SetRangeLower(double lower);
93 void SetRangeUpper(double upper);
94
95 bool GetDisplayLog() const { return mDisplayLog; }
96 void SetDisplayLog(bool displayLog) { mDisplayLog = displayLog; }
97 bool GetInterpolateLog() const;
98 void SetInterpolateLog(bool interpolateLog);
99
100 void testMe();
101
102 Ruler &GetRuler() const { return *mRuler; }
103
104 private:
105 void CleanState();
106
107 const ZoomInfo *const mZoomInfo;
108 std::unique_ptr<BoundedEnvelope> mEnvelope;
109 std::unique_ptr<Ruler> mRuler;
111 bool mRescaleXMLValues; // needed for backward-compatibility with older project files
112
118 void Init(const TimeTrack &orig);
119
120 using Holder = std::unique_ptr<TimeTrack>;
121
122private:
123 Track::Holder Clone() const override;
124};
125
127
128
129#endif // __AUDACITY_TIMETRACK__
130
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:89
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:111
void SetDisplayLog(bool displayLog)
Definition: TimeTrack.h:96
const ZoomInfo *const mZoomInfo
Definition: TimeTrack.h:107
std::unique_ptr< TimeTrack > Holder
Definition: TimeTrack.h:120
std::unique_ptr< BoundedEnvelope > mEnvelope
Definition: TimeTrack.h:108
const BoundedEnvelope * GetEnvelope() const
Definition: TimeTrack.h:85
double GetStartTime() const override
Definition: TimeTrack.h:66
double GetEndTime() const override
Definition: TimeTrack.h:67
std::unique_ptr< Ruler > mRuler
Definition: TimeTrack.h:109
BoundedEnvelope * GetEnvelope()
Definition: TimeTrack.h:84
bool GetDisplayLog() const
Definition: TimeTrack.h:95
double GetOffset() const override
Definition: TimeTrack.h:63
bool mDisplayLog
Definition: TimeTrack.h:110
Ruler & GetRuler() const
Definition: TimeTrack.h:102
void SetOffset(double) override
Definition: TimeTrack.h:64
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:1236
static const TypeInfo & ClassTypeInfo()
Definition: Track.cpp:1229
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:361
void Init(const Track &orig)
Definition: Track.cpp:65
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