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;
21
22class TIME_TRACK_API TimeTrack final : public Track {
23
24 public:
25
26 static wxString GetDefaultName();
27
28 // Construct and also build all attachments
29 static TimeTrack *New(AudacityProject &project);
30
31 TimeTrack();
42 double *pT0 = nullptr, double *pT1 = nullptr);
43
44 virtual ~TimeTrack();
45
46 const TypeInfo &GetTypeInfo() const override;
47 static const TypeInfo &ClassTypeInfo();
48
49 bool SupportsBasicEditing() const override;
50
51 Holder PasteInto( AudacityProject & ) const override;
52
53 Holder Cut( double t0, double t1 ) override;
54 Holder Copy( double t0, double t1, bool forClipboard ) const override;
55 void Clear(double t0, double t1) override;
56 void Paste(double t, const Track * src) override;
57 void Silence(double t0, double t1) override;
58 void InsertSilence(double t, double len) override;
59
60 // TimeTrack parameters
61
62 double GetOffset() const override { return 0.0; }
63 void SetOffset(double /* t */) override {}
64
65 double GetStartTime() const override { return 0.0; }
66 double GetEndTime() const override { return 0.0; }
67
68 // XMLTagHandler callback methods for loading and saving
69
70 bool HandleXMLTag(const std::string_view& tag, const AttributesList& attrs) override;
71 void HandleXMLEndTag(const std::string_view& tag) override;
72 XMLTagHandler *HandleXMLChild(const std::string_view& tag) override;
73 void WriteXML(XMLWriter &xmlFile) const override;
74
75 // Lock and unlock the track: you must lock the track before
76 // doing a copy and paste between projects.
77
78 // bool Lock();
79 // bool Unlock();
80
81 // Access the track's speed envelope
82
83 BoundedEnvelope *GetEnvelope() { return mEnvelope.get(); }
84 const BoundedEnvelope *GetEnvelope() const { return mEnvelope.get(); }
85
86 // Get/Set the speed-warping range, as percentage of original speed (e.g. 90%-110%)
87
88 double GetRangeLower() const;
89 double GetRangeUpper() const;
90
91 void SetRangeLower(double lower);
92 void SetRangeUpper(double upper);
93
94 bool GetDisplayLog() const { return mDisplayLog; }
95 void SetDisplayLog(bool displayLog) { mDisplayLog = displayLog; }
96 bool GetInterpolateLog() const;
97 void SetInterpolateLog(bool interpolateLog);
98
99 void testMe();
100
101 private:
102 void CleanState();
103
104 std::unique_ptr<BoundedEnvelope> mEnvelope;
106 bool mRescaleXMLValues; // needed for backward-compatibility with older project files
107
113 void Init(const TimeTrack &orig);
114
115 using Holder = std::unique_ptr<TimeTrack>;
116
117private:
118 Track::Holder Clone() const override;
119};
120
122
123
124#endif // __AUDACITY_TIMETRACK__
125
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
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:22
bool mRescaleXMLValues
Definition: TimeTrack.h:106
void SetDisplayLog(bool displayLog)
Definition: TimeTrack.h:95
std::unique_ptr< TimeTrack > Holder
Definition: TimeTrack.h:115
std::unique_ptr< BoundedEnvelope > mEnvelope
Definition: TimeTrack.h:104
const BoundedEnvelope * GetEnvelope() const
Definition: TimeTrack.h:84
double GetStartTime() const override
Definition: TimeTrack.h:65
double GetEndTime() const override
Definition: TimeTrack.h:66
BoundedEnvelope * GetEnvelope()
Definition: TimeTrack.h:83
bool GetDisplayLog() const
Definition: TimeTrack.h:94
double GetOffset() const override
Definition: TimeTrack.h:62
bool mDisplayLog
Definition: TimeTrack.h:105
void SetOffset(double) override
Definition: TimeTrack.h:63
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:162
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:1166
static const TypeInfo & ClassTypeInfo()
Definition: Track.cpp:1159
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:303
void Init(const Track &orig)
Definition: Track.cpp:57
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:25
Empty argument passed to some public constructors.
Definition: Track.h:169