11#ifndef __AUDACITY_WAVETRACK__
12#define __AUDACITY_WAVETRACK__
22#include <wx/longlong.h>
46#define WAVETRACK_MERGE_POINT_TOLERANCE 0.01
58 Region(
double start_,
double end_) : start(start_),
end(end_) {}
65 return this->start < b.
start;
71 static wxString GetDefaultAudioTrackNamePreference();
95 wxString MakeClipCopyName(
const wxString& originalName)
const;
96 wxString MakeNewClipName()
const;
99 using Holder = std::shared_ptr<WaveTrack>;
132 double GetRate()
const override;
133 void SetRate(
double newRate);
136 float GetGain()
const;
137 void SetGain(
float newGain);
140 float GetPan()
const;
141 void SetPan(
float newPan)
override;
146 void SetWaveColorIndex(
int colorIndex);
154 const std::function<
void(
size_t)> & progressReport = {});
174 bool keepLink =
true)
const;
180 Track::Holder Copy(
double t0,
double t1,
bool forClipboard =
true)
const override;
183 void Clear(
double t0,
double t1)
override;
184 void Paste(
double t0,
const Track *src)
override;
186 void ClearAndPaste(
double t0,
double t1,
188 bool preserve =
true,
192 void Silence(
double t0,
double t1)
override;
195 void SplitAt(
double t) ;
196 void Split(
double t0,
double t1) ;
199 void ClearAndAddCutLine(
double t0,
double t1) ;
203 void SplitDelete(
double t0,
double t1) ;
204 void Join(
double t0,
double t1) ;
206 void Disjoin(
double t0,
double t1) ;
209 void Trim(
double t0,
double t1) ;
212 void HandleClear(
double t0,
double t1,
bool addCutLines,
bool split);
221 bool IsEmpty(
double t0,
double t1)
const;
230 size_t len,
unsigned int stride = 1,
233 void Flush()
override;
249 bool mayThrow =
true,
253 sampleCount * pNumWithinClips =
nullptr)
const override;
269 double t0)
const override;
272 std::pair<float, float> GetMinMax(
273 double t0,
double t1,
bool mayThrow =
true)
const;
275 float GetRMS(
double t0,
double t1,
bool mayThrow =
true)
const;
283 Sequence* GetSequenceAtTime(
double time);
284 Envelope* GetEnvelopeAtTime(
double time);
286 WaveClip* GetClipAtTime(
double time);
298 size_t GetIdealBlockSize();
346 return mStack.back().first->get();
358 {
return !( a == b ); }
365 using Pair = std::pair< Iterator, Iterator >;
382 : mIter{ const_cast<
WaveTrack& >( track ) }
389 { ++mIter;
return *
this; }
398 {
return !( a == b ); }
417 WaveClip* CreateClip(
double offset = .0,
const wxString&
name = wxEmptyString);
434 int GetClipIndex(
const WaveClip* clip)
const;
439 WaveClip *GetClipByIndex(
int index);
440 const WaveClip* GetClipByIndex(
int index)
const;
443 int GetNumClips()
const;
455 const std::vector<WaveClip*> &clips,
457 double *allowedAmount =
nullptr
464 bool CanInsertClip(
WaveClip* clip,
double &slideBy,
double &tolerance)
const;
468 std::shared_ptr<WaveClip> RemoveAndReturnClip(
WaveClip* clip);
471 bool AddClip(
const std::shared_ptr<WaveClip> &clip);
476 void MergeClips(
int clipidx1,
int clipidx2);
479 void ExpandCutLine(
double cutLinePosition,
double* cutlineStart = NULL,
double* cutlineEnd = NULL);
482 bool RemoveCutLine(
double cutLinePosition);
499 std::shared_ptr<const WaveClip>
GetClip()
const {
return pClip; }
500 std::shared_ptr<WaveClip> &
GetClip() {
return pClip; }
511 const WaveClip* FindClipByName(
const wxString&
name)
const;
522 std::atomic<float> mGain{ 1.0f };
524 std::atomic<float> mPan{ 0.0f };
528 void DoSetPan(
float value);
529 void DoSetGain(
float value);
531 void PasteWaveTrack(
double t0,
const WaveTrack* other);
542#include <unordered_set>
576 , mpFactory(pFactory)
583 {
return mpFactory; }
589 std::shared_ptr<WaveTrack> Create();
const TranslatableString name
Vector operator*(const Vector &left, const Vector &right)
bool operator==(const EffectReverbSettings &a, const EffectReverbSettings &b)
std::shared_ptr< SampleBlockFactory > SampleBlockFactoryPtr
bool operator<(SnapPoint s1, SnapPoint s2)
std::shared_ptr< WaveClip > WaveClipHolder
std::vector< WaveClipHolder > WaveClipHolders
std::vector< std::shared_ptr< const WaveClip > > WaveClipConstHolders
std::function< void(SampleBlock &) > BlockVisitor
void VisitBlocks(TrackList &tracks, BlockVisitor visitor, SampleBlockIDSet *pIDs=nullptr)
DECLARE_XML_METHOD_REGISTRY(WAVE_TRACK_API, WaveTrackIORegistry)
WAVE_TRACK_API bool GetEditClipsCanMove()
std::unordered_set< SampleBlockID > SampleBlockIDSet
ENUMERATE_TRACK_TYPE(WaveTrack)
std::function< void(const SampleBlock &) > BlockInspector
std::vector< WaveClip * > WaveClipPointers
WAVE_TRACK_API StringSetting AudioTrackNameSetting
std::vector< const WaveClip * > WaveClipConstPointers
WAVE_TRACK_API void InspectBlocks(const TrackList &tracks, BlockInspector inspector, SampleBlockIDSet *pIDs=nullptr)
WAVE_TRACK_API BoolSetting EditClipsCanMove
bool operator!=(const WaveTrackLocation &a, const WaveTrackLocation &b)
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.
Piecewise linear or piecewise exponential function from double to double.
void Init(const PlayableTrack &init)
void Merge(const Track &init) override
Holds project sample rate.
abstract base class with methods to produce SampleBlock objects
Abstract class allows access to contents of a block of sound samples, serialization as XML,...
virtual double GetRate() const =0
virtual float GetChannelGain(int channel) const =0
Takes gain and pan into account.
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.
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.
virtual size_t GetMaxBlockSize() const =0
This returns a nonnegative number of samples meant to size a memory buffer.
virtual bool HasTrivialEnvelope() const =0
virtual sampleCount GetBlockStart(sampleCount t) const =0
This returns a possibly large or negative value.
virtual sampleFormat WidestEffectiveFormat() const =0
virtual size_t GetBestBlockSize(sampleCount t) const =0
This returns a nonnegative number of samples meant to size a memory buffer.
virtual ChannelType GetChannelIgnoringPan() const =0
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 SetPan(float)
virtual void SetOffset(double o)
virtual void Paste(double WXUNUSED(t), const Track *WXUNUSED(src))=0
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1))=0
virtual Holder PasteInto(AudacityProject &) const =0
Find or create the destination track for a paste, maybe in a different project.
virtual void Clear(double WXUNUSED(t0), double WXUNUSED(t1))=0
virtual double GetStartTime() const =0
virtual Holder Clone() const =0
virtual void SyncLockAdjust(double oldT1, double newT1)
virtual Holder Copy(double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard=true) const =0
virtual bool LinkConsistencyFix(bool doFix=true, bool completeList=true)
Check consistency of channel groups, and maybe fix it.
std::shared_ptr< Track > Holder
virtual void SetPanFromChannelType()
virtual ConstIntervals GetIntervals() const
Report times on the track where important intervals begin and end, for UI to snap to.
virtual void WriteXML(XMLWriter &xmlFile) const =0
virtual void Silence(double WXUNUSED(t0), double WXUNUSED(t1))=0
virtual ChannelType GetChannel() const
virtual double GetOffset() const =0
virtual double GetEndTime() const =0
std::vector< Interval > Intervals
virtual void InsertSilence(double WXUNUSED(t), double WXUNUSED(len))=0
virtual bool GetErrorOpening()
std::vector< ConstInterval > ConstIntervals
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
This allows multiple clips to be a part of one WaveTrack.
AllClipsConstIterator(const WaveTrack &track)
std::pair< Iterator, Iterator > Pair
std::vector< Pair > Stack
WaveClipHolders::iterator Iterator
AllClipsIterator(WaveTrack &track)
std::shared_ptr< WaveClip > pClip
IntervalData(const std::shared_ptr< WaveClip > &pClip)
std::shared_ptr< WaveClip > & GetClip()
std::shared_ptr< const WaveClip > GetClip() const
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
WaveTrackFactory(const WaveTrackFactory &) PROHIBITED
const SampleBlockFactoryPtr & GetSampleBlockFactory() const
SampleBlockFactoryPtr mpFactory
WaveTrackFactory(const ProjectRate &rate, const SampleBlockFactoryPtr &pFactory)
const ProjectRate & mRate
WaveTrackFactory & operator=(const WaveTrackFactory &) PROHIBITED
A Track that contains audio waveform data.
SampleBlockFactoryPtr mpFactory
std::vector< Region > Regions
wxCriticalSection mFlushCriticalSection
int GetWaveColorIndex() const
sampleFormat GetSampleFormat() const override
IteratorRange< AllClipsConstIterator > GetAllClips() const
IteratorRange< AllClipsIterator > GetAllClips()
const WaveClipConstHolders & GetClips() const
WaveClipHolders & GetClips()
double mLegacyProjectFileOffset
wxCriticalSection mAppendCriticalSection
virtual void Flush()=0
Flush must be called after last Append.
virtual bool Append(constSamplePtr buffer, sampleFormat format, size_t len, unsigned int stride=1, sampleFormat effectiveFormat=widestSampleFormat)=0
Append the sample data to the track. You must call Flush() after the last Append.
static const TypeInfo & ClassTypeInfo()
const TypeInfo & GetTypeInfo() const override
This class is an interface which should be implemented by classes which wish to be able to load and s...
virtual XMLTagHandler * HandleXMLChild(const std::string_view &tag)=0
virtual void HandleXMLEndTag(const std::string_view &WXUNUSED(tag))
virtual bool HandleXMLTag(const std::string_view &tag, const AttributesList &attrs)=0
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Positions or offsets within audio files need a wide type.
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
std::vector< long > Split(const PluginRegistryVersion ®ver)
A convenient default parameter for class template Site.
A convenience for use with range-for.
Empty argument passed to some public constructors.
Optional extra information about an interval, appropriate to a subtype of Track.
A convenience for defining iterators that return rvalue types, so that they cooperate correctly with ...
Structure to hold region of a wavetrack and a comparison function for sortability.
Region(double start_, double end_)