Audacity  2.2.2
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

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
 
int GetKind () const 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 ZoomInfo &zoomInfo) 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::vector< UIHandlePtrHitTest (const TrackPanelMouseState &, const AudacityProject *pProject) finaloverride
 
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)
 
TrackGetLink () const
 
 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)
 
bool GetLinked () const
 
void SetLinked (bool l)
 
virtual int GetChannel () const
 
void Offset (double t)
 
void SetChannel (int c)
 
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
 
virtual bool GetErrorOpening ()
 
bool IsSyncLockSelected () const
 
- Public Member Functions inherited from CommonTrackPanelCell
 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
- 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 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

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  { LeftChannel = 0, RightChannel = 1, MonoChannel = 2 }
 
enum  TrackKindEnum {
  None, Wave, Label, Time,
  All
}
 
enum  : unsigned { DefaultHeight = 150 }
 
using Holder = std::unique_ptr< Track >
 
- 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)
 
- 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 mSelected
 
bool mLinked
 
bool mMinimized
 
int 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 158 of file TimeTrack.h.

Constructor & Destructor Documentation

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

Definition at line 40 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.

40  :
41  Track(projDirManager)
42  , mZoomInfo(zoomInfo)
43 {
44  mHeight = 100;
45 
46  mRangeLower = 0.9;
47  mRangeUpper = 1.1;
48  mDisplayLog = false;
49 
50  mEnvelope = std::make_unique<Envelope>(true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0);
51  mEnvelope->SetTrackLen(DBL_MAX);
52  mEnvelope->SetOffset(0);
53 
54  SetDefaultName(_("Time Track"));
56 
57  mRuler = std::make_unique<Ruler>();
58  mRuler->SetUseZoomInfo(0, mZoomInfo);
59  mRuler->SetLabelEdges(false);
60  mRuler->SetFormat(Ruler::TimeFormat);
61 }
#define TIMETRACK_MAX
Definition: TimeTrack.cpp:33
int mHeight
Definition: Track.h:118
bool mDisplayLog
Definition: TimeTrack.h:146
wxString GetDefaultName() const
Definition: Track.h:273
const ZoomInfo *const mZoomInfo
Definition: TimeTrack.h:141
double mRangeUpper
Definition: TimeTrack.h:145
#define TIMETRACK_MIN
Definition: TimeTrack.cpp:32
double mRangeLower
Definition: TimeTrack.h:144
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:142
void SetDefaultName(const wxString &n)
Definition: Track.h:274
_("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:55
void SetName(const wxString &n)
Definition: Track.h:272
std::unique_ptr< Ruler > mRuler
Definition: TimeTrack.h:143
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 63 of file TimeTrack.cpp.

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

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

Definition at line 97 of file TimeTrack.cpp.

98 {
99 }

Member Function Documentation

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

Definition at line 114 of file TimeTrack.cpp.

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

Referenced by Cut().

115 {
116  auto sampleTime = 1.0 / GetActiveProject()->GetRate();
117  mEnvelope->CollapseRegion( t0, t1, sampleTime );
118 }
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:142
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
double GetRate() const
Definition: Project.h:199
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 160 of file TimeTrack.cpp.

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

Referenced by audacityAudioCallback(), AudioIO::StartStream(), and Ruler::Update().

161 {
162  return GetEnvelope()->IntegralOfInverse(t0, t1);
163 }
double IntegralOfInverse(double t0, double t1) const
Definition: Envelope.cpp:1562
Envelope * GetEnvelope()
Definition: TimeTrack.h:90
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 155 of file TimeTrack.cpp.

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

Referenced by Mixer::MixVariableRates().

156 {
157  return GetEnvelope()->AverageOfInverse(t0, t1);
158 }
double AverageOfInverse(double t0, double t1) const
Definition: Envelope.cpp:1408
Envelope * GetEnvelope()
Definition: TimeTrack.h:90
Track::Holder TimeTrack::Copy ( double  t0,
double  t1,
bool  forClipboard 
) const
override

Definition at line 108 of file TimeTrack.cpp.

Referenced by Cut().

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

Definition at line 101 of file TimeTrack.cpp.

References Clear(), and Copy().

102 {
103  auto result = Copy( t0, t1, false );
104  Clear( t0, t1 );
105  return result;
106 }
void Clear(double t0, double t1) override
Definition: TimeTrack.cpp:114
Holder Copy(double t0, double t1, bool forClipboard) const override
Definition: TimeTrack.cpp:108
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:149
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 ZoomInfo zoomInfo 
) const

Definition at line 265 of file TimeTrack.cpp.

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

Referenced by TrackArtist::DrawTimeTrack().

266 {
267  auto &dc = context.dc;
268  bool highlight = false;
269 #ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
270  auto target = dynamic_cast<EnvelopeHandle*>(context.target.get());
271  highlight = target && target->GetEnvelope() == this->GetEnvelope();
272 #endif
273 
274  double min = zoomInfo.PositionToTime(0);
275  double max = zoomInfo.PositionToTime(r.width);
276  if (min > max)
277  {
278  wxASSERT(false);
279  min = max;
280  }
281 
282  AColor::UseThemeColour( &dc, clrUnselected );
283  dc.DrawRectangle(r);
284 
285  //copy this rectangle away for future use.
286  wxRect mid = r;
287 
288  // Draw the Ruler
289  mRuler->SetBounds(r.x, r.y, r.x + r.width - 1, r.y + r.height - 1);
290  mRuler->SetRange(min, max);
291  mRuler->SetFlip(false); // If we don't do this, the Ruler doesn't redraw itself when the envelope is modified.
292  // I have no idea why!
293  //
294  // LL: It's because the ruler only Invalidate()s when the NEW value is different
295  // than the current value.
296  mRuler->SetFlip(GetHeight() > 75 ? true : true); // MB: so why don't we just call Invalidate()? :)
297  mRuler->SetTickColour( theTheme.Colour( clrTrackPanelText ));
298  mRuler->Draw(dc, this);
299 
300  Doubles envValues{ size_t(mid.width) };
302  ( 0, 0, envValues.get(), mid.width, 0, zoomInfo );
303 
304  wxPen &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
305  dc.SetPen( pen );
306 
307  double logLower = log(std::max(1.0e-7, mRangeLower)), logUpper = log(std::max(1.0e-7, mRangeUpper));
308  for (int x = 0; x < mid.width; x++)
309  {
310  double y;
311  if(mDisplayLog)
312  y = (double)mid.height * (logUpper - log(envValues[x])) / (logUpper - logLower);
313  else
314  y = (double)mid.height * (mRangeUpper - envValues[x]) / (mRangeUpper - mRangeLower);
315  int thisy = r.y + (int)y;
316  AColor::Line(dc, mid.x + x, thisy - 1, mid.x + x, thisy+2);
317  }
318 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ViewInfo.cpp:49
bool mDisplayLog
Definition: TimeTrack.h:146
static wxPen uglyPen
Definition: AColor.h:147
static wxPen envelopePen
Definition: AColor.h:122
double mRangeUpper
Definition: TimeTrack.h:145
double mRangeLower
Definition: TimeTrack.h:144
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
Envelope * GetEnvelope() const
std::unique_ptr< Ruler > mRuler
Definition: TimeTrack.h:143
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:1214
Envelope * GetEnvelope()
Definition: TimeTrack.h:90
int GetHeight() const
Definition: Track.cpp:180
Track::Holder TimeTrack::Duplicate ( ) const
overrideprivatevirtual

Implements Track.

Definition at line 140 of file TimeTrack.cpp.

141 {
142  return std::make_unique<TimeTrack>(*this);
143 }
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:137
bool TimeTrack::GetDisplayLog ( ) const
inline

Definition at line 133 of file TimeTrack.h.

References mDisplayLog.

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

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

Implements Track.

Definition at line 69 of file TimeTrack.h.

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

Definition at line 90 of file TimeTrack.h.

References mEnvelope.

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

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

Definition at line 91 of file TimeTrack.h.

References mEnvelope.

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

Definition at line 145 of file TimeTrack.cpp.

References mEnvelope.

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

146 {
147  return mEnvelope->GetExponential();
148 }
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:142
int TimeTrack::GetKind ( ) const
inlineoverridevirtual

Reimplemented from Track.

Definition at line 61 of file TimeTrack.h.

References Track::Time.

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

Implements Track.

Definition at line 65 of file TimeTrack.h.

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

Definition at line 127 of file TimeTrack.h.

References mRangeLower.

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

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

Definition at line 128 of file TimeTrack.h.

References mRangeUpper.

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

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

Implements Track.

Definition at line 68 of file TimeTrack.h.

68 { 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:137
XMLTagHandler * TimeTrack::HandleXMLChild ( const wxChar *  tag)
overridevirtual

Implements XMLTagHandler.

Definition at line 233 of file TimeTrack.cpp.

References mEnvelope.

234 {
235  if (!wxStrcmp(tag, wxT("envelope")))
236  return mEnvelope.get();
237 
238  return NULL;
239 }
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:142
void TimeTrack::HandleXMLEndTag ( const wxChar *  tag)
override

Definition at line 223 of file TimeTrack.cpp.

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

224 {
226  {
227  mRescaleXMLValues = false;
228  mEnvelope->RescaleValues(mRangeLower, mRangeUpper);
230  }
231 }
#define TIMETRACK_MAX
Definition: TimeTrack.cpp:33
double mRangeUpper
Definition: TimeTrack.h:145
#define TIMETRACK_MIN
Definition: TimeTrack.cpp:32
double mRangeLower
Definition: TimeTrack.h:144
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:142
bool mRescaleXMLValues
Definition: TimeTrack.h:147
bool TimeTrack::HandleXMLTag ( const wxChar *  tag,
const wxChar **  attrs 
)
overridevirtual

Implements XMLTagHandler.

Definition at line 170 of file TimeTrack.cpp.

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

171 {
172  if (!wxStrcmp(tag, wxT("timetrack"))) {
173  mRescaleXMLValues = true; // will be set to false if upper/lower is found
174  long nValue;
175  while(*attrs) {
176  const wxChar *attr = *attrs++;
177  const wxChar *value = *attrs++;
178 
179  if (!value)
180  break;
181 
182  const wxString strValue = value;
183  if (!wxStrcmp(attr, wxT("name")) && XMLValueChecker::IsGoodString(strValue))
184  mName = strValue;
185  else if (!wxStrcmp(attr, wxT("height")) &&
186  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
187  mHeight = nValue;
188  else if (!wxStrcmp(attr, wxT("minimized")) &&
189  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
190  mMinimized = (nValue != 0);
191  else if (!wxStrcmp(attr, wxT("rangelower")))
192  {
194  mRescaleXMLValues = false;
195  }
196  else if (!wxStrcmp(attr, wxT("rangeupper")))
197  {
199  mRescaleXMLValues = false;
200  }
201  else if (!wxStrcmp(attr, wxT("displaylog")) &&
202  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
203  {
204  SetDisplayLog(nValue != 0);
205  //TODO-MB: This causes a graphical glitch, TrackPanel should probably be Refresh()ed after loading.
206  // I don't know where to do this though.
207  }
208  else if (!wxStrcmp(attr, wxT("interpolatelog")) &&
209  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
210  {
211  SetInterpolateLog(nValue != 0);
212  }
213 
214  } // while
216  mEnvelope->SetRange(0.0, 1.0); // this will be restored to the actual range later
217  return true;
218  }
219 
220  return false;
221 }
int mHeight
Definition: Track.h:118
void SetDisplayLog(bool displayLog)
Definition: TimeTrack.h:134
static bool IsGoodInt(const wxString &strInt)
Check that the supplied string can be converted to a long (32bit) integer.
double mRangeUpper
Definition: TimeTrack.h:145
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:125
double mRangeLower
Definition: TimeTrack.h:144
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:142
void SetInterpolateLog(bool interpolateLog)
Definition: TimeTrack.cpp:150
bool mRescaleXMLValues
Definition: TimeTrack.h:147
wxString mName
Definition: Track.h:119
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 87 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().

88 {
89  Track::Init(orig);
91  SetName(orig.GetName());
95 }
bool GetDisplayLog() const
Definition: TimeTrack.h:133
void SetRangeUpper(double upper)
Definition: TimeTrack.h:131
double GetRangeLower() const
Definition: TimeTrack.h:127
void SetDisplayLog(bool displayLog)
Definition: TimeTrack.h:134
wxString GetDefaultName() const
Definition: Track.h:273
double GetRangeUpper() const
Definition: TimeTrack.h:128
wxString GetName() const
Definition: Track.h:271
void SetDefaultName(const wxString &n)
Definition: Track.h:274
void SetName(const wxString &n)
Definition: Track.h:272
void Init(const Track &orig)
Definition: Track.cpp:83
void SetRangeLower(double lower)
Definition: TimeTrack.h:130
void TimeTrack::InsertSilence ( double  t,
double  len 
)
override

Definition at line 135 of file TimeTrack.cpp.

References mEnvelope.

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

Definition at line 120 of file TimeTrack.cpp.

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

121 {
122  if (src->GetKind() != Track::Time)
123  // THROW_INCONSISTENCY_EXCEPTION; // ?
124  return;
125 
126  auto sampleTime = 1.0 / GetActiveProject()->GetRate();
127  mEnvelope->Paste
128  (t, static_cast<const TimeTrack*>(src)->mEnvelope.get(), sampleTime);
129 }
virtual int GetKind() const
Definition: Track.h:330
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:142
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
double GetRate() const
Definition: Project.h:199
void TimeTrack::SetDisplayLog ( bool  displayLog)
inline

Definition at line 134 of file TimeTrack.h.

References mDisplayLog.

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

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

Definition at line 150 of file TimeTrack.cpp.

References mEnvelope.

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

150  {
151  mEnvelope->SetExponential(interpolateLog);
152 }
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:142
void TimeTrack::SetOffset ( double  )
inlineoverridevirtual

Reimplemented from Track.

Definition at line 66 of file TimeTrack.h.

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

Definition at line 130 of file TimeTrack.h.

References mRangeLower.

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

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

Definition at line 131 of file TimeTrack.h.

References mRangeUpper.

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

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

Definition at line 131 of file TimeTrack.cpp.

132 {
133 }
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 165 of file TimeTrack.cpp.

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

Referenced by audacityAudioCallback().

166 {
167  return GetEnvelope()->SolveIntegralOfInverse(t0, length);
168 }
double SolveIntegralOfInverse(double t0, double area) const
Definition: Envelope.cpp:1625
Envelope * GetEnvelope()
Definition: TimeTrack.h:90
void TimeTrack::testMe ( )

Definition at line 320 of file TimeTrack.cpp.

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

321 {
322  GetEnvelope()->Flatten(0.0);
323  GetEnvelope()->InsertOrReplace(0.0, 0.2);
324  GetEnvelope()->InsertOrReplace(5.0 - 0.001, 0.2);
325  GetEnvelope()->InsertOrReplace(5.0 + 0.001, 1.3);
326  GetEnvelope()->InsertOrReplace(10.0, 1.3);
327 
328  double value1 = GetEnvelope()->Integral(2.0, 13.0);
329  double expected1 = (5.0 - 2.0) * 0.2 + (13.0 - 5.0) * 1.3;
330  double value2 = GetEnvelope()->IntegralOfInverse(2.0, 13.0);
331  double expected2 = (5.0 - 2.0) / 0.2 + (13.0 - 5.0) / 1.3;
332  if( fabs(value1 - expected1) > 0.01 )
333  {
334  wxPrintf( "TimeTrack: Integral failed! expected %f got %f\n", expected1, value1);
335  }
336  if( fabs(value2 - expected2) > 0.01 )
337  {
338  wxPrintf( "TimeTrack: IntegralOfInverse failed! expected %f got %f\n", expected2, value2);
339  }
340 
341  /*double reqt0 = 10.0 - .1;
342  double reqt1 = 10.0 + .1;
343  double t0 = warp( reqt0 );
344  double t1 = warp( reqt1 );
345  if( t0 > t1 )
346  {
347  wxPrintf( "TimeTrack: Warping reverses an interval! [%.2f,%.2f] -> [%.2f,%.2f]\n",
348  reqt0, reqt1,
349  t0, t1 );
350  }*/
351 }
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:194
double IntegralOfInverse(double t0, double t1) const
Definition: Envelope.cpp:1562
Envelope * GetEnvelope()
Definition: TimeTrack.h:90
double Integral(double t0, double t1) const
Definition: Envelope.cpp:1499
void TimeTrack::WriteXML ( XMLWriter xmlFile) const
overridevirtual

Implements Track.

Definition at line 241 of file TimeTrack.cpp.

243 {
244  xmlFile.StartTag(wxT("timetrack"));
245 
246  xmlFile.WriteAttr(wxT("name"), mName);
247  //xmlFile.WriteAttr(wxT("channel"), mChannel);
248  //xmlFile.WriteAttr(wxT("offset"), mOffset, 8);
249  xmlFile.WriteAttr(wxT("height"), GetActualHeight());
250  xmlFile.WriteAttr(wxT("minimized"), GetMinimized());
251  xmlFile.WriteAttr(wxT("rangelower"), mRangeLower, 12);
252  xmlFile.WriteAttr(wxT("rangeupper"), mRangeUpper, 12);
253  xmlFile.WriteAttr(wxT("displaylog"), GetDisplayLog());
254  xmlFile.WriteAttr(wxT("interpolatelog"), GetInterpolateLog());
255 
256  mEnvelope->WriteXML(xmlFile);
257 
258  xmlFile.EndTag(wxT("timetrack"));
259 }
bool GetDisplayLog() const
Definition: TimeTrack.h:133
int GetActualHeight() const
Definition: Track.h:193
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:214
bool GetInterpolateLog() const
Definition: TimeTrack.cpp:145
double mRangeUpper
Definition: TimeTrack.h:145
double mRangeLower
Definition: TimeTrack.h:144
std::unique_ptr< Envelope > mEnvelope
Definition: TimeTrack.h:142
wxString mName
Definition: Track.h:119

Friends And Related Function Documentation

friend class TrackFactory
friend

Definition at line 161 of file TimeTrack.h.

Member Data Documentation

bool TimeTrack::mDisplayLog
private

Definition at line 146 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 149 of file TimeTrack.h.

double TimeTrack::mRangeLower
private

Definition at line 144 of file TimeTrack.h.

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

double TimeTrack::mRangeUpper
private

Definition at line 145 of file TimeTrack.h.

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

bool TimeTrack::mRescaleXMLValues
private

Definition at line 147 of file TimeTrack.h.

Referenced by HandleXMLEndTag(), and HandleXMLTag().

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

Definition at line 143 of file TimeTrack.h.

Referenced by TimeTrack().

const ZoomInfo* const TimeTrack::mZoomInfo
private

Definition at line 141 of file TimeTrack.h.

Referenced by TimeTrack().


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