Audacity  2.3.1
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
TimeTrack Class Referencefinal

A kind of Track used to 'warp time'. More...

#include <TimeTrack.h>

Inheritance diagram for TimeTrack:
Track CommonTrackPanelCell XMLTagHandler TrackPanelCell TrackPanelNode

Public Member Functions

 TimeTrack (const std::shared_ptr< DirManager > &projDirManager, const ZoomInfo *zoomInfo)
 
 TimeTrack (const TimeTrack &orig, double *pT0=nullptr, double *pT1=nullptr)
 Copy-Constructor - create a NEW TimeTrack:: which is an independent copy of the original. More...
 
virtual ~TimeTrack ()
 
Holder Cut (double t0, double t1) override
 
Holder Copy (double t0, double t1, bool forClipboard) const override
 
void Clear (double t0, double t1) override
 
void Paste (double t, const Track *src) override
 
void Silence (double t0, double t1) override
 
void InsertSilence (double t, double len) override
 
std::vector< UIHandlePtrDetailedHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool) override
 
double GetOffset () const override
 
void SetOffset (double) override
 
double GetStartTime () const override
 
double GetEndTime () const override
 
void Draw (TrackPanelDrawingContext &context, const wxRect &r) const
 
bool HandleXMLTag (const wxChar *tag, const wxChar **attrs) override
 
void HandleXMLEndTag (const wxChar *tag) override
 
XMLTagHandlerHandleXMLChild (const wxChar *tag) override
 
void WriteXML (XMLWriter &xmlFile) const override
 
EnvelopeGetEnvelope ()
 
const EnvelopeGetEnvelope () const
 
double ComputeWarpFactor (double t0, double t1) const
 Compute the integral warp factor between two non-warped time points. More...
 
double ComputeWarpedLength (double t0, double t1) const
 Compute the duration (in seconds at playback) of the specified region of the track. More...
 
double SolveWarpedLength (double t0, double length) const
 Compute how much unwarped time must have elapsed if length seconds of warped time has elapsed. More...
 
double GetRangeLower () const
 
double GetRangeUpper () const
 
void SetRangeLower (double lower)
 
void SetRangeUpper (double upper)
 
bool GetDisplayLog () const
 
void SetDisplayLog (bool displayLog)
 
bool GetInterpolateLog () const
 
void SetInterpolateLog (bool interpolateLog)
 
void testMe ()
 
- Public Member Functions inherited from Track
TrackId GetId () const
 
std::shared_ptr< const TrackSubstitutePendingChangedTrack () const
 
std::shared_ptr< const TrackSubstituteOriginalTrack () const
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &, const AudacityProject *pProject) finaloverride
 
std::shared_ptr< TrackPanelCellContextMenuDelegate () override
 
std::shared_ptr< TrackPanelCellGetTrackControl ()
 
std::shared_ptr< TrackPanelCellGetVRulerControl ()
 
std::shared_ptr< TrackPanelCellGetResizer ()
 
virtual int GetMinimizedHeight () const
 
int GetActualHeight () const
 
int GetIndex () const
 
void SetIndex (int index)
 
int GetY () const
 
int GetHeight () const
 
void SetHeight (int h)
 
bool GetMinimized () const
 
void SetMinimized (bool isMinimized)
 
bool LinkConsistencyCheck ()
 
 Track (const std::shared_ptr< DirManager > &projDirManager)
 
 Track (const Track &orig)
 
virtual ~Track ()
 
void Init (const Track &orig)
 
virtual void Merge (const Track &orig)
 
wxString GetName () const
 
void SetName (const wxString &n)
 
wxString GetDefaultName () const
 
void SetDefaultName (const wxString &n)
 
bool GetSelected () const
 
virtual void SetSelected (bool s)
 
virtual ChannelType GetChannel () const
 
void Offset (double t)
 
virtual void SetPan (float)
 
virtual void SetPanFromChannelType ()
 
const std::shared_ptr
< DirManager > & 
GetDirManager () const
 
virtual Holder Cut (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual Holder Copy (double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard=true) const =0
 
virtual void Clear (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void Paste (double WXUNUSED(t), const Track *WXUNUSED(src))=0
 
virtual void SyncLockAdjust (double oldT1, double newT1)
 
virtual void Silence (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void InsertSilence (double WXUNUSED(t), double WXUNUSED(len))=0
 
bool SameKindAs (const Track &track) const
 
template<typename R = void, typename... Functions>
TypeSwitch (const Functions &...functions)
 
template<typename R = void, typename... Functions>
TypeSwitch (const Functions &...functions) const
 
virtual bool GetErrorOpening ()
 
bool IsSyncLockSelected () const
 
void Notify (int code=-1)
 
bool Any () const
 
bool IsSelected () const
 
bool IsSelectedOrSyncLockSelected () const
 
bool IsLeader () const
 
bool IsSelectedLeader () const
 
- Public Member Functions inherited from CommonTrackPanelCell
 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
HitTestPreview DefaultPreview (const TrackPanelMouseState &, const AudacityProject *) override
 
- Public Member Functions inherited from TrackPanelCell
virtual ~TrackPanelCell ()=0
 
virtual unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, wxPoint *pPosition)
 
virtual unsigned CaptureKey (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent)
 
virtual unsigned KeyDown (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent)
 
virtual unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent)
 
virtual unsigned Char (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent)
 
- Public Member Functions inherited from TrackPanelNode
 TrackPanelNode ()
 
virtual ~TrackPanelNode ()=0
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual void HandleXMLEndTag (const wxChar *WXUNUSED(tag))
 
virtual void HandleXMLContent (const wxString &WXUNUSED(content))
 
bool ReadXMLTag (const char *tag, const char **attrs)
 
void ReadXMLEndTag (const char *tag)
 
void ReadXMLContent (const char *s, int len)
 
XMLTagHandlerReadXMLChild (const char *tag)
 

Protected Member Functions

std::shared_ptr< TrackControlsGetControls () override
 
std::shared_ptr
< TrackVRulerControls
GetVRulerControls () override
 
- Protected Member Functions inherited from Track
virtual void DoSetHeight (int h)
 
virtual void DoSetMinimized (bool isMinimized)
 
std::shared_ptr< TrackFindTrack () override
 
- Protected Member Functions inherited from CommonTrackPanelCell
unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 

Private Types

using Holder = std::unique_ptr< TimeTrack >
 

Private Member Functions

TrackKind GetKind () const override
 
void Init (const TimeTrack &orig)
 Copy the metadata from another track but not the points. More...
 
Track::Holder Duplicate () const override
 

Private Attributes

const ZoomInfo *const mZoomInfo
 
std::unique_ptr< EnvelopemEnvelope
 
std::unique_ptr< RulermRuler
 
double mRangeLower
 
double mRangeUpper
 
bool mDisplayLog
 
bool mRescaleXMLValues
 
std::weak_ptr< EnvelopeHandlemEnvelopeHandle
 

Friends

class TrackFactory
 

Additional Inherited Members

- Public Types inherited from Track
enum  ChannelType { LeftChannel = 0, RightChannel = 1, MonoChannel = 2 }
 
enum  : unsigned { DefaultHeight = 150 }
 
using Holder = std::unique_ptr< Track >
 
template<typename R = void>
using Continuation = std::function< R() >
 
using Fallthrough = Continuation<>
 
- Static Public Member Functions inherited from Track
template<typename Subclass = Track>
static std::shared_ptr< Subclass > Pointer (Track *t)
 
template<typename Subclass = const Track>
static std::shared_ptr< Subclass > Pointer (const Track *t)
 
static void FinishCopy (const Track *n, Track *dest)
 
- Public Attributes inherited from Track
wxSize vrulerSize
 
- Protected Attributes inherited from Track
std::weak_ptr< TrackListmList
 
TrackNodePointer mNode {}
 
int mIndex
 
int mY
 
int mHeight
 
wxString mName
 
wxString mDefaultName
 
bool mLinked
 
bool mMinimized
 
ChannelType mChannel
 
double mOffset
 
std::shared_ptr< DirManagermDirManager
 
std::shared_ptr< TrackControlsmpControls
 
std::shared_ptr
< TrackVRulerControls
mpVRulerContols
 
std::shared_ptr
< TrackPanelResizerCell
mpResizer
 
std::weak_ptr< SelectHandlemSelectHandle
 
std::weak_ptr< TimeShiftHandlemTimeShiftHandle
 

Detailed Description

A kind of Track used to 'warp time'.

Definition at line 29 of file TimeTrack.h.

Member Typedef Documentation

using TimeTrack::Holder = std::unique_ptr<TimeTrack>
private

Definition at line 157 of file TimeTrack.h.

Constructor & Destructor Documentation

TimeTrack::TimeTrack ( const std::shared_ptr< DirManager > &  projDirManager,
const ZoomInfo zoomInfo 
)

Definition at line 41 of file TimeTrack.cpp.

References _(), Track::GetDefaultName(), mDisplayLog, mEnvelope, Track::mHeight, mRangeLower, mRangeUpper, mRuler, mZoomInfo, Track::SetDefaultName(), Track::SetName(), Ruler::TimeFormat, TIMETRACK_MAX, and TIMETRACK_MIN.

41  :
42  Track(projDirManager)
43  , mZoomInfo(zoomInfo)
44 {
45  mHeight = 100;
46 
47  mRangeLower = 0.9;
48  mRangeUpper = 1.1;
49  mDisplayLog = false;
50 
51  mEnvelope = std::make_unique<Envelope>(true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0);
52  mEnvelope->SetTrackLen(DBL_MAX);
53  mEnvelope->SetOffset(0);
54 
55  SetDefaultName(_("Time Track"));
57 
58  mRuler = std::make_unique<Ruler>();
59  mRuler->SetUseZoomInfo(0, mZoomInfo);
60  mRuler->SetLabelEdges(false);
61  mRuler->SetFormat(Ruler::TimeFormat);
62 }
#define TIMETRACK_MAX
Definition: TimeTrack.cpp:34
int mHeight
Definition: Track.h:205
bool mDisplayLog
Definition: TimeTrack.h:145
wxString GetDefaultName() const
Definition: Track.h:378
const ZoomInfo *const mZoomInfo
Definition: TimeTrack.h:140
double mRangeUpper
Definition: TimeTrack.h:144
#define TIMETRACK_MIN
Definition: TimeTrack.cpp:33
double mRangeLower
Definition: TimeTrack.h:143
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:141
void SetDefaultName(const wxString &n)
Definition: Track.h:379
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
Track(const std::shared_ptr< DirManager > &projDirManager)
Definition: Track.cpp:50
void SetName(const wxString &n)
Definition: Track.cpp:94
std::unique_ptr< Ruler > mRuler
Definition: TimeTrack.h:142
TimeTrack::TimeTrack ( const TimeTrack orig,
double *  pT0 = nullptr,
double *  pT1 = nullptr 
)

Copy-Constructor - create a NEW TimeTrack:: which is an independent copy of the original.

Calls TimeTrack::Init() to copy the track metadata, then does a bunch of manipulations on the Envelope:: and Ruler:: members in order to copy one to the other - unfortunately both lack a copy-constructor to encapsulate this.

Parameters
origThe original track to copy from
pT0if not null, then the start of the sub-range to copy
pT1if not null, then the end of the sub-range to copy

: Give Ruler:: a copy-constructor instead of this?

Definition at line 64 of file TimeTrack.cpp.

References Init(), mEnvelope, mRuler, mZoomInfo, and Ruler::TimeFormat.

65  : Track(orig)
66  , mZoomInfo(orig.mZoomInfo)
67 {
68  Init(orig); // this copies the TimeTrack metadata (name, range, etc)
69 
70  auto len = DBL_MAX;
71  if (pT0 && pT1) {
72  len = *pT1 - *pT0;
73  mEnvelope = std::make_unique<Envelope>( *orig.mEnvelope, *pT0, *pT1 );
74  }
75  else
76  mEnvelope = std::make_unique<Envelope>( *orig.mEnvelope );
77  mEnvelope->SetTrackLen( len );
78  mEnvelope->SetOffset(0);
79 
81  mRuler = std::make_unique<Ruler>();
82  mRuler->SetUseZoomInfo(0, mZoomInfo);
83  mRuler->SetLabelEdges(false);
84  mRuler->SetFormat(Ruler::TimeFormat);
85 }
void Init(const TimeTrack &orig)
Copy the metadata from another track but not the points.
Definition: TimeTrack.cpp:88
const ZoomInfo *const mZoomInfo
Definition: TimeTrack.h:140
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:141
Track(const std::shared_ptr< DirManager > &projDirManager)
Definition: Track.cpp:50
std::unique_ptr< Ruler > mRuler
Definition: TimeTrack.h:142
TimeTrack::~TimeTrack ( )
virtual

Definition at line 98 of file TimeTrack.cpp.

99 {
100 }

Member Function Documentation

void TimeTrack::Clear ( double  t0,
double  t1 
)
override

Definition at line 115 of file TimeTrack.cpp.

References GetActiveProject(), AudacityProject::GetRate(), and mEnvelope.

Referenced by Cut().

116 {
117  auto sampleTime = 1.0 / GetActiveProject()->GetRate();
118  mEnvelope->CollapseRegion( t0, t1, sampleTime );
119 }
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:141
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:311
double GetRate() const
Definition: Project.h:216
double TimeTrack::ComputeWarpedLength ( double  t0,
double  t1 
) const

Compute the duration (in seconds at playback) of the specified region of the track.

Takes a region of the time track (specified by the unwarped time points in the project), and calculates how long it will actually take to play this region back, taking the time track's warping effects into account.

Parameters
t0unwarped time to start calculation from
t1unwarped time to stop calculation at
Returns
the warped duration in seconds

Definition at line 164 of file TimeTrack.cpp.

References GetEnvelope(), and Envelope::IntegralOfInverse().

Referenced by Ruler::Update().

165 {
166  return GetEnvelope()->IntegralOfInverse(t0, t1);
167 }
double IntegralOfInverse(double t0, double t1) const
Definition: Envelope.cpp:1572
Envelope * GetEnvelope()
Definition: TimeTrack.h:86
double TimeTrack::ComputeWarpFactor ( double  t0,
double  t1 
) const

Compute the integral warp factor between two non-warped time points.

Calculate the relative length increase of the chosen segment from the original sound. So if this time track has a low value (i.e. makes the sound slower), the NEW warped sound will be longer than the original sound, so the return value of this function is larger.

Parameters
t0The starting time to calculate from
t1The ending time to calculate to
Returns
The relative length increase of the chosen segment from the original sound.

Definition at line 159 of file TimeTrack.cpp.

References Envelope::AverageOfInverse(), and GetEnvelope().

Referenced by Mixer::MixVariableRates().

160 {
161  return GetEnvelope()->AverageOfInverse(t0, t1);
162 }
double AverageOfInverse(double t0, double t1) const
Definition: Envelope.cpp:1418
Envelope * GetEnvelope()
Definition: TimeTrack.h:86
Track::Holder TimeTrack::Copy ( double  t0,
double  t1,
bool  forClipboard 
) const
override

Definition at line 109 of file TimeTrack.cpp.

Referenced by Cut().

110 {
111  auto result = std::make_unique<TimeTrack>( *this, &t0, &t1 );
112  return Track::Holder{ std::move( result ) };
113 }
std::unique_ptr< Track > Holder
Definition: Track.h:369
Track::Holder TimeTrack::Cut ( double  t0,
double  t1 
)
override

Definition at line 102 of file TimeTrack.cpp.

References Clear(), and Copy().

103 {
104  auto result = Copy( t0, t1, false );
105  Clear( t0, t1 );
106  return result;
107 }
void Clear(double t0, double t1) override
Definition: TimeTrack.cpp:115
Holder Copy(double t0, double t1, bool forClipboard) const override
Definition: TimeTrack.cpp:109
std::vector< UIHandlePtr > TimeTrack::DetailedHitTest ( const TrackPanelMouseState state,
const AudacityProject pProject,
int  currentTool,
bool  bMultiTool 
)
overridevirtual

Implements Track.

Definition at line 22 of file TimeTrackUI.cpp.

References TrackPanelMouseState::rect, TrackPanelMouseState::state, and EnvelopeHandle::TimeTrackHitTest().

24 {
25  std::vector<UIHandlePtr> results;
27  ( mEnvelopeHandle, st.state, st.rect, pProject, Pointer<TimeTrack>(this) );
28  if (result)
29  results.push_back(result);
30  return results;
31 }
std::weak_ptr< EnvelopeHandle > mEnvelopeHandle
Definition: TimeTrack.h:148
static UIHandlePtr TimeTrackHitTest(std::weak_ptr< EnvelopeHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< TimeTrack > &tt)
void TimeTrack::Draw ( TrackPanelDrawingContext context,
const wxRect &  r 
) const

Definition at line 269 of file TimeTrack.cpp.

References ThemeBase::Colour(), TrackPanelDrawingContext::dc, AColor::envelopePen, TrackArtist::Get(), EnvelopeHandle::GetEnvelope(), AColor::Line(), min(), TrackPanelDrawingContext::target, theTheme, AColor::uglyPen, and AColor::UseThemeColour().

Referenced by TrackArt::DrawTimeTrack().

270 {
271  auto &dc = context.dc;
272  const auto artist = TrackArtist::Get( context );
273  const auto &zoomInfo = *artist->pZoomInfo;
274 
275  bool highlight = false;
276 #ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
277  auto target = dynamic_cast<EnvelopeHandle*>(context.target.get());
278  highlight = target && target->GetEnvelope() == this->GetEnvelope();
279 #endif
280 
281  double min = zoomInfo.PositionToTime(0);
282  double max = zoomInfo.PositionToTime(r.width);
283  if (min > max)
284  {
285  wxASSERT(false);
286  min = max;
287  }
288 
289  AColor::UseThemeColour( &dc, clrUnselected );
290  dc.DrawRectangle(r);
291 
292  //copy this rectangle away for future use.
293  wxRect mid = r;
294 
295  // Draw the Ruler
296  mRuler->SetBounds(r.x, r.y, r.x + r.width - 1, r.y + r.height - 1);
297  mRuler->SetRange(min, max);
298  mRuler->SetFlip(false); // If we don't do this, the Ruler doesn't redraw itself when the envelope is modified.
299  // I have no idea why!
300  //
301  // LL: It's because the ruler only Invalidate()s when the NEW value is different
302  // than the current value.
303  mRuler->SetFlip(GetHeight() > 75 ? true : true); // MB: so why don't we just call Invalidate()? :)
304  mRuler->SetTickColour( theTheme.Colour( clrTrackPanelText ));
305  mRuler->Draw(dc, this);
306 
307  Doubles envValues{ size_t(mid.width) };
309  ( 0, 0, envValues.get(), mid.width, 0, zoomInfo );
310 
311  wxPen &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
312  dc.SetPen( pen );
313 
314  double logLower = log(std::max(1.0e-7, mRangeLower)), logUpper = log(std::max(1.0e-7, mRangeUpper));
315  for (int x = 0; x < mid.width; x++)
316  {
317  double y;
318  if(mDisplayLog)
319  y = (double)mid.height * (logUpper - log(envValues[x])) / (logUpper - logLower);
320  else
321  y = (double)mid.height * (mRangeUpper - envValues[x]) / (mRangeUpper - mRangeLower);
322  int thisy = r.y + (int)y;
323  AColor::Line(dc, mid.x + x, thisy - 1, mid.x + x, thisy+2);
324  }
325 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
bool mDisplayLog
Definition: TimeTrack.h:145
static wxPen uglyPen
Definition: AColor.h:147
static wxPen envelopePen
Definition: AColor.h:122
double mRangeUpper
Definition: TimeTrack.h:144
double mRangeLower
Definition: TimeTrack.h:143
int min(int a, int b)
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1)
Definition: AColor.cpp:289
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:122
static TrackArtist * Get(TrackPanelDrawingContext &)
Envelope * GetEnvelope() const
std::unique_ptr< Ruler > mRuler
Definition: TimeTrack.h:142
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void GetValues(double *buffer, int len, double t0, double tstep) const
Get many envelope points at once.
Definition: Envelope.cpp:1224
Envelope * GetEnvelope()
Definition: TimeTrack.h:86
int GetHeight() const
Definition: Track.cpp:183
Track::Holder TimeTrack::Duplicate ( ) const
overrideprivatevirtual

Implements Track.

Definition at line 144 of file TimeTrack.cpp.

145 {
146  return std::make_unique<TimeTrack>(*this);
147 }
std::shared_ptr< TrackControls > TimeTrack::GetControls ( )
overrideprotectedvirtual

Implements Track.

Definition at line 33 of file TimeTrackUI.cpp.

References Track::Pointer().

34 {
35  return std::make_shared<TimeTrackControls>( Pointer( this ) );
36 }
static std::shared_ptr< Subclass > Pointer(Track *t)
Definition: Track.h:233
bool TimeTrack::GetDisplayLog ( ) const
inline

Definition at line 129 of file TimeTrack.h.

References mDisplayLog.

Referenced by TrackArt::DrawTimeTrack(), Init(), and TimeTrackMenuTable::InitMenu().

129 { return mDisplayLog; }
bool mDisplayLog
Definition: TimeTrack.h:145
double TimeTrack::GetEndTime ( ) const
inlineoverridevirtual

Implements Track.

Definition at line 66 of file TimeTrack.h.

66 { return 0.0; }
Envelope* TimeTrack::GetEnvelope ( )
inline

Definition at line 86 of file TimeTrack.h.

References mEnvelope.

Referenced by ComputeWarpedLength(), ComputeWarpFactor(), TrackArt::DrawTimeTrack(), SolveWarpedLength(), and testMe().

86 { return mEnvelope.get(); }
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:141
const Envelope* TimeTrack::GetEnvelope ( ) const
inline

Definition at line 87 of file TimeTrack.h.

References mEnvelope.

87 { return mEnvelope.get(); }
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:141
bool TimeTrack::GetInterpolateLog ( ) const

Definition at line 149 of file TimeTrack.cpp.

References mEnvelope.

Referenced by TimeTrackMenuTable::InitMenu(), and TimeTrackMenuTable::OnTimeTrackLogInt().

150 {
151  return mEnvelope->GetExponential();
152 }
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:141
TrackKind TimeTrack::GetKind ( ) const
inlineoverrideprivatevirtual

Reimplemented from Track.

Definition at line 138 of file TimeTrack.h.

References Time.

138 { return TrackKind::Time; }
double TimeTrack::GetOffset ( ) const
inlineoverridevirtual

Implements Track.

Definition at line 62 of file TimeTrack.h.

62 { return 0.0; }
double TimeTrack::GetRangeLower ( ) const
inline

Definition at line 123 of file TimeTrack.h.

References mRangeLower.

Referenced by TrackArt::DrawTimeTrack(), Init(), and TimeTrackMenuTable::OnSetTimeTrackRange().

123 { return mRangeLower; }
double mRangeLower
Definition: TimeTrack.h:143
double TimeTrack::GetRangeUpper ( ) const
inline

Definition at line 124 of file TimeTrack.h.

References mRangeUpper.

Referenced by TrackArt::DrawTimeTrack(), Init(), and TimeTrackMenuTable::OnSetTimeTrackRange().

124 { return mRangeUpper; }
double mRangeUpper
Definition: TimeTrack.h:144
double TimeTrack::GetStartTime ( ) const
inlineoverridevirtual

Implements Track.

Definition at line 65 of file TimeTrack.h.

65 { return 0.0; }
std::shared_ptr< TrackVRulerControls > TimeTrack::GetVRulerControls ( )
overrideprotectedvirtual

Implements Track.

Definition at line 38 of file TimeTrackUI.cpp.

References Track::Pointer().

39 {
40  return std::make_shared<TimeTrackVRulerControls>( Pointer( this ) );
41 }
static std::shared_ptr< Subclass > Pointer(Track *t)
Definition: Track.h:233
XMLTagHandler * TimeTrack::HandleXMLChild ( const wxChar *  tag)
overridevirtual

Implements XMLTagHandler.

Definition at line 237 of file TimeTrack.cpp.

References mEnvelope.

238 {
239  if (!wxStrcmp(tag, wxT("envelope")))
240  return mEnvelope.get();
241 
242  return NULL;
243 }
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:141
void TimeTrack::HandleXMLEndTag ( const wxChar *  tag)
override

Definition at line 227 of file TimeTrack.cpp.

References mEnvelope, mRangeLower, mRangeUpper, mRescaleXMLValues, TIMETRACK_MAX, and TIMETRACK_MIN.

228 {
230  {
231  mRescaleXMLValues = false;
232  mEnvelope->RescaleValues(mRangeLower, mRangeUpper);
234  }
235 }
#define TIMETRACK_MAX
Definition: TimeTrack.cpp:34
double mRangeUpper
Definition: TimeTrack.h:144
#define TIMETRACK_MIN
Definition: TimeTrack.cpp:33
double mRangeLower
Definition: TimeTrack.h:143
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:141
bool mRescaleXMLValues
Definition: TimeTrack.h:146
bool TimeTrack::HandleXMLTag ( const wxChar *  tag,
const wxChar **  attrs 
)
overridevirtual

Implements XMLTagHandler.

Definition at line 174 of file TimeTrack.cpp.

References Internat::CompatibleToDouble(), XMLValueChecker::IsGoodInt(), XMLValueChecker::IsGoodString(), mEnvelope, Track::mHeight, Track::mMinimized, Track::mName, mRangeLower, mRangeUpper, mRescaleXMLValues, SetDisplayLog(), and SetInterpolateLog().

175 {
176  if (!wxStrcmp(tag, wxT("timetrack"))) {
177  mRescaleXMLValues = true; // will be set to false if upper/lower is found
178  long nValue;
179  while(*attrs) {
180  const wxChar *attr = *attrs++;
181  const wxChar *value = *attrs++;
182 
183  if (!value)
184  break;
185 
186  const wxString strValue = value;
187  if (!wxStrcmp(attr, wxT("name")) && XMLValueChecker::IsGoodString(strValue))
188  mName = strValue;
189  else if (!wxStrcmp(attr, wxT("height")) &&
190  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
191  mHeight = nValue;
192  else if (!wxStrcmp(attr, wxT("minimized")) &&
193  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
194  mMinimized = (nValue != 0);
195  else if (!wxStrcmp(attr, wxT("rangelower")))
196  {
198  mRescaleXMLValues = false;
199  }
200  else if (!wxStrcmp(attr, wxT("rangeupper")))
201  {
203  mRescaleXMLValues = false;
204  }
205  else if (!wxStrcmp(attr, wxT("displaylog")) &&
206  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
207  {
208  SetDisplayLog(nValue != 0);
209  //TODO-MB: This causes a graphical glitch, TrackPanel should probably be Refresh()ed after loading.
210  // I don't know where to do this though.
211  }
212  else if (!wxStrcmp(attr, wxT("interpolatelog")) &&
213  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
214  {
215  SetInterpolateLog(nValue != 0);
216  }
217 
218  } // while
220  mEnvelope->SetRange(0.0, 1.0); // this will be restored to the actual range later
221  return true;
222  }
223 
224  return false;
225 }
int mHeight
Definition: Track.h:205
void SetDisplayLog(bool displayLog)
Definition: TimeTrack.h:130
static bool IsGoodInt(const wxString &strInt)
Check that the supplied string can be converted to a long (32bit) integer.
double mRangeUpper
Definition: TimeTrack.h:144
static bool IsGoodString(const wxString &str)
static bool CompatibleToDouble(const wxString &stringToConvert, double *result)
Convert a string to a number.
Definition: Internat.cpp:122
bool mMinimized
Definition: Track.h:214
double mRangeLower
Definition: TimeTrack.h:143
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:141
void SetInterpolateLog(bool interpolateLog)
Definition: TimeTrack.cpp:154
bool mRescaleXMLValues
Definition: TimeTrack.h:146
wxString mName
Definition: Track.h:206
void TimeTrack::Init ( const TimeTrack orig)
private

Copy the metadata from another track but not the points.

Copies the Name, DefaultName, Range and Display data from the source track

Parameters
origthe TimeTrack to copy from

Definition at line 88 of file TimeTrack.cpp.

References Track::GetDefaultName(), GetDisplayLog(), Track::GetName(), GetRangeLower(), GetRangeUpper(), Track::Init(), Track::SetDefaultName(), SetDisplayLog(), Track::SetName(), SetRangeLower(), and SetRangeUpper().

Referenced by TimeTrack().

89 {
90  Track::Init(orig);
92  SetName(orig.GetName());
96 }
bool GetDisplayLog() const
Definition: TimeTrack.h:129
void SetRangeUpper(double upper)
Definition: TimeTrack.h:127
double GetRangeLower() const
Definition: TimeTrack.h:123
void SetDisplayLog(bool displayLog)
Definition: TimeTrack.h:130
wxString GetDefaultName() const
Definition: Track.h:378
double GetRangeUpper() const
Definition: TimeTrack.h:124
wxString GetName() const
Definition: Track.h:376
void SetDefaultName(const wxString &n)
Definition: Track.h:379
void SetName(const wxString &n)
Definition: Track.cpp:94
void Init(const Track &orig)
Definition: Track.cpp:78
void SetRangeLower(double lower)
Definition: TimeTrack.h:126
void TimeTrack::InsertSilence ( double  t,
double  len 
)
override

Definition at line 139 of file TimeTrack.cpp.

References mEnvelope.

140 {
141  mEnvelope->InsertSpace(t, len);
142 }
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:141
void TimeTrack::Paste ( double  t,
const Track src 
)
override

Definition at line 121 of file TimeTrack.cpp.

References GetActiveProject(), AudacityProject::GetRate(), mEnvelope, and Track::TypeSwitch().

122 {
123  bool bOk = src && src->TypeSwitch< bool >( [&] (const TimeTrack *tt) {
124  auto sampleTime = 1.0 / GetActiveProject()->GetRate();
125  mEnvelope->PasteEnvelope
126  (t, tt->mEnvelope.get(), sampleTime);
127  return true;
128  } );
129 
130  if (! bOk )
131  // THROW_INCONSISTENCY_EXCEPTION // ?
132  (void)0;// intentionally do nothing.
133 }
R TypeSwitch(const Functions &...functions)
Definition: Track.h:630
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:29
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:141
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:311
double GetRate() const
Definition: Project.h:216
void TimeTrack::SetDisplayLog ( bool  displayLog)
inline

Definition at line 130 of file TimeTrack.h.

References mDisplayLog.

Referenced by HandleXMLTag(), Init(), TimeTrackMenuTable::OnTimeTrackLin(), and TimeTrackMenuTable::OnTimeTrackLog().

130 { mDisplayLog = displayLog; }
bool mDisplayLog
Definition: TimeTrack.h:145
void TimeTrack::SetInterpolateLog ( bool  interpolateLog)

Definition at line 154 of file TimeTrack.cpp.

References mEnvelope.

Referenced by HandleXMLTag(), and TimeTrackMenuTable::OnTimeTrackLogInt().

154  {
155  mEnvelope->SetExponential(interpolateLog);
156 }
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:141
void TimeTrack::SetOffset ( double  )
inlineoverridevirtual

Reimplemented from Track.

Definition at line 63 of file TimeTrack.h.

63 {}
void TimeTrack::SetRangeLower ( double  lower)
inline

Definition at line 126 of file TimeTrack.h.

References mRangeLower.

Referenced by Init(), and TimeTrackMenuTable::OnSetTimeTrackRange().

126 { mRangeLower = lower; }
double mRangeLower
Definition: TimeTrack.h:143
void TimeTrack::SetRangeUpper ( double  upper)
inline

Definition at line 127 of file TimeTrack.h.

References mRangeUpper.

Referenced by Init(), and TimeTrackMenuTable::OnSetTimeTrackRange().

127 { mRangeUpper = upper; }
double mRangeUpper
Definition: TimeTrack.h:144
void TimeTrack::Silence ( double  t0,
double  t1 
)
override

Definition at line 135 of file TimeTrack.cpp.

136 {
137 }
double TimeTrack::SolveWarpedLength ( double  t0,
double  length 
) const

Compute how much unwarped time must have elapsed if length seconds of warped time has elapsed.

Parameters
t0The unwarped time (seconds from project start) at which to start
lengthHow many seconds of warped time went past.
Returns
The end point (in seconds from project start) as unwarped time

Definition at line 169 of file TimeTrack.cpp.

References GetEnvelope(), and Envelope::SolveIntegralOfInverse().

170 {
171  return GetEnvelope()->SolveIntegralOfInverse(t0, length);
172 }
double SolveIntegralOfInverse(double t0, double area) const
Definition: Envelope.cpp:1635
Envelope * GetEnvelope()
Definition: TimeTrack.h:86
void TimeTrack::testMe ( )

Definition at line 327 of file TimeTrack.cpp.

References Envelope::Flatten(), GetEnvelope(), Envelope::InsertOrReplace(), Envelope::Integral(), and Envelope::IntegralOfInverse().

328 {
329  GetEnvelope()->Flatten(0.0);
330  GetEnvelope()->InsertOrReplace(0.0, 0.2);
331  GetEnvelope()->InsertOrReplace(5.0 - 0.001, 0.2);
332  GetEnvelope()->InsertOrReplace(5.0 + 0.001, 1.3);
333  GetEnvelope()->InsertOrReplace(10.0, 1.3);
334 
335  double value1 = GetEnvelope()->Integral(2.0, 13.0);
336  double expected1 = (5.0 - 2.0) * 0.2 + (13.0 - 5.0) * 1.3;
337  double value2 = GetEnvelope()->IntegralOfInverse(2.0, 13.0);
338  double expected2 = (5.0 - 2.0) / 0.2 + (13.0 - 5.0) / 1.3;
339  if( fabs(value1 - expected1) > 0.01 )
340  {
341  wxPrintf( "TimeTrack: Integral failed! expected %f got %f\n", expected1, value1);
342  }
343  if( fabs(value2 - expected2) > 0.01 )
344  {
345  wxPrintf( "TimeTrack: IntegralOfInverse failed! expected %f got %f\n", expected2, value2);
346  }
347 
348  /*double reqt0 = 10.0 - .1;
349  double reqt1 = 10.0 + .1;
350  double t0 = warp( reqt0 );
351  double t1 = warp( reqt1 );
352  if( t0 > t1 )
353  {
354  wxPrintf( "TimeTrack: Warping reverses an interval! [%.2f,%.2f] -> [%.2f,%.2f]\n",
355  reqt0, reqt1,
356  t0, t1 );
357  }*/
358 }
void Flatten(double value)
Definition: Envelope.cpp:137
int InsertOrReplace(double when, double value)
Add a point at a particular absolute time coordinate.
Definition: Envelope.h:196
double IntegralOfInverse(double t0, double t1) const
Definition: Envelope.cpp:1572
Envelope * GetEnvelope()
Definition: TimeTrack.h:86
double Integral(double t0, double t1) const
Definition: Envelope.cpp:1509
void TimeTrack::WriteXML ( XMLWriter xmlFile) const
overridevirtual

Implements Track.

Definition at line 245 of file TimeTrack.cpp.

247 {
248  xmlFile.StartTag(wxT("timetrack"));
249 
250  xmlFile.WriteAttr(wxT("name"), mName);
251  //xmlFile.WriteAttr(wxT("channel"), mChannel);
252  //xmlFile.WriteAttr(wxT("offset"), mOffset, 8);
253  xmlFile.WriteAttr(wxT("height"), GetActualHeight());
254  xmlFile.WriteAttr(wxT("minimized"), GetMinimized());
255  xmlFile.WriteAttr(wxT("rangelower"), mRangeLower, 12);
256  xmlFile.WriteAttr(wxT("rangeupper"), mRangeUpper, 12);
257  xmlFile.WriteAttr(wxT("displaylog"), GetDisplayLog());
258  xmlFile.WriteAttr(wxT("interpolatelog"), GetInterpolateLog());
259 
260  mEnvelope->WriteXML(xmlFile);
261 
262  xmlFile.EndTag(wxT("timetrack"));
263 }
bool GetDisplayLog() const
Definition: TimeTrack.h:129
int GetActualHeight() const
Definition: Track.h:301
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:78
virtual void WriteAttr(const wxString &name, const wxString &value)
Definition: XMLWriter.cpp:131
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:101
bool GetMinimized() const
Definition: Track.cpp:217
bool GetInterpolateLog() const
Definition: TimeTrack.cpp:149
double mRangeUpper
Definition: TimeTrack.h:144
double mRangeLower
Definition: TimeTrack.h:143
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:141
wxString mName
Definition: Track.h:206

Friends And Related Function Documentation

friend class TrackFactory
friend

Definition at line 160 of file TimeTrack.h.

Member Data Documentation

bool TimeTrack::mDisplayLog
private

Definition at line 145 of file TimeTrack.h.

Referenced by GetDisplayLog(), SetDisplayLog(), and TimeTrack().

std::unique_ptr<Envelope> TimeTrack::mEnvelope
private
std::weak_ptr<EnvelopeHandle> TimeTrack::mEnvelopeHandle
private

Definition at line 148 of file TimeTrack.h.

double TimeTrack::mRangeLower
private

Definition at line 143 of file TimeTrack.h.

Referenced by GetRangeLower(), HandleXMLEndTag(), HandleXMLTag(), SetRangeLower(), and TimeTrack().

double TimeTrack::mRangeUpper
private

Definition at line 144 of file TimeTrack.h.

Referenced by GetRangeUpper(), HandleXMLEndTag(), HandleXMLTag(), SetRangeUpper(), and TimeTrack().

bool TimeTrack::mRescaleXMLValues
private

Definition at line 146 of file TimeTrack.h.

Referenced by HandleXMLEndTag(), and HandleXMLTag().

std::unique_ptr<Ruler> TimeTrack::mRuler
private

Definition at line 142 of file TimeTrack.h.

Referenced by TimeTrack().

const ZoomInfo* const TimeTrack::mZoomInfo
private

Definition at line 140 of file TimeTrack.h.

Referenced by TimeTrack().


The documentation for this class was generated from the following files: