Audacity  3.0.3
Classes | Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
WaveTrack Class Referencefinal

A Track that contains audio waveform data. More...

#include <WaveTrack.h>

Inheritance diagram for WaveTrack:
[legend]
Collaboration diagram for WaveTrack:
[legend]

Classes

class  AllClipsConstIterator
 
class  AllClipsIterator
 
class  IntervalData
 

Public Types

typedef WaveTrackLocation Location
 
using Holder = std::shared_ptr< WaveTrack >
 
- Public Types inherited from Track
using AttachedObjects = ::AttachedTrackObjects
 Alias for my base type. More...
 
using ChannelType = XMLValueChecker::ChannelType
 
using IntervalData = TrackIntervalData
 
using Interval = TrackInterval
 
using Intervals = std::vector< Interval >
 
using ConstInterval = ConstTrackInterval
 
using ConstIntervals = std::vector< ConstInterval >
 
using Holder = std::shared_ptr< Track >
 
template<typename R = void>
using Continuation = std::function< R() >
 Type of arguments passed as optional second parameter to TypeSwitch() cases. More...
 
using Fallthrough = Continuation<>
 Type of arguments passed as optional second parameter to TypeSwitch<void>() cases. More...
 
- Public Types inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
using DataType = ClientData
 
using DataPointer = Pointer< ClientData >
 
using DataFactory = std::function< DataPointer(Host &) >
 Type of function from which RegisteredFactory is constructed; it builds attachments. More...
 

Public Member Functions

 WaveTrack (const SampleBlockFactoryPtr &pFactory, sampleFormat format, double rate)
 
 WaveTrack (const WaveTrack &orig)
 
void Reinit (const WaveTrack &orig)
 
virtual ~WaveTrack ()
 
double GetOffset () const override
 
void SetOffset (double o) override
 
virtual ChannelType GetChannelIgnoringPan () const
 
ChannelType GetChannel () const override
 
virtual void SetPanFromChannelType () override
 
double GetStartTime () const override
 Get the time at which the first clip in the track starts. More...
 
double GetEndTime () const override
 Get the time at which the last clip in the track ends, plus recorded stuff. More...
 
double GetRate () const
 
void SetRate (double newRate)
 
float GetGain () const
 
void SetGain (float newGain)
 
float GetPan () const
 
void SetPan (float newPan) override
 
float GetChannelGain (int channel) const
 
float GetOldChannelGain (int channel) const
 
void SetOldChannelGain (int channel, float gain)
 
int GetWaveColorIndex () const
 
void SetWaveColorIndex (int colorIndex)
 
sampleCount GetNumSamples () const
 
sampleFormat GetSampleFormat () const
 
void ConvertToSampleFormat (sampleFormat format, const std::function< void(size_t)> &progressReport={})
 
const SpectrogramSettingsGetSpectrogramSettings () const
 
SpectrogramSettingsGetSpectrogramSettings ()
 
SpectrogramSettingsGetIndependentSpectrogramSettings ()
 
void SetSpectrogramSettings (std::unique_ptr< SpectrogramSettings > &&pSettings)
 
const WaveformSettingsGetWaveformSettings () const
 
WaveformSettingsGetWaveformSettings ()
 
void SetWaveformSettings (std::unique_ptr< WaveformSettings > &&pSettings)
 
void UseSpectralPrefs (bool bUse=true)
 
Track::Holder Cut (double t0, double t1) override
 
Holder EmptyCopy (const SampleBlockFactoryPtr &pFactory={}) const
 
Track::Holder Copy (double t0, double t1, bool forClipboard=true) const override
 
Track::Holder CopyNonconst (double t0, double t1)
 
void Clear (double t0, double t1) override
 
void Paste (double t0, const Track *src) override
 
void ClearAndPaste (double t0, double t1, const Track *src, bool preserve=true, bool merge=true, const TimeWarper *effectWarper=NULL)
 
void Silence (double t0, double t1) override
 
void InsertSilence (double t, double len) override
 
void SplitAt (double t)
 
void Split (double t0, double t1)
 
void ClearAndAddCutLine (double t0, double t1)
 
Track::Holder SplitCut (double t0, double t1)
 
void SplitDelete (double t0, double t1)
 
void Join (double t0, double t1)
 
void Disjoin (double t0, double t1)
 
void Trim (double t0, double t1)
 
void HandleClear (double t0, double t1, bool addCutLines, bool split)
 
void SyncLockAdjust (double oldT1, double newT1) override
 
bool IsEmpty (double t0, double t1) const
 Returns true if there are no WaveClips in the specified region. More...
 
bool Append (constSamplePtr buffer, sampleFormat format, size_t len, unsigned int stride=1)
 Append the sample data to the WaveTrack. You must call Flush() after the last Append. More...
 
void Flush ()
 Flush must be called after last Append. More...
 
void ClearWaveCaches ()
 Invalidates all clips' wavecaches. Careful, This may not be threadsafe. More...
 
bool Get (samplePtr buffer, sampleFormat format, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
 
void Set (constSamplePtr buffer, sampleFormat format, sampleCount start, size_t len)
 
void GetEnvelopeValues (double *buffer, size_t bufferLen, double t0) const
 
std::pair< float, float > GetMinMax (double t0, double t1, bool mayThrow=true) const
 
float GetRMS (double t0, double t1, bool mayThrow=true) const
 
SequenceGetSequenceAtTime (double time)
 
EnvelopeGetEnvelopeAtTime (double time)
 
WaveClipGetClipAtSample (sampleCount sample)
 
WaveClipGetClipAtTime (double time)
 
sampleCount GetBlockStart (sampleCount t) const
 
size_t GetBestBlockSize (sampleCount t) const
 
size_t GetMaxBlockSize () const
 
size_t GetIdealBlockSize ()
 
bool HandleXMLTag (const wxChar *tag, const wxChar **attrs) override
 
void HandleXMLEndTag (const wxChar *tag) override
 
XMLTagHandlerHandleXMLChild (const wxChar *tag) override
 
void WriteXML (XMLWriter &xmlFile) const override
 
bool GetErrorOpening () override
 
bool CloseLock ()
 
sampleCount TimeToLongSamples (double t0) const
 Convert correctly between an (absolute) time in seconds and a number of samples. More...
 
double LongSamplesToTime (sampleCount pos) const
 Convert correctly between a number of samples and an (absolute) time in seconds. More...
 
WaveClipHoldersGetClips ()
 
const WaveClipConstHoldersGetClips () const
 
IteratorRange< AllClipsIteratorGetAllClips ()
 
IteratorRange< AllClipsConstIteratorGetAllClips () const
 
WaveClipCreateClip ()
 
WaveClipNewestOrNewClip ()
 Get access to the most recently added clip, or create a clip, if there is not already one. THIS IS NOT NECESSARILY RIGHTMOST. More...
 
WaveClipRightmostOrNewClip ()
 Get access to the last (rightmost) clip, or create a clip, if there is not already one. More...
 
int GetClipIndex (const WaveClip *clip) const
 
WaveClipGetClipByIndex (int index)
 
const WaveClipGetClipByIndex (int index) const
 
int GetNumClips () const
 
WaveClipPointers SortedClipArray ()
 
WaveClipConstPointers SortedClipArray () const
 
bool CanOffsetClips (const std::vector< WaveClip * > &clips, double amount, double *allowedAmount=nullptr)
 Decide whether the clips could be offset (and inserted) together without overlapping other clips. More...
 
bool CanInsertClip (WaveClip *clip, double &slideBy, double &tolerance) const
 
std::shared_ptr< WaveClipRemoveAndReturnClip (WaveClip *clip)
 
bool AddClip (const std::shared_ptr< WaveClip > &clip)
 Append a clip to the track; which must have the same block factory as this track; return success. More...
 
void MergeClips (int clipidx1, int clipidx2)
 
void UpdateLocationsCache () const
 
const std::vector< Location > & GetCachedLocations () const
 
void ExpandCutLine (double cutLinePosition, double *cutlineStart=NULL, double *cutlineEnd=NULL)
 
bool RemoveCutLine (double cutLinePosition)
 
void Merge (const Track &orig) override
 
void Resample (int rate, ProgressDialog *progress=NULL)
 
int GetLastScaleType () const
 
void SetLastScaleType () const
 
int GetLastdBRange () const
 
void SetLastdBRange () const
 
void GetDisplayBounds (float *min, float *max) const
 
void SetDisplayBounds (float min, float max) const
 
void GetSpectrumBounds (float *min, float *max) const
 
void SetSpectrumBounds (float min, float max) const
 
int ZeroLevelYCoordinate (wxRect rect) const
 
Track::Holder PasteInto (AudacityProject &) const override
 Find or create the destination track for a paste, maybe in a different project. More...
 
ConstIntervals GetIntervals () const override
 Report times on the track where important intervals begin and end, for UI to snap to. More...
 
Intervals GetIntervals () override
 
- Public Member Functions inherited from PlayableTrack
 PlayableTrack ()
 
 PlayableTrack (const Track &orig)
 
bool GetMute () const
 
bool GetSolo () const
 
bool GetNotMute () const
 
bool GetNotSolo () const
 
void SetMute (bool m)
 
void SetSolo (bool s)
 
void Init (const PlayableTrack &init)
 
void WriteXMLAttributes (XMLWriter &xmlFile) const
 
bool HandleXMLAttribute (const wxChar *attr, const wxChar *value)
 
- Public Member Functions inherited from AudioTrack
 AudioTrack ()
 
 AudioTrack (const Track &orig)
 
void WriteXMLAttributes (XMLWriter &WXUNUSED(xmlFile)) const
 
bool HandleXMLAttribute (const wxChar *, const wxChar *)
 
- Public Member Functions inherited from Track
TrackId GetId () const
 
template<typename Subclass = Track>
std::shared_ptr< Subclass > SharedPointer ()
 
template<typename Subclass = const Track>
auto SharedPointer () const -> typename std::enable_if< std::is_const< Subclass >::value, std::shared_ptr< Subclass > >::type
 
std::shared_ptr< TrackSubstitutePendingChangedTrack ()
 
std::shared_ptr< const TrackSubstitutePendingChangedTrack () const
 
std::shared_ptr< const TrackSubstituteOriginalTrack () const
 
virtual bool SupportsBasicEditing () const
 Whether this track type implements cut-copy-paste; by default, true. More...
 
const std::shared_ptr< CommonTrackCell > & GetTrackView ()
 
void SetTrackView (const std::shared_ptr< CommonTrackCell > &pView)
 
const std::shared_ptr< CommonTrackCell > & GetTrackControls ()
 
void SetTrackControls (const std::shared_ptr< CommonTrackCell > &pControls)
 
int GetIndex () const
 
void SetIndex (int index)
 
bool LinkConsistencyCheck ()
 
bool HasOwner () const
 
std::shared_ptr< TrackListGetOwner () const
 
 Track ()
 
 Track (const Track &orig)
 
virtual ~ Track ()
 
void Init (const Track &orig)
 
virtual Holder Duplicate () const
 
wxString GetName () const
 
void SetName (const wxString &n)
 
wxString GetDefaultName () const
 
void SetDefaultName (const wxString &n)
 
bool GetSelected () const
 
virtual void SetSelected (bool s)
 
void EnsureVisible (bool modifyState=false)
 
void Offset (double t)
 
virtual Holder Cut (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual Holder Copy (double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard=true) const =0
 
virtual void Clear (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void Paste (double WXUNUSED(t), const Track *WXUNUSED(src))=0
 
virtual void Silence (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void InsertSilence (double WXUNUSED(t), double WXUNUSED(len))=0
 
bool SameKindAs (const Track &track) const
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions)
 Use this function rather than testing track type explicitly and making down-casts. More...
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions) const
 Use this function rather than testing track type explicitly and making down-casts. More...
 
bool IsSyncLockSelected () const
 
void Notify (int code=-1)
 
bool Any () const
 
bool IsSelected () const
 
bool IsSelectedOrSyncLockSelected () const
 
bool IsLeader () const
 
bool IsSelectedLeader () const
 
void AdjustPositions ()
 
void WriteCommonXMLAttributes (XMLWriter &xmlFile, bool includeNameAndSelected=true) const
 
bool HandleCommonXMLAttribute (const wxChar *attr, const wxChar *value)
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual void HandleXMLEndTag (const wxChar *WXUNUSED(tag))
 
virtual void HandleXMLContent (const wxString &WXUNUSED(content))
 
bool ReadXMLTag (const char *tag, const char **attrs)
 
void ReadXMLEndTag (const char *tag)
 
void ReadXMLContent (const char *s, int len)
 
XMLTagHandlerReadXMLChild (const char *tag)
 
- Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
 ~Site ()
 
 Site ()
 
 Site (const Site &other)
 
Siteoperator= (const Site &other)
 
 Site (Site &&other)
 
Siteoperator= (Site &&other)
 
size_t size () const
 How many attachment pointers are in the Site. More...
 
template<typename Subclass = ClientData>
Subclass & Get (const RegisteredFactory &key)
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = const ClientData>
auto Get (const RegisteredFactory &key) const -> typename std::enable_if< std::is_const< Subclass >::value, Subclass & >::type
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = ClientData>
Subclass * Find (const RegisteredFactory &key)
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename Subclass = const ClientData>
auto Find (const RegisteredFactory &key) const -> typename std::enable_if< std::is_const< Subclass >::value, Subclass * >::type
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename ReplacementPointer >
void Assign (const RegisteredFactory &key, ReplacementPointer &&replacement)
 Reassign Site's pointer to ClientData. More...
 

Protected Attributes

WaveClipHolders mClips
 
sampleFormat mFormat
 
int mRate
 
float mGain
 
float mPan
 
int mWaveColorIndex
 
float mOldGain [2]
 
float mDisplayMin
 
float mDisplayMax
 
float mSpectrumMin
 
float mSpectrumMax
 
int mLastScaleType
 
int mLastdBRange
 
std::vector< LocationmDisplayLocationsCache
 
- Protected Attributes inherited from PlayableTrack
bool mMute { false }
 
bool mSolo { false }
 
- Protected Attributes inherited from Track
std::weak_ptr< TrackListmList
 
TrackNodePointer mNode {}
 Holds iterator to self, so that TrackList::Find can be constant-time. More...
 
int mIndex
 0-based position of this track in its TrackList More...
 
wxString mName
 
wxString mDefaultName
 
bool mLinked
 
ChannelType mChannel
 
double mOffset
 
std::shared_ptr< CommonTrackCellmpView
 
std::shared_ptr< CommonTrackCellmpControls
 

Private Member Functions

void Init (const WaveTrack &orig)
 
Track::Holder Clone () const override
 
TrackKind GetKind () const override
 

Private Attributes

SampleBlockFactoryPtr mpFactory
 
wxCriticalSection mFlushCriticalSection
 
wxCriticalSection mAppendCriticalSection
 
double mLegacyProjectFileOffset
 
std::unique_ptr< SpectrogramSettingsmpSpectrumSettings
 
std::unique_ptr< WaveformSettingsmpWaveformSettings
 

Friends

class WaveTrackFactory
 

Additional Inherited Members

- Static Public Member Functions inherited from Track
template<typename Subclass = Track>
static std::shared_ptr< Subclass > SharedPointer (Track *pTrack)
 
template<typename Subclass = const Track>
static std::shared_ptr< Subclass > SharedPointer (const Track *pTrack)
 
static void FinishCopy (const Track *n, Track *dest)
 
- Static Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
static size_t slots ()
 How many static factories have been registered with this specialization of Site. More...
 
- Public Attributes inherited from Track
wxSize vrulerSize
 
- Static Public Attributes inherited from Track
static const auto LeftChannel = XMLValueChecker::LeftChannel
 
static const auto RightChannel = XMLValueChecker::RightChannel
 
static const auto MonoChannel = XMLValueChecker::MonoChannel
 
- Protected Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
template<typename Function >
void ForEach (const Function &function)
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
void ForEach (const Function &function) const
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
ClientData * FindIf (const Function &function)
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
template<typename Function >
const ClientData * FindIf (const Function &function) const
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
void BuildAll ()
 For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it. More...
 

Detailed Description

A Track that contains audio waveform data.

Definition at line 68 of file WaveTrack.h.

Member Typedef Documentation

◆ Holder

using WaveTrack::Holder = std::shared_ptr<WaveTrack>

Definition at line 93 of file WaveTrack.h.

◆ Location

Definition at line 92 of file WaveTrack.h.

Constructor & Destructor Documentation

◆ WaveTrack() [1/2]

WaveTrack::WaveTrack ( const SampleBlockFactoryPtr pFactory,
sampleFormat  format,
double  rate 
)

Definition at line 94 of file WaveTrack.cpp.

96  : PlayableTrack()
97  , mpFactory(pFactory)
98 {
100 
101  mFormat = format;
102  mRate = (int) rate;
103  mGain = 1.0;
104  mPan = 0.0;
105  mOldGain[0] = 0.0;
106  mOldGain[1] = 0.0;
107  mWaveColorIndex = 0;
110  mDisplayMin = -1.0;
111  mDisplayMax = 1.0;
112  mSpectrumMin = mSpectrumMax = -1; // so values will default to settings
113  mLastScaleType = -1;
114  mLastdBRange = -1;
115 }

References format, TracksPrefs::GetDefaultAudioTrackNamePreference(), Track::GetDefaultName(), mDisplayMax, mDisplayMin, mFormat, mGain, mLastdBRange, mLastScaleType, mLegacyProjectFileOffset, mOldGain, mPan, mRate, mSpectrumMax, mSpectrumMin, mWaveColorIndex, Track::SetDefaultName(), and Track::SetName().

Here is the call graph for this function:

◆ WaveTrack() [2/2]

WaveTrack::WaveTrack ( const WaveTrack orig)

Definition at line 117 of file WaveTrack.cpp.

117  :
118  PlayableTrack(orig)
119  , mpFactory( orig.mpFactory )
121  ? std::make_unique<SpectrogramSettings>(*orig.mpSpectrumSettings)
122  : nullptr
123  )
125  ? std::make_unique<WaveformSettings>(*orig.mpWaveformSettings)
126  : nullptr
127  )
128 {
129  mLastScaleType = -1;
130  mLastdBRange = -1;
131 
133 
134  Init(orig);
135 
136  for (const auto &clip : orig.mClips)
137  mClips.push_back
138  ( std::make_unique<WaveClip>( *clip, mpFactory, true ) );
139 }

References Init(), mClips, mLastdBRange, mLastScaleType, mLegacyProjectFileOffset, and mpFactory.

Here is the call graph for this function:

◆ ~WaveTrack()

WaveTrack::~WaveTrack ( )
virtual

Definition at line 202 of file WaveTrack.cpp.

203 {
204 }

Member Function Documentation

◆ AddClip()

bool WaveTrack::AddClip ( const std::shared_ptr< WaveClip > &  clip)

Append a clip to the track; which must have the same block factory as this track; return success.

Definition at line 981 of file WaveTrack.cpp.

982 {
983  if (clip->GetSequence()->GetFactory() != this->mpFactory)
984  return false;
985 
986  // Uncomment the following line after we correct the problem of zero-length clips
987  //if (CanInsertClip(clip))
988  mClips.push_back(clip); // transfer ownership
989 
990  return true;
991 }

References Sequence::GetFactory(), WaveClip::GetSequence(), and mClips.

Referenced by EffectReverse::ProcessOneWave().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Append()

bool WaveTrack::Append ( constSamplePtr  buffer,
sampleFormat  format,
size_t  len,
unsigned int  stride = 1 
)

Append the sample data to the WaveTrack. You must call Flush() after the last Append.

If there is an existing WaveClip in the WaveTrack then the data is appended to that clip. If there are no WaveClips in the track, then a NEW one is created.

Returns
true if at least one complete block was created
Exception safety guarantee:
Partial – Some prefix (maybe none) of the buffer is appended, and no content already flushed to disk is lost.

Definition at line 1541 of file WaveTrack.cpp.

1543 {
1544  return RightmostOrNewClip()->Append(buffer, format, len, stride);
1545 }

References WaveClip::Append(), format, and RightmostOrNewClip().

Referenced by BlockGenerator::GenerateTrack(), EffectTwoPassSimpleMono::ProcessOne(), Effect::ProcessTrack(), NyquistEffect::PutCallback(), and EffectNoiseReduction::Worker::ReduceNoise().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CanInsertClip()

bool WaveTrack::CanInsertClip ( WaveClip clip,
double &  slideBy,
double &  tolerance 
) const

Definition at line 2265 of file WaveTrack.cpp.

2267 {
2268  for (const auto &c : mClips)
2269  {
2270  double d1 = c->GetStartTime() - (clip->GetEndTime()+slideBy);
2271  double d2 = (clip->GetStartTime()+slideBy) - c->GetEndTime();
2272  if ( (d1<0) && (d2<0) )
2273  {
2274  // clips overlap.
2275  // Try to rescue it.
2276  // The rescue logic is not perfect, and will typically
2277  // move the clip at most once.
2278  // We divide by 1000 rather than set to 0, to allow for
2279  // a second 'micro move' that is really about rounding error.
2280  if( -d1 < tolerance ){
2281  // right edge of clip overlaps slightly.
2282  // slide clip left a small amount.
2283  slideBy +=d1;
2284  tolerance /=1000;
2285  } else if( -d2 < tolerance ){
2286  // left edge of clip overlaps slightly.
2287  // slide clip right a small amount.
2288  slideBy -= d2;
2289  tolerance /=1000;
2290  }
2291  else
2292  return false; // clips overlap No tolerance left.
2293  }
2294  }
2295 
2296  return true;
2297 }

References WaveClip::GetEndTime(), WaveClip::GetStartTime(), and mClips.

Here is the call graph for this function:

◆ CanOffsetClips()

bool WaveTrack::CanOffsetClips ( const std::vector< WaveClip * > &  clips,
double  amount,
double *  allowedAmount = nullptr 
)

Decide whether the clips could be offset (and inserted) together without overlapping other clips.

Returns
true if possible to offset by (allowedAmount ? *allowedAmount : amount)
Parameters
clipsnot necessarily in this track
amountsigned
[out]allowedAmountif null, test exact amount only; else, largest (in magnitude) possible offset with same sign

Definition at line 2207 of file WaveTrack.cpp.

2211 {
2212  if (allowedAmount)
2213  *allowedAmount = amount;
2214 
2215  const auto &moving = [&](WaveClip *clip){
2216  // linear search might be improved, but expecting few moving clips
2217  // compared with the fixed clips
2218  return clips.end() != std::find( clips.begin(), clips.end(), clip );
2219  };
2220 
2221  for (const auto &c: mClips) {
2222  if ( moving( c.get() ) )
2223  continue;
2224  for (const auto clip : clips) {
2225  if (c->GetStartTime() < clip->GetEndTime() + amount &&
2226  c->GetEndTime() > clip->GetStartTime() + amount)
2227  {
2228  if (!allowedAmount)
2229  return false; // clips overlap
2230 
2231  if (amount > 0)
2232  {
2233  if (c->GetStartTime()-clip->GetEndTime() < *allowedAmount)
2234  *allowedAmount = c->GetStartTime()-clip->GetEndTime();
2235  if (*allowedAmount < 0)
2236  *allowedAmount = 0;
2237  } else
2238  {
2239  if (c->GetEndTime()-clip->GetStartTime() > *allowedAmount)
2240  *allowedAmount = c->GetEndTime()-clip->GetStartTime();
2241  if (*allowedAmount > 0)
2242  *allowedAmount = 0;
2243  }
2244  }
2245  }
2246  }
2247 
2248  if (allowedAmount)
2249  {
2250  if (*allowedAmount == amount)
2251  return true;
2252 
2253  // Check if the NEW calculated amount would not violate
2254  // any other constraint
2255  if (!CanOffsetClips(clips, *allowedAmount, nullptr)) {
2256  *allowedAmount = 0; // play safe and don't allow anything
2257  return false;
2258  }
2259  else
2260  return true;
2261  } else
2262  return true;
2263 }

References mClips.

◆ Clear()

void WaveTrack::Clear ( double  t0,
double  t1 
)
override
Exception safety guarantee:
Strong

Definition at line 654 of file WaveTrack.cpp.

655 {
656  HandleClear(t0, t1, false, false);
657 }

References HandleClear().

Referenced by Cut(), EffectTruncSilence::DoRemoval(), LabelEditActions::Handler::OnCutLabels(), Generator::Process(), EffectEqualization::ProcessOne(), EffectStereoToMono::ProcessOne(), EffectPaulstretch::ProcessOne(), SyncLockAdjust(), and Trim().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearAndAddCutLine()

void WaveTrack::ClearAndAddCutLine ( double  t0,
double  t1 
)
Exception safety guarantee:
Strong

Definition at line 660 of file WaveTrack.cpp.

661 {
662  HandleClear(t0, t1, true, false);
663 }

References HandleClear().

Referenced by EditActions::Handler::OnCut(), and LabelEditActions::Handler::OnCutLabels().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearAndPaste()

void WaveTrack::ClearAndPaste ( double  t0,
double  t1,
const Track src,
bool  preserve = true,
bool  merge = true,
const TimeWarper effectWarper = NULL 
)
Exception safety guarantee:
Weak – This WaveTrack remains destructible in case of AudacityException. But some of its cutline clips may have been destroyed.

Definition at line 750 of file WaveTrack.cpp.

757 {
758  double dur = std::min(t1 - t0, src->GetEndTime());
759 
760  // If duration is 0, then it's just a plain paste
761  if (dur == 0.0) {
762  // use Weak-guarantee
763  Paste(t0, src);
764  return;
765  }
766 
767  std::vector<EnvPoint> envPoints;
768  std::vector<double> splits;
769  WaveClipHolders cuts;
770 
771  // If provided time warper was NULL, use a default one that does nothing
772  IdentityTimeWarper localWarper;
773  const TimeWarper *warper = (effectWarper ? effectWarper : &localWarper);
774 
775  // Align to a sample
778 
779  // Save the cut/split lines whether preserving or not since merging
780  // needs to know if a clip boundary is being crossed since Paste()
781  // will add split lines around the pasted clip if so.
782  for (const auto &clip : mClips) {
783  double st;
784 
785  // Remember clip boundaries as locations to split
786  st = LongSamplesToTime(TimeToLongSamples(clip->GetStartTime()));
787  if (st >= t0 && st <= t1 && !make_iterator_range(splits).contains(st)) {
788  splits.push_back(st);
789  }
790 
791  st = LongSamplesToTime(TimeToLongSamples(clip->GetEndTime()));
792  if (st >= t0 && st <= t1 && !make_iterator_range(splits).contains(st)) {
793  splits.push_back(st);
794  }
795 
796  // Search for cut lines
797  auto &cutlines = clip->GetCutLines();
798  // May erase from cutlines, so don't use range-for
799  for (auto it = cutlines.begin(); it != cutlines.end(); ) {
800  WaveClip *cut = it->get();
801  double cs = LongSamplesToTime(TimeToLongSamples(clip->GetOffset() +
802  cut->GetOffset()));
803 
804  // Remember cut point
805  if (cs >= t0 && cs <= t1) {
806 
807  // Remember the absolute offset and add to our cuts array.
808  cut->SetOffset(cs);
809  cuts.push_back(std::move(*it)); // transfer ownership!
810  it = cutlines.erase(it);
811  }
812  else
813  ++it;
814  }
815 
816  // Save the envelope points
817  const auto &env = *clip->GetEnvelope();
818  for (size_t i = 0, numPoints = env.GetNumberOfPoints(); i < numPoints; ++i) {
819  envPoints.push_back(env[i]);
820  }
821  }
822 
823  const auto tolerance = 2.0 / GetRate();
824 
825  // Now, clear the selection
826  HandleClear(t0, t1, false, false);
827  {
828  // And paste in the NEW data
829  Paste(t0, src);
830  {
831  // First, merge the NEW clip(s) in with the existing clips
832  if (merge && splits.size() > 0)
833  {
834  // Now t1 represents the absolute end of the pasted data.
835  t1 = t0 + src->GetEndTime();
836 
837  // Get a sorted array of the clips
838  auto clips = SortedClipArray();
839 
840  // Scan the sorted clips for the first clip whose start time
841  // exceeds the pasted regions end time.
842  {
843  WaveClip *prev = nullptr;
844  for (const auto clip : clips) {
845  // Merge this clip and the previous clip if the end time
846  // falls within it and this isn't the first clip in the track.
847  if (fabs(t1 - clip->GetStartTime()) < tolerance) {
848  if (prev)
849  MergeClips(GetClipIndex(prev), GetClipIndex(clip));
850  break;
851  }
852  prev = clip;
853  }
854  }
855  }
856 
857  // Refill the array since clips have changed.
858  auto clips = SortedClipArray();
859 
860  {
861  // Scan the sorted clips to look for the start of the pasted
862  // region.
863  WaveClip *prev = nullptr;
864  for (const auto clip : clips) {
865  if (prev) {
866  // It must be that clip is what was pasted and it begins where
867  // prev ends.
868  // use Weak-guarantee
869  MergeClips(GetClipIndex(prev), GetClipIndex(clip));
870  break;
871  }
872  if (fabs(t0 - clip->GetEndTime()) < tolerance)
873  // Merge this clip and the next clip if the start time
874  // falls within it and this isn't the last clip in the track.
875  prev = clip;
876  else
877  prev = nullptr;
878  }
879  }
880  }
881 
882  // Restore cut/split lines
883  if (preserve) {
884 
885  // Restore the split lines, transforming the position appropriately
886  for (const auto split: splits) {
887  SplitAt(warper->Warp(split));
888  }
889 
890  // Restore the saved cut lines, also transforming if time altered
891  for (const auto &clip : mClips) {
892  double st;
893  double et;
894 
895  st = clip->GetStartTime();
896  et = clip->GetEndTime();
897 
898  // Scan the cuts for any that live within this clip
899  for (auto it = cuts.begin(); it != cuts.end();) {
900  WaveClip *cut = it->get();
901  double cs = cut->GetOffset();
902 
903  // Offset the cut from the start of the clip and add it to
904  // this clips cutlines.
905  if (cs >= st && cs <= et) {
906  cut->SetOffset(warper->Warp(cs) - st);
907  clip->GetCutLines().push_back( std::move(*it) ); // transfer ownership!
908  it = cuts.erase(it);
909  }
910  else
911  ++it;
912  }
913  }
914  }
915 
916  // Restore the envelope points
917  for (auto point : envPoints) {
918  auto t = warper->Warp(point.GetT());
919  if (auto clip = GetClipAtTime(t))
920  clip->GetEnvelope()->Insert(t, point.GetVal());
921  }
922  }
923 }

References GetClipAtTime(), GetClipIndex(), Track::GetEndTime(), WaveClip::GetOffset(), GetRate(), HandleClear(), LongSamplesToTime(), make_iterator_range(), mClips, MergeClips(), min(), Paste(), WaveClip::SetOffset(), SortedClipArray(), SplitAt(), TimeToLongSamples(), and TimeWarper::Warp().

Referenced by EffectSBSMS::Finalize(), EditActions::Handler::OnPaste(), Generator::Process(), NyquistEffect::ProcessOne(), EffectNoiseReduction::Worker::ProcessOne(), EffectNoiseRemoval::ProcessOne(), EffectChangeSpeed::ProcessOne(), and Effect::ProcessTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearWaveCaches()

void WaveTrack::ClearWaveCaches ( )

Invalidates all clips' wavecaches. Careful, This may not be threadsafe.

Deletes all clips' wavecaches. Careful, This may not be threadsafe.

Definition at line 2513 of file WaveTrack.cpp.

2514 {
2515  for (const auto &clip : mClips)
2516  clip->ClearWaveCache();
2517 }

References mClips.

◆ Clone()

Track::Holder WaveTrack::Clone ( ) const
overrideprivatevirtual

Implements Track.

Definition at line 355 of file WaveTrack.cpp.

356 {
357  return std::make_shared<WaveTrack>( *this );
358 }

◆ CloseLock()

bool WaveTrack::CloseLock ( )

Definition at line 1759 of file WaveTrack.cpp.

1760 {
1761  for (const auto &clip : mClips)
1762  clip->CloseLock();
1763 
1764  return true;
1765 }

References mClips.

◆ ConvertToSampleFormat()

void WaveTrack::ConvertToSampleFormat ( sampleFormat  format,
const std::function< void(size_t)> &  progressReport = {} 
)
Exception safety guarantee:
Weak – Might complete on only some clips

Definition at line 455 of file WaveTrack.cpp.

457 {
458  for (const auto& clip : mClips)
459  clip->ConvertToSampleFormat(format, progressReport);
460  mFormat = format;
461 }

References format, mClips, and mFormat.

Referenced by EffectEqualization::ProcessOne().

Here is the caller graph for this function:

◆ Copy()

Track::Holder WaveTrack::Copy ( double  t0,
double  t1,
bool  forClipboard = true 
) const
override

Definition at line 583 of file WaveTrack.cpp.

584 {
585  if (t1 < t0)
587 
588  auto result = EmptyCopy();
589  WaveTrack *newTrack = result.get();
590 
591  // PRL: Why shouldn't cutlines be copied and pasted too? I don't know, but
592  // that was the old behavior. But this function is also used by the
593  // Duplicate command and I changed its behavior in that case.
594 
595  for (const auto &clip : mClips)
596  {
597  if (t0 <= clip->GetStartTime() && t1 >= clip->GetEndTime())
598  {
599  // Whole clip is in copy region
600  //wxPrintf("copy: clip %i is in copy region\n", (int)clip);
601 
602  newTrack->mClips.push_back
603  (std::make_unique<WaveClip>(*clip, mpFactory, ! forClipboard));
604  WaveClip *const newClip = newTrack->mClips.back().get();
605  newClip->Offset(-t0);
606  }
607  else if (t1 > clip->GetStartTime() && t0 < clip->GetEndTime())
608  {
609  // Clip is affected by command
610  //wxPrintf("copy: clip %i is affected by command\n", (int)clip);
611 
612  const double clip_t0 = std::max(t0, clip->GetStartTime());
613  const double clip_t1 = std::min(t1, clip->GetEndTime());
614 
615  auto newClip = std::make_unique<WaveClip>
616  (*clip, mpFactory, ! forClipboard, clip_t0, clip_t1);
617 
618  //wxPrintf("copy: clip_t0=%f, clip_t1=%f\n", clip_t0, clip_t1);
619 
620  newClip->Offset(-t0);
621  if (newClip->GetOffset() < 0)
622  newClip->SetOffset(0);
623 
624  newTrack->mClips.push_back(std::move(newClip)); // transfer ownership
625  }
626  }
627 
628  // AWD, Oct 2009: If the selection ends in whitespace, create a placeholder
629  // clip representing that whitespace
630  // PRL: Only if we want the track for pasting into other tracks. Not if it
631  // goes directly into a project as in the Duplicate command.
632  if (forClipboard &&
633  newTrack->GetEndTime() + 1.0 / newTrack->GetRate() < t1 - t0)
634  {
635  auto placeholder = std::make_unique<WaveClip>(mpFactory,
636  newTrack->GetSampleFormat(),
637  static_cast<int>(newTrack->GetRate()),
638  0 /*colourindex*/);
639  placeholder->SetIsPlaceholder(true);
640  placeholder->InsertSilence(0, (t1 - t0) - newTrack->GetEndTime());
641  placeholder->Offset(newTrack->GetEndTime());
642  newTrack->mClips.push_back(std::move(placeholder)); // transfer ownership
643  }
644 
645  return result;
646 }

References EmptyCopy(), GetEndTime(), GetRate(), GetSampleFormat(), GetStartTime(), mClips, min(), mpFactory, WaveClip::Offset(), and THROW_INCONSISTENCY_EXCEPTION.

Referenced by CopyNonconst(), Cut(), EditActions::Handler::OnSplitCut(), LabelEditActions::Handler::OnSplitCutLabels(), EffectRepeat::Process(), and SplitCut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CopyNonconst()

Track::Holder WaveTrack::CopyNonconst ( double  t0,
double  t1 
)

Definition at line 648 of file WaveTrack.cpp.

649 {
650  return Copy(t0, t1);
651 }

References Copy().

Referenced by LabelEditActions::Handler::OnCopyLabels(), and LabelEditActions::Handler::OnCutLabels().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateClip()

WaveClip * WaveTrack::CreateClip ( )

Definition at line 2141 of file WaveTrack.cpp.

2142 {
2143  mClips.push_back(std::make_unique<WaveClip>(mpFactory, mFormat, mRate, GetWaveColorIndex()));
2144  return mClips.back().get();
2145 }

References GetWaveColorIndex(), mClips, mFormat, mpFactory, and mRate.

Referenced by AUPImportFileHandle::HandleWaveClip(), HandleXMLChild(), Join(), NewestOrNewClip(), and RightmostOrNewClip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cut()

Track::Holder WaveTrack::Cut ( double  t0,
double  t1 
)
override

Definition at line 486 of file WaveTrack.cpp.

487 {
488  if (t1 < t0)
490 
491  auto tmp = Copy(t0, t1);
492 
493  Clear(t0, t1);
494 
495  return tmp;
496 }

References Clear(), Copy(), and THROW_INCONSISTENCY_EXCEPTION.

Referenced by Paste(), and SyncLockAdjust().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Disjoin()

void WaveTrack::Disjoin ( double  t0,
double  t1 
)
Exception safety guarantee:
Weak

Definition at line 1407 of file WaveTrack.cpp.

1408 {
1410  const size_t maxAtOnce = 1048576;
1411  Floats buffer{ maxAtOnce };
1412  Regions regions;
1413 
1414  wxBusyCursor busy;
1415 
1416  for (const auto &clip : mClips)
1417  {
1418  double startTime = clip->GetStartTime();
1419  double endTime = clip->GetEndTime();
1420 
1421  if( endTime < t0 || startTime > t1 )
1422  continue;
1423 
1424  if( t0 > startTime )
1425  startTime = t0;
1426  if( t1 < endTime )
1427  endTime = t1;
1428 
1429  //simply look for a sequence of zeroes and if the sequence
1430  //is greater than minimum number, split-DELETE the region
1431 
1432  sampleCount seqStart = -1;
1433  sampleCount start, end;
1434  clip->TimeToSamplesClip( startTime, &start );
1435  clip->TimeToSamplesClip( endTime, &end );
1436 
1437  auto len = ( end - start );
1438  for( decltype(len) done = 0; done < len; done += maxAtOnce )
1439  {
1440  auto numSamples = limitSampleBufferSize( maxAtOnce, len - done );
1441 
1442  clip->GetSamples( ( samplePtr )buffer.get(), floatSample, start + done,
1443  numSamples );
1444  for( decltype(numSamples) i = 0; i < numSamples; i++ )
1445  {
1446  auto curSamplePos = start + done + i;
1447 
1448  //start a NEW sequence
1449  if( buffer[ i ] == 0.0 && seqStart == -1 )
1450  seqStart = curSamplePos;
1451  else if( buffer[ i ] != 0.0 || curSamplePos == end - 1 )
1452  {
1453  if( seqStart != -1 )
1454  {
1455  decltype(end) seqEnd;
1456 
1457  //consider the end case, where selection ends in zeroes
1458  if( curSamplePos == end - 1 && buffer[ i ] == 0.0 )
1459  seqEnd = end;
1460  else
1461  seqEnd = curSamplePos;
1462  if( seqEnd - seqStart + 1 > minSamples )
1463  {
1464  regions.push_back(Region(
1465  seqStart.as_double() / GetRate()
1466  + clip->GetStartTime(),
1467  seqEnd.as_double() / GetRate()
1468  + clip->GetStartTime()));
1469  }
1470  seqStart = -1;
1471  }
1472  }
1473  }
1474  }
1475  }
1476 
1477  for( unsigned int i = 0; i < regions.size(); i++ )
1478  {
1479  const Region &region = regions.at(i);
1480  SplitDelete(region.start, region.end );
1481  }
1482 }

References sampleCount::as_double(), Region::end, floatSample, GetRate(), limitSampleBufferSize(), mClips, Region, SplitDelete(), Region::start, TimeToLongSamples(), and WAVETRACK_MERGE_POINT_TOLERANCE.

Referenced by LabelEditActions::Handler::OnDisjoinLabels().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EmptyCopy()

WaveTrack::Holder WaveTrack::EmptyCopy ( const SampleBlockFactoryPtr pFactory = {}) const

Definition at line 574 of file WaveTrack.cpp.

576 {
577  auto result = std::make_shared<WaveTrack>( pFactory, mFormat, mRate );
578  result->Init(*this);
579  result->mpFactory = pFactory ? pFactory : mpFactory;
580  return result;
581 }

References mFormat, mpFactory, and mRate.

Referenced by Copy(), PasteInto(), Generator::Process(), EffectSBSMS::Process(), NyquistEffect::ProcessOne(), EffectNoiseReduction::Worker::ProcessOne(), EffectEqualization::ProcessOne(), EffectNoiseRemoval::ProcessOne(), EffectStereoToMono::ProcessOne(), EffectChangeSpeed::ProcessOne(), EffectPaulstretch::ProcessOne(), and Effect::ProcessTrack().

Here is the caller graph for this function:

◆ ExpandCutLine()

void WaveTrack::ExpandCutLine ( double  cutLinePosition,
double *  cutlineStart = NULL,
double *  cutlineEnd = NULL 
)
Exception safety guarantee:
Strong

Definition at line 2398 of file WaveTrack.cpp.

2400 {
2401  bool editClipCanMove = GetEditClipsCanMove();
2402 
2403  // Find clip which contains this cut line
2404  double start = 0, end = 0;
2405  auto pEnd = mClips.end();
2406  auto pClip = std::find_if( mClips.begin(), pEnd,
2407  [&](const WaveClipHolder &clip) {
2408  return clip->FindCutLine(cutLinePosition, &start, &end); } );
2409  if (pClip != pEnd)
2410  {
2411  auto &clip = *pClip;
2412  if (!editClipCanMove)
2413  {
2414  // We are not allowed to move the other clips, so see if there
2415  // is enough room to expand the cut line
2416  for (const auto &clip2: mClips)
2417  {
2418  if (clip2->GetStartTime() > clip->GetStartTime() &&
2419  clip->GetEndTime() + end - start > clip2->GetStartTime())
2420  // Strong-guarantee in case of this path
2422  XO("There is not enough room available to expand the cut line"),
2423  XO("Warning"),
2424  "Error:_Insufficient_space_in_track"
2425  };
2426  }
2427  }
2428 
2429  clip->ExpandCutLine(cutLinePosition);
2430 
2431  // Strong-guarantee provided that the following gives No-fail-guarantee
2432 
2433  if (cutlineStart)
2434  *cutlineStart = start;
2435  if (cutlineEnd)
2436  *cutlineEnd = end;
2437 
2438  // Move clips which are to the right of the cut line
2439  if (editClipCanMove)
2440  {
2441  for (const auto &clip2 : mClips)
2442  {
2443  if (clip2->GetStartTime() > clip->GetStartTime())
2444  clip2->Offset(end - start);
2445  }
2446  }
2447  }
2448 }

References GetEditClipsCanMove(), mClips, and XO.

Here is the call graph for this function:

◆ Flush()

void WaveTrack::Flush ( )

Flush must be called after last Append.

Exception safety guarantee:
Mixed
Exception safety guarantee:
No-fail – The rightmost clip will be in a flushed state.
Exception safety guarantee:
Partial – Some initial portion (maybe none) of the append buffer of the rightmost clip gets appended; no previously saved contents are lost.

Definition at line 1608 of file WaveTrack.cpp.

1609 {
1610  // After appending, presumably. Do this to the clip that gets appended.
1612 }

References WaveClip::Flush(), and RightmostOrNewClip().

Referenced by NyquistEffect::ProcessOne(), EffectTwoPassSimpleMono::ProcessOne(), Effect::ProcessTrack(), and AudioIO::StopStream().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get()

bool WaveTrack::Get ( samplePtr  buffer,
sampleFormat  format,
sampleCount  start,
size_t  len,
fillFormat  fill = fillZero,
bool  mayThrow = true,
sampleCount pNumWithinClips = nullptr 
) const

MM: Now that each wave track can contain multiple clips, we don't have a continuous space of samples anymore, but we simulate it, because there are a lot of places (e.g. effects) using this interface. This interface makes much sense for modifying samples, but note that it is not time-accurate, because the "offset" is a double value and therefore can lie inbetween samples. But as long as you use the same value for "start" in both calls to "Set" and "Get" it is guaranteed that the same samples are affected.

Definition at line 1895 of file WaveTrack.cpp.

1898 {
1899  // Simple optimization: When this buffer is completely contained within one clip,
1900  // don't clear anything (because we won't have to). Otherwise, just clear
1901  // everything to be on the safe side.
1902  bool doClear = true;
1903  bool result = true;
1904  sampleCount samplesCopied = 0;
1905  for (const auto &clip: mClips)
1906  {
1907  if (start >= clip->GetStartSample() && start+len <= clip->GetEndSample())
1908  {
1909  doClear = false;
1910  break;
1911  }
1912  }
1913  if (doClear)
1914  {
1915  // Usually we fill in empty space with zero
1916  if( fill == fillZero )
1917  ClearSamples(buffer, format, 0, len);
1918  // but we don't have to.
1919  else if( fill==fillTwo )
1920  {
1921  wxASSERT( format==floatSample );
1922  float * pBuffer = (float*)buffer;
1923  for(size_t i=0;i<len;i++)
1924  pBuffer[i]=2.0f;
1925  }
1926  else
1927  {
1928  wxFAIL_MSG(wxT("Invalid fill format"));
1929  }
1930  }
1931 
1932  // Iterate the clips. They are not necessarily sorted by time.
1933  for (const auto &clip: mClips)
1934  {
1935  auto clipStart = clip->GetStartSample();
1936  auto clipEnd = clip->GetEndSample();
1937 
1938  if (clipEnd > start && clipStart < start+len)
1939  {
1940  // Clip sample region and Get/Put sample region overlap
1941  auto samplesToCopy =
1942  std::min( start+len - clipStart, clip->GetNumSamples() );
1943  auto startDelta = clipStart - start;
1944  decltype(startDelta) inclipDelta = 0;
1945  if (startDelta < 0)
1946  {
1947  inclipDelta = -startDelta; // make positive value
1948  samplesToCopy -= inclipDelta;
1949  // samplesToCopy is now either len or
1950  // (clipEnd - clipStart) - (start - clipStart)
1951  // == clipEnd - start > 0
1952  // samplesToCopy is not more than len
1953  //
1954  startDelta = 0;
1955  // startDelta is zero
1956  }
1957  else {
1958  // startDelta is nonnegative and less than len
1959  // samplesToCopy is positive and not more than len
1960  }
1961 
1962  if (!clip->GetSamples(
1963  (samplePtr)(((char*)buffer) +
1964  startDelta.as_size_t() *
1965  SAMPLE_SIZE(format)),
1966  format, inclipDelta, samplesToCopy.as_size_t(), mayThrow ))
1967  result = false;
1968  else
1969  samplesCopied += samplesToCopy;
1970  }
1971  }
1972  if( pNumWithinClips )
1973  *pNumWithinClips = samplesCopied;
1974  return result;
1975 }

References ClearSamples(), fillTwo, fillZero, floatSample, format, mClips, min(), and SAMPLE_SIZE.

Referenced by EffectNormalize::AnalyseTrackData(), EffectTruncSilence::Analyze(), CompareAudioCommand::Apply(), EffectAutoDuck::ApplyDuckFade(), EffectTruncSilence::DoRemoval(), WaveTrackFactory::Get(), NyquistEffect::GetCallback(), VoiceKey::OffBackward(), VoiceKey::OffForward(), VoiceKey::OnBackward(), VoiceKey::OnForward(), EffectAutoDuck::Process(), VampEffect::Process(), EffectNoiseReduction::Worker::ProcessOne(), EffectEqualization::ProcessOne(), EffectClickRemoval::ProcessOne(), EffectNoiseRemoval::ProcessOne(), EffectRepair::ProcessOne(), EffectFindClipping::ProcessOne(), EffectNormalize::ProcessOne(), EffectChangeSpeed::ProcessOne(), EffectSimpleMono::ProcessOne(), EffectTwoPassSimpleMono::ProcessOne(), EffectPaulstretch::ProcessOne(), EffectReverse::ProcessOneClip(), Effect::ProcessTrack(), resampleCB(), SelectHandle::StartSnappingFreqSelection(), VoiceKey::TestDirectionChanges(), VoiceKey::TestEnergy(), VoiceKey::TestSignChanges(), and MixerTrackCluster::UpdateMeter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAllClips() [1/2]

IteratorRange< AllClipsIterator > WaveTrack::GetAllClips ( )
inline

Definition at line 421 of file WaveTrack.h.

422  {
423  return { AllClipsIterator{ *this }, AllClipsIterator{ } };
424  }

◆ GetAllClips() [2/2]

IteratorRange< AllClipsConstIterator > WaveTrack::GetAllClips ( ) const
inline

Definition at line 426 of file WaveTrack.h.

427  {
428  return { AllClipsConstIterator{ *this }, AllClipsConstIterator{ } };
429  }

◆ GetBestBlockSize()

size_t WaveTrack::GetBestBlockSize ( sampleCount  t) const

Definition at line 1560 of file WaveTrack.cpp.

1561 {
1562  auto bestBlockSize = GetMaxBlockSize();
1563 
1564  for (const auto &clip : mClips)
1565  {
1566  auto startSample = (sampleCount)floor(clip->GetStartTime()*mRate + 0.5);
1567  auto endSample = startSample + clip->GetNumSamples();
1568  if (s >= startSample && s < endSample)
1569  {
1570  bestBlockSize = clip->GetSequence()->GetBestBlockSize(s - startSample);
1571  break;
1572  }
1573  }
1574 
1575  return bestBlockSize;
1576 }

References GetMaxBlockSize(), mClips, and mRate.

Referenced by EffectNormalize::AnalyseTrackData(), CompareAudioCommand::Apply(), BlockGenerator::GenerateTrack(), NyquistEffect::GetCallback(), EffectNoiseReduction::Worker::ProcessOne(), EffectNoiseRemoval::ProcessOne(), EffectLoudness::ProcessOne(), EffectNormalize::ProcessOne(), EffectChangeSpeed::ProcessOne(), EffectSimpleMono::ProcessOne(), EffectTwoPassSimpleMono::ProcessOne(), EffectReverse::ProcessOneClip(), resampleCB(), VoiceKey::TestDirectionChanges(), VoiceKey::TestEnergy(), and VoiceKey::TestSignChanges().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBlockStart()

sampleCount WaveTrack::GetBlockStart ( sampleCount  t) const

Definition at line 1547 of file WaveTrack.cpp.

1548 {
1549  for (const auto &clip : mClips)
1550  {
1551  const auto startSample = (sampleCount)floor(0.5 + clip->GetStartTime()*mRate);
1552  const auto endSample = startSample + clip->GetNumSamples();
1553  if (s >= startSample && s < endSample)
1554  return startSample + clip->GetSequence()->GetBlockStart(s - startSample);
1555  }
1556 
1557  return -1;
1558 }

References mClips, and mRate.

◆ GetCachedLocations()

const std::vector<Location>& WaveTrack::GetCachedLocations ( ) const
inline

Definition at line 498 of file WaveTrack.h.

498 { return mDisplayLocationsCache; }

Referenced by WaveTrackSubView::DrawBoldBoundaries(), anonymous_namespace{CutlineHandle.cpp}::FindMergeLine(), and anonymous_namespace{CutlineHandle.cpp}::IsOverCutline().

Here is the caller graph for this function:

◆ GetChannel()

auto WaveTrack::GetChannel ( ) const
overridevirtual

Reimplemented from Track.

Definition at line 227 of file WaveTrack.cpp.

228 {
230  return mChannel;
231  auto pan = GetPan();
232  if( pan < -0.99 )
233  return Track::LeftChannel;
234  if( pan > 0.99 )
235  return Track::RightChannel;
236  return mChannel;
237 }

References GetPan(), Track::LeftChannel, Track::mChannel, Track::MonoChannel, and Track::RightChannel.

Referenced by Mixer::Process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChannelGain()

float WaveTrack::GetChannelGain ( int  channel) const

Definition at line 408 of file WaveTrack.cpp.

409 {
410  float left = 1.0;
411  float right = 1.0;
412 
413  if (mPan < 0)
414  right = (mPan + 1.0);
415  else if (mPan > 0)
416  left = 1.0 - mPan;
417 
418  if ((channel%2) == 0)
419  return left*mGain;
420  else
421  return right*mGain;
422 }

References mGain, and mPan.

Referenced by AudioIoCallback::AddToOutputChannel(), Mixer::MixSameRate(), Mixer::MixVariableRates(), and MixerTrackCluster::UpdateMeter().

Here is the caller graph for this function:

◆ GetChannelIgnoringPan()

auto WaveTrack::GetChannelIgnoringPan ( ) const
virtual

Definition at line 223 of file WaveTrack.cpp.

223  {
224  return mChannel;
225 }

References Track::mChannel.

Referenced by AudioIoCallback::FillOutputBuffers(), and AudioIoCallback::TrackHasBeenFadedOut().

Here is the caller graph for this function:

◆ GetClipAtSample()

WaveClip * WaveTrack::GetClipAtSample ( sampleCount  sample)

Definition at line 2086 of file WaveTrack.cpp.

2087 {
2088  for (const auto &clip: mClips)
2089  {
2090  auto start = clip->GetStartSample();
2091  auto len = clip->GetNumSamples();
2092 
2093  if (sample >= start && sample < start + len)
2094  return clip.get();
2095  }
2096 
2097  return NULL;
2098 }

References WaveClip::GetStartSample(), and mClips.

Here is the call graph for this function:

◆ GetClipAtTime()

WaveClip * WaveTrack::GetClipAtTime ( double  time)

Definition at line 2102 of file WaveTrack.cpp.

2103 {
2104 
2105  const auto clips = SortedClipArray();
2106  auto p = std::find_if(clips.rbegin(), clips.rend(), [&] (WaveClip* const& clip) {
2107  return time >= clip->GetStartTime() && time <= clip->GetEndTime(); });
2108 
2109  // When two clips are immediately next to each other, the GetEndTime() of the first clip
2110  // and the GetStartTime() of the second clip may not be exactly equal due to rounding errors.
2111  // If "time" is the end time of the first of two such clips, and the end time is slightly
2112  // less than the start time of the second clip, then the first rather than the
2113  // second clip is found by the above code. So correct this.
2114  if (p != clips.rend() && p != clips.rbegin() &&
2115  time == (*p)->GetEndTime() &&
2116  (*p)->SharesBoundaryWithNextClip(*(p-1))) {
2117  p--;
2118  }
2119 
2120  return p != clips.rend() ? *p : nullptr;
2121 }

References SortedClipArray().

Referenced by ClearAndPaste(), SelectHandle::Click(), GetEnvelopeAtTime(), GetSequenceAtTime(), and EffectEqualization::ProcessOne().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetClipByIndex() [1/2]

WaveClip * WaveTrack::GetClipByIndex ( int  index)

Definition at line 2189 of file WaveTrack.cpp.

2190 {
2191  if(index < (int)mClips.size())
2192  return mClips[index].get();
2193  else
2194  return nullptr;
2195 }

References mClips.

Referenced by GetClipByIndex(), and MergeClips().

Here is the caller graph for this function:

◆ GetClipByIndex() [2/2]

const WaveClip * WaveTrack::GetClipByIndex ( int  index) const

Definition at line 2197 of file WaveTrack.cpp.

2198 {
2199  return const_cast<WaveTrack&>(*this).GetClipByIndex(index);
2200 }

References GetClipByIndex().

Here is the call graph for this function:

◆ GetClipIndex()

int WaveTrack::GetClipIndex ( const WaveClip clip) const

Definition at line 2182 of file WaveTrack.cpp.

2183 {
2184  int result;
2185  FindClip(mClips, clip, &result);
2186  return result;
2187 }

References anonymous_namespace{WaveTrack.cpp}::FindClip(), and mClips.

Referenced by ClearAndPaste(), and UpdateLocationsCache().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetClips() [1/2]

WaveClipHolders& WaveTrack::GetClips ( )
inline

Definition at line 339 of file WaveTrack.h.

339 { return mClips; }

Referenced by SpectrumView::DoDraw(), WaveformView::DoDraw(), EffectEqualization::ProcessOne(), EffectReverse::ProcessOneWave(), and anonymous_namespace{ClipMenus.cpp}::TwoChannelsHaveSameBoundaries().

Here is the caller graph for this function:

◆ GetClips() [2/2]

const WaveClipConstHolders& WaveTrack::GetClips ( ) const
inline

Definition at line 340 of file WaveTrack.h.

341  { return reinterpret_cast< const WaveClipConstHolders& >( mClips ); }

◆ GetDisplayBounds()

void WaveTrack::GetDisplayBounds ( float *  min,
float *  max 
) const

Definition at line 257 of file WaveTrack.cpp.

258 {
259  *min = mDisplayMin;
260  *max = mDisplayMax;
261 }

References mDisplayMax, mDisplayMin, and min().

Referenced by WaveformVRulerControls::DoHandleWheelRotation(), WaveformVRulerControls::DoUpdateVRuler(), WaveformVZoomHandle::DoZoom(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), GetInfoCommand::SendTracks(), and EnvelopeHandle::WaveTrackHitTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEndTime()

double WaveTrack::GetEndTime ( ) const
overridevirtual

Get the time at which the last clip in the track ends, plus recorded stuff.

Returns
time in seconds, or zero if there are no clips in the track.

Implements Track.

Definition at line 1797 of file WaveTrack.cpp.

1798 {
1799  bool found = false;
1800  double best = 0.0;
1801 
1802  if (mClips.empty())
1803  return 0;
1804 
1805  for (const auto &clip : mClips)
1806  if (!found)
1807  {
1808  found = true;
1809  best = clip->GetEndTime();
1810  }
1811  else if (clip->GetEndTime() > best)
1812  best = clip->GetEndTime();
1813 
1814  return best;
1815 }

References mClips.

Referenced by AUPImportFileHandle::AddSilence(), EffectTruncSilence::Analyze(), Copy(), Effect::GetBounds(), GetMinMax(), GetRMS(), Mixer::MixSameRate(), Mixer::MixVariableRates(), Paste(), EffectChangeSpeed::Process(), EffectSBSMS::Process(), NyquistEffect::ProcessOne(), EffectStereoToMono::ProcessOne(), Effect::ProcessTrack(), GetInfoCommand::SendTracks(), SyncLockAdjust(), and Trim().

Here is the caller graph for this function:

◆ GetEnvelopeAtTime()

Envelope * WaveTrack::GetEnvelopeAtTime ( double  time)

Definition at line 2123 of file WaveTrack.cpp.

2124 {
2125  WaveClip* clip = GetClipAtTime(time);
2126  if (clip)
2127  return clip->GetEnvelope();
2128  else
2129  return NULL;
2130 }

References GetClipAtTime(), and WaveClip::GetEnvelope().

Referenced by EnvelopeHandle::WaveTrackHitTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEnvelopeValues()

void WaveTrack::GetEnvelopeValues ( double *  buffer,
size_t  bufferLen,
double  t0 
) const

Definition at line 2020 of file WaveTrack.cpp.

2022 {
2023  // The output buffer corresponds to an unbroken span of time which the callers expect
2024  // to be fully valid. As clips are processed below, the output buffer is updated with
2025  // envelope values from any portion of a clip, start, end, middle, or none at all.
2026  // Since this does not guarantee that the entire buffer is filled with values we need
2027  // to initialize the entire buffer to a default value.
2028  //
2029  // This does mean that, in the cases where a usable clip is located, the buffer value will
2030  // be set twice. Unfortunately, there is no easy way around this since the clips are not
2031  // stored in increasing time order. If they were, we could just track the time as the
2032  // buffer is filled.
2033  for (decltype(bufferLen) i = 0; i < bufferLen; i++)
2034  {
2035  buffer[i] = 1.0;
2036  }
2037 
2038  double startTime = t0;
2039  auto tstep = 1.0 / mRate;
2040  double endTime = t0 + tstep * bufferLen;
2041  for (const auto &clip: mClips)
2042  {
2043  // IF clip intersects startTime..endTime THEN...
2044  auto dClipStartTime = clip->GetStartTime();
2045  auto dClipEndTime = clip->GetEndTime();
2046  if ((dClipStartTime < endTime) && (dClipEndTime > startTime))
2047  {
2048  auto rbuf = buffer;
2049  auto rlen = bufferLen;
2050  auto rt0 = t0;
2051 
2052  if (rt0 < dClipStartTime)
2053  {
2054  // This is not more than the number of samples in
2055  // (endTime - startTime) which is bufferLen:
2056  auto nDiff = (sampleCount)floor((dClipStartTime - rt0) * mRate + 0.5);
2057  auto snDiff = nDiff.as_size_t();
2058  rbuf += snDiff;
2059  wxASSERT(snDiff <= rlen);
2060  rlen -= snDiff;
2061  rt0 = dClipStartTime;
2062  }
2063 
2064  if (rt0 + rlen*tstep > dClipEndTime)
2065  {
2066  auto nClipLen = clip->GetEndSample() - clip->GetStartSample();
2067 
2068  if (nClipLen <= 0) // Testing for bug 641, this problem is consistently '== 0', but doesn't hurt to check <.
2069  return;
2070 
2071  // This check prevents problem cited in http://bugzilla.audacityteam.org/show_bug.cgi?id=528#c11,
2072  // Gale's cross_fade_out project, which was already corrupted by bug 528.
2073  // This conditional prevents the previous write past the buffer end, in clip->GetEnvelope() call.
2074  // Never increase rlen here.
2075  // PRL bug 827: rewrote it again
2076  rlen = limitSampleBufferSize( rlen, nClipLen );
2077  rlen = std::min(rlen, size_t(floor(0.5 + (dClipEndTime - rt0) / tstep)));
2078  }
2079  // Samples are obtained for the purpose of rendering a wave track,
2080  // so quantize time
2081  clip->GetEnvelope()->GetValues(rbuf, rlen, rt0, tstep);
2082  }
2083  }
2084 }

References limitSampleBufferSize(), mClips, min(), and mRate.

Referenced by Mixer::MixSameRate(), and Mixer::MixVariableRates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetErrorOpening()

bool WaveTrack::GetErrorOpening ( )
overridevirtual

Reimplemented from Track.

Definition at line 1750 of file WaveTrack.cpp.

1751 {
1752  for (const auto &clip : mClips)
1753  if (clip->GetSequence()->GetErrorOpening())
1754  return true;
1755 
1756  return false;
1757 }

References mClips.

◆ GetGain()

float WaveTrack::GetGain ( ) const

Definition at line 377 of file WaveTrack.cpp.

378 {
379  return mGain;
380 }

References mGain.

Referenced by WaveTrackControls::GainSlider(), and GetInfoCommand::SendTracks().

Here is the caller graph for this function:

◆ GetIdealBlockSize()

size_t WaveTrack::GetIdealBlockSize ( )

Definition at line 1598 of file WaveTrack.cpp.

1599 {
1601 }

References Sequence::GetIdealBlockSize(), WaveClip::GetSequence(), and NewestOrNewClip().

Referenced by NyquistEffect::GetCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetIndependentSpectrogramSettings()

SpectrogramSettings & WaveTrack::GetIndependentSpectrogramSettings ( )

Definition at line 681 of file WaveTrack.cpp.

682 {
683  if (!mpSpectrumSettings)
685  std::make_unique<SpectrogramSettings>(SpectrogramSettings::defaults());
686  return *mpSpectrumSettings;
687 }

References SpectrogramSettings::defaults(), and mpSpectrumSettings.

Referenced by SpectrumVRulerControls::DoHandleWheelRotation(), and UseSpectralPrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetIntervals() [1/2]

auto WaveTrack::GetIntervals ( ) const
overridevirtual

Report times on the track where important intervals begin and end, for UI to snap to.

Some intervals may be empty, and no ordering of the intervals is assumed.

Reimplemented from Track.

Definition at line 345 of file WaveTrack.cpp.

346 {
347  return MakeIntervals<ConstIntervals>( mClips );
348 }

References mClips.

◆ GetIntervals() [2/2]

auto WaveTrack::GetIntervals ( )
overridevirtual

This overload exposes the extra data of the intervals as non-const This overload exposes the extra data of the intervals as non-const

Reimplemented from Track.

Definition at line 350 of file WaveTrack.cpp.

351 {
352  return MakeIntervals<Intervals>( mClips );
353 }

◆ GetKind()

TrackKind WaveTrack::GetKind ( ) const
inlineoverrideprivatevirtual

Reimplemented from Track.

Definition at line 579 of file WaveTrack.h.

579 { return TrackKind::Wave; }

References Wave.

◆ GetLastdBRange()

int WaveTrack::GetLastdBRange ( ) const
inline

Definition at line 516 of file WaveTrack.h.

516 { return mLastdBRange; }

Referenced by WaveformVRulerControls::DoUpdateVRuler().

Here is the caller graph for this function:

◆ GetLastScaleType()

int WaveTrack::GetLastScaleType ( ) const
inline

Definition at line 513 of file WaveTrack.h.

513 { return mLastScaleType; }

Referenced by WaveformVRulerControls::DoUpdateVRuler().

Here is the caller graph for this function:

◆ GetMaxBlockSize()

size_t WaveTrack::GetMaxBlockSize ( ) const

Definition at line 1578 of file WaveTrack.cpp.

1579 {
1580  decltype(GetMaxBlockSize()) maxblocksize = 0;
1581  for (const auto &clip : mClips)
1582  {
1583  maxblocksize = std::max(maxblocksize, clip->GetSequence()->GetMaxBlockSize());
1584  }
1585 
1586  if (maxblocksize == 0)
1587  {
1588  // We really need the maximum block size, so create a
1589  // temporary sequence to get it.
1590  maxblocksize = Sequence{ mpFactory, mFormat }.GetMaxBlockSize();
1591  }
1592 
1593  wxASSERT(maxblocksize > 0);
1594 
1595  return maxblocksize;
1596 }

References mClips, mFormat, and mpFactory.

Referenced by EffectNormalize::AnalyseTrackData(), EffectTruncSilence::Analyze(), CompareAudioCommand::Apply(), BlockGenerator::GenerateTrack(), GetBestBlockSize(), EffectCompressor::InitPass1(), EffectSBSMS::Process(), EffectNoiseReduction::Worker::ProcessOne(), EffectEqualization::ProcessOne(), EffectClickRemoval::ProcessOne(), EffectNoiseRemoval::ProcessOne(), EffectStereoToMono::ProcessOne(), EffectNormalize::ProcessOne(), EffectChangeSpeed::ProcessOne(), EffectSimpleMono::ProcessOne(), EffectTwoPassSimpleMono::ProcessOne(), EffectReverse::ProcessOneClip(), Effect::ProcessPass(), WaveTrackCache::SetTrack(), VoiceKey::TestDirectionChanges(), VoiceKey::TestEnergy(), and VoiceKey::TestSignChanges().

Here is the caller graph for this function:

◆ GetMinMax()

std::pair< float, float > WaveTrack::GetMinMax ( double  t0,
double  t1,
bool  mayThrow = true 
) const

Definition at line 1822 of file WaveTrack.cpp.

1824 {
1825  std::pair<float, float> results {
1826  // we need these at extremes to make sure we find true min and max
1827  FLT_MAX, -FLT_MAX
1828  };
1829  bool clipFound = false;
1830 
1831  if (t0 > t1) {
1832  if (mayThrow)
1834  return results;
1835  }
1836 
1837  if (t0 == t1)
1838  return results;
1839 
1840  for (const auto &clip: mClips)
1841  {
1842  if (t1 >= clip->GetStartTime() && t0 <= clip->GetEndTime())
1843  {
1844  clipFound = true;
1845  auto clipResults = clip->GetMinMax(t0, t1, mayThrow);
1846  if (clipResults.first < results.first)
1847  results.first = clipResults.first;
1848  if (clipResults.second > results.second)
1849  results.second = clipResults.second;
1850  }
1851  }
1852 
1853  if(!clipFound)
1854  {
1855  results = { 0.f, 0.f }; // sensible defaults if no clips found
1856  }
1857 
1858  return results;
1859 }

References GetEndTime(), mClips, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by EffectNormalize::AnalyseTrack(), and NyquistEffect::ProcessOne().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNumClips()

int WaveTrack::GetNumClips ( ) const

Definition at line 2202 of file WaveTrack.cpp.

2203 {
2204  return mClips.size();
2205 }

References mClips.

◆ GetNumSamples()

sampleCount WaveTrack::GetNumSamples ( ) const

Definition at line 444 of file WaveTrack.cpp.

445 {
446  sampleCount result{ 0 };
447 
448  for (const auto& clip : mClips)
449  result += clip->GetNumSamples();
450 
451  return result;
452 }

References mClips.

Referenced by TranscriptionToolBar::GetSamples().

Here is the caller graph for this function:

◆ GetOffset()

double WaveTrack::GetOffset ( ) const
overridevirtual

Implements Track.

Definition at line 206 of file WaveTrack.cpp.

207 {
208  return GetStartTime();
209 }

References GetStartTime().

Referenced by TranscriptionToolBar::GetSamples(), EditActions::Handler::OnSplitNew(), Reinit(), and SetOffset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetOldChannelGain()

float WaveTrack::GetOldChannelGain ( int  channel) const

Definition at line 424 of file WaveTrack.cpp.

425 {
426  return mOldGain[channel%2];
427 }

References mOldGain.

Referenced by AudioIoCallback::AddToOutputChannel(), and AudioIoCallback::TrackHasBeenFadedOut().

Here is the caller graph for this function:

◆ GetPan()

float WaveTrack::GetPan ( ) const

Definition at line 390 of file WaveTrack.cpp.

391 {
392  return mPan;
393 }

References mPan.

Referenced by GetChannel(), MixAndRender(), WaveTrackControls::PanSlider(), and GetInfoCommand::SendTracks().

Here is the caller graph for this function:

◆ GetRate()

double WaveTrack::GetRate ( ) const

◆ GetRMS()

float WaveTrack::GetRMS ( double  t0,
double  t1,
bool  mayThrow = true 
) const

Definition at line 1861 of file WaveTrack.cpp.

1862 {
1863  if (t0 > t1) {
1864  if (mayThrow)
1866  return 0.f;
1867  }
1868 
1869  if (t0 == t1)
1870  return 0.f;
1871 
1872  double sumsq = 0.0;
1873  sampleCount length = 0;
1874 
1875  for (const auto &clip: mClips)
1876  {
1877  // If t1 == clip->GetStartTime() or t0 == clip->GetEndTime(), then the clip
1878  // is not inside the selection, so we don't want it.
1879  // if (t1 >= clip->GetStartTime() && t0 <= clip->GetEndTime())
1880  if (t1 >= clip->GetStartTime() && t0 <= clip->GetEndTime())
1881  {
1882  sampleCount clipStart, clipEnd;
1883 
1884  float cliprms = clip->GetRMS(t0, t1, mayThrow);
1885 
1886  clip->TimeToSamplesClip(wxMax(t0, clip->GetStartTime()), &clipStart);
1887  clip->TimeToSamplesClip(wxMin(t1, clip->GetEndTime()), &clipEnd);
1888  sumsq += cliprms * cliprms * (clipEnd - clipStart).as_float();
1889  length += (clipEnd - clipStart);
1890  }
1891  }
1892  return length > 0 ? sqrt(sumsq / length.as_double()) : 0.0;
1893 }

References sampleCount::as_double(), GetEndTime(), mClips, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by EffectLoudness::GetTrackRMS(), and NyquistEffect::ProcessOne().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSampleFormat()

sampleFormat WaveTrack::GetSampleFormat ( ) const
inline

Definition at line 148 of file WaveTrack.h.

148 { return mFormat; }

Referenced by Copy(), and SyncLockAdjust().

Here is the caller graph for this function:

◆ GetSequenceAtTime()

Sequence * WaveTrack::GetSequenceAtTime ( double  time)

Definition at line 2132 of file WaveTrack.cpp.

2133 {
2134  WaveClip* clip = GetClipAtTime(time);
2135  if (clip)
2136  return clip->GetSequence();
2137  else
2138  return NULL;
2139 }

References GetClipAtTime(), and WaveClip::GetSequence().

Here is the call graph for this function:

◆ GetSpectrogramSettings() [1/2]

SpectrogramSettings & WaveTrack::GetSpectrogramSettings ( )

Definition at line 673 of file WaveTrack.cpp.

674 {
675  if (mpSpectrumSettings)
676  return *mpSpectrumSettings;
677  else
679 }

References SpectrogramSettings::defaults(), and mpSpectrumSettings.

Here is the call graph for this function:

◆ GetSpectrogramSettings() [2/2]

const SpectrogramSettings & WaveTrack::GetSpectrogramSettings ( ) const

Definition at line 665 of file WaveTrack.cpp.

666 {
667  if (mpSpectrumSettings)
668  return *mpSpectrumSettings;
669  else
671 }

References SpectrogramSettings::defaults(), and mpSpectrumSettings.

Referenced by SpectrumVRulerControls::DoUpdateVRuler(), SpectrumVZoomHandle::DoZoom(), anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum(), for(), anonymous_namespace{SelectHandle.cpp}::FrequencyToPosition(), WaveClip::GetSpectrogram(), GetSpectrumBounds(), SpectrumVRulerMenuTable::OnSpectrumScaleType(), anonymous_namespace{SelectHandle.cpp}::PositionToFrequency(), NyquistEffect::ProcessOne(), SelectHandle::SnapCenterOnce(), and SelectHandle::StartSnappingFreqSelection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSpectrumBounds()

void WaveTrack::GetSpectrumBounds ( float *  min,
float *  max 
) const

Definition at line 269 of file WaveTrack.cpp.

270 {
271  const double rate = GetRate();
272 
274  const SpectrogramSettings::ScaleType type = settings.scaleType;
275 
276  const float top = (rate / 2.);
277 
278  float bottom;
279  if (type == SpectrogramSettings::stLinear)
280  bottom = 0.0f;
281  else if (type == SpectrogramSettings::stPeriod) {
282  // special case
283  const auto half = settings.GetFFTLength() / 2;
284  // EAC returns no data for below this frequency:
285  const float bin2 = rate / half;
286  bottom = bin2;
287  }
288  else
289  // logarithmic, etc.
290  bottom = 1.0f;
291 
292  {
293  float spectrumMax = mSpectrumMax;
294  if (spectrumMax < 0)
295  spectrumMax = settings.maxFreq;
296  if (spectrumMax < 0)
297  *max = top;
298  else
299  *max = std::max(bottom, std::min(top, spectrumMax));
300  }
301 
302  {
303  float spectrumMin = mSpectrumMin;
304  if (spectrumMin < 0)
305  spectrumMin = settings.minFreq;
306  if (spectrumMin < 0)
307  *min = std::max(bottom, top / 1000.0f);
308  else
309  *min = std::max(bottom, std::min(top, spectrumMin));
310  }
311 }

References GetRate(), GetSpectrogramSettings(), min(), mSpectrumMax, mSpectrumMin, settings(), SpectrogramSettings::stLinear, and SpectrogramSettings::stPeriod.

Referenced by SpectrumVRulerControls::DoHandleWheelRotation(), SpectrumVRulerControls::DoUpdateVRuler(), SpectrumVZoomHandle::DoZoom(), anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum(), anonymous_namespace{SelectHandle.cpp}::FrequencyToPosition(), and anonymous_namespace{SelectHandle.cpp}::PositionToFrequency().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetStartTime()

double WaveTrack::GetStartTime ( ) const
overridevirtual

Get the time at which the first clip in the track starts.

Returns
time in seconds, or zero if there are no clips in the track

Implements Track.

Definition at line 1777 of file WaveTrack.cpp.

1778 {
1779  bool found = false;
1780  double best = 0.0;
1781 
1782  if (mClips.empty())
1783  return 0;
1784 
1785  for (const auto &clip : mClips)
1786  if (!found)
1787  {
1788  found = true;
1789  best = clip->GetStartTime();
1790  }
1791  else if (clip->GetStartTime() < best)
1792  best = clip->GetStartTime();
1793 
1794  return best;
1795 }

References mClips.

Referenced by Copy(), Effect::GetBounds(), GetOffset(), Mixer::MixSameRate(), Mixer::MixVariableRates(), EffectChangeSpeed::Process(), EffectSBSMS::Process(), EffectStereoToMono::ProcessOne(), GetInfoCommand::SendTracks(), and Trim().

Here is the caller graph for this function:

◆ GetWaveColorIndex()

int WaveTrack::GetWaveColorIndex ( ) const
inline

Definition at line 143 of file WaveTrack.h.

143 { return mWaveColorIndex; };

Referenced by CreateClip(), and InsertSilence().

Here is the caller graph for this function:

◆ GetWaveformSettings() [1/2]

WaveformSettings & WaveTrack::GetWaveformSettings ( )

Definition at line 719 of file WaveTrack.cpp.

720 {
721  // Create on demand
722  if (!mpWaveformSettings)
723  mpWaveformSettings = std::make_unique<WaveformSettings>(WaveformSettings::defaults());
724  return *mpWaveformSettings;
725 }

References WaveformSettings::defaults(), and mpWaveformSettings.

Here is the call graph for this function:

◆ GetWaveformSettings() [2/2]

const WaveformSettings & WaveTrack::GetWaveformSettings ( ) const

Definition at line 713 of file WaveTrack.cpp.

714 {
715  // Create on demand
716  return const_cast<WaveTrack*>(this)->GetWaveformSettings();
717 }

Referenced by WaveformView::DoDraw(), WaveformVRulerControls::DoHandleWheelRotation(), WaveformVRulerControls::DoUpdateVRuler(), WaveformVZoomHandle::DoZoom(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), for(), WaveformVRulerMenuTable::OnWaveformScaleType(), SetLastdBRange(), SetLastScaleType(), and EnvelopeHandle::WaveTrackHitTest().

Here is the caller graph for this function:

◆ HandleClear()

void WaveTrack::HandleClear ( double  t0,
double  t1,
bool  addCutLines,
bool  split 
)
Exception safety guarantee:
Strong

Definition at line 994 of file WaveTrack.cpp.

996 {
997  if (t1 < t0)
999 
1000  bool editClipCanMove = GetEditClipsCanMove();
1001 
1002  WaveClipPointers clipsToDelete;
1003  WaveClipHolders clipsToAdd;
1004 
1005  // We only add cut lines when deleting in the middle of a single clip
1006  // The cut line code is not really prepared to handle other situations
1007  if (addCutLines)
1008  {
1009  for (const auto &clip : mClips)
1010  {
1011  if (!clip->BeforeClip(t1) && !clip->AfterClip(t0) &&
1012  (clip->BeforeClip(t0) || clip->AfterClip(t1)))
1013  {
1014  addCutLines = false;
1015  break;
1016  }
1017  }
1018  }
1019 
1020  for (const auto &clip : mClips)
1021  {
1022  if (clip->BeforeClip(t0) && clip->AfterClip(t1))
1023  {
1024  // Whole clip must be deleted - remember this
1025  clipsToDelete.push_back(clip.get());
1026  }
1027  else if (!clip->BeforeClip(t1) && !clip->AfterClip(t0))
1028  {
1029  // Clip data is affected by command
1030  if (addCutLines)
1031  {
1032  // Don't modify this clip in place, because we want a strong
1033  // guarantee, and might modify another clip
1034  clipsToDelete.push_back( clip.get() );
1035  auto newClip = std::make_unique<WaveClip>( *clip, mpFactory, true );
1036  newClip->ClearAndAddCutLine( t0, t1 );
1037  clipsToAdd.push_back( std::move( newClip ) );
1038  }
1039  else
1040  {
1041  if (split) {
1042  // Three cases:
1043 
1044  if (clip->BeforeClip(t0)) {
1045  // Delete from the left edge
1046 
1047  // Don't modify this clip in place, because we want a strong
1048  // guarantee, and might modify another clip
1049  clipsToDelete.push_back( clip.get() );
1050  auto newClip = std::make_unique<WaveClip>( *clip, mpFactory, true );
1051  newClip->Clear(clip->GetStartTime(), t1);
1052  newClip->Offset(t1-clip->GetStartTime());
1053 
1054  clipsToAdd.push_back( std::move( newClip ) );
1055  }
1056  else if (clip->AfterClip(t1)) {
1057  // Delete to right edge
1058 
1059  // Don't modify this clip in place, because we want a strong
1060  // guarantee, and might modify another clip
1061  clipsToDelete.push_back( clip.get() );
1062  auto newClip = std::make_unique<WaveClip>( *clip, mpFactory, true );
1063  newClip->Clear(t0, clip->GetEndTime());
1064 
1065  clipsToAdd.push_back( std::move( newClip ) );
1066  }
1067  else {
1068  // Delete in the middle of the clip...we actually create two
1069  // NEW clips out of the left and right halves...
1070 
1071  // left
1072  clipsToAdd.push_back
1073  ( std::make_unique<WaveClip>( *clip, mpFactory, true ) );
1074  clipsToAdd.back()->Clear(t0, clip->GetEndTime());
1075 
1076  // right
1077  clipsToAdd.push_back
1078  ( std::make_unique<WaveClip>( *clip, mpFactory, true ) );
1079  WaveClip *const right = clipsToAdd.back().get();
1080  right->Clear(clip->GetStartTime(), t1);
1081  right->Offset(t1 - clip->GetStartTime());
1082 
1083  clipsToDelete.push_back(clip.get());
1084  }
1085  }
1086  else {
1087  // (We are not doing a split cut)
1088 
1089  // Don't modify this clip in place, because we want a strong
1090  // guarantee, and might modify another clip
1091  clipsToDelete.push_back( clip.get() );
1092  auto newClip = std::make_unique<WaveClip>( *clip, mpFactory, true );
1093 
1094  // clip->Clear keeps points < t0 and >= t1 via Envelope::CollapseRegion
1095  newClip->Clear(t0,t1);
1096 
1097  clipsToAdd.push_back( std::move( newClip ) );
1098  }
1099  }
1100  }
1101  }
1102 
1103  // Only now, change the contents of this track
1104  // use No-fail-guarantee for the rest
1105 
1106  for (const auto &clip : mClips)
1107  {
1108  if (clip->BeforeClip(t1))
1109  {
1110  // Clip is "behind" the region -- offset it unless we're splitting
1111  // or we're using the "don't move other clips" mode
1112  if (!split && editClipCanMove)
1113  clip->Offset(-(t1-t0));
1114  }
1115  }
1116 
1117  for (const auto &clip: clipsToDelete)
1118  {
1119  auto myIt = FindClip(mClips, clip);
1120  if (myIt != mClips.end())
1121  mClips.erase(myIt); // deletes the clip!
1122  else
1123  wxASSERT(false);
1124  }
1125 
1126  for (auto &clip: clipsToAdd)
1127  mClips.push_back(std::move(clip)); // transfer ownership
1128 }

References WaveClip::Clear(), anonymous_namespace{WaveTrack.cpp}::FindClip(), GetEditClipsCanMove(), mClips, mpFactory, WaveClip::Offset(), and THROW_INCONSISTENCY_EXCEPTION.

Referenced by Clear(), ClearAndAddCutLine(), ClearAndPaste(), and SplitDelete().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleXMLChild()

XMLTagHandler * WaveTrack::HandleXMLChild ( const wxChar *  tag)
overridevirtual

Implements XMLTagHandler.

Definition at line 1692 of file WaveTrack.cpp.

1693 {
1694  //
1695  // This is legacy code (1.2 and previous) and is not called for NEW projects!
1696  //
1697  if (!wxStrcmp(tag, wxT("sequence")) || !wxStrcmp(tag, wxT("envelope")))
1698  {
1699  // This is a legacy project, so set the cached offset
1701 
1702  // Legacy project file tracks are imported as one single wave clip
1703  if (!wxStrcmp(tag, wxT("sequence")))
1704  return NewestOrNewClip()->GetSequence();
1705  else if (!wxStrcmp(tag, wxT("envelope")))
1706  return NewestOrNewClip()->GetEnvelope();
1707  }
1708 
1709  // JKC... for 1.1.0, one step better than what we had, but still badly broken.
1710  //If we see a waveblock at this level, we'd better generate a sequence.
1711  if( !wxStrcmp( tag, wxT("waveblock" )))
1712  {
1713  // This is a legacy project, so set the cached offset
1715  Sequence *pSeq = NewestOrNewClip()->GetSequence();
1716  return pSeq;
1717  }
1718 
1719  //
1720  // This is for the NEW file format (post-1.2)
1721  //
1722  if (!wxStrcmp(tag, wxT("waveclip")))
1723  return CreateClip();
1724  else
1725  return NULL;
1726 }

References CreateClip(), WaveClip::GetEnvelope(), WaveClip::GetSequence(), mLegacyProjectFileOffset, NewestOrNewClip(), and WaveClip::SetOffset().

Here is the call graph for this function:

◆ HandleXMLEndTag()

void WaveTrack::HandleXMLEndTag ( const wxChar *  tag)
override

Definition at line 1685 of file WaveTrack.cpp.

1686 {
1687  // In case we opened a pre-multiclip project, we need to
1688  // simulate closing the waveclip tag.
1689  NewestOrNewClip()->HandleXMLEndTag(wxT("waveclip"));
1690 }

References WaveClip::HandleXMLEndTag(), and NewestOrNewClip().

Here is the call graph for this function:

◆ HandleXMLTag()

bool WaveTrack::HandleXMLTag ( const wxChar *  tag,
const wxChar **  attrs 
)
overridevirtual

Implements XMLTagHandler.

Definition at line 1614 of file WaveTrack.cpp.

1615 {
1616  if (!wxStrcmp(tag, wxT("wavetrack"))) {
1617  double dblValue;
1618  long nValue;
1619  while(*attrs) {
1620  const wxChar *attr = *attrs++;
1621  const wxChar *value = *attrs++;
1622 
1623  if (!value)
1624  break;
1625 
1626  const wxString strValue = value;
1627  if (!wxStrcmp(attr, wxT("rate")))
1628  {
1629  // mRate is an int, but "rate" in the project file is a float.
1630  if (!XMLValueChecker::IsGoodString(strValue) ||
1631  !Internat::CompatibleToDouble(strValue, &dblValue) ||
1632  (dblValue < 1.0) || (dblValue > 1000000.0)) // allow a large range to be read
1633  return false;
1634  mRate = lrint(dblValue);
1635  }
1636  else if (!wxStrcmp(attr, wxT("offset")) &&
1637  XMLValueChecker::IsGoodString(strValue) &&
1638  Internat::CompatibleToDouble(strValue, &dblValue))
1639  {
1640  // Offset is only relevant for legacy project files. The value
1641  // is cached until the actual WaveClip containing the legacy
1642  // track is created.
1643  mLegacyProjectFileOffset = dblValue;
1644  }
1645  else if (this->PlayableTrack::HandleXMLAttribute(attr, value))
1646  {}
1647  else if (this->Track::HandleCommonXMLAttribute(attr, strValue))
1648  ;
1649  else if (!wxStrcmp(attr, wxT("gain")) &&
1650  XMLValueChecker::IsGoodString(strValue) &&
1651  Internat::CompatibleToDouble(strValue, &dblValue))
1652  mGain = dblValue;
1653  else if (!wxStrcmp(attr, wxT("pan")) &&
1654  XMLValueChecker::IsGoodString(strValue) &&
1655  Internat::CompatibleToDouble(strValue, &dblValue) &&
1656  (dblValue >= -1.0) && (dblValue <= 1.0))
1657  mPan = dblValue;
1658  else if (!wxStrcmp(attr, wxT("channel")))
1659  {
1660  if (!XMLValueChecker::IsGoodInt(strValue) || !strValue.ToLong(&nValue) ||
1662  return false;
1663  mChannel = static_cast<Track::ChannelType>( nValue );
1664  }
1665  else if (!wxStrcmp(attr, wxT("linked")) &&
1666  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
1667  SetLinked(nValue != 0);
1668  else if (!wxStrcmp(attr, wxT("colorindex")) &&
1669  XMLValueChecker::IsGoodString(strValue) &&
1670  strValue.ToLong(&nValue))
1671  // Don't use SetWaveColorIndex as it sets the clips too.
1672  mWaveColorIndex = nValue;
1673  else if (!wxStrcmp(attr, wxT("sampleformat")) &&
1674  XMLValueChecker::IsGoodInt(strValue) &&
1675  strValue.ToLong(&nValue) &&
1677  mFormat = static_cast<sampleFormat>(nValue);
1678  } // while
1679  return true;
1680  }
1681 
1682  return false;
1683 }

References Internat::CompatibleToDouble(), Track::HandleCommonXMLAttribute(), PlayableTrack::HandleXMLAttribute(), XMLValueChecker::IsGoodInt(), XMLValueChecker::IsGoodString(), XMLValueChecker::IsValidChannel(), XMLValueChecker::IsValidSampleFormat(), lrint, Track::mChannel, mFormat, mGain, mLegacyProjectFileOffset, mPan, mRate, mWaveColorIndex, and Track::SetLinked().

Here is the call graph for this function:

◆ Init()

void WaveTrack::Init ( const WaveTrack orig)
private

Definition at line 142 of file WaveTrack.cpp.

143 {
144  PlayableTrack::Init(orig);
145  mpFactory = orig.mpFactory;
146 
147  mFormat = orig.mFormat;
149  mRate = orig.mRate;
150  mGain = orig.mGain;
151  mPan = orig.mPan;
152  mOldGain[0] = 0.0;
153  mOldGain[1] = 0.0;
155  SetName(orig.GetName());
156  mDisplayMin = orig.mDisplayMin;
157  mDisplayMax = orig.mDisplayMax;
158  mSpectrumMin = orig.mSpectrumMin;
159  mSpectrumMax = orig.mSpectrumMax;
160  mDisplayLocationsCache.clear();
161 }

References Track::GetDefaultName(), Track::GetName(), PlayableTrack::Init(), mDisplayLocationsCache, mDisplayMax, mDisplayMin, mFormat, mGain, mOldGain, mPan, mpFactory, mRate, mSpectrumMax, mSpectrumMin, mWaveColorIndex, Track::SetDefaultName(), and Track::SetName().

Referenced by Reinit(), and WaveTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsertSilence()

void WaveTrack::InsertSilence ( double  t,
double  len 
)
override
Exception safety guarantee:
Strong

Definition at line 1367 of file WaveTrack.cpp.

1368 {
1369  // Nothing to do, if length is zero.
1370  // Fixes Bug 1626
1371  if( len == 0 )
1372  return;
1373  if (len <= 0)
1375 
1376  if (mClips.empty())
1377  {
1378  // Special case if there is no clip yet
1379  auto clip = std::make_unique<WaveClip>(mpFactory, mFormat, mRate, this->GetWaveColorIndex());
1380  clip->InsertSilence(0, len);
1381  // use No-fail-guarantee
1382  mClips.push_back( std::move( clip ) );
1383  return;
1384  }
1385  else {
1386  // Assume at most one clip contains t
1387  const auto end = mClips.end();
1388  const auto it = std::find_if( mClips.begin(), end,
1389  [&](const WaveClipHolder &clip) { return clip->WithinClip(t); } );
1390 
1391  // use Strong-guarantee
1392  if (it != end)
1393  it->get()->InsertSilence(t, len);
1394 
1395  // use No-fail-guarantee
1396  for (const auto &clip : mClips)
1397  {
1398  if (clip->BeforeClip(t))
1399  clip->Offset(len);
1400  }
1401  }
1402 }

References GetWaveColorIndex(), mClips, mFormat, mpFactory, mRate, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by AUPImportFileHandle::AddSilence(), EffectSilence::GenerateTrack(), and FFmpegImportFileHandle::Import().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsEmpty()

bool WaveTrack::IsEmpty ( double  t0,
double  t1 
) const

Returns true if there are no WaveClips in the specified region.

Returns
true if no clips in the track overlap the specified time range, false otherwise.

Definition at line 464 of file WaveTrack.cpp.

465 {
466  if (t0 > t1)
467  return true;
468 
469  //wxPrintf("Searching for overlap in %.6f...%.6f\n", t0, t1);
470  for (const auto &clip : mClips)
471  {
472  if (!clip->BeforeClip(t1) && !clip->AfterClip(t0)) {
473  //wxPrintf("Overlapping clip: %.6f...%.6f\n",
474  // clip->GetStartTime(),
475  // clip->GetEndTime());
476  // We found a clip that overlaps this region
477  return false;
478  }
479  }
480  //wxPrintf("No overlap found\n");
481 
482  // Otherwise, no clips overlap this region
483  return true;
484 }

References mClips.

Referenced by Paste(), Generator::Process(), and SyncLockAdjust().

Here is the caller graph for this function:

◆ Join()

void WaveTrack::Join ( double  t0,
double  t1 
)
Exception safety guarantee:
Weak

Definition at line 1485 of file WaveTrack.cpp.

1486 {
1487  // Merge all WaveClips overlapping selection into one
1488 
1489  WaveClipPointers clipsToDelete;
1490  WaveClip *newClip;
1491 
1492  for (const auto &clip: mClips)
1493  {
1494  if (clip->GetStartTime() < t1-(1.0/mRate) &&
1495  clip->GetEndTime()-(1.0/mRate) > t0) {
1496 
1497  // Put in sorted order
1498  auto it = clipsToDelete.begin(), end = clipsToDelete.end();
1499  for (; it != end; ++it)
1500  if ((*it)->GetStartTime() > clip->GetStartTime())
1501  break;
1502  //wxPrintf("Insert clip %.6f at position %d\n", clip->GetStartTime(), i);
1503  clipsToDelete.insert(it, clip.get());
1504  }
1505  }
1506 
1507  //if there are no clips to DELETE, nothing to do
1508  if( clipsToDelete.size() == 0 )
1509  return;
1510 
1511  newClip = CreateClip();
1512  double t = clipsToDelete[0]->GetOffset();
1513  newClip->SetOffset(t);
1514  for (const auto &clip : clipsToDelete)
1515  {
1516  //wxPrintf("t=%.6f adding clip (offset %.6f, %.6f ... %.6f)\n",
1517  // t, clip->GetOffset(), clip->GetStartTime(), clip->GetEndTime());
1518 
1519  if (clip->GetOffset() - t > (1.0 / mRate)) {
1520  double addedSilence = (clip->GetOffset() - t);
1521  //wxPrintf("Adding %.6f seconds of silence\n");
1522  auto offset = clip->GetOffset();
1523  auto value = clip->GetEnvelope()->GetValue( offset );
1524  newClip->AppendSilence( addedSilence, value );
1525  t += addedSilence;
1526  }
1527 
1528  //wxPrintf("Pasting at %.6f\n", t);
1529  newClip->Paste(t, clip);
1530 
1531  t = newClip->GetEndTime();
1532 
1533  auto it = FindClip(mClips, clip);
1534  mClips.erase(it); // deletes the clip
1535  }
1536 }

References WaveClip::AppendSilence(), CreateClip(), anonymous_namespace{WaveTrack.cpp}::FindClip(), WaveClip::GetEndTime(), mClips, mRate, WaveClip::Paste(), and WaveClip::SetOffset().

Referenced by LabelEditActions::Handler::OnJoinLabels(), and EffectEqualization::ProcessOne().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LongSamplesToTime()

double WaveTrack::LongSamplesToTime ( sampleCount  pos) const

Convert correctly between a number of samples and an (absolute) time in seconds.

Parameters
posThe time number of samples from the start of the track to convert.
Returns
The time in seconds.

Definition at line 1772 of file WaveTrack.cpp.

1773 {
1774  return pos.as_double() / mRate;
1775 }

References sampleCount::as_double(), and mRate.

Referenced by AUPImportFileHandle::AddSilence(), anonymous_namespace{SampleHandle.cpp}::adjustTime(), EffectTruncSilence::Analyze(), CompareAudioCommand::Apply(), EffectAutoDuck::ApplyDuckFade(), ClearAndPaste(), EffectTruncSilence::DoRemoval(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), EffectSBSMS::Finalize(), EditActions::Handler::OnSplitNew(), EffectAutoDuck::Process(), EffectRepeat::Process(), EffectEqualization::ProcessOne(), EffectFindClipping::ProcessOne(), EffectChangeSpeed::ProcessOne(), EffectReverse::ProcessOneWave(), and SplitAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Merge()

void WaveTrack::Merge ( const Track orig)
overridevirtual

Reimplemented from PlayableTrack.

Definition at line 186 of file WaveTrack.cpp.

187 {
188  orig.TypeSwitch( [&](const WaveTrack *pwt) {
189  const WaveTrack &wt = *pwt;
190  mGain = wt.mGain;
191  mPan = wt.mPan;
195  ? std::make_unique<SpectrogramSettings>(*wt.mpSpectrumSettings) : nullptr);
197  (wt.mpWaveformSettings ? std::make_unique<WaveformSettings>(*wt.mpWaveformSettings) : nullptr);
198  });
199  PlayableTrack::Merge(orig);
200 }

References mDisplayMax, mDisplayMin, PlayableTrack::Merge(), mGain, mPan, mpSpectrumSettings, mpWaveformSettings, SetSpectrogramSettings(), SetWaveformSettings(), and Track::TypeSwitch().

Referenced by WaveTrackMenuTable::OnMergeStereo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MergeClips()

void WaveTrack::MergeClips ( int  clipidx1,
int  clipidx2 
)
Exception safety guarantee:
Strong

Definition at line 2460 of file WaveTrack.cpp.

2461 {
2462  WaveClip* clip1 = GetClipByIndex(clipidx1);
2463  WaveClip* clip2 = GetClipByIndex(clipidx2);
2464 
2465  if (!clip1 || !clip2) // Could happen if one track of a linked pair had a split and the other didn't.
2466  return; // Don't throw, just do nothing.
2467 
2468  // Append data from second clip to first clip
2469  // use Strong-guarantee
2470  clip1->Paste(clip1->GetEndTime(), clip2);
2471 
2472  // use No-fail-guarantee for the rest
2473  // Delete second clip
2474  auto it = FindClip(mClips, clip2);
2475  mClips.erase(it);
2476 }

References anonymous_namespace{WaveTrack.cpp}::FindClip(), GetClipByIndex(), WaveClip::GetEndTime(), mClips, and WaveClip::Paste().

Referenced by ClearAndPaste().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NewestOrNewClip()

WaveClip * WaveTrack::NewestOrNewClip ( )

Get access to the most recently added clip, or create a clip, if there is not already one. THIS IS NOT NECESSARILY RIGHTMOST.

Returns
a pointer to the most recently added WaveClip

Definition at line 2147 of file WaveTrack.cpp.

2148 {
2149  if (mClips.empty()) {
2150  WaveClip *clip = CreateClip();
2151  clip->SetOffset(mOffset);
2152  return clip;
2153  }
2154  else
2155  return mClips.back().get();
2156 }

References CreateClip(), mClips, Track::mOffset, and WaveClip::SetOffset().

Referenced by GetIdealBlockSize(), HandleXMLChild(), and HandleXMLEndTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Paste()

void WaveTrack::Paste ( double  t0,
const Track src 
)
override
Exception safety guarantee:
Weak

Definition at line 1171 of file WaveTrack.cpp.

1172 {
1173  bool editClipCanMove = GetEditClipsCanMove();
1174 
1175  bool bOk = src && src->TypeSwitch< bool >( [&](const WaveTrack *other) {
1176 
1177  //
1178  // Pasting is a bit complicated, because with the existence of multiclip mode,
1179  // we must guess the behaviour the user wants.
1180  //
1181  // Currently, two modes are implemented:
1182  //
1183  // - If a single clip should be pasted, and it should be pasted inside another
1184  // clip, no NEW clips are generated. The audio is simply inserted.
1185  // This resembles the old (pre-multiclip support) behaviour. However, if
1186  // the clip is pasted outside of any clip, a NEW clip is generated. This is
1187  // the only behaviour which is different to what was done before, but it
1188  // shouldn't confuse users too much.
1189  //
1190  // - If multiple clips should be pasted, or a single clip that does not fill
1191  // the duration of the pasted track, these are always pasted as single
1192  // clips, and the current clip is split, when necessary. This may seem
1193  // strange at first, but it probably is better than trying to auto-merge
1194  // anything. The user can still merge the clips by hand (which should be a
1195  // simple command reachable by a hotkey or single mouse click).
1196  //
1197 
1198  if (other->GetNumClips() == 0)
1199  return true;
1200 
1201  //wxPrintf("paste: we have at least one clip\n");
1202 
1203  bool singleClipMode = (other->GetNumClips() == 1 &&
1204  other->GetStartTime() == 0.0);
1205 
1206  const double insertDuration = other->GetEndTime();
1207  if( insertDuration != 0 && insertDuration < 1.0/mRate )
1208  // PRL: I added this check to avoid violations of preconditions in other WaveClip and Sequence
1209  // methods, but allow the value 0 so I don't subvert the purpose of commit
1210  // 739422ba70ceb4be0bb1829b6feb0c5401de641e which causes append-recording always to make
1211  // a new clip.
1212  return true;
1213 
1214  //wxPrintf("Check if we need to make room for the pasted data\n");
1215 
1216  // Make room for the pasted data
1217  if (editClipCanMove) {
1218  if (!singleClipMode) {
1219  // We need to insert multiple clips, so split the current clip and
1220  // move everything to the right, then try to paste again
1221  if (!IsEmpty(t0, GetEndTime())) {
1222  auto tmp = Cut(t0, GetEndTime()+1.0/mRate);
1223  Paste(t0 + insertDuration, tmp.get());
1224  }
1225  }
1226  else {
1227  // We only need to insert one single clip, so just move all clips
1228  // to the right of the paste point out of the way
1229  for (const auto &clip : mClips)
1230  {
1231  if (clip->GetStartTime() > t0-(1.0/mRate))
1232  clip->Offset(insertDuration);
1233  }
1234  }
1235  }
1236 
1237  if (singleClipMode)
1238  {
1239  // Single clip mode
1240  // wxPrintf("paste: checking for single clip mode!\n");
1241 
1242  WaveClip *insideClip = NULL;
1243 
1244  for (const auto &clip : mClips)
1245  {
1246  if (editClipCanMove)
1247  {
1248  if (clip->WithinClip(t0))
1249  {
1250  //wxPrintf("t0=%.6f: inside clip is %.6f ... %.6f\n",
1251  // t0, clip->GetStartTime(), clip->GetEndTime());
1252  insideClip = clip.get();
1253  break;
1254  }
1255  }
1256  else
1257  {
1258  // If clips are immovable we also allow prepending to clips
1259  if (clip->WithinClip(t0) ||
1260  TimeToLongSamples(t0) == clip->GetStartSample())
1261  {
1262  insideClip = clip.get();
1263  break;
1264  }
1265  }
1266  }
1267 
1268  if (insideClip)
1269  {
1270  // Exhibit traditional behaviour
1271  //wxPrintf("paste: traditional behaviour\n");
1272  if (!editClipCanMove)
1273  {
1274  // We did not move other clips out of the way already, so
1275  // check if we can paste without having to move other clips
1276  for (const auto &clip : mClips)
1277  {
1278  if (clip->GetStartTime() > insideClip->GetStartTime() &&
1279  insideClip->GetEndTime() + insertDuration >
1280  clip->GetStartTime())
1281  // Strong-guarantee in case of this path
1282  // not that it matters.
1284  XO("There is not enough room available to paste the selection"),
1285  XO("Warning"),
1286  "Error:_Insufficient_space_in_track"
1287  };
1288  }
1289  }
1290 
1291  insideClip->Paste(t0, other->GetClipByIndex(0));
1292  return true;
1293  }
1294 
1295  // Just fall through and exhibit NEW behaviour
1296 
1297  }
1298 
1299  // Insert NEW clips
1300  //wxPrintf("paste: multi clip mode!\n");
1301 
1302  if (!editClipCanMove && !IsEmpty(t0, t0+insertDuration-1.0/mRate))
1303  // Strong-guarantee in case of this path
1304  // not that it matters.
1306  XO("There is not enough room available to paste the selection"),
1307  XO("Warning"),
1308  "Error:_Insufficient_space_in_track"
1309  };
1310 
1311  for (const auto &clip : other->mClips)
1312  {
1313  // AWD Oct. 2009: Don't actually paste in placeholder clips
1314  if (!clip->GetIsPlaceholder())
1315  {
1316  auto newClip =
1317  std::make_unique<WaveClip>( *clip, mpFactory, true );
1318  newClip->Resample(mRate);
1319  newClip->Offset(t0);
1320  newClip->MarkChanged();
1321  mClips.push_back(std::move(newClip)); // transfer ownership
1322  }
1323  }
1324  return true;
1325  } );
1326 
1327  if( !bOk )
1328  // THROW_INCONSISTENCY_EXCEPTION; // ?
1329  (void)0;// Empty if intentional.
1330 }

References Cut(), GetEditClipsCanMove(), WaveClip::GetEndTime(), GetEndTime(), WaveClip::GetStartTime(), IsEmpty(), mClips, mpFactory, mRate, WaveClip::Paste(), TimeToLongSamples(), Track::TypeSwitch(), and XO.

Referenced by ClearAndPaste(), EffectRepeat::Process(), EffectEqualization::ProcessOne(), EffectStereoToMono::ProcessOne(), EffectPaulstretch::ProcessOne(), and SyncLockAdjust().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PasteInto()

Track::Holder WaveTrack::PasteInto ( AudacityProject ) const
overridevirtual

Find or create the destination track for a paste, maybe in a different project.

Returns
A smart pointer to the track; its use_count() can tell whether it is new

Implements Track.

Definition at line 336 of file WaveTrack.cpp.

337 {
338  auto &trackFactory = WaveTrackFactory::Get( project );
339  auto &pSampleBlockFactory = trackFactory.GetSampleBlockFactory();
340  auto pNewTrack = EmptyCopy( pSampleBlockFactory );
341  pNewTrack->Paste(0.0, this);
342  return pNewTrack;
343 }

References EmptyCopy(), and WaveTrackFactory::Get().

Here is the call graph for this function:

◆ Reinit()

void WaveTrack::Reinit ( const WaveTrack orig)

Definition at line 163 of file WaveTrack.cpp.

164 {
165  Init(orig);
166 
167  {
168  auto &settings = orig.mpSpectrumSettings;
169  if (settings)
170  mpSpectrumSettings = std::make_unique<SpectrogramSettings>(*settings);
171  else
172  mpSpectrumSettings.reset();
173  }
174 
175  {
176  auto &settings = orig.mpWaveformSettings;
177  if (settings)
178  mpWaveformSettings = std::make_unique<WaveformSettings>(*settings);
179  else
180  mpWaveformSettings.reset();
181  }
182 
183  this->SetOffset(orig.GetOffset());
184 }

References GetOffset(), Init(), mpSpectrumSettings, mpWaveformSettings, SetOffset(), and settings().

Referenced by ProjectAudioManager::DoRecord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveAndReturnClip()

std::shared_ptr< WaveClip > WaveTrack::RemoveAndReturnClip ( WaveClip clip)

Definition at line 968 of file WaveTrack.cpp.

969 {
970  // Be clear about who owns the clip!!
971  auto it = FindClip(mClips, clip);
972  if (it != mClips.end()) {
973  auto result = std::move(*it); // Array stops owning the clip, before we shrink it
974  mClips.erase(it);
975  return result;
976  }
977  else
978  return {};
979 }

References anonymous_namespace{WaveTrack.cpp}::FindClip(), and mClips.

Referenced by EffectReverse::ProcessOneWave().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveCutLine()

bool WaveTrack::RemoveCutLine ( double  cutLinePosition)

Definition at line 2450 of file WaveTrack.cpp.

2451 {
2452  for (const auto &clip : mClips)
2453  if (clip->RemoveCutLine(cutLinePosition))
2454  return true;
2455 
2456  return false;
2457 }

References mClips.

◆ Resample()

void WaveTrack::Resample ( int  rate,
ProgressDialog progress = NULL 
)
Exception safety guarantee:
Weak – Partial completion may leave clips at differing sample rates!

Definition at line 2480 of file WaveTrack.cpp.

2481 {
2482  for (const auto &clip : mClips)
2483  clip->Resample(rate, progress);
2484 
2485  mRate = rate;
2486 }

References mClips, and mRate.

◆ RightmostOrNewClip()

WaveClip * WaveTrack::RightmostOrNewClip ( )

Get access to the last (rightmost) clip, or create a clip, if there is not already one.

Returns
a pointer to a WaveClip at the end of the track
Exception safety guarantee:
No-fail

Definition at line 2159 of file WaveTrack.cpp.

2160 {
2161  if (mClips.empty()) {
2162  WaveClip *clip = CreateClip();
2163  clip->SetOffset(mOffset);
2164  return clip;
2165  }
2166  else
2167  {
2168  auto it = mClips.begin();
2169  WaveClip *rightmost = (*it++).get();
2170  double maxOffset = rightmost->GetOffset();
2171  for (auto end = mClips.end(); it != end; ++it)
2172  {
2173  WaveClip *clip = it->get();
2174  double offset = clip->GetOffset();
2175  if (maxOffset < offset)
2176  maxOffset = offset, rightmost = clip;
2177  }
2178  return rightmost;
2179  }
2180 }

References CreateClip(), WaveClip::GetOffset(), mClips, Track::mOffset, and WaveClip::SetOffset().

Referenced by AUPImportFileHandle::AddSamples(), Append(), Flush(), and AUPImportFileHandle::HandleEnvelope().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Set()

void WaveTrack::Set ( constSamplePtr  buffer,
sampleFormat  format,
sampleCount  start,
size_t  len 
)
Exception safety guarantee:
Weak

Definition at line 1978 of file WaveTrack.cpp.

1980 {
1981  for (const auto &clip: mClips)
1982  {
1983  auto clipStart = clip->GetStartSample();
1984  auto clipEnd = clip->GetEndSample();
1985 
1986  if (clipEnd > start && clipStart < start+len)
1987  {
1988  // Clip sample region and Get/Put sample region overlap
1989  auto samplesToCopy =
1990  std::min( start+len - clipStart, clip->GetNumSamples() );
1991  auto startDelta = clipStart - start;
1992  decltype(startDelta) inclipDelta = 0;
1993  if (startDelta < 0)
1994  {
1995  inclipDelta = -startDelta; // make positive value
1996  samplesToCopy -= inclipDelta;
1997  // samplesToCopy is now either len or
1998  // (clipEnd - clipStart) - (start - clipStart)
1999  // == clipEnd - start > 0
2000  // samplesToCopy is not more than len
2001  //
2002  startDelta = 0;
2003  // startDelta is zero
2004  }
2005  else {
2006  // startDelta is nonnegative and less than len
2007  // samplesToCopy is positive and not more than len
2008  }
2009 
2010  clip->SetSamples(
2011  (constSamplePtr)(((const char*)buffer) +
2012  startDelta.as_size_t() *
2013  SAMPLE_SIZE(format)),
2014  format, inclipDelta, samplesToCopy.as_size_t() );
2015  clip->MarkChanged();
2016  }
2017  }
2018 }

References format, mClips, min(), and SAMPLE_SIZE.

Referenced by EffectAutoDuck::ApplyDuckFade(), EffectTruncSilence::DoRemoval(), EffectClickRemoval::ProcessOne(), EffectRepair::ProcessOne(), EffectNormalize::ProcessOne(), EffectSimpleMono::ProcessOne(), EffectTwoPassSimpleMono::ProcessOne(), EffectReverse::ProcessOneClip(), and Effect::ProcessTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDisplayBounds()

void WaveTrack::SetDisplayBounds ( float  min,
float  max 
) const

Definition at line 263 of file WaveTrack.cpp.

264 {
265  mDisplayMin = min;
266  mDisplayMax = max;
267 }

References mDisplayMax, mDisplayMin, and min().

Referenced by WaveformVRulerControls::DoUpdateVRuler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetGain()

void WaveTrack::SetGain ( float  newGain)

Definition at line 382 of file WaveTrack.cpp.

383 {
384  if (mGain != newGain) {
385  mGain = newGain;
386  Notify();
387  }
388 }

References mGain, and Track::Notify().

Referenced by MixerTrackCluster::HandleSliderGain().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetLastdBRange()

void WaveTrack::SetLastdBRange ( ) const

Definition at line 252 of file WaveTrack.cpp.

253 {
255 }

References WaveformSettings::dBRange, GetWaveformSettings(), and mLastdBRange.

Referenced by WaveformVRulerControls::DoUpdateVRuler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetLastScaleType()

void WaveTrack::SetLastScaleType ( ) const

Definition at line 247 of file WaveTrack.cpp.

248 {
250 }

References GetWaveformSettings(), mLastScaleType, and WaveformSettings::scaleType.

Referenced by WaveformVRulerControls::DoUpdateVRuler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetOffset()

void WaveTrack::SetOffset ( double  o)
overridevirtual
Exception safety guarantee:
No-fail

Reimplemented from Track.

Definition at line 212 of file WaveTrack.cpp.

213 {
214  double delta = o - GetOffset();
215 
216  for (const auto &clip : mClips)
217  // assume No-fail-guarantee
218  clip->SetOffset(clip->GetOffset() + delta);
219 
220  mOffset = o;
221 }

References GetOffset(), mClips, and Track::mOffset.

Referenced by Reinit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetOldChannelGain()

void WaveTrack::SetOldChannelGain ( int  channel,
float  gain 
)

Definition at line 429 of file WaveTrack.cpp.

430 {
431  mOldGain[channel % 2] = gain;
432 }

References mOldGain.

Referenced by AudioIoCallback::AddToOutputChannel().

Here is the caller graph for this function:

◆ SetPan()

void WaveTrack::SetPan ( float  newPan)
overridevirtual

Reimplemented from Track.

Definition at line 395 of file WaveTrack.cpp.

396 {
397  if (newPan > 1.0)
398  newPan = 1.0;
399  else if (newPan < -1.0)
400  newPan = -1.0;
401 
402  if ( mPan != newPan ) {
403  mPan = newPan;
404  Notify();
405  }
406 }

References mPan, and Track::Notify().

Referenced by MixerTrackCluster::HandleSliderPan(), WaveTrackMenuTable::OnMergeStereo(), and SetPanFromChannelType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPanFromChannelType()

void WaveTrack::SetPanFromChannelType ( )
overridevirtual

Reimplemented from Track.

Definition at line 239 of file WaveTrack.cpp.

240 {
242  SetPan( -1.0f );
243  else if( mChannel == Track::RightChannel )
244  SetPan( 1.0f );
245 };

References Track::LeftChannel, Track::mChannel, Track::RightChannel, and SetPan().

Here is the call graph for this function:

◆ SetRate()

void WaveTrack::SetRate ( double  newRate)

Definition at line 365 of file WaveTrack.cpp.

366 {
367  wxASSERT( newRate > 0 );
368  newRate = std::max( 1.0, newRate );
369  auto ratio = mRate / newRate;
370  mRate = (int) newRate;
371  for (const auto &clip : mClips) {
372  clip->SetRate((int)newRate);
373  clip->SetOffset( clip->GetOffset() * ratio );
374  }
375 }

References mClips, and mRate.

Referenced by NyquistEffect::ProcessOne().

Here is the caller graph for this function:

◆ SetSpectrogramSettings()

void WaveTrack::SetSpectrogramSettings ( std::unique_ptr< SpectrogramSettings > &&  pSettings)

Definition at line 689 of file WaveTrack.cpp.

690 {
691  if (mpSpectrumSettings != pSettings) {
692  mpSpectrumSettings = std::move(pSettings);
693  }
694 }

References mpSpectrumSettings.

Referenced by Merge().

Here is the caller graph for this function:

◆ SetSpectrumBounds()

void WaveTrack::SetSpectrumBounds ( float  min,
float  max 
) const

Definition at line 313 of file WaveTrack.cpp.

314 {
315  mSpectrumMin = min;
316  mSpectrumMax = max;
317 }

References min(), mSpectrumMax, and mSpectrumMin.

Here is the call graph for this function:

◆ SetWaveColorIndex()

void WaveTrack::SetWaveColorIndex ( int  colorIndex)
Exception safety guarantee:
Strong

Definition at line 437 of file WaveTrack.cpp.

438 {
439  for (const auto &clip : mClips)
440  clip->SetColourIndex( colorIndex );
441  mWaveColorIndex = colorIndex;
442 }

References mClips, and mWaveColorIndex.

Referenced by SetTrackVisualsCommand::ApplyInner().

Here is the caller graph for this function:

◆ SetWaveformSettings()

void WaveTrack::SetWaveformSettings ( std::unique_ptr< WaveformSettings > &&  pSettings)

Definition at line 727 of file WaveTrack.cpp.

728 {
729  if (mpWaveformSettings != pSettings) {
730  mpWaveformSettings = std::move(pSettings);
731  }
732 }

References mpWaveformSettings.

Referenced by Merge().

Here is the caller graph for this function:

◆ Silence()

void WaveTrack::Silence ( double  t0,
double  t1 
)
override

Definition at line 1332 of file WaveTrack.cpp.

1333 {
1334  if (t1 < t0)
1336 
1337  auto start = (sampleCount)floor(t0 * mRate + 0.5);
1338  auto len = (sampleCount)floor(t1 * mRate + 0.5) - start;
1339 
1340  for (const auto &clip : mClips)
1341  {
1342  auto clipStart = clip->GetStartSample();
1343  auto clipEnd = clip->GetEndSample();
1344 
1345  if (clipEnd > start && clipStart < start+len)
1346  {
1347  // Clip sample region and Get/Put sample region overlap
1348  auto samplesToCopy = start+len - clipStart;
1349  if (samplesToCopy > clip->GetNumSamples())
1350  samplesToCopy = clip->GetNumSamples();
1351  auto startDelta = clipStart - start;
1352  decltype(startDelta) inclipDelta = 0;
1353  if (startDelta < 0)
1354  {
1355  inclipDelta = -startDelta; // make positive value
1356  samplesToCopy -= inclipDelta;
1357  startDelta = 0;
1358  }
1359 
1360  clip->GetSequence()->SetSilence(inclipDelta, samplesToCopy);
1361  clip->MarkChanged();
1362  }
1363  }
1364 }

References mClips, mRate, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by LabelEditActions::Handler::OnSilenceLabels(), EditActions::Handler::OnSplitCut(), LabelEditActions::Handler::OnSplitCutLabels(), and LabelEditActions::Handler::OnSplitDeleteLabels().

Here is the caller graph for this function:

◆ SortedClipArray() [1/2]

WaveClipPointers WaveTrack::SortedClipArray ( )

◆ SortedClipArray() [2/2]

WaveClipConstPointers WaveTrack::SortedClipArray ( ) const

Definition at line 2507 of file WaveTrack.cpp.

2508 {
2509  return FillSortedClipArray<WaveClipConstPointers>(mClips);
2510 }

References mClips.

◆ Split()

void WaveTrack::Split ( double  t0,
double  t1 
)
Exception safety guarantee:
Weak

Definition at line 2300 of file WaveTrack.cpp.

2301 {
2302  SplitAt( t0 );
2303  if( t0 != t1 )
2304  SplitAt( t1 );
2305 }

References SplitAt().

Referenced by LabelEditActions::Handler::OnSplitLabels().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SplitAt()

void WaveTrack::SplitAt ( double  t)
Exception safety guarantee:
Weak

Definition at line 2308 of file WaveTrack.cpp.

2309 {
2310  for (const auto &c : mClips)
2311  {
2312  if (c->WithinClip(t))
2313  {
2314  t = LongSamplesToTime(TimeToLongSamples(t)); // put t on a sample
2315  auto newClip = std::make_unique<WaveClip>( *c, mpFactory, true );
2316  c->Clear(t, c->GetEndTime());
2317  newClip->Clear(c->GetStartTime(), t);
2318 
2319  //offset the NEW clip by the splitpoint (noting that it is already offset to c->GetStartTime())
2320  sampleCount here = llrint(floor(((t - c->GetStartTime()) * mRate) + 0.5));
2321  newClip->Offset(here.as_double()/(double)mRate);
2322  // This could invalidate the iterators for the loop! But we return
2323  // at once so it's okay
2324  mClips.push_back(std::move(newClip)); // transfer ownership
2325  return;
2326  }
2327  }
2328 }

References sampleCount::as_double(), LongSamplesToTime(), mClips, mpFactory, mRate, and TimeToLongSamples().

Referenced by ClearAndPaste(), EffectReverse::ProcessOneWave(), and Split().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SplitCut()

Track::Holder WaveTrack::SplitCut ( double  t0,
double  t1 
)
Exception safety guarantee:
Strong

Definition at line 499 of file WaveTrack.cpp.

500 {
501  if (t1 < t0)
503 
504  // SplitCut is the same as 'Copy', then 'SplitDelete'
505  auto tmp = Copy(t0, t1);
506 
507  SplitDelete(t0, t1);
508 
509  return tmp;
510 }

References Copy(), SplitDelete(), and THROW_INCONSISTENCY_EXCEPTION.

Referenced by EditActions::Handler::OnSplitCut(), LabelEditActions::Handler::OnSplitCutLabels(), and EditActions::Handler::OnSplitNew().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SplitDelete()

void WaveTrack::SplitDelete ( double  t0,
double  t1 
)
Exception safety guarantee:
Strong

Definition at line 926 of file WaveTrack.cpp.

927 {
928  bool addCutLines = false;
929  bool split = true;
930  HandleClear(t0, t1, addCutLines, split);
931 }

References HandleClear().

Referenced by Disjoin(), EffectSBSMS::Finalize(), EditActions::Handler::OnSplitDelete(), LabelEditActions::Handler::OnSplitDeleteLabels(), EffectChangeSpeed::ProcessOne(), SplitCut(), and Trim().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SyncLockAdjust()

void WaveTrack::SyncLockAdjust ( double  oldT1,
double  newT1 
)
overridevirtual

Reimplemented from Track.

Definition at line 1130 of file WaveTrack.cpp.

1131 {
1132  if (newT1 > oldT1) {
1133  // Insert space within the track
1134 
1135  // JKC: This is a rare case where using >= rather than > on a float matters.
1136  // GetEndTime() looks through the clips and may give us EXACTLY the same
1137  // value as T1, when T1 was set to be at the end of one of those clips.
1138  if (oldT1 >= GetEndTime())
1139  return;
1140 
1141  // If track is empty at oldT1 insert whitespace; otherwise, silence
1142  if (IsEmpty(oldT1, oldT1))
1143  {
1144  // Check if clips can move
1145  bool clipsCanMove = true;
1146  gPrefs->Read(wxT("/GUI/EditClipCanMove"), &clipsCanMove);
1147  if (clipsCanMove) {
1148  auto tmp = Cut (oldT1, GetEndTime() + 1.0/GetRate());
1149 
1150  Paste(newT1, tmp.get());
1151  }
1152  return;
1153  }
1154  else {
1155  // AWD: Could just use InsertSilence() on its own here, but it doesn't
1156  // follow EditClipCanMove rules (Paste() does it right)
1157  auto tmp = std::make_shared<WaveTrack>(
1159 
1160  tmp->InsertSilence(0.0, newT1 - oldT1);
1161  tmp->Flush();
1162  Paste(oldT1, tmp.get());
1163  }
1164  }
1165  else if (newT1 < oldT1) {
1166  Clear(newT1, oldT1);
1167  }
1168 }

References Clear(), Cut(), GetEndTime(), GetRate(), GetSampleFormat(), gPrefs, IsEmpty(), mpFactory, and Paste().

Here is the call graph for this function:

◆ TimeToLongSamples()

AUDACITY_DLL_API sampleCount WaveTrack::TimeToLongSamples ( double  t0) const

Convert correctly between an (absolute) time in seconds and a number of samples.

This method will not give the correct results if used on a relative time (difference of two times). Each absolute time must be converted and the numbers of samples differenced: sampleCount start = track->TimeToLongSamples(t0); sampleCount end = track->TimeToLongSamples(t1); sampleCount len = (sampleCount)(end - start); NOT the likes of: sampleCount len = track->TimeToLongSamples(t1 - t0); See also WaveTrack::TimeToLongSamples().

Parameters
t0The time (floating point seconds) to convert
Returns
The number of samples from the start of the track which lie before the given time.

Definition at line 1767 of file WaveTrack.cpp.

1768 {
1769  return sampleCount( floor(t0 * mRate + 0.5) );
1770 }

References mRate.

Referenced by anonymous_namespace{SampleHandle.cpp}::adjustTime(), EffectNormalize::AnalyseTrackData(), EffectTruncSilence::Analyze(), CompareAudioCommand::Apply(), EffectAutoDuck::ApplyDuckFade(), ClearAndPaste(), ClipParameters::ClipParameters(), Disjoin(), EffectTruncSilence::DoRemoval(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), EffectSBSMS::Finalize(), BlockGenerator::GenerateTrack(), Effect::GetBounds(), Mixer::MixVariableRates(), EditActions::Handler::OnSplitNew(), Paste(), EffectAutoDuck::Process(), EffectChangeSpeed::Process(), NyquistEffect::Process(), EffectRepeat::Process(), EffectReverse::Process(), EffectSBSMS::Process(), NyquistEffect::ProcessOne(), EffectLoudness::ProcessOne(), EffectNormalize::ProcessOne(), EffectChangeSpeed::ProcessOne(), EffectPaulstretch::ProcessOne(), EffectReverse::ProcessOneWave(), Effect::ProcessPass(), SplitAt(), and SelectHandle::StartSnappingFreqSelection().

Here is the caller graph for this function:

◆ Trim()

void WaveTrack::Trim ( double  t0,
double  t1 
)
Exception safety guarantee:
Weak

Definition at line 532 of file WaveTrack.cpp.

533 {
534  bool inside0 = false;
535  bool inside1 = false;
536  //Keeps track of the offset of the first clip greater than
537  // the left selection t0.
538  double firstGreaterOffset = -1;
539 
540  for (const auto &clip : mClips)
541  {
542  //Find the first clip greater than the offset.
543  //If we end up clipping the entire track, this is useful.
544  if(firstGreaterOffset < 0 &&
545  clip->GetStartTime() >= t0)
546  firstGreaterOffset = clip->GetStartTime();
547 
548  if(t1 > clip->GetStartTime() && t1 < clip->GetEndTime())
549  {
550  clip->Clear(t1,clip->GetEndTime());
551  inside1 = true;
552  }
553 
554  if(t0 > clip->GetStartTime() && t0 < clip->GetEndTime())
555  {
556  clip->Clear(clip->GetStartTime(),t0);
557  clip->SetOffset(t0);
558  inside0 = true;
559  }
560  }
561 
562  //if inside0 is false, then the left selector was between
563  //clips, so DELETE everything to its left.
564  if(!inside1 && t1 < GetEndTime())
565  Clear(t1,GetEndTime());
566 
567  if(!inside0 && t0 > GetStartTime())
568  SplitDelete(GetStartTime(), t0);
569 }

References Clear(), GetEndTime(), GetStartTime(), mClips, and SplitDelete().

Referenced by EditActions::Handler::OnTrim().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateLocationsCache()

void WaveTrack::UpdateLocationsCache ( ) const

Definition at line 2330 of file WaveTrack.cpp.

2331 {
2332  auto clips = SortedClipArray();
2333 
2334  mDisplayLocationsCache.clear();
2335 
2336  // Count number of display locations
2337  int num = 0;
2338  {
2339  const WaveClip *prev = nullptr;
2340  for (const auto clip : clips)
2341  {
2342  num += clip->NumCutLines();
2343 
2344  if (prev && fabs(prev->GetEndTime() -
2345  clip->GetStartTime()) < WAVETRACK_MERGE_POINT_TOLERANCE)
2346  ++num;
2347 
2348  prev = clip;
2349  }
2350  }
2351 
2352  if (num == 0)
2353  return;
2354 
2355  // Alloc necessary number of display locations
2356  mDisplayLocationsCache.reserve(num);
2357 
2358  // Add all display locations to cache
2359  int curpos = 0;
2360 
2361  const WaveClip *previousClip = nullptr;
2362  for (const auto clip: clips)
2363  {
2364  for (const auto &cc : clip->GetCutLines())
2365  {
2366  // Add cut line expander point
2368  clip->GetOffset() + cc->GetOffset(),
2370  });
2371  curpos++;
2372  }
2373 
2374  if (previousClip)
2375  {
2376  if (fabs(previousClip->GetEndTime() - clip->GetStartTime())
2378  {
2379  // Add merge point
2381  previousClip->GetEndTime(),
2383  GetClipIndex(previousClip),
2384  GetClipIndex(clip)
2385  });
2386  curpos++;
2387  }
2388  }
2389 
2390  previousClip = clip;
2391  }
2392 
2393  wxASSERT(curpos == num);
2394 }

References GetClipIndex(), WaveClip::GetEndTime(), WaveTrackLocation::locationCutLine, WaveTrackLocation::locationMergePoint, mDisplayLocationsCache, WaveClip::NumCutLines(), SortedClipArray(), and WAVETRACK_MERGE_POINT_TOLERANCE.

Here is the call graph for this function:

◆ UseSpectralPrefs()

void WaveTrack::UseSpectralPrefs ( bool  bUse = true)

Definition at line 696 of file WaveTrack.cpp.

697 {
698  if( bUse ){
699  if( !mpSpectrumSettings )
700  return;
701  // reset it, and next we will be getting the defaults.
702  mpSpectrumSettings.reset();
703  }
704  else {
705  if( mpSpectrumSettings )
706  return;
708  }
709 }

References GetIndependentSpectrogramSettings(), and mpSpectrumSettings.

Here is the call graph for this function:

◆ WriteXML()

void WaveTrack::WriteXML ( XMLWriter xmlFile) const
overridevirtual

Implements Track.

Definition at line 1728 of file WaveTrack.cpp.

1730 {
1731  xmlFile.StartTag(wxT("wavetrack"));
1732  this->Track::WriteCommonXMLAttributes( xmlFile );
1733  xmlFile.WriteAttr(wxT("channel"), mChannel);
1734  xmlFile.WriteAttr(wxT("linked"), mLinked);
1735  this->PlayableTrack::WriteXMLAttributes(xmlFile);
1736  xmlFile.WriteAttr(wxT("rate"), mRate);
1737  xmlFile.WriteAttr(wxT("gain"), (double)mGain);
1738  xmlFile.WriteAttr(wxT("pan"), (double)mPan);
1739  xmlFile.WriteAttr(wxT("colorindex"), mWaveColorIndex );
1740  xmlFile.WriteAttr(wxT("sampleformat"), static_cast<long>(mFormat) );
1741 
1742  for (const auto &clip : mClips)
1743  {
1744  clip->WriteXML(xmlFile);
1745  }
1746 
1747  xmlFile.EndTag(wxT("wavetrack"));
1748 }

References Track::WriteCommonXMLAttributes(), and PlayableTrack::WriteXMLAttributes().

Here is the call graph for this function:

◆ ZeroLevelYCoordinate()

int WaveTrack::ZeroLevelYCoordinate ( wxRect  rect) const

Definition at line 319 of file WaveTrack.cpp.

320 {
321  return rect.GetTop() +
322  (int)((mDisplayMax / (mDisplayMax - mDisplayMin)) * rect.height);
323 }

References mDisplayMax, and mDisplayMin.

Referenced by WaveformVRulerControls::DoHandleWheelRotation(), and anonymous_namespace{WaveformView.cpp}::DrawClipWaveform().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ WaveTrackFactory

friend class WaveTrackFactory
friend

Definition at line 88 of file WaveTrack.h.

Member Data Documentation

◆ mAppendCriticalSection

wxCriticalSection WaveTrack::mAppendCriticalSection
private

Definition at line 588 of file WaveTrack.h.

◆ mClips

WaveClipHolders WaveTrack::mClips
protected

◆ mDisplayLocationsCache

std::vector<Location> WaveTrack::mDisplayLocationsCache
mutableprotected

Definition at line 571 of file WaveTrack.h.

Referenced by Init(), and UpdateLocationsCache().

◆ mDisplayMax

float WaveTrack::mDisplayMax
mutableprotected

◆ mDisplayMin

float WaveTrack::mDisplayMin
mutableprotected

◆ mFlushCriticalSection

wxCriticalSection WaveTrack::mFlushCriticalSection
private

Definition at line 587 of file WaveTrack.h.

◆ mFormat

sampleFormat WaveTrack::mFormat
protected

◆ mGain

float WaveTrack::mGain
protected

Definition at line 554 of file WaveTrack.h.

Referenced by GetChannelGain(), GetGain(), HandleXMLTag(), Init(), Merge(), SetGain(), and WaveTrack().

◆ mLastdBRange

int WaveTrack::mLastdBRange
mutableprotected

Definition at line 570 of file WaveTrack.h.

Referenced by SetLastdBRange(), and WaveTrack().

◆ mLastScaleType

int WaveTrack::mLastScaleType
mutableprotected

Definition at line 569 of file WaveTrack.h.

Referenced by SetLastScaleType(), and WaveTrack().

◆ mLegacyProjectFileOffset

double WaveTrack::mLegacyProjectFileOffset
private

Definition at line 589 of file WaveTrack.h.

Referenced by HandleXMLChild(), HandleXMLTag(), and WaveTrack().

◆ mOldGain

float WaveTrack::mOldGain[2]
protected

Definition at line 557 of file WaveTrack.h.

Referenced by GetOldChannelGain(), Init(), SetOldChannelGain(), and WaveTrack().

◆ mPan

float WaveTrack::mPan
protected

Definition at line 555 of file WaveTrack.h.

Referenced by GetChannelGain(), GetPan(), HandleXMLTag(), Init(), Merge(), SetPan(), and WaveTrack().

◆ mpFactory

SampleBlockFactoryPtr WaveTrack::mpFactory
private

◆ mpSpectrumSettings

std::unique_ptr<SpectrogramSettings> WaveTrack::mpSpectrumSettings
private

◆ mpWaveformSettings

std::unique_ptr<WaveformSettings> WaveTrack::mpWaveformSettings
private

Definition at line 592 of file WaveTrack.h.

Referenced by GetWaveformSettings(), Merge(), Reinit(), and SetWaveformSettings().

◆ mRate

int WaveTrack::mRate
protected

◆ mSpectrumMax

float WaveTrack::mSpectrumMax
mutableprotected

Definition at line 567 of file WaveTrack.h.

Referenced by GetSpectrumBounds(), Init(), SetSpectrumBounds(), and WaveTrack().

◆ mSpectrumMin

float WaveTrack::mSpectrumMin
mutableprotected

Definition at line 566 of file WaveTrack.h.

Referenced by GetSpectrumBounds(), Init(), SetSpectrumBounds(), and WaveTrack().

◆ mWaveColorIndex

int WaveTrack::mWaveColorIndex
protected

Definition at line 556 of file WaveTrack.h.

Referenced by HandleXMLTag(), Init(), SetWaveColorIndex(), and WaveTrack().


The documentation for this class was generated from the following files:
WaveClip::Flush
void Flush()
Flush must be called after last Append.
Definition: WaveClip.cpp:1267
XMLWriter::EndTag
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:100
WaveformSettings::scaleType
ScaleType scaleType
Definition: WaveformSettings.h:68
ClearSamples
void ClearSamples(samplePtr dst, sampleFormat format, size_t start, size_t len)
Definition: SampleFormat.cpp:77
XMLValueChecker::IsValidSampleFormat
static bool IsValidSampleFormat(const int nValue)
Definition: XMLTagHandler.cpp:182
Track::mChannel
ChannelType mChannel
Definition: Track.h:390
WaveTrackFactory::Get
static WaveTrackFactory & Get(AudacityProject &project)
Definition: WaveTrack.cpp:2786
SpectrogramSettings
Spectrogram settings, either for one track or as defaults.
Definition: SpectrogramSettings.h:27
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:68
Track::GetDefaultName
wxString GetDefaultName() const
Definition: Track.h:411
Track::mOffset
double mOffset
Definition: Track.h:391
Track::WriteCommonXMLAttributes
void WriteCommonXMLAttributes(XMLWriter &xmlFile, bool includeNameAndSelected=true) const
Definition: Track.cpp:1243
make_iterator_range
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:625
Track::RightChannel
static const auto RightChannel
Definition: Track.h:266
TimeWarper
Transforms one point in time to another point. For example, a time stretching effect might use one to...
Definition: TimeWarper.h:62
XMLValueChecker::IsGoodInt
static bool IsGoodInt(const wxString &strInt)
Check that the supplied string can be converted to a long (32bit) integer.
Definition: XMLTagHandler.cpp:158
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:67
Track::GetEndTime
virtual double GetEndTime() const =0
WaveClip::GetEnvelope
Envelope * GetEnvelope()
Definition: WaveClip.h:242
WaveTrack::GetEndTime
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1797
constSamplePtr
const char * constSamplePtr
Definition: Types.h:738
Track::GetName
wxString GetName() const
Definition: Track.h:409
WaveTrack::mWaveColorIndex
int mWaveColorIndex
Definition: WaveTrack.h:556
WaveClip::GetOffset
double GetOffset() const
Definition: WaveClip.h:219
WaveClip::Paste
void Paste(double t0, const WaveClip *other)
Paste data from other clip, resampling it if not equal rate.
Definition: WaveClip.cpp:1369
WaveTrack::CreateClip
WaveClip * CreateClip()
Definition: WaveTrack.cpp:2141
WaveTrack::mLastdBRange
int mLastdBRange
Definition: WaveTrack.h:570
PlayableTrack::Merge
void Merge(const Track &init) override
Definition: Track.cpp:309
WaveTrack::GetClipByIndex
WaveClip * GetClipByIndex(int index)
Definition: WaveTrack.cpp:2189
fillTwo
@ fillTwo
Definition: SampleFormat.h:40
WaveTrack::RightmostOrNewClip
WaveClip * RightmostOrNewClip()
Get access to the last (rightmost) clip, or create a clip, if there is not already one.
Definition: WaveTrack.cpp:2159
WaveTrack::mpSpectrumSettings
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:591
WaveClip::SetOffset
void SetOffset(double offset)
Definition: WaveClip.cpp:214
WaveClip::GetEndTime
double GetEndTime() const
Definition: WaveClip.cpp:253
WaveTrackLocation::locationMergePoint
@ locationMergePoint
Definition: WaveTrackLocation.h:18
GetEditClipsCanMove
bool GetEditClipsCanMove()
Definition: TracksBehaviorsPrefs.cpp:149
for
for(int ii=0, nn=names.size();ii< nn;++ii)
Definition: SpectrumVZoomHandle.cpp:271
XO
#define XO(s)
Definition: Internat.h:32
Region::start
double start
Definition: WaveTrack.h:55
WaveTrack::GetWaveColorIndex
int GetWaveColorIndex() const
Definition: WaveTrack.h:143
PlayableTrack::Init
void Init(const PlayableTrack &init)
Definition: Track.cpp:302
WaveTrack::mSpectrumMax
float mSpectrumMax
Definition: WaveTrack.h:567
WaveTrack::GetOffset
double GetOffset() const override
Definition: WaveTrack.cpp:206
floatSample
@ floatSample
Definition: Types.h:722
WaveTrackLocation
Definition: WaveTrackLocation.h:14
WaveClipPointers
std::vector< WaveClip * > WaveClipPointers
Definition: WaveTrack.h:40
WaveTrack::GetSpectrogramSettings
const SpectrogramSettings & GetSpectrogramSettings() const
Definition: WaveTrack.cpp:665
Sequence
A WaveTrack contains WaveClip(s). A WaveClip contains a Sequence. A Sequence is primarily an interfac...
Definition: Sequence.h:61
WaveTrack::mpWaveformSettings
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:592
WaveClipHolders
std::vector< WaveClipHolder > WaveClipHolders
Definition: WaveClip.h:121
Regions
std::vector< Region > Regions
Definition: WaveTrack.h:64
WaveTrack::Copy
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: WaveTrack.cpp:583
Track::HandleCommonXMLAttribute
bool HandleCommonXMLAttribute(const wxChar *attr, const wxChar *value)
Definition: Track.cpp:1257
TracksPrefs::GetDefaultAudioTrackNamePreference
static wxString GetDefaultAudioTrackNamePreference()
Definition: TracksPrefs.cpp:422
fillZero
@ fillZero
Definition: SampleFormat.h:39
WaveTrack::EmptyCopy
Holder EmptyCopy(const SampleBlockFactoryPtr &pFactory={}) const
Definition: WaveTrack.cpp:574
XMLValueChecker::IsGoodString
static bool IsGoodString(const wxString &str)
Definition: XMLTagHandler.cpp:39
WaveTrack::SplitDelete
void SplitDelete(double t0, double t1)
Definition: WaveTrack.cpp:926
WaveTrack::Cut
Track::Holder Cut(double t0, double t1) override
Definition: WaveTrack.cpp:486
WaveTrack::mSpectrumMin
float mSpectrumMin
Definition: WaveTrack.h:566
Track::mLinked
bool mLinked
Definition: Track.h:257
WaveTrack::SortedClipArray
WaveClipPointers SortedClipArray()
Definition: WaveTrack.cpp:2502
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: Types.h:706
WaveClip::GetStartTime
double GetStartTime() const
Definition: WaveClip.cpp:247
WaveClip::GetSequence
Sequence * GetSequence()
Definition: WaveClip.h:250
WaveTrack::NewestOrNewClip
WaveClip * NewestOrNewClip()
Get access to the most recently added clip, or create a clip, if there is not already one....
Definition: WaveTrack.cpp:2147
WaveTrack::GetIndependentSpectrogramSettings
SpectrogramSettings & GetIndependentSpectrogramSettings()
Definition: WaveTrack.cpp:681
WaveTrack::mLastScaleType
int mLastScaleType
Definition: WaveTrack.h:569
WaveTrack::SetSpectrogramSettings
void SetSpectrogramSettings(std::unique_ptr< SpectrogramSettings > &&pSettings)
Definition: WaveTrack.cpp:689
WaveClip
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:172
samplePtr
char * samplePtr
Definition: Types.h:737
sampleFormat
sampleFormat
Definition: Types.h:717
WaveTrack::Clear
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:654
sampleCount::as_double
double as_double() const
Definition: Types.h:616
Sequence::GetFactory
const SampleBlockFactoryPtr & GetFactory()
Definition: Sequence.h:128
WaveTrack::IsEmpty
bool IsEmpty(double t0, double t1) const
Returns true if there are no WaveClips in the specified region.
Definition: WaveTrack.cpp:464
WaveTrack::LongSamplesToTime
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: WaveTrack.cpp:1772
Track::SetDefaultName
void SetDefaultName(const wxString &n)
Definition: Track.h:412
WaveTrack::mRate
int mRate
Definition: WaveTrack.h:553
Track::MonoChannel
static const auto MonoChannel
Definition: Track.h:267
WaveClip::Offset
void Offset(double delta)
Definition: WaveClip.h:221
WaveTrack::mGain
float mGain
Definition: WaveTrack.h:554
WaveTrack::Paste
void Paste(double t0, const Track *src) override
Definition: WaveTrack.cpp:1171
WaveTrack::mDisplayLocationsCache
std::vector< Location > mDisplayLocationsCache
Definition: WaveTrack.h:571
format
int format
Definition: ExportPCM.cpp:54
WaveTrack::mpFactory
SampleBlockFactoryPtr mpFactory
Definition: WaveTrack.h:585
WaveTrack::mClips
WaveClipHolders mClips
Definition: WaveTrack.h:550
Track::SetLinked
void SetLinked(bool l)
Definition: Track.cpp:175
THROW_INCONSISTENCY_EXCEPTION
#define THROW_INCONSISTENCY_EXCEPTION
Throw InconsistencyException, using C++ preprocessor to identify the source code location.
Definition: InconsistencyException.h:77
Track::LeftChannel
static const auto LeftChannel
Definition: Track.h:265
SpectrogramSettings::ScaleType
int ScaleType
Definition: SpectrogramSettings.h:57
WaveTrack::GetWaveformSettings
const WaveformSettings & GetWaveformSettings() const
Definition: WaveTrack.cpp:713
WaveTrack::GetStartTime
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1777
WaveTrack::Init
void Init(const WaveTrack &orig)
Definition: WaveTrack.cpp:142
WaveTrack::GetSampleFormat
sampleFormat GetSampleFormat() const
Definition: WaveTrack.h:148
WaveClipHolder
std::shared_ptr< WaveClip > WaveClipHolder
Definition: WaveClip.h:120
SpectrogramSettings::stLinear
@ stLinear
Definition: SpectrogramSettings.h:59
WaveTrack::GetClipAtTime
WaveClip * GetClipAtTime(double time)
Definition: WaveTrack.cpp:2102
TimeWarper::Warp
virtual double Warp(double originalTime) const =0
Region::end
double end
Definition: WaveTrack.h:55
WaveClip::Clear
void Clear(double t0, double t1)
Definition: WaveClip.cpp:1466
WaveClip::AppendSilence
void AppendSilence(double len, double envelopeValue)
Definition: WaveClip.cpp:1459
WaveClip::Append
bool Append(constSamplePtr buffer, sampleFormat format, size_t len, unsigned int stride)
Definition: WaveClip.cpp:1206
WaveTrack::mFormat
sampleFormat mFormat
Definition: WaveTrack.h:552
WaveTrack::MergeClips
void MergeClips(int clipidx1, int clipidx2)
Definition: WaveTrack.cpp:2460
WaveformSettings::defaults
static WaveformSettings & defaults()
Definition: WaveformSettings.cpp:69
WaveTrack::GetMaxBlockSize
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:1578
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
Track::TypeSwitch
R TypeSwitch(const Functions &...functions)
Use this function rather than testing track type explicitly and making down-casts.
Definition: Track.h:692
WaveTrack::HandleClear
void HandleClear(double t0, double t1, bool addCutLines, bool split)
Definition: WaveTrack.cpp:994
WaveTrack::CanOffsetClips
bool CanOffsetClips(const std::vector< WaveClip * > &clips, double amount, double *allowedAmount=nullptr)
Decide whether the clips could be offset (and inserted) together without overlapping other clips.
Definition: WaveTrack.cpp:2207
XMLValueChecker::IsValidChannel
static bool IsValidChannel(const int nValue)
Definition: XMLTagHandler.cpp:170
WaveTrack::TimeToLongSamples
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1767
Track::SetName
void SetName(const wxString &n)
Definition: Track.cpp:83
Track::Notify
void Notify(int code=-1)
Definition: Track.cpp:277
WaveClip::NumCutLines
size_t NumCutLines() const
Definition: WaveClip.h:314
WaveTrack::SetPan
void SetPan(float newPan) override
Definition: WaveTrack.cpp:395
XMLValueChecker::ChannelType
ChannelType
Definition: XMLTagHandler.h:67
sampleCount
Definition: Types.h:589
TrackKind::Wave
@ Wave
WaveClipConstHolders
std::vector< std::shared_ptr< const WaveClip > > WaveClipConstHolders
Definition: WaveClip.h:122
WaveformSettings::dBRange
int dBRange
Definition: WaveformSettings.h:69
WaveTrack::SetOffset
void SetOffset(double o) override
Definition: WaveTrack.cpp:212
WaveTrack::mOldGain
float mOldGain[2]
Definition: WaveTrack.h:557
XMLWriter::WriteAttr
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:34
WaveTrackLocation::locationCutLine
@ locationCutLine
Definition: WaveTrackLocation.h:17
Region
#define Region
Definition: VSTControlGTK.h:16
PlayableTrack::PlayableTrack
PlayableTrack()
Definition: Track.h:839
WaveTrack::GetPan
float GetPan() const
Definition: WaveTrack.cpp:390
PlayableTrack::HandleXMLAttribute
bool HandleXMLAttribute(const wxChar *attr, const wxChar *value)
Definition: Track.cpp:343
WaveTrack::mDisplayMax
float mDisplayMax
Definition: WaveTrack.h:565
WAVETRACK_MERGE_POINT_TOLERANCE
#define WAVETRACK_MERGE_POINT_TOLERANCE
Definition: WaveTrack.h:46
anonymous_namespace{WaveTrack.cpp}::FindClip
WaveClipHolders::iterator FindClip(WaveClipHolders &list, const WaveClip *clip, int *distance=nullptr)
Definition: WaveTrack.cpp:952
PlayableTrack::WriteXMLAttributes
void WriteXMLAttributes(XMLWriter &xmlFile) const
Definition: Track.cpp:335
Region
Structure to hold region of a wavetrack and a comparison function for sortability.
Definition: WaveTrack.h:51
settings
static Settings & settings()
Definition: TrackInfo.cpp:87
lrint
#define lrint(dbl)
Definition: float_cast.h:148
WaveTrack::SplitAt
void SplitAt(double t)
Definition: WaveTrack.cpp:2308
SpectrogramSettings::stPeriod
@ stPeriod
Definition: SpectrogramSettings.h:64
SimpleMessageBoxException
A MessageBoxException that shows a given, unvarying string.
Definition: AudacityException.h:80
WaveTrack::mLegacyProjectFileOffset
double mLegacyProjectFileOffset
Definition: WaveTrack.h:589
WaveTrack::mPan
float mPan
Definition: WaveTrack.h:555
ArrayOf< float >
XMLWriter::StartTag
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:77
WaveTrack::SetWaveformSettings
void SetWaveformSettings(std::unique_ptr< WaveformSettings > &&pSettings)
Definition: WaveTrack.cpp:727
WaveTrack::GetClipIndex
int GetClipIndex(const WaveClip *clip) const
Definition: WaveTrack.cpp:2182
SAMPLE_SIZE
#define SAMPLE_SIZE(SampleFormat)
Definition: Types.h:732
SpectrogramSettings::defaults
static SpectrogramSettings & defaults()
Definition: SpectrogramSettings.cpp:133
Internat::CompatibleToDouble
static bool CompatibleToDouble(const wxString &stringToConvert, double *result)
Convert a string to a number.
Definition: Internat.cpp:139
WaveTrack::mDisplayMin
float mDisplayMin
Definition: WaveTrack.h:564
Sequence::GetIdealBlockSize
size_t GetIdealBlockSize() const
Definition: Sequence.cpp:81
WaveClip::HandleXMLEndTag
void HandleXMLEndTag(const wxChar *tag) override
Definition: WaveClip.cpp:1328
IdentityTimeWarper
No change to time at all.
Definition: TimeWarper.h:69
WaveTrack::GetRate
double GetRate() const
Definition: WaveTrack.cpp:360