Audacity  3.0.3
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 
18 class wxRect;
19 class BoundedEnvelope;
20 class Ruler;
21 class ZoomInfo;
23 
24 class AUDACITY_DLL_API TimeTrack final : public Track {
25 
26  public:
27 
28  explicit TimeTrack(const ZoomInfo *zoomInfo);
38  TimeTrack(const TimeTrack &orig, double *pT0 = nullptr, double *pT1 = nullptr);
39 
40  virtual ~TimeTrack();
41 
42 
43  bool SupportsBasicEditing() const override;
44 
45  Holder PasteInto( AudacityProject & ) const override;
46 
47  Holder Cut( double t0, double t1 ) override;
48  Holder Copy( double t0, double t1, bool forClipboard ) const override;
49  void Clear(double t0, double t1) override;
50  void Paste(double t, const Track * src) override;
51  void Silence(double t0, double t1) override;
52  void InsertSilence(double t, double len) override;
53 
54  // TimeTrack parameters
55 
56  double GetOffset() const override { return 0.0; }
57  void SetOffset(double /* t */) override {}
58 
59  double GetStartTime() const override { return 0.0; }
60  double GetEndTime() const override { return 0.0; }
61 
62  // XMLTagHandler callback methods for loading and saving
63 
64  bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override;
65  void HandleXMLEndTag(const wxChar *tag) override;
66  XMLTagHandler *HandleXMLChild(const wxChar *tag) override;
67  void WriteXML(XMLWriter &xmlFile) const override;
68 
69  // Lock and unlock the track: you must lock the track before
70  // doing a copy and paste between projects.
71 
72  // bool Lock();
73  // bool Unlock();
74 
75  // Access the track's speed envelope
76 
77  BoundedEnvelope *GetEnvelope() { return mEnvelope.get(); }
78  const BoundedEnvelope *GetEnvelope() const { return mEnvelope.get(); }
79 
80  // Get/Set the speed-warping range, as percentage of original speed (e.g. 90%-110%)
81 
82  double GetRangeLower() const;
83  double GetRangeUpper() const;
84 
85  void SetRangeLower(double lower);
86  void SetRangeUpper(double upper);
87 
88  bool GetDisplayLog() const { return mDisplayLog; }
89  void SetDisplayLog(bool displayLog) { mDisplayLog = displayLog; }
90  bool GetInterpolateLog() const;
91  void SetInterpolateLog(bool interpolateLog);
92 
93  void testMe();
94 
95  Ruler &GetRuler() const { return *mRuler; }
96 
97  private:
98  void CleanState();
99 
100  // Identifying the type of track
101  TrackKind GetKind() const override { return TrackKind::Time; }
102 
103  const ZoomInfo *const mZoomInfo;
104  std::unique_ptr<BoundedEnvelope> mEnvelope;
105  std::unique_ptr<Ruler> mRuler;
107  bool mRescaleXMLValues; // needed for backward-compatibility with older project files
108 
114  void Init(const TimeTrack &orig);
115 
116  using Holder = std::unique_ptr<TimeTrack>;
117 
118 private:
119  Track::Holder Clone() const override;
120 };
121 
122 
123 #endif // __AUDACITY_TIMETRACK__
124 
XMLWriter
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:23
TimeTrack::GetRuler
Ruler & GetRuler() const
Definition: TimeTrack.h:95
Track::SupportsBasicEditing
virtual bool SupportsBasicEditing() const
Whether this track type implements cut-copy-paste; by default, true.
Definition: Track.cpp:1239
ZoomInfo
Definition: ZoomInfo.h:47
TrackPanelDrawingContext
Definition: TrackPanelDrawingContext.h:22
Track::Cut
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1))=0
TimeTrack::mDisplayLog
bool mDisplayLog
Definition: TimeTrack.h:106
XMLTagHandler::HandleXMLEndTag
virtual void HandleXMLEndTag(const wxChar *WXUNUSED(tag))
Definition: XMLTagHandler.h:79
Track::InsertSilence
virtual void InsertSilence(double WXUNUSED(t), double WXUNUSED(len))=0
TimeTrack::Holder
std::unique_ptr< TimeTrack > Holder
Definition: TimeTrack.h:116
TimeTrack::GetKind
TrackKind GetKind() const override
Definition: TimeTrack.h:101
Track::Paste
virtual void Paste(double WXUNUSED(t), const Track *WXUNUSED(src))=0
TimeTrack::GetDisplayLog
bool GetDisplayLog() const
Definition: TimeTrack.h:88
TimeTrack::GetOffset
double GetOffset() const override
Definition: TimeTrack.h:56
TimeTrack::GetStartTime
double GetStartTime() const override
Definition: TimeTrack.h:59
TimeTrack::SetOffset
void SetOffset(double) override
Definition: TimeTrack.h:57
BoundedEnvelope
Definition: Envelope.h:284
TimeTrack::SetDisplayLog
void SetDisplayLog(bool displayLog)
Definition: TimeTrack.h:89
TimeTrack::GetEndTime
double GetEndTime() const override
Definition: TimeTrack.h:60
TrackKind::Time
@ Time
Track::Holder
std::shared_ptr< Track > Holder
Definition: Track.h:336
Track::Silence
virtual void Silence(double WXUNUSED(t0), double WXUNUSED(t1))=0
Ruler
Used to display a Ruler.
Definition: Ruler.h:26
TimeTrack::GetEnvelope
BoundedEnvelope * GetEnvelope()
Definition: TimeTrack.h:77
Track::Clone
virtual Holder Clone() const =0
TimeTrack::mZoomInfo
const ZoomInfo *const mZoomInfo
Definition: TimeTrack.h:103
TimeTrack::GetEnvelope
const BoundedEnvelope * GetEnvelope() const
Definition: TimeTrack.h:78
XMLTagHandler
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:62
TrackKind
TrackKind
Enumerates all subclasses of Track (not just the leaf classes) and the None value.
Definition: Track.h:69
Track::WriteXML
virtual void WriteXML(XMLWriter &xmlFile) const =0
TimeTrack::mRescaleXMLValues
bool mRescaleXMLValues
Definition: TimeTrack.h:107
TimeTrack::mEnvelope
std::unique_ptr< BoundedEnvelope > mEnvelope
Definition: TimeTrack.h:104
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
Track::Init
void Init(const Track &orig)
Definition: Track.cpp:70
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
XMLTagHandler::HandleXMLTag
virtual bool HandleXMLTag(const wxChar *tag, const wxChar **attrs)=0
XMLTagHandler::HandleXMLChild
virtual XMLTagHandler * HandleXMLChild(const wxChar *tag)=0
Track::Clear
virtual void Clear(double WXUNUSED(t0), double WXUNUSED(t1))=0
Track.h
declares abstract base class Track, TrackList, and iterators over TrackList
TimeTrack::mRuler
std::unique_ptr< Ruler > mRuler
Definition: TimeTrack.h:105
Track::Copy
virtual Holder Copy(double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard=true) const =0
Track::PasteInto
virtual Holder PasteInto(AudacityProject &) const =0
Find or create the destination track for a paste, maybe in a different project.
TimeTrack
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:24