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 "ClipInterface.h"
15#include "PlaybackDirection.h"
16#include "Prefs.h"
17#include "SampleCount.h"
18#include "SampleFormat.h"
19#include "SampleTrack.h"
20#include "WideSampleSequence.h"
21
22#include <functional>
23#include <optional>
24#include <vector>
25#include <wx/thread.h>
26#include <wx/longlong.h>
27
28class AudacityProject;
29class BlockArray;
30
31namespace BasicUI{ class ProgressDialog; }
32
34using SampleBlockFactoryPtr = std::shared_ptr<SampleBlockFactory>;
35
36class TimeWarper;
37
38class ClipInterface;
39class Sequence;
40class WaveClip;
41class WaveClipChannel;
44
46using WaveClipHolder = std::shared_ptr<WaveClip>;
47using WaveClipConstHolder = std::shared_ptr<const WaveClip>;
48using WaveClipHolders = std::vector<WaveClipHolder>;
49using WaveClipConstHolder = std::shared_ptr<const WaveClip>;
50using WaveClipConstHolders = std::vector<WaveClipConstHolder>;
51
52using ClipConstHolders = std::vector<std::shared_ptr<const ClipInterface>>;
53
54// Temporary arrays of mere pointers
55using WaveClipPointers = std::vector < WaveClip* >;
56using WaveClipConstPointers = std::vector < const WaveClip* >;
57
58using ChannelSampleView = std::vector<AudioSegmentSampleView>;
59using ChannelGroupSampleView = std::vector<ChannelSampleView>;
60
61using TimeInterval = std::pair<double, double>;
62using ProgressReporter = std::function<void(double)>;
63
64//
65// Tolerance for merging wave tracks (in seconds)
66//
67#define WAVETRACK_MERGE_POINT_TOLERANCE 0.01
68
69class Envelope;
70class WaveTrack;
71
74 const enum Type {
78 } type{};
79};
80
81class WAVE_TRACK_API WaveChannel final
82 : public Channel
83 , public WideSampleSequence
84{
85public:
86 explicit WaveChannel(WaveTrack &owner);
87 ~WaveChannel() override;
88
89 inline WaveTrack &GetTrack();
90 inline const WaveTrack &GetTrack() const;
91
93
94 size_t NChannels() const override;
95
97 float GetChannelGain(int channel) const override;
98
100 bool DoGet(
101 size_t iChannel, size_t nBuffers, const samplePtr buffers[],
102 sampleFormat format, sampleCount start, size_t len, bool backwards,
103 fillFormat fill = FillFormat::fillZero, bool mayThrow = true,
104 // Report how many samples were copied from within clips, rather than
105 // filled according to fillFormat; but these were not necessarily one
106 // contiguous range.
107 sampleCount* pNumWithinClips = nullptr) const override;
108
109 double GetStartTime() const override;
110 double GetEndTime() const override;
111 double GetRate() const override;
112 bool HasTrivialEnvelope() const override;
114 double* buffer, size_t bufferLen, double t0,
115 bool backwards) const override;
116 sampleFormat WidestEffectiveFormat() const override;
117
118 ChannelGroup &DoGetChannelGroup() const override;
119
120 std::shared_ptr<WaveClipChannel> GetInterval(size_t iInterval);
121 std::shared_ptr<const WaveClipChannel> GetInterval(size_t iInterval) const;
122
125
127
129 bool GetFloats(float *buffer, sampleCount start, size_t len,
130 fillFormat fill = FillFormat::fillZero, bool mayThrow = true,
131 sampleCount * pNumWithinClips = nullptr) const
132 {
133 constexpr auto backwards = false;
134 return GetFloats(
135 0, 1, &buffer, start, len, backwards, fill, mayThrow, pNumWithinClips);
136 }
137
148 ChannelSampleView GetSampleView(double t0, double t1, bool mayThrow) const;
149
151 [[nodiscard]] bool Set(constSamplePtr buffer, sampleFormat format,
152 sampleCount start, size_t len,
153 sampleFormat effectiveFormat = widestSampleFormat
159 );
160
162 [[nodiscard]] bool SetFloats(const float *buffer,
163 sampleCount start, size_t len,
164 sampleFormat effectiveFormat = widestSampleFormat
170 )
171 {
172 return Set(reinterpret_cast<constSamplePtr>(buffer), floatSample,
173 start, len, effectiveFormat);
174 }
175
176 bool AppendBuffer(constSamplePtr buffer, sampleFormat format, size_t len, unsigned stride, sampleFormat effectiveFormat);
177
184 bool Append(constSamplePtr buffer, sampleFormat format, size_t len);
185
187 inline size_t GetBestBlockSize(sampleCount t) const;
189 inline size_t GetIdealBlockSize();
192 inline size_t GetMaxBlockSize() const;
193
194 inline sampleFormat GetSampleFormat() const;
195
196private:
198};
199
200class WAVE_TRACK_API WaveTrack final
201 : public WritableSampleTrack
202 , public Observer::Publisher<WaveTrackMessage>
203{
204 struct CreateToken {};
205public:
206 static const char *WaveTrack_tag;
207
209 using IntervalHolder = std::shared_ptr<Interval>;
210 using IntervalHolders = std::vector<IntervalHolder>;
211 using IntervalConstHolder = std::shared_ptr<const Interval>;
212 using IntervalConstHolders = std::vector<IntervalConstHolder>;
213
216 struct Region
217 {
218 Region() : start(0), end(0) {}
219 Region(double start_, double end_) : start(start_), end(end_) {}
220
221 double start, end;
222
223 //used for sorting
224 bool operator < (const Region &b) const
225 {
226 return this->start < b.start;
227 }
228 };
229
230 using Regions = std::vector < Region >;
231
232 static wxString GetDefaultAudioTrackNamePreference();
233
234 static double ProjectNyquistFrequency(const AudacityProject &project);
235
236 //
237 // Constructor / Destructor / Duplicator
238 //
239
240 // Construct and also build all attachments
241 static WaveTrack *New( AudacityProject &project );
242
245 const SampleBlockFactoryPtr &pFactory, sampleFormat format, double rate);
246
247 using Holder = std::shared_ptr<WaveTrack>;
248
250 static Holder Create(
251 const SampleBlockFactoryPtr &pFactory, sampleFormat format, double rate);
252
254 { return mpFactory; }
255
256 size_t NChannels() const override;
257
258 auto GetChannel(size_t iChannel) {
259 return this->ChannelGroup::GetChannel<WaveChannel>(iChannel); }
260 auto GetChannel(size_t iChannel) const {
261 return this->ChannelGroup::GetChannel<const WaveChannel>(iChannel); }
262
263 auto Channels() {
264 return this->ChannelGroup::Channels<WaveChannel>(); }
265 auto Channels() const {
266 return this->ChannelGroup::Channels<const WaveChannel>(); }
267
269
272 void Init(const WaveTrack &orig);
273 private:
274 std::ptrdiff_t FindClip(const Interval &clip);
275
276 void RemoveClip(std::ptrdiff_t distance);
277
278 Track::Holder Clone(bool backup) const override;
279
280 friend class WaveTrackFactory;
281
282 wxString MakeClipCopyName(const wxString& originalName) const;
283 wxString MakeNewClipName() const;
284
285public:
286
287 virtual ~WaveTrack();
288
289 void MoveTo(double o) override;
290
291 bool LinkConsistencyFix(bool doFix) override;
292
294 double GetStartTime() const override;
296 double GetEndTime() const override;
297
298 //
299 // Identifying the type of track
300 //
301
302 //
303 // WaveTrack parameters
304 //
305
306 double GetRate() const override;
308
311 void SetRate(double newRate);
312
313 // Multiplicative factor. Only converted to dB for display.
314 float GetGain() const;
315 void SetGain(float newGain);
316
317 // -1.0 (left) -> 1.0 (right)
318 float GetPan() const;
319 void SetPan(float newPan);
320
322 float GetChannelGain(int channel) const override;
323
324 sampleCount GetVisibleSampleCount() const;
325
326 sampleFormat GetSampleFormat() const override;
327
328 void ConvertToSampleFormat(sampleFormat format,
329 const std::function<void(size_t)> & progressReport = {});
330
331 //
332 // High-level editing
333 //
334
335 Track::Holder Cut(double t0, double t1) override;
336
339
345 Holder EmptyCopy(size_t nChannels,
346 const SampleBlockFactoryPtr &pFactory = {}) const;
347
350
356 Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory = {})
357 const;
358
360 void MakeMono();
361
365 Holder MonoToStereo();
366
367 /*
368 @return a vector of mono tracks, which are in the list that owns `this`
369 @pre `GetOwner()`
370 */
371 std::vector<Holder> SplitChannels();
372
374 void SwapChannels();
375
376 // If forClipboard is true,
377 // and there is no clip at the end time of the selection, then the result
378 // will contain a "placeholder" clip whose only purpose is to make
379 // GetEndTime() correct. This clip is not re-copied when pasting.
380 Track::Holder Copy(double t0, double t1, bool forClipboard = true)
381 const override;
382
383 void Clear(double t0, double t1) override;
384 void Paste(double t0, const Track &src) override;
385 using Track::Paste; // Get the non-virtual overload too
386
392 void ClearAndPaste(
393 double t0, double t1, const WaveTrack& src, bool preserve = true,
394 bool merge = true, const TimeWarper* effectWarper = nullptr,
395 bool clearByTrimming = false) /* not override */;
396
397 void Silence(double t0, double t1, ProgressReporter reportProgress) override;
398 void InsertSilence(double t, double len) override;
399
400 void Split(double t0, double t1);
401
402 std::pair<IntervalHolder, IntervalHolder> SplitAt(double t);
403
407 void ClearAndAddCutLine(double t0, double t1) /* not override */;
408
412 Holder SplitCut(double t0, double t1) /* not override */;
413
414 // May assume precondition: t0 <= t1
415 void SplitDelete(double t0, double t1) /* not override */;
416 void Join(
417 double t0, double t1,
418 const ProgressReporter& reportProgress) /* not override */;
419 // May assume precondition: t0 <= t1
420 void Disjoin(double t0, double t1) /* not override */;
421
422 // May assume precondition: t0 <= t1
423 void Trim(double t0, double t1) /* not override */;
424
425 /*
426 * @param interval Entire track is rendered if nullopt, else only samples
427 * within [interval->first, interval->second), in which case clips are split
428 * at these boundaries before rendering - if rendering is needed.
429 *
430 * @pre `!interval.has_value() || interval->first <= interval->second`
431 */
432 void ApplyPitchAndSpeed(
433 std::optional<TimeInterval> interval, ProgressReporter reportProgress);
434
435 void SyncLockAdjust(double oldT1, double newT1) override;
436
442 bool IsEmpty(double t0, double t1) const;
443
451 bool Append(size_t iChannel, constSamplePtr buffer, sampleFormat format,
452 size_t len, unsigned int stride = 1,
453 sampleFormat effectiveFormat = widestSampleFormat)
454 override;
455
456 void Flush() override;
457
458 void RepairChannels() override;
459
462 const ChannelGroup *FindChannelGroup() const override;
463 bool GetMute() const override;
464 bool GetSolo() const override;
466
477
479 bool DoGet(
480 size_t iChannel, size_t nBuffers, const samplePtr buffers[],
481 sampleFormat format, sampleCount start, size_t len, bool backwards,
482 fillFormat fill = FillFormat::fillZero, bool mayThrow = true,
483 // Report how many samples were copied from within clips, rather than
484 // filled according to fillFormat; but these were not necessarily one
485 // contiguous range.
486 sampleCount* pNumWithinClips = nullptr) const override;
487
500 GetSampleView(double t0, double t1, bool mayThrow = true) const;
501
502 sampleFormat WidestEffectiveFormat() const override;
503
504 bool HasTrivialEnvelope() const override;
505
507 double* buffer, size_t bufferLen, double t0,
508 bool backwards) const override;
509
510 //
511 // Getting information about the track's internal block sizes
512 // and alignment for efficiency
513 //
514
515 // These return a nonnegative number of samples meant to size a memory buffer
516 size_t GetBestBlockSize(sampleCount t) const;
517 size_t GetMaxBlockSize() const;
518 size_t GetIdealBlockSize();
519
520 //
521 // XMLTagHandler callback methods for loading and saving
522 //
523
524 bool HandleXMLTag(const std::string_view& tag, const AttributesList& attrs) override;
525 void HandleXMLEndTag(const std::string_view& tag) override;
526 XMLTagHandler *HandleXMLChild(const std::string_view& tag) override;
527 void WriteXML(XMLWriter &xmlFile) const override;
528
529 // Returns true if an error occurred while reading from XML
530 std::optional<TranslatableString> GetErrorOpening() const override;
531
532 //
533 // Lock and unlock the track: you must lock the track before
534 // doing a copy and paste between projects.
535 //
536
537 IntervalHolder GetLeftmostClip();
538 IntervalConstHolder GetLeftmostClip() const;
539
540 IntervalHolder GetRightmostClip();
541 IntervalConstHolder GetRightmostClip() const;
542
547 ClipConstHolders GetClipInterfaces() const;
548
551
558 CreateClip(double offset = .0, const wxString& name = wxEmptyString,
559 const Interval *pToCopy = nullptr, bool copyCutlines = true);
560
562
567 IntervalHolder CopyClip(const Interval &toCopy, bool copyCutlines);
568
569private:
570 void CopyWholeClip(const Interval &clip, double t0, bool forClipboard);
571 void CopyPartOfClip(const Interval &clip,
572 double t0, double t1, bool forClipboard);
573 void FinishCopy(double t0, double t1, double endTime, bool forClipboard);
574
576 IntervalConstHolders SortedClipArray() const;
577 IntervalConstHolder GetClipAtTime(double time) const;
578
579 void CreateRight();
580
582
588 WaveClipHolder DoCreateClip(
589 double offset = .0, const wxString& name = wxEmptyString) const;
590
591public:
597 IntervalHolder NewestOrNewClip();
598
604 IntervalHolder RightmostOrNewClip();
605
606 // Get number of clips in this WaveTrack
607 int GetNumClips() const;
608
609public:
611 IntervalHolders SortedIntervalArray();
613 IntervalConstHolders SortedIntervalArray() const;
614
616
619 bool CanOffsetClips(
620 const std::vector<Interval*> &movingClips,
621 double amount,
622 double *allowedAmount = nullptr
624 );
625
626 // Before moving a clip into a track (or inserting a clip), use this
627 // function to see if the times are valid (i.e. don't overlap with
628 // existing clips).
629 bool
630 CanInsertClip(const Interval& clip, double& slideBy, double tolerance) const;
631
632 // Merge two clips, that is append data from clip2 to clip1,
633 // then remove clip2 from track.
634 // clipidx1 and clipidx2 are indices into the clip list.
635 bool MergeClips(int clipidx1, int clipidx2);
636
637 // Resample track (i.e. all clips in the track)
638 void Resample(int rate, BasicUI::ProgressDialog *progress = NULL);
639
641
645 [[nodiscard]] bool SetFloats(const float *const *buffers,
646 sampleCount start, size_t len,
647 sampleFormat effectiveFormat = widestSampleFormat
653 );
654
655 const TypeInfo &GetTypeInfo() const override;
656 static const TypeInfo &ClassTypeInfo();
657
659 IntervalConstHolder GetNextInterval(
660 const Interval& interval, PlaybackDirection searchDirection) const;
661
666 GetNextInterval(const Interval& interval, PlaybackDirection searchDirection);
667
669
670 auto Intervals() { return ChannelGroup::Intervals<Interval>(); }
671 auto Intervals() const { return ChannelGroup::Intervals<const Interval>(); }
672
673 /*
674 @param newClip false if clip has contents from another clip or track
675 @pre interval is not already owned by this or any other track
676 */
677 void InsertInterval(const IntervalHolder& interval,
678 bool newClip, bool allowEmpty = false);
679
680 void RemoveInterval(const IntervalHolder& interval);
681
683 const override;
684
685 bool HasClipNamed(const wxString& name) const;
686
687 size_t NIntervals() const override;
688
689 IntervalHolder GetClip(size_t iInterval);
690 IntervalConstHolder GetClip(size_t iInterval) const;
691
693 void SetLegacyFormat(sampleFormat format);
694
695private:
703 bool InsertClip(WaveClipHolders &clips, WaveClipHolder clip,
704 bool newClip, bool backup, bool allowEmpty);
705
706 void CopyClips(WaveClipHolders &clips,
707 SampleBlockFactoryPtr pFactory, const WaveClipHolders &orig, bool backup);
708
711 void MergeChannelAttachments(WaveTrack &&other);
712
714 void EraseChannelAttachments(size_t index);
715
716public:
718 int GetClipIndex(const Interval &clip) const;
719
720private:
721 // May assume precondition: t0 <= t1
722 void HandleClear(
723 double t0, double t1, bool addCutLines, bool split,
724 bool clearByTrimming = false);
725
726 /*
727 * @brief Copy/Paste operations must preserve beat durations, but time
728 * boundaries are expressed in seconds. For pasting to work, source and
729 * destination tracks must therefore have equal tempo.
730 * @pre Preconditions of `ClearAndPaste`
731 * @pre `GetProjectTempo().has_value() && GetProjectTempo() ==
732 * src.GetProjectTempo()`
733 */
734 void ClearAndPasteAtSameTempo(
735 double t0, double t1, const WaveTrack& src, bool preserve, bool merge,
736 const TimeWarper* effectWarper, bool clearByTrimming);
737
739 static void JoinOne(WaveTrack& track, double t0, double t1);
740 static void WriteOneXML(const WaveChannel &channel, XMLWriter &xmlFile,
741 size_t iChannel, size_t nChannels);
742 void ExpandOneCutLine(double cutLinePosition,
743 double* cutlineStart, double* cutlineEnd);
744 void ApplyPitchAndSpeedOnIntervals(
745 const std::vector<IntervalHolder>& intervals,
746 const ProgressReporter& reportProgress);
752 void
753 ReplaceInterval(const IntervalHolder& oldOne, const IntervalHolder& newOne);
754
755 std::shared_ptr<WideChannelGroupInterval> DoGetInterval(size_t iInterval)
756 override;
757 std::shared_ptr<::Channel> DoGetChannel(size_t iChannel) override;
758
759 WaveClipHolders &NarrowClips();
760 const WaveClipHolders &NarrowClips() const;
761
762 //
763 // Protected variables
764 //
765
769 std::optional<WaveChannel> mRightChannel;
770
776
777 mutable int mLegacyRate{ 0 };
778 sampleFormat mLegacyFormat{ undefinedSample };
779
780private:
781 //Updates rate parameter only in WaveTrackData
782 void DoSetRate(double newRate);
783 [[nodiscard]] Holder DuplicateWithOtherTempo(double newTempo) const;
784
785 bool GetOne(const WaveClipHolders &clips, size_t iChannel,
786 samplePtr buffer, sampleFormat format, sampleCount start, size_t len,
787 bool backwards, fillFormat fill, bool mayThrow,
788 sampleCount* pNumWithinClips) const;
789
790 void DoSetPan(float value);
791 void DoSetGain(float value);
792
793 /*
794 @pre `other.NChannels() == 1 || other.NChannels() == NChannels()`
795 */
796 void PasteWaveTrack(double t0, const WaveTrack &other, bool merge);
797 /*
798 * @copybrief ClearAndPasteAtSameTempo
799 * @pre Preconditions of `PasteWaveTrack`
800 * @pre `GetProjectTempo().has_value() && GetProjectTempo() ==
801 * other.GetProjectTempo()`
802 */
803 void
804 PasteWaveTrackAtSameTempo(double t0, const WaveTrack& other, bool merge);
805
807 bool RateConsistencyCheck() const;
810 bool FormatConsistencyCheck() const;
811
813 double t0, double t1, const ProgressReporter& reportProgress);
814
815public:
818
826 void ZipClips(bool mustAlign = true);
827
828private:
830
831 wxCriticalSection mFlushCriticalSection;
832 wxCriticalSection mAppendCriticalSection;
833 double mLegacyProjectFileOffset{ 0 };
834
835 friend WaveChannel; // so it can Publish
836};
837
839
841 auto &result = static_cast<WaveTrack&>(DoGetChannelGroup());
842 return result;
843}
844
846 auto &result = static_cast<const WaveTrack&>(DoGetChannelGroup());
847 return result;
848}
849
851 return GetTrack().GetBestBlockSize(t);
852}
853
855 return GetTrack().GetIdealBlockSize();
856}
857
859 return GetTrack().GetMaxBlockSize();
860}
861
863 return GetTrack().GetSampleFormat();
864}
865
866class ProjectRate;
867
868class WAVE_TRACK_API WaveTrackFactory final
869 : public ClientData::Base
870{
871 public:
873 static const WaveTrackFactory &Get( const AudacityProject &project );
874 static WaveTrackFactory &Reset( AudacityProject &project );
875 static void Destroy( AudacityProject &project );
876
878 const ProjectRate& rate,
879 const SampleBlockFactoryPtr &pFactory)
880 : mRate{ rate }
881 , mpFactory(pFactory)
882 {
883 }
886
888 { return mpFactory; }
889
894 std::shared_ptr<WaveTrack> Create();
895
902 std::shared_ptr<WaveTrack> Create(sampleFormat format, double rate);
903
910 WaveTrack::Holder Create(size_t nChannels);
911
916 TrackListHolder CreateMany(size_t nChannels);
917
924 WaveTrack::Holder Create(size_t nChannels, sampleFormat format, double rate);
925
930 TrackListHolder CreateMany(size_t nChannels, sampleFormat format, double rate);
931
936 WaveTrack::Holder Create(size_t nChannels, const WaveTrack& proto);
937
938 private:
939 std::shared_ptr<WaveTrack> DoCreate(
940 size_t nChannels, sampleFormat format, double rate);
941
944};
945
946extern WAVE_TRACK_API BoolSetting
948;
949
950extern WAVE_TRACK_API StringSetting AudioTrackNameSetting;
951
952WAVE_TRACK_API bool GetEditClipsCanMove();
953
954// Generate a registry for serialized data
955#include "XMLMethodRegistry.h"
958
959#endif // __AUDACITY_WAVETRACK__
std::vector< std::shared_ptr< const ClipInterface > > ClipConstHolders
std::vector< AudioSegmentSampleView > ChannelSampleView
const TranslatableString name
Definition: Distortion.cpp:76
std::vector< std::vector< AudioSegmentSampleView > > ChannelGroupSampleView
Definition: MixerBoard.h:35
PlaybackDirection
std::shared_ptr< SampleBlockFactory > SampleBlockFactoryPtr
Definition: SampleBlock.h:31
bool operator<(sampleCount a, sampleCount b)
Definition: SampleCount.h:85
sampleFormat
The ordering of these values with operator < agrees with the order of increasing bit width.
Definition: SampleFormat.h:30
char * samplePtr
Definition: SampleFormat.h:57
const char * constSamplePtr
Definition: SampleFormat.h:58
enum FillFormat fillFormat
ResultType Join(const ContainerType< ResultType, Rest... > &container, const SeparatorType &separator)
Definition: StringUtils.h:52
const auto project
std::function< void(double)> ProgressReporter
Definition: Track.h:48
std::shared_ptr< TrackList > TrackListHolder
Definition: Track.h:42
std::vector< WaveClipConstHolder > WaveClipConstHolders
Definition: WaveClip.h:46
std::shared_ptr< const WaveClip > WaveClipConstHolder
Definition: WaveClip.h:44
std::shared_ptr< WaveClip > WaveClipHolder
Definition: WaveClip.h:43
std::vector< WaveClipHolder > WaveClipHolders
Definition: WaveClip.h:45
DECLARE_XML_METHOD_REGISTRY(WAVE_TRACK_API, WaveTrackIORegistry)
WAVE_TRACK_API bool GetEditClipsCanMove()
Definition: WaveTrack.cpp:3381
ENUMERATE_TRACK_TYPE(WaveTrack)
std::pair< double, double > TimeInterval
Definition: WaveTrack.h:61
std::vector< WaveClip * > WaveClipPointers
Definition: WaveTrack.h:55
WAVE_TRACK_API StringSetting AudioTrackNameSetting
Definition: WaveTrack.cpp:3371
std::vector< const WaveClip * > WaveClipConstPointers
Definition: WaveTrack.h:56
WAVE_TRACK_API BoolSetting EditClipsCanMove
Definition: WaveTrack.cpp:3390
Append(Adapt< My >([](My &table) { return(WaveChannelSubViews::numFactories() > 1) ? std::make_unique< Entry >("MultiView", Entry::CheckItem, OnMultiViewID, XXO("&Multi-view"), POPUP_MENU_FN(OnMultiView), table, [](PopupMenuHandler &handler, wxMenu &menu, int id){ auto &table=static_cast< WaveTrackMenuTable & >(handler);auto &track=table.FindWaveTrack();const auto &view=WaveChannelView::GetFirst(track);menu.Check(id, view.GetMultiView());}) :nullptr;}))
std::vector< Attribute > AttributesList
Definition: XMLTagHandler.h:40
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Abstraction of a progress dialog with well defined time-to-completion estimate.
Definition: BasicUI.h:157
This specialization of Setting for bool adds a Toggle method to negate the saved value.
Definition: Prefs.h:346
size_t NIntervals() const
Report the number of intervals.
Definition: Channel.h:537
std::shared_ptr< IntervalType > GetInterval(size_t iInterval)
Retrieve an interval, cast to the given type.
Definition: Channel.h:543
IteratorRange< IntervalIterator< IntervalType > > Intervals()
Get range of intervals with mutative access.
Definition: Channel.h:248
virtual ChannelGroup & DoGetChannelGroup() const =0
Subclass must override.
Piecewise linear or piecewise exponential function from double to double.
Definition: Envelope.h:72
An object that sends messages to an open-ended list of subscribed callbacks.
Definition: Observer.h:108
ProgressDialog Class.
Holds project sample rate.
Definition: ProjectRate.h:24
Interface to libsoxr.
Definition: Resample.h:27
abstract base class with methods to produce SampleBlock objects
Definition: SampleBlock.h:117
A WaveTrack contains WaveClip(s). A WaveClip contains a Sequence. A Sequence is primarily an interfac...
Definition: Sequence.h:53
Specialization of Setting for strings.
Definition: Prefs.h:370
Transforms one point in time to another point. For example, a time stretching effect might use one to...
Definition: TimeWarper.h:62
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
virtual void Paste(double t, const Track &src)=0
Weak precondition allows overrides to replicate one channel into many.
std::shared_ptr< Track > Holder
Definition: Track.h:202
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
bool SetFloats(const float *buffer, sampleCount start, size_t len, sampleFormat effectiveFormat=widestSampleFormat)
Random-access assignment of a range of samples.
Definition: WaveTrack.h:162
WaveTrack & GetTrack()
Definition: WaveTrack.h:840
~WaveChannel() override
WaveTrack & mOwner
Definition: WaveTrack.h:197
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=FillFormat::fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
"narrow" overload fetches from the unique channel
Definition: WaveTrack.h:129
size_t GetIdealBlockSize()
A hint for sizing of well aligned fetches.
Definition: WaveTrack.h:854
ChannelGroup & DoGetChannelGroup() const override
Subclass must override.
Definition: WaveTrack.cpp:731
size_t GetBestBlockSize(sampleCount t) const
A hint for sizing of well aligned fetches.
Definition: WaveTrack.h:850
sampleFormat GetSampleFormat() const
Definition: WaveTrack.h:862
size_t GetMaxBlockSize() const
Definition: WaveTrack.h:858
WaveClipChannel(WaveClip &clip, size_t iChannel)
Definition: WaveClip.h:90
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:238
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
Definition: WaveTrack.h:870
WaveTrackFactory(const WaveTrackFactory &)=delete
const SampleBlockFactoryPtr & GetSampleBlockFactory() const
Definition: WaveTrack.h:887
SampleBlockFactoryPtr mpFactory
Definition: WaveTrack.h:943
WaveTrackFactory & operator=(const WaveTrackFactory &)=delete
WaveTrackFactory(const ProjectRate &rate, const SampleBlockFactoryPtr &pFactory)
Definition: WaveTrack.h:877
const ProjectRate & mRate
Definition: WaveTrack.h:942
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
SampleBlockFactoryPtr mpFactory
Definition: WaveTrack.h:829
friend WaveChannel
Definition: WaveTrack.h:835
std::vector< Region > Regions
Definition: WaveTrack.h:230
auto GetChannel(size_t iChannel) const
Definition: WaveTrack.h:260
auto Channels()
Definition: WaveTrack.h:263
wxCriticalSection mFlushCriticalSection
Definition: WaveTrack.h:831
sampleFormat GetSampleFormat() const override
Definition: WaveTrack.cpp:895
WaveChannel mChannel
Definition: WaveTrack.h:767
void ExpandOneCutLine(double cutLinePosition, double *cutlineStart, double *cutlineEnd)
size_t GetIdealBlockSize()
Definition: WaveTrack.cpp:2279
std::shared_ptr< Interval > IntervalHolder
Definition: WaveTrack.h:209
static const char * WaveTrack_tag
Definition: WaveTrack.h:206
auto Intervals() const
Definition: WaveTrack.h:671
const SampleBlockFactoryPtr & GetSampleBlockFactory() const
Definition: WaveTrack.h:253
std::vector< IntervalHolder > IntervalHolders
Definition: WaveTrack.h:210
std::optional< WaveChannel > mRightChannel
may be null
Definition: WaveTrack.h:769
void ApplyPitchAndSpeedOne(double t0, double t1, const ProgressReporter &reportProgress)
auto Intervals()
Definition: WaveTrack.h:670
auto Channels() const
Definition: WaveTrack.h:265
std::vector< IntervalConstHolder > IntervalConstHolders
Definition: WaveTrack.h:212
static void JoinOne(WaveTrack &track, double t0, double t1)
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:2258
auto GetChannel(size_t iChannel)
Definition: WaveTrack.h:258
size_t GetBestBlockSize(sampleCount t) const
Definition: WaveTrack.cpp:2239
std::shared_ptr< WaveTrack > Holder
Definition: WaveTrack.h:247
wxCriticalSection mAppendCriticalSection
Definition: WaveTrack.h:832
WaveClipHolders mClips
Definition: WaveTrack.h:775
std::shared_ptr< const Interval > IntervalConstHolder
Definition: WaveTrack.h:211
virtual float GetChannelGain(int channel) const =0
virtual bool HasTrivialEnvelope() const =0
virtual double GetStartTime() const =0
virtual void GetEnvelopeValues(double *buffer, size_t bufferLen, double t0, bool backwards) const =0
virtual sampleFormat WidestEffectiveFormat() const =0
virtual bool DoGet(size_t iChannel, size_t nBuffers, const samplePtr buffers[], sampleFormat format, sampleCount start, size_t len, bool backward, fillFormat fill=FillFormat::fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const =0
virtual double GetEndTime() const =0
bool GetFloats(size_t iChannel, size_t nBuffers, float *const buffers[], sampleCount start, size_t len, bool backwards=false, fillFormat fill=FillFormat::fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
virtual size_t NChannels() const =0
A constant property.
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:42
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:25
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
ChannelType
Mutually exclusive channel classifications.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:201
WAVE_TRACK_API ClipPointer GetIntervalAtTime(WaveChannel &channel, double t)
WAVE_TRACK_API ClipPointer GetClipAtTime(WaveChannel &channel, double time)
WAVE_TRACK_API ClipPointers SortedClipArray(WaveChannel &channel)
Get clips sorted by play start time.
std::vector< IntervalHolder > IntervalHolders
std::shared_ptr< WaveTrack::Interval > IntervalHolder
std::shared_ptr< const WaveTrack::Interval > IntervalConstHolder
std::vector< long > Split(const PluginRegistryVersion &regver)
double GetRate(const Track &track)
Definition: TimeTrack.cpp:182
Track & GetTrack(Channel &channel)
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
virtual ChannelType GetChannelType() const =0
Classify this channel.
A convenient default parameter for class template Site.
Definition: ClientData.h:29
A convenience for use with range-for.
Definition: IteratorX.h:39
Structure to hold region of a wavetrack and a comparison function for sortability.
Definition: WaveTrack.h:217
Region(double start_, double end_)
Definition: WaveTrack.h:219
@ Deserialized
being read from project file
Definition: WaveTrack.h:76
@ New
newly created and empty
Definition: WaveTrack.h:75
@ Inserted
(partly) copied from another clip, or moved from a track
Definition: WaveTrack.h:77
WaveClipHolder pClip
Definition: WaveTrack.h:73
enum WaveTrackMessage::Type type