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
23 : public UniqueChannelTrack<>
24{
25
26 public:
27
28 static wxString GetDefaultName();
29
30 // Construct and also build all attachments
31 static TimeTrack *New(AudacityProject &project);
32
33 TimeTrack();
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
54 const override;
55
56 Track::Holder Cut(double t0, double t1) override;
57 Track::Holder Copy(double t0, double t1, bool forClipboard) const override;
58 void Clear(double t0, double t1) override;
59 void Paste(double t, const Track &src) override;
60 void
61 Silence(double t0, double t1, ProgressReporter reportProgress = {}) override;
62 void InsertSilence(double t, double len) override;
63
64 // TimeTrack parameters
65
66 void MoveTo(double /* t */) override {}
67 void ShiftBy(double, double) override {}
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 size_t NIntervals() const override;
103
104private:
105 std::shared_ptr<WideChannelGroupInterval> DoGetInterval(size_t iInterval)
106 override;
107
108 void CleanState();
109
110 std::unique_ptr<BoundedEnvelope> mEnvelope;
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(bool backup) const override;
125};
126
128
129
130#endif // __AUDACITY_TIMETRACK__
131
const auto project
ENUMERATE_TRACK_TYPE(TimeTrack)
declares abstract base class Track, TrackList, and iterators over TrackList
std::function< void(double)> ProgressReporter
Definition: Track.h:48
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
virtual std::shared_ptr< Interval > DoGetInterval(size_t iInterval)=0
Retrieve an interval.
size_t NIntervals() const
Report the number of intervals.
Definition: Channel.h:540
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:96
std::unique_ptr< TimeTrack > Holder
Definition: TimeTrack.h:121
std::unique_ptr< BoundedEnvelope > mEnvelope
Definition: TimeTrack.h:110
const BoundedEnvelope * GetEnvelope() const
Definition: TimeTrack.h:85
void ShiftBy(double, double) override
Shift all intervals that starts after t0 by delta seconds.
Definition: TimeTrack.h:67
BoundedEnvelope * GetEnvelope()
Definition: TimeTrack.h:84
bool GetDisplayLog() const
Definition: TimeTrack.h:95
bool mDisplayLog
Definition: TimeTrack.h:111
void MoveTo(double) override
Change start time to given time point.
Definition: TimeTrack.h:66
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
virtual Holder Clone(bool backup) const =0
virtual void Paste(double t, const Track &src)=0
Weak precondition allows overrides to replicate one channel into many.
virtual Holder PasteInto(AudacityProject &project, TrackList &list) const =0
virtual Holder Copy(double t0, double t1, bool forClipboard=true) const =0
Create new tracks and don't modify this track.
virtual const TypeInfo & GetTypeInfo() const =0
virtual void InsertSilence(double t, double len)=0
virtual bool SupportsBasicEditing() const
Whether this track type implements cut-copy-paste; by default, true.
Definition: Track.cpp:797
static const TypeInfo & ClassTypeInfo()
Definition: Track.cpp:790
virtual void Clear(double t0, double t1)=0
std::shared_ptr< Track > Holder
Definition: Track.h:202
void Init(const Track &orig)
Definition: Track.cpp:47
virtual void WriteXML(XMLWriter &xmlFile) const =0
virtual void Silence(double t0, double t1, ProgressReporter reportProgress={})=0
virtual Holder Cut(double t0, double t1)=0
Create tracks and modify this track.
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
Generates overrides of channel-related functions.
Definition: Track.h:450
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:117