Audacity  3.2.0
WaveTrack.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  WaveTrack.h
6 
7  Dominic Mazzoni
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_WAVETRACK__
12 #define __AUDACITY_WAVETRACK__
13 
14 #include "Prefs.h"
15 #include "SampleCount.h"
16 #include "SampleFormat.h"
17 #include "SampleTrack.h"
18 
19 #include <vector>
20 #include <functional>
21 #include <wx/thread.h>
22 #include <wx/longlong.h>
23 
24 class wxRect;
25 
26 #include "WaveTrackLocation.h"
27 
28 namespace BasicUI{ class ProgressDialog; }
29 
30 class SampleBlockFactory;
31 using SampleBlockFactoryPtr = std::shared_ptr<SampleBlockFactory>;
32 
34 class WaveformSettings;
35 class TimeWarper;
36 
37 class Sequence;
38 class WaveClip;
39 
40 // Array of pointers that assume ownership
41 using WaveClipHolder = std::shared_ptr< WaveClip >;
42 using WaveClipHolders = std::vector < WaveClipHolder >;
43 using WaveClipConstHolders = std::vector < std::shared_ptr< const WaveClip > >;
44 
45 // Temporary arrays of mere pointers
46 using WaveClipPointers = std::vector < WaveClip* >;
47 using WaveClipConstPointers = std::vector < const WaveClip* >;
48 
49 //
50 // Tolerance for merging wave tracks (in seconds)
51 //
52 #define WAVETRACK_MERGE_POINT_TOLERANCE 0.01
53 
56 struct Region
57 {
58  Region() : start(0), end(0) {}
59  Region(double start_, double end_) : start(start_), end(end_) {}
60 
61  double start, end;
62 
63  //used for sorting
64  bool operator < (const Region &b) const
65  {
66  return this->start < b.start;
67  }
68 };
69 
70 using Regions = std::vector < Region >;
71 
72 class Envelope;
73 
74 class AUDACITY_DLL_API WaveTrack final : public WritableSampleTrack
75 {
76 public:
77  static wxString GetDefaultAudioTrackNamePreference();
78 
79  //
80  // Constructor / Destructor / Duplicator
81  //
82 
83  // Construct and also build all attachments
84  static WaveTrack *New( AudacityProject &project );
85 
86  WaveTrack(
87  const SampleBlockFactoryPtr &pFactory, sampleFormat format, double rate);
88  WaveTrack(const WaveTrack &orig);
89 
90  // overwrite data excluding the sample sequence but including display
91  // settings
92  void Reinit(const WaveTrack &orig);
93 private:
94  void Init(const WaveTrack &orig);
95 
96  Track::Holder Clone() const override;
97 
98  friend class WaveTrackFactory;
99 
100  wxString MakeClipCopyName(const wxString& originalName) const;
101  wxString MakeNewClipName() const;
102  public:
103 
105  using Holder = std::shared_ptr<WaveTrack>;
106 
107  virtual ~WaveTrack();
108 
109  double GetOffset() const override;
110  void SetOffset(double o) override;
111  ChannelType GetChannelIgnoringPan() const override;
112  ChannelType GetChannel() const override;
113  virtual void SetPanFromChannelType() override;
114 
115  bool LinkConsistencyCheck() override;
116 
121  double GetStartTime() const override;
122 
128  double GetEndTime() const override;
129 
130  //
131  // Identifying the type of track
132  //
133 
134  //
135  // WaveTrack parameters
136  //
137 
138  double GetRate() const override;
139  void SetRate(double newRate);
140 
141  // Multiplicative factor. Only converted to dB for display.
142  float GetGain() const;
143  void SetGain(float newGain);
144 
145  // -1.0 (left) -> 1.0 (right)
146  float GetPan() const;
147  void SetPan(float newPan) override;
148 
149  float GetChannelGain(int channel) const override;
150 
151  float GetOldChannelGain(int channel) const override;
152  void SetOldChannelGain(int channel, float gain) override;
153 
154  int GetWaveColorIndex() const { return mWaveColorIndex; };
155  void SetWaveColorIndex(int colorIndex);
156 
157  sampleCount GetPlaySamplesCount() const;
158  sampleCount GetSequenceSamplesCount() const;
159 
160  sampleFormat GetSampleFormat() const override { return mFormat; }
161 
162  void ConvertToSampleFormat(sampleFormat format,
163  const std::function<void(size_t)> & progressReport = {});
164 
165  const SpectrogramSettings &GetSpectrogramSettings() const;
166  SpectrogramSettings &GetSpectrogramSettings();
167  SpectrogramSettings &GetIndependentSpectrogramSettings();
168  void SetSpectrogramSettings(std::unique_ptr<SpectrogramSettings> &&pSettings);
169 
170  const WaveformSettings &GetWaveformSettings() const;
171  WaveformSettings &GetWaveformSettings();
172  void SetWaveformSettings(std::unique_ptr<WaveformSettings> &&pSettings);
173  void UseSpectralPrefs( bool bUse=true );
174  //
175  // High-level editing
176  //
177 
178  Track::Holder Cut(double t0, double t1) override;
179 
180  // Make another track copying format, rate, color, etc. but containing no
181  // clips
182  // It is important to pass the correct factory (that for the project
183  // which will own the copy) in the unusual case that a track is copied from
184  // another project or the clipboard. For copies within one project, the
185  // default will do.
186  Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory = {} ) const;
187 
188  // If forClipboard is true,
189  // and there is no clip at the end time of the selection, then the result
190  // will contain a "placeholder" clip whose only purpose is to make
191  // GetEndTime() correct. This clip is not re-copied when pasting.
192  Track::Holder Copy(double t0, double t1, bool forClipboard = true) const override;
193  Track::Holder CopyNonconst(double t0, double t1) /* not override */;
194 
195  void Clear(double t0, double t1) override;
196  void Paste(double t0, const Track *src) override;
197  // May assume precondition: t0 <= t1
198  void ClearAndPaste(double t0, double t1,
199  const Track *src,
200  bool preserve = true,
201  bool merge = true,
202  const TimeWarper *effectWarper = NULL) /* not override */;
203 
204  void Silence(double t0, double t1) override;
205  void InsertSilence(double t, double len) override;
206 
207  void SplitAt(double t) /* not override */;
208  void Split(double t0, double t1) /* not override */;
209  // Track::Holder CutAndAddCutLine(double t0, double t1) /* not override */;
210  // May assume precondition: t0 <= t1
211  void ClearAndAddCutLine(double t0, double t1) /* not override */;
212 
213  Track::Holder SplitCut(double t0, double t1) /* not override */;
214  // May assume precondition: t0 <= t1
215  void SplitDelete(double t0, double t1) /* not override */;
216  void Join(double t0, double t1) /* not override */;
217  // May assume precondition: t0 <= t1
218  void Disjoin(double t0, double t1) /* not override */;
219 
220  // May assume precondition: t0 <= t1
221  void Trim(double t0, double t1) /* not override */;
222 
223  // May assume precondition: t0 <= t1
224  void HandleClear(double t0, double t1, bool addCutLines, bool split);
225 
226  void SyncLockAdjust(double oldT1, double newT1) override;
227 
233  bool IsEmpty(double t0, double t1) const;
234 
235  /*
236  * If there is an existing WaveClip in the WaveTrack then the data is
237  * appended to that clip. If there are no WaveClips in the track, then a NEW
238  * one is created.
239  *
240  */
242  size_t len, unsigned int stride=1) override;
243  void Flush() override;
244 
255 
256  bool Get(samplePtr buffer, sampleFormat format,
257  sampleCount start, size_t len,
258  fillFormat fill = fillZero,
259  bool mayThrow = true,
260  // Report how many samples were copied from within clips, rather than
261  // filled according to fillFormat; but these were not necessarily one
262  // contiguous range.
263  sampleCount * pNumWithinClips = nullptr) const override;
264  void Set(constSamplePtr buffer, sampleFormat format,
265  sampleCount start, size_t len);
266 
267  void GetEnvelopeValues(double *buffer, size_t bufferLen,
268  double t0) const override;
269 
270  // May assume precondition: t0 <= t1
271  std::pair<float, float> GetMinMax(
272  double t0, double t1, bool mayThrow = true) const;
273  // May assume precondition: t0 <= t1
274  float GetRMS(double t0, double t1, bool mayThrow = true) const;
275 
276  //
277  // MM: We now have more than one sequence and envelope per track, so
278  // instead of GetSequence() and GetEnvelope() we have the following
279  // function which give the sequence and envelope which contains the given
280  // time.
281  //
282  Sequence* GetSequenceAtTime(double time);
283  Envelope* GetEnvelopeAtTime(double time);
284 
285  WaveClip* GetClipAtSample(sampleCount sample);
286  WaveClip* GetClipAtTime(double time);
287 
288  //
289  // Getting information about the track's internal block sizes
290  // and alignment for efficiency
291  //
292 
293  sampleCount GetBlockStart(sampleCount t) const override;
294 
295  // These return a nonnegative number of samples meant to size a memory buffer
296  size_t GetBestBlockSize(sampleCount t) const override;
297  size_t GetMaxBlockSize() const override;
298  size_t GetIdealBlockSize();
299 
300  //
301  // XMLTagHandler callback methods for loading and saving
302  //
303 
304  bool HandleXMLTag(const std::string_view& tag, const AttributesList& attrs) override;
305  void HandleXMLEndTag(const std::string_view& tag) override;
306  XMLTagHandler *HandleXMLChild(const std::string_view& tag) override;
307  void WriteXML(XMLWriter &xmlFile) const override;
308 
309  // Returns true if an error occurred while reading from XML
310  bool GetErrorOpening() override;
311 
312  //
313  // Lock and unlock the track: you must lock the track before
314  // doing a copy and paste between projects.
315  //
316 
317  bool CloseLock(); //should be called when the project closes.
318  // not balanced by unlocking calls.
319 
320  // Get access to the (visible) clips in the tracks, in unspecified order
321  // (not necessarily sequenced in time).
322  WaveClipHolders &GetClips() { return mClips; }
324  { return reinterpret_cast< const WaveClipConstHolders& >( mClips ); }
325 
326  // Get mutative access to all clips (in some unspecified sequence),
327  // including those hidden in cutlines.
329  : public ValueIterator< WaveClip * >
330  {
331  public:
332  // Constructs an "end" iterator
334 
335  // Construct a "begin" iterator
336  explicit AllClipsIterator( WaveTrack &track )
337  {
338  push( track.mClips );
339  }
340 
342  {
343  if (mStack.empty())
344  return nullptr;
345  else
346  return mStack.back().first->get();
347  }
348 
349  AllClipsIterator &operator ++ ();
350 
351  // Define == well enough to serve for loop termination test
352  friend bool operator == (
353  const AllClipsIterator &a, const AllClipsIterator &b)
354  { return a.mStack.empty() == b.mStack.empty(); }
355 
356  friend bool operator != (
357  const AllClipsIterator &a, const AllClipsIterator &b)
358  { return !( a == b ); }
359 
360  private:
361 
362  void push( WaveClipHolders &clips );
363 
364  using Iterator = WaveClipHolders::iterator;
365  using Pair = std::pair< Iterator, Iterator >;
366  using Stack = std::vector< Pair >;
367 
369  };
370 
371  // Get const access to all clips (in some unspecified sequence),
372  // including those hidden in cutlines.
374  : public ValueIterator< const WaveClip * >
375  {
376  public:
377  // Constructs an "end" iterator
379 
380  // Construct a "begin" iterator
381  explicit AllClipsConstIterator( const WaveTrack &track )
382  : mIter{ const_cast< WaveTrack& >( track ) }
383  {}
384 
385  const WaveClip *operator * () const
386  { return *mIter; }
387 
388  AllClipsConstIterator &operator ++ ()
389  { ++mIter; return *this; }
390 
391  // Define == well enough to serve for loop termination test
392  friend bool operator == (
393  const AllClipsConstIterator &a, const AllClipsConstIterator &b)
394  { return a.mIter == b.mIter; }
395 
396  friend bool operator != (
397  const AllClipsConstIterator &a, const AllClipsConstIterator &b)
398  { return !( a == b ); }
399 
400  private:
402  };
403 
405  {
406  return { AllClipsIterator{ *this }, AllClipsIterator{ } };
407  }
408 
410  {
411  return { AllClipsConstIterator{ *this }, AllClipsConstIterator{ } };
412  }
413 
414  // Create NEW clip and add it to this track. Returns a pointer
415  // to the newly created clip. Optionally initial offset and
416  // clip name may be provided
417  WaveClip* CreateClip(double offset = .0, const wxString& name = wxEmptyString);
418 
424  WaveClip* NewestOrNewClip();
425 
431  WaveClip* RightmostOrNewClip();
432 
433  // Get the linear index of a given clip (-1 if the clip is not found)
434  int GetClipIndex(const WaveClip* clip) const;
435 
436  // Get the nth clip in this WaveTrack (will return NULL if not found).
437  // Use this only in special cases (like getting the linked clip), because
438  // it is much slower than GetClipIterator().
439  WaveClip *GetClipByIndex(int index);
440  const WaveClip* GetClipByIndex(int index) const;
441 
442  // Get number of clips in this WaveTrack
443  int GetNumClips() const;
444 
445  // Add all wave clips to the given array 'clips' and sort the array by
446  // clip start time. The array is emptied prior to adding the clips.
447  WaveClipPointers SortedClipArray();
448  WaveClipConstPointers SortedClipArray() const;
449 
451 
454  bool CanOffsetClips(
455  const std::vector<WaveClip*> &clips,
456  double amount,
457  double *allowedAmount = nullptr
459  );
460 
461  // Before moving a clip into a track (or inserting a clip), use this
462  // function to see if the times are valid (i.e. don't overlap with
463  // existing clips).
464  bool CanInsertClip(WaveClip* clip, double &slideBy, double &tolerance) const;
465 
466  // Remove the clip from the track and return a SMART pointer to it.
467  // You assume responsibility for its memory!
468  std::shared_ptr<WaveClip> RemoveAndReturnClip(WaveClip* clip);
469 
471  bool AddClip(const std::shared_ptr<WaveClip> &clip);
472 
473  // Merge two clips, that is append data from clip2 to clip1,
474  // then remove clip2 from track.
475  // clipidx1 and clipidx2 are indices into the clip list.
476  void MergeClips(int clipidx1, int clipidx2);
477 
478  // Cache special locations (e.g. cut lines) for later speedy access
479  void UpdateLocationsCache() const;
480 
481  // Get cached locations
482  const std::vector<Location> &GetCachedLocations() const { return mDisplayLocationsCache; }
483 
484  // Expand cut line (that is, re-insert audio, then DELETE audio saved in cut line)
485  void ExpandCutLine(double cutLinePosition, double* cutlineStart = NULL, double* cutlineEnd = NULL);
486 
487  // Remove cut line, without expanding the audio in it
488  bool RemoveCutLine(double cutLinePosition);
489 
490  // This track has been merged into a stereo track. Copy shared parameters
491  // from the NEW partner.
492  void Merge(const Track &orig) override;
493 
494  // Resample track (i.e. all clips in the track)
495  void Resample(int rate, BasicUI::ProgressDialog *progress = NULL);
496 
497  const TypeInfo &GetTypeInfo() const override;
498  static const TypeInfo &ClassTypeInfo();
499 
500  int GetLastScaleType() const { return mLastScaleType; }
501  void SetLastScaleType() const;
502 
503  int GetLastdBRange() const { return mLastdBRange; }
504  void SetLastdBRange() const;
505 
506  void GetDisplayBounds(float *min, float *max) const;
507  void SetDisplayBounds(float min, float max) const;
508  void GetSpectrumBounds(float *min, float *max) const;
509  void SetSpectrumBounds(float min, float max) const;
510 
511  // For display purposes, calculate the y coordinate where the midline of
512  // the wave should be drawn, if display minimum and maximum map to the
513  // bottom and top. Maybe that is out of bounds.
514  int ZeroLevelYCoordinate(wxRect rect) const;
515 
516  class IntervalData final : public Track::IntervalData {
517  public:
518  explicit IntervalData( const std::shared_ptr<WaveClip> &pClip )
519  : pClip{ pClip }
520  {}
521  std::shared_ptr<const WaveClip> GetClip() const { return pClip; }
522  std::shared_ptr<WaveClip> &GetClip() { return pClip; }
523  private:
524  std::shared_ptr<WaveClip> pClip;
525  };
526 
527  Track::Holder PasteInto( AudacityProject & ) const override;
528 
529  ConstIntervals GetIntervals() const override;
530  Intervals GetIntervals() override;
531 
533  const WaveClip* FindClipByName(const wxString& name) const;
534  protected:
535  //
536  // Protected variables
537  //
538 
540 
542  int mRate;
543  float mGain;
544  float mPan;
546  float mOldGain[2];
547 
548 
549  //
550  // Data that should be part of GUIWaveTrack
551  // and will be taken out of the WaveTrack class:
552  //
553  mutable float mDisplayMin;
554  mutable float mDisplayMax;
555  mutable float mSpectrumMin;
556  mutable float mSpectrumMax;
557 
558  mutable int mLastScaleType; // last scale type choice
559  mutable int mLastdBRange;
560  mutable std::vector <Location> mDisplayLocationsCache;
561 
562  //
563  // Protected methods
564  //
565 
566 private:
567 
568  void PasteWaveTrack(double t0, const WaveTrack* other);
569 
570  //
571  // Private variables
572  //
573 
575 
576  wxCriticalSection mFlushCriticalSection;
577  wxCriticalSection mAppendCriticalSection;
579 
580  std::unique_ptr<SpectrogramSettings> mpSpectrumSettings;
581  std::unique_ptr<WaveformSettings> mpWaveformSettings;
582 };
583 
585 
586 #include <unordered_set>
587 class SampleBlock;
588 using SampleBlockID = long long;
589 using SampleBlockIDSet = std::unordered_set<SampleBlockID>;
590 class TrackList;
591 using BlockVisitor = std::function< void(SampleBlock&) >;
592 using BlockInspector = std::function< void(const SampleBlock&) >;
593 
594 // Function to visit all sample blocks from a list of tracks.
595 // If a set is supplied, then only visit once each unique block ID not already
596 // in that set, and accumulate those into the set as a side-effect.
597 // The visitor function may be null.
598 void VisitBlocks(TrackList &tracks, BlockVisitor visitor,
599  SampleBlockIDSet *pIDs = nullptr);
600 
601 // Non-mutating version of the above
602 void InspectBlocks(const TrackList &tracks, BlockInspector inspector,
603  SampleBlockIDSet *pIDs = nullptr);
604 
605 class ProjectRate;
606 
607 class AUDACITY_DLL_API WaveTrackFactory final
608  : public ClientData::Base
609 {
610  public:
611  static WaveTrackFactory &Get( AudacityProject &project );
612  static const WaveTrackFactory &Get( const AudacityProject &project );
613  static WaveTrackFactory &Reset( AudacityProject &project );
614  static void Destroy( AudacityProject &project );
615 
617  const ProjectRate& rate,
618  const SampleBlockFactoryPtr &pFactory)
619  : mRate{ rate }
620  , mpFactory(pFactory)
621  {
622  }
623  WaveTrackFactory( const WaveTrackFactory & ) PROHIBITED;
625 
627  { return mpFactory; }
628 
629  private:
632  public:
633  std::shared_ptr<WaveTrack> DuplicateWaveTrack(const WaveTrack &orig);
634  std::shared_ptr<WaveTrack> NewWaveTrack(
636  double rate = 0);
637 };
638 
639 extern AUDACITY_DLL_API StringSetting AudioTrackNameSetting;
640 
641 AUDACITY_DLL_API bool GetEditClipsCanMove();
642 
643 #endif // __AUDACITY_WAVETRACK__
XMLWriter
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:26
ENUMERATE_TRACK_TYPE
ENUMERATE_TRACK_TYPE(WaveTrack)
WaveClipConstPointers
std::vector< const WaveClip * > WaveClipConstPointers
Definition: WaveTrack.h:47
WaveTrack::AllClipsIterator::AllClipsIterator
AllClipsIterator(WaveTrack &track)
Definition: WaveTrack.h:336
WritableSampleTrack::Flush
virtual void Flush()=0
Flush must be called after last Append.
WaveTrack::IntervalData::IntervalData
IntervalData(const std::shared_ptr< WaveClip > &pClip)
Definition: WaveTrack.h:518
SpectrogramSettings
Spectrogram settings, either for one track or as defaults.
Definition: SpectrogramSettings.h:27
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:75
SampleTrack::GetEnvelopeValues
virtual void GetEnvelopeValues(double *buffer, size_t bufferLen, double t0) const =0
Fetch envelope values corresponding to uniformly separated sample times starting at the given time.
VisitBlocks
void VisitBlocks(TrackList &tracks, BlockVisitor visitor, SampleBlockIDSet *pIDs=nullptr)
Definition: WaveTrack.cpp:2759
TimeWarper
Transforms one point in time to another point. For example, a time stretching effect might use one to...
Definition: TimeWarper.h:62
WaveTrack::AllClipsConstIterator::AllClipsConstIterator
AllClipsConstIterator()
Definition: WaveTrack.h:378
SampleBlockIDSet
std::unordered_set< SampleBlockID > SampleBlockIDSet
Definition: WaveTrack.h:589
operator*
Vector operator*(const Vector &left, const Vector &right)
Definition: Matrix.cpp:153
WaveTrack::AllClipsIterator::Pair
std::pair< Iterator, Iterator > Pair
Definition: WaveTrack.h:365
WritableSampleTrack
Definition: SampleTrack.h:113
WaveTrack::GetAllClips
IteratorRange< AllClipsIterator > GetAllClips()
Definition: WaveTrack.h:404
WaveTrack::AllClipsConstIterator::mIter
AllClipsIterator mIter
Definition: WaveTrack.h:401
Track::GetEndTime
virtual double GetEndTime() const =0
WaveTrack::mWaveColorIndex
int mWaveColorIndex
Definition: WaveTrack.h:545
Track::ConstIntervals
std::vector< ConstInterval > ConstIntervals
Definition: Track.h:316
WaveTrackFactory::mRate
const ProjectRate & mRate
Definition: WaveTrack.h:630
WaveTrackLocation.h
fillFormat
fillFormat
Definition: SampleFormat.h:53
WaveTrack::mLastdBRange
int mLastdBRange
Definition: WaveTrack.h:559
Track::GetIntervals
virtual ConstIntervals GetIntervals() const
Report times on the track where important intervals begin and end, for UI to snap to.
Definition: Track.cpp:1108
PlayableTrack::Merge
void Merge(const Track &init) override
Definition: Track.cpp:242
operator!=
bool operator!=(const Tags &lhs, const Tags &rhs)
Definition: Tags.h:128
TrackList
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1288
Envelope
Piecewise linear or piecewise exponential function from double to double.
Definition: Envelope.h:72
TrackIntervalData
Optional extra information about an interval, appropriate to a subtype of Track.
Definition: Track.h:171
SampleTrack::GetMaxBlockSize
virtual size_t GetMaxBlockSize() const =0
This returns a nonnegative number of samples meant to size a memory buffer.
WaveTrack::mpSpectrumSettings
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:580
Track::Cut
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1))=0
WaveTrack::AllClipsIterator::mStack
Stack mStack
Definition: WaveTrack.h:368
Track::LinkConsistencyCheck
virtual bool LinkConsistencyCheck()
Definition: Track.cpp:316
IteratorRange
A convenience for use with range-for.
Definition: MemoryX.h:252
Track::InsertSilence
virtual void InsertSilence(double WXUNUSED(t), double WXUNUSED(len))=0
ClientData::Base
A convenient default parameter for class template Site.
Definition: ClientData.h:28
Region::start
double start
Definition: WaveTrack.h:61
WaveTrack::GetWaveColorIndex
int GetWaveColorIndex() const
Definition: WaveTrack.h:154
WaveTrack::IntervalData
Definition: WaveTrack.h:516
Track::SetPanFromChannelType
virtual void SetPanFromChannelType()
Definition: Track.h:445
WritableSampleTrack::ClassTypeInfo
static const TypeInfo & ClassTypeInfo()
Definition: SampleTrack.cpp:55
PlayableTrack::Init
void Init(const PlayableTrack &init)
Definition: Track.cpp:235
Track::Paste
virtual void Paste(double WXUNUSED(t), const Track *WXUNUSED(src))=0
WaveTrack::mSpectrumMax
float mSpectrumMax
Definition: WaveTrack.h:556
WaveTrackLocation
Definition: WaveTrackLocation.h:14
Track::SetOffset
virtual void SetOffset(double o)
Definition: Track.h:442
WaveClipPointers
std::vector< WaveClip * > WaveClipPointers
Definition: WaveTrack.h:46
WaveTrackFactory::WaveTrackFactory
WaveTrackFactory(const WaveTrackFactory &) PROHIBITED
Sequence
A WaveTrack contains WaveClip(s). A WaveClip contains a Sequence. A Sequence is primarily an interfac...
Definition: Sequence.h:61
WaveTrack::mpWaveformSettings
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:581
WaveClipHolders
std::vector< WaveClipHolder > WaveClipHolders
Definition: WaveClip.h:42
Regions
std::vector< Region > Regions
Definition: WaveTrack.h:70
XMLTagHandler::HandleXMLEndTag
virtual void HandleXMLEndTag(const std::string_view &WXUNUSED(tag))
Definition: XMLTagHandler.h:59
fillZero
@ fillZero
Definition: SampleFormat.h:54
SampleTrack.h
InspectBlocks
void InspectBlocks(const TrackList &tracks, BlockInspector inspector, SampleBlockIDSet *pIDs=nullptr)
Definition: WaveTrack.cpp:2780
WaveTrack::IntervalData::GetClip
std::shared_ptr< WaveClip > & GetClip()
Definition: WaveTrack.h:522
WaveTrack::GetCachedLocations
const std::vector< Location > & GetCachedLocations() const
Definition: WaveTrack.h:482
SampleBlockID
long long SampleBlockID
Definition: ProjectFileIO.h:41
WaveTrack::mSpectrumMin
float mSpectrumMin
Definition: WaveTrack.h:555
operator==
bool operator==(const Tags &lhs, const Tags &rhs)
Definition: Tags.cpp:332
WaveTrack::AllClipsIterator::AllClipsIterator
AllClipsIterator()
Definition: WaveTrack.h:333
WaveTrackFactory::mpFactory
SampleBlockFactoryPtr mpFactory
Definition: WaveTrack.h:631
WaveTrackFactory::operator=
WaveTrackFactory & operator=(const WaveTrackFactory &) PROHIBITED
StringSetting
Specialization of Setting for strings.
Definition: Prefs.h:227
WaveTrack::AllClipsConstIterator::AllClipsConstIterator
AllClipsConstIterator(const WaveTrack &track)
Definition: WaveTrack.h:381
SampleTrack::GetBlockStart
virtual sampleCount GetBlockStart(sampleCount t) const =0
This returns a possibly large or negative value.
WaveTrack::Holder
std::shared_ptr< WaveTrack > Holder
Definition: WaveTrack.h:105
SampleCount.h
BlockVisitor
std::function< void(SampleBlock &) > BlockVisitor
Definition: WaveTrack.h:591
WaveTrack::mLastScaleType
int mLastScaleType
Definition: WaveTrack.h:558
Track::GetStartTime
virtual double GetStartTime() const =0
WaveTrack::IntervalData::pClip
std::shared_ptr< WaveClip > pClip
Definition: WaveTrack.h:524
ProjectRate
Holds project sample rate.
Definition: ProjectRate.h:24
Track::GetErrorOpening
virtual bool GetErrorOpening()
Definition: Track.h:822
WaveClip
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:101
Region::Region
Region(double start_, double end_)
Definition: WaveTrack.h:59
SampleTrack::GetChannelIgnoringPan
virtual ChannelType GetChannelIgnoringPan() const =0
ProgressDialog
ProgressDialog Class.
Definition: ProgressDialog.h:51
Track::Holder
std::shared_ptr< Track > Holder
Definition: Track.h:347
BasicUI::Get
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
WaveTrack::mRate
int mRate
Definition: WaveTrack.h:542
constSamplePtr
const char * constSamplePtr
Definition: SampleFormat.h:50
Track::Silence
virtual void Silence(double WXUNUSED(t0), double WXUNUSED(t1))=0
Region::Region
Region()
Definition: WaveTrack.h:58
WritableSampleTrack::GetTypeInfo
const TypeInfo & GetTypeInfo() const override
Definition: SampleTrack.cpp:60
WaveTrack::GetClips
WaveClipHolders & GetClips()
Definition: WaveTrack.h:322
Track::GetOffset
virtual double GetOffset() const =0
SampleTrack::GetRate
virtual double GetRate() const =0
WaveTrack::mGain
float mGain
Definition: WaveTrack.h:543
Track::Clone
virtual Holder Clone() const =0
name
const TranslatableString name
Definition: Distortion.cpp:98
WaveTrack::mDisplayLocationsCache
std::vector< Location > mDisplayLocationsCache
Definition: WaveTrack.h:560
WaveTrack::AllClipsConstIterator
Definition: WaveTrack.h:375
format
int format
Definition: ExportPCM.cpp:56
WaveTrack::mpFactory
SampleBlockFactoryPtr mpFactory
Definition: WaveTrack.h:574
WaveTrack::mClips
WaveClipHolders mClips
Definition: WaveTrack.h:539
Region::operator<
bool operator<(const Region &b) const
Definition: WaveTrack.h:64
Resample
Interface to libsoxr.
Definition: Resample.h:27
Track::SetPan
virtual void SetPan(float)
Definition: Track.h:444
WaveClipHolder
std::shared_ptr< WaveClip > WaveClipHolder
Definition: WaveClip.h:41
Region::end
double end
Definition: WaveTrack.h:61
GetEditClipsCanMove
AUDACITY_DLL_API bool GetEditClipsCanMove()
Definition: WaveTrack.cpp:2849
WaveTrack::GetLastdBRange
int GetLastdBRange() const
Definition: WaveTrack.h:503
WaveTrack::AllClipsIterator::Iterator
WaveClipHolders::iterator Iterator
Definition: WaveTrack.h:364
WritableSampleTrack::Append
virtual bool Append(constSamplePtr buffer, sampleFormat format, size_t len, unsigned int stride=1)=0
Append the sample data to the track. You must call Flush() after the last Append.
WaveTrackFactory
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
Definition: WaveTrack.h:609
XMLTagHandler
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:42
Track::Intervals
std::vector< Interval > Intervals
Definition: Track.h:314
WaveTrack::mFlushCriticalSection
wxCriticalSection mFlushCriticalSection
Definition: WaveTrack.h:576
WaveTrack::mFormat
sampleFormat mFormat
Definition: WaveTrack.h:541
sampleFormat
sampleFormat
Definition: SampleFormat.h:29
WaveTrackFactory::WaveTrackFactory
WaveTrackFactory(const ProjectRate &rate, const SampleBlockFactoryPtr &pFactory)
Definition: WaveTrack.h:616
samplePtr
char * samplePtr
Definition: SampleFormat.h:49
BlockInspector
std::function< void(const SampleBlock &) > BlockInspector
Definition: WaveTrack.h:592
SampleTrack::Get
virtual bool Get(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const =0
Retrieve samples from a track in a specified format.
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
Track::WriteXML
virtual void WriteXML(XMLWriter &xmlFile) const =0
XMLTagHandler::HandleXMLChild
virtual XMLTagHandler * HandleXMLChild(const std::string_view &tag)=0
SampleTrack::GetBestBlockSize
virtual size_t GetBestBlockSize(sampleCount t) const =0
This returns a nonnegative number of samples meant to size a memory buffer.
BasicUI
Definition: Effect.h:47
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:224
SampleTrack::GetOldChannelGain
virtual float GetOldChannelGain(int channel) const =0
Track::ChannelType
ChannelType
Definition: Track.h:260
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
BasicUI::ProgressDialog
Abstraction of a progress dialog with well defined time-to-completion estimate.
Definition: BasicUI.h:154
WaveTrack::Location
WaveTrackLocation Location
Definition: WaveTrack.h:104
AudioTrackNameSetting
AUDACITY_DLL_API StringSetting AudioTrackNameSetting
Definition: WaveTrack.cpp:2839
WaveTrackFactory::GetSampleBlockFactory
const SampleBlockFactoryPtr & GetSampleBlockFactory() const
Definition: WaveTrack.h:626
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
WaveTrack::AllClipsIterator
Definition: WaveTrack.h:330
SampleBlock
Abstract class allows access to contents of a block of sound samples, serialization as XML,...
Definition: SampleBlock.h:44
WaveTrack::GetAllClips
IteratorRange< AllClipsConstIterator > GetAllClips() const
Definition: WaveTrack.h:409
WaveClipConstHolders
std::vector< std::shared_ptr< const WaveClip > > WaveClipConstHolders
Definition: WaveClip.h:43
ValueIterator
A convenience for defining iterators that return rvalue types, so that they cooperate correctly with ...
Definition: MemoryX.h:238
WaveTrack::GetLastScaleType
int GetLastScaleType() const
Definition: WaveTrack.h:500
WaveTrack::AllClipsIterator::Stack
std::vector< Pair > Stack
Definition: WaveTrack.h:366
Track::GetChannel
virtual ChannelType GetChannel() const
Definition: Track.h:438
WaveTrack::IntervalData::GetClip
std::shared_ptr< const WaveClip > GetClip() const
Definition: WaveTrack.h:521
WaveformSettings
Waveform settings, either for one track or as defaults.
Definition: WaveformSettings.h:19
SampleBlockFactory
abstract base class with methods to produce SampleBlock objects
Definition: SampleBlock.h:105
Track::Clear
virtual void Clear(double WXUNUSED(t0), double WXUNUSED(t1))=0
WritableSampleTrack::SetOldChannelGain
virtual void SetOldChannelGain(int channel, float gain)=0
Prefs.h
WaveTrack::mDisplayMax
float mDisplayMax
Definition: WaveTrack.h:554
SampleBlockFactoryPtr
std::shared_ptr< SampleBlockFactory > SampleBlockFactoryPtr
Definition: SampleBlock.h:28
Region
Structure to hold region of a wavetrack and a comparison function for sortability.
Definition: WaveTrack.h:57
WaveTrack::GetSampleFormat
sampleFormat GetSampleFormat() const override
Definition: WaveTrack.h:160
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.
WaveTrack::mLegacyProjectFileOffset
double mLegacyProjectFileOffset
Definition: WaveTrack.h:578
WaveTrack::mPan
float mPan
Definition: WaveTrack.h:544
SampleFormat.h
Track::SyncLockAdjust
virtual void SyncLockAdjust(double oldT1, double newT1)
Definition: Track.cpp:217
AttributesList
std::vector< Attribute > AttributesList
Definition: XMLTagHandler.h:40
SampleTrack::GetChannelGain
virtual float GetChannelGain(int channel) const =0
Takes gain and pan into account.
WaveTrack::mDisplayMin
float mDisplayMin
Definition: WaveTrack.h:553
WaveTrack::GetClips
const WaveClipConstHolders & GetClips() const
Definition: WaveTrack.h:323
XMLTagHandler::HandleXMLTag
virtual bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs)=0
WaveTrack::mAppendCriticalSection
wxCriticalSection mAppendCriticalSection
Definition: WaveTrack.h:577