11#ifndef __AUDACITY_WAVETRACK__
12#define __AUDACITY_WAVETRACK__
26#include <wx/longlong.h>
67#define WAVETRACK_MERGE_POINT_TOLERANCE 0.01
107 sampleCount* pNumWithinClips =
nullptr)
const override;
111 double GetRate()
const override;
114 double* buffer,
size_t bufferLen,
double t0,
115 bool backwards)
const override;
120 std::shared_ptr<WaveClipChannel>
GetInterval(
size_t iInterval);
121 std::shared_ptr<const WaveClipChannel>
GetInterval(
size_t iInterval)
const;
133 constexpr auto backwards =
false;
135 0, 1, &buffer, start, len, backwards, fill, mayThrow, pNumWithinClips);
173 start, len, effectiveFormat);
187 inline size_t GetBestBlockSize(
sampleCount t)
const;
189 inline size_t GetIdealBlockSize();
192 inline size_t GetMaxBlockSize()
const;
219 Region(
double start_,
double end_) : start(start_),
end(end_) {}
226 return this->start < b.
start;
232 static wxString GetDefaultAudioTrackNamePreference();
247 using Holder = std::shared_ptr<WaveTrack>;
254 {
return mpFactory; }
259 return this->ChannelGroup::GetChannel<WaveChannel>(
iChannel); }
261 return this->ChannelGroup::GetChannel<const WaveChannel>(
iChannel); }
264 return this->ChannelGroup::Channels<WaveChannel>(); }
266 return this->ChannelGroup::Channels<const WaveChannel>(); }
274 std::ptrdiff_t FindClip(
const Interval &clip);
276 void RemoveClip(std::ptrdiff_t distance);
282 wxString MakeClipCopyName(
const wxString& originalName)
const;
283 wxString MakeNewClipName()
const;
289 void MoveTo(
double o)
override;
291 bool LinkConsistencyFix(
bool doFix)
override;
306 double GetRate()
const override;
311 void SetRate(
double newRate);
314 float GetGain()
const;
315 void SetGain(
float newGain);
318 float GetPan()
const;
319 void SetPan(
float newPan);
329 const std::function<
void(
size_t)> & progressReport = {});
345 Holder EmptyCopy(
size_t nChannels,
365 Holder MonoToStereo();
371 std::vector<Holder> SplitChannels();
380 Track::Holder Copy(
double t0,
double t1,
bool forClipboard =
true)
383 void Clear(
double t0,
double t1)
override;
384 void Paste(
double t0,
const Track &src)
override;
393 double t0,
double t1,
const WaveTrack& src,
bool preserve =
true,
394 bool merge =
true,
const TimeWarper* effectWarper =
nullptr,
395 bool clearByTrimming =
false) ;
397 void Silence(
double t0,
double t1,
ProgressReporter reportProgress)
override;
398 void InsertSilence(
double t,
double len)
override;
400 void Split(
double t0,
double t1);
402 std::pair<IntervalHolder, IntervalHolder> SplitAt(
double t);
407 void ClearAndAddCutLine(
double t0,
double t1) ;
412 Holder SplitCut(
double t0,
double t1) ;
415 void SplitDelete(
double t0,
double t1) ;
417 double t0,
double t1,
420 void Disjoin(
double t0,
double t1) ;
423 void Trim(
double t0,
double t1) ;
432 void ApplyPitchAndSpeed(
435 void SyncLockAdjust(
double oldT1,
double newT1)
override;
442 bool IsEmpty(
double t0,
double t1)
const;
452 size_t len,
unsigned int stride = 1,
456 void Flush()
override;
458 void RepairChannels()
override;
463 bool GetMute()
const override;
464 bool GetSolo()
const override;
486 sampleCount* pNumWithinClips =
nullptr)
const override;
500 GetSampleView(
double t0,
double t1,
bool mayThrow =
true)
const;
507 double* buffer,
size_t bufferLen,
double t0,
508 bool backwards)
const override;
517 size_t GetMaxBlockSize()
const;
518 size_t GetIdealBlockSize();
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;
530 std::optional<TranslatableString> GetErrorOpening()
const override;
558 CreateClip(
double offset = .0,
const wxString&
name = wxEmptyString,
559 const Interval *pToCopy =
nullptr,
bool copyCutlines =
true);
567 IntervalHolder CopyClip(
const Interval &toCopy,
bool copyCutlines);
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);
589 double offset = .0,
const wxString&
name = wxEmptyString)
const;
607 int GetNumClips()
const;
613 IntervalConstHolders SortedIntervalArray()
const;
620 const std::vector<Interval*> &movingClips,
622 double *allowedAmount =
nullptr
630 CanInsertClip(
const Interval& clip,
double& slideBy,
double tolerance)
const;
635 bool MergeClips(
int clipidx1,
int clipidx2);
645 [[nodiscard]]
bool SetFloats(
const float *
const *buffers,
655 const TypeInfo &GetTypeInfo()
const override;
656 static const TypeInfo &ClassTypeInfo();
670 auto Intervals() {
return ChannelGroup::Intervals<Interval>(); }
671 auto Intervals()
const {
return ChannelGroup::Intervals<const Interval>(); }
678 bool newClip,
bool allowEmpty =
false);
685 bool HasClipNamed(
const wxString&
name)
const;
704 bool newClip,
bool backup,
bool allowEmpty);
711 void MergeChannelAttachments(
WaveTrack &&other);
714 void EraseChannelAttachments(
size_t index);
718 int GetClipIndex(
const Interval &clip)
const;
723 double t0,
double t1,
bool addCutLines,
bool split,
724 bool clearByTrimming =
false);
734 void ClearAndPasteAtSameTempo(
735 double t0,
double t1,
const WaveTrack& src,
bool preserve,
bool merge,
736 const TimeWarper* effectWarper,
bool clearByTrimming);
743 double* cutlineStart,
double* cutlineEnd);
744 void ApplyPitchAndSpeedOnIntervals(
745 const std::vector<IntervalHolder>& intervals,
755 std::shared_ptr<WideChannelGroupInterval> DoGetInterval(
size_t iInterval)
757 std::shared_ptr<::Channel> DoGetChannel(
size_t iChannel)
override;
777 mutable int mLegacyRate{ 0 };
782 void DoSetRate(
double newRate);
783 [[nodiscard]] Holder DuplicateWithOtherTempo(
double newTempo)
const;
787 bool backwards,
fillFormat fill,
bool mayThrow,
790 void DoSetPan(
float value);
791 void DoSetGain(
float value);
796 void PasteWaveTrack(
double t0,
const WaveTrack &other,
bool merge);
804 PasteWaveTrackAtSameTempo(
double t0,
const WaveTrack& other,
bool merge);
807 bool RateConsistencyCheck()
const;
810 bool FormatConsistencyCheck()
const;
826 void ZipClips(
bool mustAlign =
true);
833 double mLegacyProjectFileOffset{ 0 };
881 , mpFactory(pFactory)
888 {
return mpFactory; }
894 std::shared_ptr<WaveTrack> Create();
939 std::shared_ptr<WaveTrack> DoCreate(
std::vector< std::shared_ptr< const ClipInterface > > ClipConstHolders
std::vector< AudioSegmentSampleView > ChannelSampleView
const TranslatableString name
std::vector< std::vector< AudioSegmentSampleView > > ChannelGroupSampleView
std::shared_ptr< SampleBlockFactory > SampleBlockFactoryPtr
bool operator<(sampleCount a, sampleCount b)
ResultType Join(const ContainerType< ResultType, Rest... > &container, const SeparatorType &separator)
std::function< void(double)> ProgressReporter
std::shared_ptr< TrackList > TrackListHolder
std::vector< WaveClipConstHolder > WaveClipConstHolders
std::shared_ptr< const WaveClip > WaveClipConstHolder
std::shared_ptr< WaveClip > WaveClipHolder
std::vector< WaveClipHolder > WaveClipHolders
DECLARE_XML_METHOD_REGISTRY(WAVE_TRACK_API, WaveTrackIORegistry)
WAVE_TRACK_API bool GetEditClipsCanMove()
ENUMERATE_TRACK_TYPE(WaveTrack)
std::pair< double, double > TimeInterval
std::vector< WaveClip * > WaveClipPointers
WAVE_TRACK_API StringSetting AudioTrackNameSetting
std::vector< const WaveClip * > WaveClipConstPointers
WAVE_TRACK_API BoolSetting EditClipsCanMove
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
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Abstraction of a progress dialog with well defined time-to-completion estimate.
This specialization of Setting for bool adds a Toggle method to negate the saved value.
size_t NIntervals() const
Report the number of intervals.
std::shared_ptr< IntervalType > GetInterval(size_t iInterval)
Retrieve an interval, cast to the given type.
IteratorRange< IntervalIterator< IntervalType > > Intervals()
Get range of intervals with mutative access.
virtual ChannelGroup & DoGetChannelGroup() const =0
Subclass must override.
Piecewise linear or piecewise exponential function from double to double.
An object that sends messages to an open-ended list of subscribed callbacks.
Holds project sample rate.
abstract base class with methods to produce SampleBlock objects
A WaveTrack contains WaveClip(s). A WaveClip contains a Sequence. A Sequence is primarily an interfac...
Specialization of Setting for strings.
Transforms one point in time to another point. For example, a time stretching effect might use one to...
Abstract base class for an object holding data associated with points on a time axis.
virtual void Paste(double t, const Track &src)=0
Weak precondition allows overrides to replicate one channel into many.
std::shared_ptr< Track > Holder
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
bool SetFloats(const float *buffer, sampleCount start, size_t len, sampleFormat effectiveFormat=widestSampleFormat)
Random-access assignment of a range of samples.
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
size_t GetIdealBlockSize()
A hint for sizing of well aligned fetches.
ChannelGroup & DoGetChannelGroup() const override
Subclass must override.
size_t GetBestBlockSize(sampleCount t) const
A hint for sizing of well aligned fetches.
sampleFormat GetSampleFormat() const
size_t GetMaxBlockSize() const
WaveClipChannel(WaveClip &clip, size_t iChannel)
This allows multiple clips to be a part of one WaveTrack.
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
WaveTrackFactory(const WaveTrackFactory &)=delete
const SampleBlockFactoryPtr & GetSampleBlockFactory() const
SampleBlockFactoryPtr mpFactory
WaveTrackFactory & operator=(const WaveTrackFactory &)=delete
WaveTrackFactory(const ProjectRate &rate, const SampleBlockFactoryPtr &pFactory)
const ProjectRate & mRate
A Track that contains audio waveform data.
SampleBlockFactoryPtr mpFactory
std::vector< Region > Regions
auto GetChannel(size_t iChannel) const
wxCriticalSection mFlushCriticalSection
sampleFormat GetSampleFormat() const override
void ExpandOneCutLine(double cutLinePosition, double *cutlineStart, double *cutlineEnd)
size_t GetIdealBlockSize()
std::shared_ptr< Interval > IntervalHolder
static const char * WaveTrack_tag
const SampleBlockFactoryPtr & GetSampleBlockFactory() const
std::vector< IntervalHolder > IntervalHolders
std::optional< WaveChannel > mRightChannel
may be null
void ApplyPitchAndSpeedOne(double t0, double t1, const ProgressReporter &reportProgress)
std::vector< IntervalConstHolder > IntervalConstHolders
static void JoinOne(WaveTrack &track, double t0, double t1)
size_t GetMaxBlockSize() const
auto GetChannel(size_t iChannel)
size_t GetBestBlockSize(sampleCount t) const
std::shared_ptr< WaveTrack > Holder
wxCriticalSection mAppendCriticalSection
std::shared_ptr< const Interval > IntervalConstHolder
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...
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Positions or offsets within audio files need a wide type.
ChannelType
Mutually exclusive channel classifications.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
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 ®ver)
double GetRate(const Track &track)
Track & GetTrack(Channel &channel)
const char * end(const char *str) noexcept
virtual ChannelType GetChannelType() const =0
Classify this channel.
A convenient default parameter for class template Site.
A convenience for use with range-for.
Structure to hold region of a wavetrack and a comparison function for sortability.
Region(double start_, double end_)
@ Deserialized
being read from project file
@ New
newly created and empty
@ Inserted
(partly) copied from another clip, or moved from a track
enum WaveTrackMessage::Type type