11#ifndef __AUDACITY_WAVETRACK__
12#define __AUDACITY_WAVETRACK__
22#include <wx/longlong.h>
52#define WAVETRACK_MERGE_POINT_TOLERANCE 0.01
64 Region(
double start_,
double end_) : start(start_),
end(end_) {}
71 return this->start < b.
start;
77 static wxString GetDefaultAudioTrackNamePreference();
101 wxString MakeClipCopyName(
const wxString& originalName)
const;
102 wxString MakeNewClipName()
const;
106 using Holder = std::shared_ptr<WaveTrack>;
139 double GetRate()
const override;
140 void SetRate(
double newRate);
143 float GetGain()
const;
144 void SetGain(
float newGain);
147 float GetPan()
const;
148 void SetPan(
float newPan)
override;
156 void SetWaveColorIndex(
int colorIndex);
164 const std::function<
void(
size_t)> & progressReport = {});
169 void SetSpectrogramSettings(std::unique_ptr<SpectrogramSettings> &&pSettings);
173 void SetWaveformSettings(std::unique_ptr<WaveformSettings> &&pSettings);
174 void UseSpectralPrefs(
bool bUse=
true );
193 bool keepLink =
true)
const;
199 Track::Holder Copy(
double t0,
double t1,
bool forClipboard =
true)
const override;
202 void Clear(
double t0,
double t1)
override;
203 void Paste(
double t0,
const Track *src)
override;
205 void ClearAndPaste(
double t0,
double t1,
207 bool preserve =
true,
211 void Silence(
double t0,
double t1)
override;
214 void SplitAt(
double t) ;
215 void Split(
double t0,
double t1) ;
218 void ClearAndAddCutLine(
double t0,
double t1) ;
222 void SplitDelete(
double t0,
double t1) ;
223 void Join(
double t0,
double t1) ;
225 void Disjoin(
double t0,
double t1) ;
228 void Trim(
double t0,
double t1) ;
231 void HandleClear(
double t0,
double t1,
bool addCutLines,
bool split);
240 bool IsEmpty(
double t0,
double t1)
const;
249 size_t len,
unsigned int stride=1)
override;
250 void Flush()
override;
266 bool mayThrow =
true,
270 sampleCount * pNumWithinClips =
nullptr)
const override;
275 double t0)
const override;
278 std::pair<float, float> GetMinMax(
279 double t0,
double t1,
bool mayThrow =
true)
const;
281 float GetRMS(
double t0,
double t1,
bool mayThrow =
true)
const;
289 Sequence* GetSequenceAtTime(
double time);
290 Envelope* GetEnvelopeAtTime(
double time);
293 WaveClip* GetClipAtTime(
double time);
305 size_t GetIdealBlockSize();
353 return mStack.back().first->get();
365 {
return !( a == b ); }
372 using Pair = std::pair< Iterator, Iterator >;
389 : mIter{ const_cast<
WaveTrack& >( track ) }
396 { ++mIter;
return *
this; }
405 {
return !( a == b ); }
424 WaveClip* CreateClip(
double offset = .0,
const wxString&
name = wxEmptyString);
441 int GetClipIndex(
const WaveClip* clip)
const;
446 WaveClip *GetClipByIndex(
int index);
447 const WaveClip* GetClipByIndex(
int index)
const;
450 int GetNumClips()
const;
462 const std::vector<WaveClip*> &clips,
464 double *allowedAmount =
nullptr
471 bool CanInsertClip(
WaveClip* clip,
double &slideBy,
double &tolerance)
const;
475 std::shared_ptr<WaveClip> RemoveAndReturnClip(
WaveClip* clip);
478 bool AddClip(
const std::shared_ptr<WaveClip> &clip);
483 void MergeClips(
int clipidx1,
int clipidx2);
486 void UpdateLocationsCache()
const;
492 void ExpandCutLine(
double cutLinePosition,
double* cutlineStart = NULL,
double* cutlineEnd = NULL);
495 bool RemoveCutLine(
double cutLinePosition);
508 void SetLastScaleType()
const;
511 void SetLastdBRange()
const;
513 void GetDisplayBounds(
float *
min,
float *max)
const;
514 void SetDisplayBounds(
float min,
float max)
const;
515 void GetSpectrumBounds(
float *
min,
float *max)
const;
516 void SetSpectrumBounds(
float min,
float max)
const;
521 int ZeroLevelYCoordinate(wxRect rect)
const;
528 std::shared_ptr<const WaveClip>
GetClip()
const {
return pClip; }
529 std::shared_ptr<WaveClip> &
GetClip() {
return pClip; }
540 const WaveClip* FindClipByName(
const wxString&
name)
const;
551 std::atomic<float> mGain{ 1.0f };
553 std::atomic<float> mPan{ 0.0f };
573 void DoSetPan(
float value);
574 void DoSetGain(
float value);
576 void PasteWaveTrack(
double t0,
const WaveTrack* other);
590#include <unordered_set>
624 , mpFactory(pFactory)
631 {
return mpFactory; }
637 std::shared_ptr<WaveTrack> Create();
const TranslatableString name
Vector operator*(const Vector &left, const Vector &right)
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
DECLARE_XML_METHOD_REGISTRY(AUDACITY_DLL_API, WaveTrackIORegistry)
AUDACITY_DLL_API StringSetting AudioTrackNameSetting
void VisitBlocks(TrackList &tracks, BlockVisitor visitor, SampleBlockIDSet *pIDs=nullptr)
AUDACITY_DLL_API BoolSetting EditClipsCanMove
void InspectBlocks(const TrackList &tracks, BlockInspector inspector, SampleBlockIDSet *pIDs=nullptr)
AUDACITY_DLL_API bool GetEditClipsCanMove()
std::unordered_set< SampleBlockID > SampleBlockIDSet
ENUMERATE_TRACK_TYPE(WaveTrack)
std::function< void(const SampleBlock &) > BlockInspector
std::vector< WaveClip * > WaveClipPointers
std::vector< const WaveClip * > WaveClipConstPointers
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 sampleCount GetBlockStart(sampleCount t) const =0
This returns a possibly large or negative value.
virtual float GetOldChannelGain(int channel) 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...
Spectrogram settings, either for one track or as defaults.
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()
WaveTrackLocation Location
std::vector< Location > mDisplayLocationsCache
const std::vector< Location > & GetCachedLocations() const
const WaveClipConstHolders & GetClips() const
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
WaveClipHolders & GetClips()
int GetLastScaleType() const
double mLegacyProjectFileOffset
std::shared_ptr< WaveTrack > Holder
wxCriticalSection mAppendCriticalSection
std::unique_ptr< WaveformSettings > mpWaveformSettings
int GetLastdBRange() const
virtual void Flush()=0
Flush must be called after last Append.
static const TypeInfo & ClassTypeInfo()
virtual void SetOldChannelGain(int channel, float gain)=0
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.
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_)