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 GetChannelVolume(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 void ShiftBy(double t0, double delta) override;
291
292 bool LinkConsistencyFix(bool doFix) override;
293
295 double GetStartTime() const override;
297 double GetEndTime() const override;
298
299 //
300 // Identifying the type of track
301 //
302
303 //
304 // WaveTrack parameters
305 //
306
307 double GetRate() const override;
309
312 void SetRate(double newRate);
313
314 // Multiplicative factor. Only converted to dB for display.
315 float GetVolume() const;
316 void SetVolume(float newVolume);
317
318 // -1.0 (left) -> 1.0 (right)
319 float GetPan() const;
320 void SetPan(float newPan);
321
323 float GetChannelVolume(int channel) const override;
324
325 sampleCount GetVisibleSampleCount() const;
326
327 sampleFormat GetSampleFormat() const override;
328
329 void ConvertToSampleFormat(sampleFormat format,
330 const std::function<void(size_t)> & progressReport = {});
331
332 //
333 // High-level editing
334 //
335
336 Track::Holder Cut(double t0, double t1) override;
337
340
346 Holder EmptyCopy(size_t nChannels,
347 const SampleBlockFactoryPtr &pFactory = {}) const;
348
351
357 Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory = {})
358 const;
359
361 void MakeMono();
362
366 Holder MonoToStereo();
367
368 /*
369 @return a vector of mono tracks, which are in the list that owns `this`
370 @pre `GetOwner()`
371 */
372 std::vector<Holder> SplitChannels();
373
375 void SwapChannels();
376
377 // If forClipboard is true,
378 // and there is no clip at the end time of the selection, then the result
379 // will contain a "placeholder" clip whose only purpose is to make
380 // GetEndTime() correct. This clip is not re-copied when pasting.
381 Track::Holder Copy(double t0, double t1, bool forClipboard = true)
382 const override;
383
384 void Clear(double t0, double t1) override;
385 void Paste(double t0, const Track &src) override;
386 using Track::Paste; // Get the non-virtual overload too
387
393 void ClearAndPaste(
394 double t0, double t1, const WaveTrack& src, bool preserve = true,
395 bool merge = true, const TimeWarper* effectWarper = nullptr,
396 bool clearByTrimming = false) /* not override */;
397
398 void Silence(double t0, double t1, ProgressReporter reportProgress) override;
399 void InsertSilence(double t, double len) override;
400
401 void Split(double t0, double t1);
402
403 std::pair<IntervalHolder, IntervalHolder> SplitAt(double t);
404
408 void ClearAndAddCutLine(double t0, double t1) /* not override */;
409
413 Holder SplitCut(double t0, double t1) /* not override */;
414
415 // May assume precondition: t0 <= t1
416 void SplitDelete(double t0, double t1) /* not override */;
417 void Join(
418 double t0, double t1,
419 const ProgressReporter& reportProgress) /* not override */;
420 // May assume precondition: t0 <= t1
421 void Disjoin(double t0, double t1) /* not override */;
422
423 // May assume precondition: t0 <= t1
424 void Trim(double t0, double t1) /* not override */;
425
426 /*
427 * @param interval Entire track is rendered if nullopt, else only samples
428 * within [interval->first, interval->second), in which case clips are split
429 * at these boundaries before rendering - if rendering is needed.
430 *
431 * @pre `!interval.has_value() || interval->first <= interval->second`
432 */
433 void ApplyPitchAndSpeed(
434 std::optional<TimeInterval> interval, ProgressReporter reportProgress);
435
436 void SyncLockAdjust(double oldT1, double newT1) override;
437
443 bool IsEmpty(double t0, double t1) const;
444
452 bool Append(size_t iChannel, constSamplePtr buffer, sampleFormat format,
453 size_t len, unsigned int stride = 1,
454 sampleFormat effectiveFormat = widestSampleFormat)
455 override;
456
457 void Flush() override;
458
459 void RepairChannels() override;
460
463 const ChannelGroup *FindChannelGroup() const override;
464 bool GetMute() const override;
465 bool GetSolo() const override;
467
478
480 bool DoGet(
481 size_t iChannel, size_t nBuffers, const samplePtr buffers[],
482 sampleFormat format, sampleCount start, size_t len, bool backwards,
483 fillFormat fill = FillFormat::fillZero, bool mayThrow = true,
484 // Report how many samples were copied from within clips, rather than
485 // filled according to fillFormat; but these were not necessarily one
486 // contiguous range.
487 sampleCount* pNumWithinClips = nullptr) const override;
488
501 GetSampleView(double t0, double t1, bool mayThrow = true) const;
502
503 sampleFormat WidestEffectiveFormat() const override;
504
505 bool HasTrivialEnvelope() const override;
506
508 double* buffer, size_t bufferLen, double t0,
509 bool backwards) const override;
510
511 //
512 // Getting information about the track's internal block sizes
513 // and alignment for efficiency
514 //
515
516 // These return a nonnegative number of samples meant to size a memory buffer
517 size_t GetBestBlockSize(sampleCount t) const;
518 size_t GetMaxBlockSize() const;
519 size_t GetIdealBlockSize();
520
521 //
522 // XMLTagHandler callback methods for loading and saving
523 //
524
525 bool HandleXMLTag(const std::string_view& tag, const AttributesList& attrs) override;
526 void HandleXMLEndTag(const std::string_view& tag) override;
527 XMLTagHandler *HandleXMLChild(const std::string_view& tag) override;
528 void WriteXML(XMLWriter &xmlFile) const override;
529
530 // Returns true if an error occurred while reading from XML
531 std::optional<TranslatableString> GetErrorOpening() const override;
532
533 //
534 // Lock and unlock the track: you must lock the track before
535 // doing a copy and paste between projects.
536 //
537
538 IntervalHolder GetLeftmostClip();
539 IntervalConstHolder GetLeftmostClip() const;
540
541 IntervalHolder GetRightmostClip();
542 IntervalConstHolder GetRightmostClip() const;
543
548 ClipConstHolders GetClipInterfaces() const;
549
552
559 CreateClip(double offset = .0, const wxString& name = wxEmptyString,
560 const Interval *pToCopy = nullptr, bool copyCutlines = true);
561
563
568 IntervalHolder CopyClip(const Interval &toCopy, bool copyCutlines);
569
570private:
571 void CopyWholeClip(const Interval &clip, double t0, bool forClipboard);
572 void CopyPartOfClip(const Interval &clip,
573 double t0, double t1, bool forClipboard);
574 void FinishCopy(double t0, double t1, bool forClipboard);
575
577 IntervalConstHolders SortedClipArray() const;
578 IntervalConstHolder GetClipAtTime(double time) const;
579
580 void CreateRight();
581
583
589 WaveClipHolder DoCreateClip(
590 double offset = .0, const wxString& name = wxEmptyString) const;
591
592public:
598 IntervalHolder NewestOrNewClip();
599
605 IntervalHolder RightmostOrNewClip();
606
607 // Get number of clips in this WaveTrack
608 int GetNumClips() const;
609
610public:
612 IntervalHolders SortedIntervalArray();
614 IntervalConstHolders SortedIntervalArray() const;
615
617
620 bool CanOffsetClips(
621 const std::vector<Interval*> &movingClips,
622 double amount,
623 double *allowedAmount = nullptr
625 );
626
627 // Before moving a clip into a track (or inserting a clip), use this
628 // function to see if the times are valid (i.e. don't overlap with
629 // existing clips).
630 bool
631 CanInsertClip(const Interval& clip, double& slideBy, double tolerance) const;
632
633 // Merge two clips, that is append data from clip2 to clip1,
634 // then remove clip2 from track.
635 // clipidx1 and clipidx2 are indices into the clip list.
636 bool MergeClips(int clipidx1, int clipidx2);
637
638 // Resample track (i.e. all clips in the track)
639 void Resample(int rate, BasicUI::ProgressDialog *progress = NULL);
640
642
646 [[nodiscard]] bool SetFloats(const float *const *buffers,
647 sampleCount start, size_t len,
648 sampleFormat effectiveFormat = widestSampleFormat
654 );
655
656 const TypeInfo &GetTypeInfo() const override;
657 static const TypeInfo &ClassTypeInfo();
658
660 IntervalConstHolder GetNextInterval(
661 const Interval& interval, PlaybackDirection searchDirection) const;
662
667 GetNextInterval(const Interval& interval, PlaybackDirection searchDirection);
668
670
671 auto Intervals() { return ChannelGroup::Intervals<Interval>(); }
672 auto Intervals() const { return ChannelGroup::Intervals<const Interval>(); }
673
674 /*
675 @param newClip false if clip has contents from another clip or track
676 @pre interval is not already owned by this or any other track
677 */
678 void InsertInterval(const IntervalHolder& interval,
679 bool newClip, bool allowEmpty = false);
680
681 void RemoveInterval(const IntervalHolder& interval);
682
684 const override;
685
686 bool HasClipNamed(const wxString& name) const;
687
688 size_t NIntervals() const override;
689
690 IntervalHolder GetClip(size_t iInterval);
691 IntervalConstHolder GetClip(size_t iInterval) const;
692
694 void SetLegacyFormat(sampleFormat format);
695
696private:
704 bool InsertClip(WaveClipHolders &clips, WaveClipHolder clip,
705 bool newClip, bool backup, bool allowEmpty);
706
707 void CopyClips(WaveClipHolders &clips,
708 SampleBlockFactoryPtr pFactory, const WaveClipHolders &orig, bool backup);
709
712 void MergeChannelAttachments(WaveTrack &&other);
713
715 void EraseChannelAttachments(size_t index);
716
717public:
719 int GetClipIndex(const Interval &clip) const;
720
721private:
722 // May assume precondition: t0 <= t1
723 void HandleClear(
724 double t0, double t1, bool addCutLines, bool split,
725 bool clearByTrimming = false);
726
727 /*
728 * @brief Copy/Paste operations must preserve beat durations, but time
729 * boundaries are expressed in seconds. For pasting to work, source and
730 * destination tracks must therefore have equal tempo.
731 * @pre Preconditions of `ClearAndPaste`
732 * @pre `GetProjectTempo().has_value() && GetProjectTempo() ==
733 * src.GetProjectTempo()`
734 */
735 void ClearAndPasteAtSameTempo(
736 double t0, double t1, const WaveTrack& src, bool preserve, bool merge,
737 const TimeWarper* effectWarper, bool clearByTrimming);
738
740 static void JoinOne(WaveTrack& track, double t0, double t1);
741 static void WriteOneXML(const WaveChannel &channel, XMLWriter &xmlFile,
742 size_t iChannel, size_t nChannels);
743 void ExpandOneCutLine(double cutLinePosition,
744 double* cutlineStart, double* cutlineEnd);
745 void ApplyPitchAndSpeedOnIntervals(
746 const std::vector<IntervalHolder>& intervals,
747 const ProgressReporter& reportProgress);
753 void
754 ReplaceInterval(const IntervalHolder& oldOne, const IntervalHolder& newOne);
755
756 std::shared_ptr<WideChannelGroupInterval> DoGetInterval(size_t iInterval)
757 override;
758 std::shared_ptr<::Channel> DoGetChannel(size_t iChannel) override;
759
760 WaveClipHolders &NarrowClips();
761 const WaveClipHolders &NarrowClips() const;
762
763 //
764 // Protected variables
765 //
766
770 std::optional<WaveChannel> mRightChannel;
771
777
778 mutable int mLegacyRate{ 0 };
779 sampleFormat mLegacyFormat{ undefinedSample };
780
781private:
782 //Updates rate parameter only in WaveTrackData
783 void DoSetRate(double newRate);
784 [[nodiscard]] Holder DuplicateWithOtherTempo(double newTempo) const;
785
786 bool GetOne(const WaveClipHolders &clips, size_t iChannel,
787 samplePtr buffer, sampleFormat format, sampleCount start, size_t len,
788 bool backwards, fillFormat fill, bool mayThrow,
789 sampleCount* pNumWithinClips) const;
790
791 void DoSetPan(float value);
792 void DoSetVolume(float value);
793
794 /*
795 @pre `other.NChannels() == 1 || other.NChannels() == NChannels()`
796 */
797 void PasteWaveTrack(double t0, const WaveTrack &other, bool merge);
798 /*
799 * @copybrief ClearAndPasteAtSameTempo
800 * @pre Preconditions of `PasteWaveTrack`
801 * @pre `GetProjectTempo().has_value() && GetProjectTempo() ==
802 * other.GetProjectTempo()`
803 */
804 void
805 PasteWaveTrackAtSameTempo(double t0, const WaveTrack& other, bool merge);
806
808 bool RateConsistencyCheck() const;
811 bool FormatConsistencyCheck() const;
812
814 double t0, double t1, const ProgressReporter& reportProgress);
815
816public:
819
827 void ZipClips(bool mustAlign = true);
828
829private:
831
832 wxCriticalSection mFlushCriticalSection;
833 wxCriticalSection mAppendCriticalSection;
834 double mLegacyProjectFileOffset{ 0 };
835
836 friend WaveChannel; // so it can Publish
837};
838
840
842 auto &result = static_cast<WaveTrack&>(DoGetChannelGroup());
843 return result;
844}
845
847 auto &result = static_cast<const WaveTrack&>(DoGetChannelGroup());
848 return result;
849}
850
852 return GetTrack().GetBestBlockSize(t);
853}
854
856 return GetTrack().GetIdealBlockSize();
857}
858
860 return GetTrack().GetMaxBlockSize();
861}
862
864 return GetTrack().GetSampleFormat();
865}
866
867class ProjectRate;
868
869class WAVE_TRACK_API WaveTrackFactory final
870 : public ClientData::Base
871{
872 public:
874 static const WaveTrackFactory &Get( const AudacityProject &project );
875 static WaveTrackFactory &Reset( AudacityProject &project );
876 static void Destroy( AudacityProject &project );
877
879 const ProjectRate& rate,
880 const SampleBlockFactoryPtr &pFactory)
881 : mRate{ rate }
882 , mpFactory(pFactory)
883 {
884 }
887
889 { return mpFactory; }
890
895 std::shared_ptr<WaveTrack> Create();
896
903 std::shared_ptr<WaveTrack> Create(sampleFormat format, double rate);
904
911 WaveTrack::Holder Create(size_t nChannels);
912
917 TrackListHolder CreateMany(size_t nChannels);
918
925 WaveTrack::Holder Create(size_t nChannels, sampleFormat format, double rate);
926
931 TrackListHolder CreateMany(size_t nChannels, sampleFormat format, double rate);
932
937 WaveTrack::Holder Create(size_t nChannels, const WaveTrack& proto);
938
939 private:
940 std::shared_ptr<WaveTrack> DoCreate(
941 size_t nChannels, sampleFormat format, double rate);
942
945};
946
947extern WAVE_TRACK_API BoolSetting
949;
950
951extern WAVE_TRACK_API StringSetting AudioTrackNameSetting;
952
953WAVE_TRACK_API bool GetEditClipsCanMove();
954
955// Generate a registry for serialized data
956#include "XMLMethodRegistry.h"
959
960#endif // __AUDACITY_WAVETRACK__
std::vector< std::shared_ptr< const ClipInterface > > ClipConstHolders
std::vector< AudioSegmentSampleView > ChannelSampleView
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
wxString name
Definition: TagsEditor.cpp:166
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:3408
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:3398
std::vector< const WaveClip * > WaveClipConstPointers
Definition: WaveTrack.h:56
WAVE_TRACK_API BoolSetting EditClipsCanMove
Definition: WaveTrack.cpp:3417
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:164
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:540
std::shared_ptr< IntervalType > GetInterval(size_t iInterval)
Retrieve an interval, cast to the given type.
Definition: Channel.h:546
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:115
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:841
~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:855
ChannelGroup & DoGetChannelGroup() const override
Subclass must override.
Definition: WaveTrack.cpp:748
size_t GetBestBlockSize(sampleCount t) const
A hint for sizing of well aligned fetches.
Definition: WaveTrack.h:851
sampleFormat GetSampleFormat() const
Definition: WaveTrack.h:863
size_t GetMaxBlockSize() const
Definition: WaveTrack.h:859
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:871
WaveTrackFactory(const WaveTrackFactory &)=delete
const SampleBlockFactoryPtr & GetSampleBlockFactory() const
Definition: WaveTrack.h:888
SampleBlockFactoryPtr mpFactory
Definition: WaveTrack.h:944
WaveTrackFactory & operator=(const WaveTrackFactory &)=delete
WaveTrackFactory(const ProjectRate &rate, const SampleBlockFactoryPtr &pFactory)
Definition: WaveTrack.h:878
const ProjectRate & mRate
Definition: WaveTrack.h:943
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
SampleBlockFactoryPtr mpFactory
Definition: WaveTrack.h:830
friend WaveChannel
Definition: WaveTrack.h:836
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:832
sampleFormat GetSampleFormat() const override
Definition: WaveTrack.cpp:918
WaveChannel mChannel
Definition: WaveTrack.h:768
void ExpandOneCutLine(double cutLinePosition, double *cutlineStart, double *cutlineEnd)
size_t GetIdealBlockSize()
Definition: WaveTrack.cpp:2300
std::shared_ptr< Interval > IntervalHolder
Definition: WaveTrack.h:209
static const char * WaveTrack_tag
Definition: WaveTrack.h:206
auto Intervals() const
Definition: WaveTrack.h:672
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:770
void ApplyPitchAndSpeedOne(double t0, double t1, const ProgressReporter &reportProgress)
auto Intervals()
Definition: WaveTrack.h:671
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:2279
auto GetChannel(size_t iChannel)
Definition: WaveTrack.h:258
size_t GetBestBlockSize(sampleCount t) const
Definition: WaveTrack.cpp:2260
std::shared_ptr< WaveTrack > Holder
Definition: WaveTrack.h:247
wxCriticalSection mAppendCriticalSection
Definition: WaveTrack.h:833
WaveClipHolders mClips
Definition: WaveTrack.h:776
std::shared_ptr< const Interval > IntervalConstHolder
Definition: WaveTrack.h:211
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 float GetChannelVolume(int channel) const =0
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:202
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