Audacity  2.2.2
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected 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:
PlayableTrack AudioTrack Track CommonTrackPanelCell XMLTagHandler TrackPanelCell

Classes

class  AllClipsIterator
 
class  Location
 Used only by WaveTrack, a special way to hold location that can accommodate merged regions. More...
 
struct  Locker
 
struct  WaveTrackLockDeleter
 

Public Types

enum  WaveTrackDisplayValues : int {
  Waveform = 0, MinDisplay = Waveform, obsoleteWaveformDBDisplay, Spectrum,
  obsolete1, obsolete2, obsolete3, obsolete4,
  MaxDisplay = Spectrum, NoDisplay
}
 
enum  SampleDisplay { LinearInterpolate = 0, StemPlot }
 
enum  ZoomPresets {
  kZoomToFit = 0, kZoomToSelection, kZoomDefault, kZoomMinutes,
  kZoomSeconds, kZoom5ths, kZoom10ths, kZoom20ths,
  kZoom50ths, kZoom100ths, kZoom500ths, kZoomMilliSeconds,
  kZoomSamples, kZoom4To1, kMaxZoom
}
 
typedef WaveTrackLocation Location
 
using Holder = std::unique_ptr< WaveTrack >
 
using LockerBase = std::unique_ptr< const WaveTrack, WaveTrackLockDeleter >
 
typedef int WaveTrackDisplay
 
- Public Types inherited from Track
enum  { LeftChannel = 0, RightChannel = 1, MonoChannel = 2 }
 
enum  TrackKindEnum {
  None, Wave, Label, Time,
  All
}
 
enum  : unsigned { DefaultHeight = 150 }
 
using Holder = std::unique_ptr< Track >
 

Public Member Functions

void Reinit (const WaveTrack &orig)
 
virtual ~WaveTrack ()
 
std::vector< UIHandlePtrDetailedHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool) override
 
double GetOffset () const override
 
void SetOffset (double o) override
 
virtual int 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...
 
int GetKind () const override
 
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
 
void DoSetMinimized (bool isMinimized) override
 
int GetWaveColorIndex () const
 
void SetWaveColorIndex (int colorIndex)
 
sampleFormat GetSampleFormat () const
 
void ConvertToSampleFormat (sampleFormat format)
 
const SpectrogramSettingsGetSpectrogramSettings () const
 
SpectrogramSettingsGetSpectrogramSettings ()
 
SpectrogramSettingsGetIndependentSpectrogramSettings ()
 
void SetSpectrogramSettings (std::unique_ptr< SpectrogramSettings > &&pSettings)
 
const WaveformSettingsGetWaveformSettings () const
 
WaveformSettingsGetWaveformSettings ()
 
WaveformSettingsGetIndependentWaveformSettings ()
 
void SetWaveformSettings (std::unique_ptr< WaveformSettings > &&pSettings)
 
void UseSpectralPrefs (bool bUse=true)
 
Track::Holder Cut (double t0, double t1) override
 
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...
 
void Append (samplePtr buffer, sampleFormat format, size_t len, unsigned int stride=1, XMLWriter *blockFileLog=NULL)
 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 AppendAlias (const wxString &fName, sampleCount start, size_t len, int channel, bool useOD)
 
void AppendCoded (const wxString &fName, sampleCount start, size_t len, int channel, int decodeType)
 
unsigned int GetODFlags () const
 gets an int with OD flags so that we can determine which ODTasks should be run on this track after save/open, etc. More...
 
void ClearWaveCaches ()
 Invalidates all clips' wavecaches. Careful, This may not be threadsafe. More...
 
void AddInvalidRegion (sampleCount startSample, sampleCount endSample)
 Adds an invalid region to the wavecache so it redraws that portion only. More...
 
bool Get (samplePtr buffer, sampleFormat format, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumCopied=nullptr) const
 
void Set (samplePtr 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
 
WaveClipGetClipAtX (int xcoord)
 
SequenceGetSequenceAtX (int xcoord)
 
EnvelopeGetEnvelopeAtX (int xcoord)
 
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 Lock () const
 
bool Unlock () const
 
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 an number of samples and an (absolute) time in seconds. More...
 
WaveClipHoldersGetClips ()
 
const WaveClipConstHoldersGetClips () const
 
IteratorRange< AllClipsIteratorGetAllClips ()
 
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 CanOffsetClip (WaveClip *clip, double amount, double *allowedAmount=NULL)
 
bool CanInsertClip (WaveClip *clip, double &slideBy, double &tolerance)
 
std::shared_ptr< WaveClipRemoveAndReturnClip (WaveClip *clip)
 
void AddClip (std::shared_ptr< WaveClip > &&clip)
 
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 GetAutoSaveIdent ()
 
void SetAutoSaveIdent (int id)
 
int GetLastScaleType () const
 
void SetLastScaleType () const
 
int GetLastdBRange () const
 
void SetLastdBRange () const
 
WaveTrackDisplay GetDisplay () const
 
void SetDisplay (WaveTrackDisplay display)
 
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
 
- Public Member Functions inherited from PlayableTrack
 PlayableTrack (const std::shared_ptr< DirManager > &projDirManager)
 
 PlayableTrack (const Track &orig)
 
bool GetMute () const
 
bool GetSolo () 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 (const std::shared_ptr< DirManager > &projDirManager)
 
 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
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &, const AudacityProject *pProject) finaloverride
 
std::shared_ptr< TrackPanelCellGetTrackControl ()
 
std::shared_ptr< TrackPanelCellGetVRulerControl ()
 
std::shared_ptr< TrackPanelCellGetResizer ()
 
virtual int GetMinimizedHeight () const
 
int GetActualHeight () const
 
int GetIndex () const
 
void SetIndex (int index)
 
int GetY () const
 
int GetHeight () const
 
void SetHeight (int h)
 
bool GetMinimized () const
 
void SetMinimized (bool isMinimized)
 
TrackGetLink () const
 
 Track (const std::shared_ptr< DirManager > &projDirManager)
 
 Track (const Track &orig)
 
virtual ~Track ()
 
void Init (const Track &orig)
 
wxString GetName () const
 
void SetName (const wxString &n)
 
wxString GetDefaultName () const
 
void SetDefaultName (const wxString &n)
 
bool GetSelected () const
 
virtual void SetSelected (bool s)
 
bool GetLinked () const
 
void SetLinked (bool l)
 
void Offset (double t)
 
void SetChannel (int c)
 
const std::shared_ptr
< DirManager > & 
GetDirManager () const
 
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 IsSyncLockSelected () const
 
- Public Member Functions inherited from CommonTrackPanelCell
 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
- Public Member Functions inherited from TrackPanelCell
virtual ~TrackPanelCell ()=0
 
virtual unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, wxPoint *pPosition)
 
virtual unsigned CaptureKey (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent)
 
virtual unsigned KeyDown (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent)
 
virtual unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent)
 
virtual unsigned Char (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent)
 
- 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)
 

Static Public Member Functions

static WaveTrackDisplay ConvertLegacyDisplayValue (int oldValue)
 
static WaveTrackDisplay ValidateWaveTrackDisplay (WaveTrackDisplay display)
 
- Static Public Member Functions inherited from Track
template<typename Subclass = Track>
static std::shared_ptr< Subclass > Pointer (Track *t)
 
template<typename Subclass = const Track>
static std::shared_ptr< Subclass > Pointer (const Track *t)
 

Protected Member Functions

std::shared_ptr< TrackControlsGetControls () override
 
std::shared_ptr
< TrackVRulerControls
GetVRulerControls () override
 
- Protected Member Functions inherited from Track
virtual void DoSetHeight (int h)
 
std::shared_ptr< TrackFindTrack () override
 
- Protected Member Functions inherited from CommonTrackPanelCell
unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 

Protected Attributes

WaveClipHolders mClips
 
sampleFormat mFormat
 
int mRate
 
float mGain
 
float mPan
 
int mWaveColorIndex
 
float mDisplayMin
 
float mDisplayMax
 
float mSpectrumMin
 
float mSpectrumMax
 
WaveTrackDisplay mDisplay
 
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 {}
 
int mIndex
 
int mY
 
int mHeight
 
wxString mName
 
wxString mDefaultName
 
bool mSelected
 
bool mLinked
 
bool mMinimized
 
int mChannel
 
double mOffset
 
std::shared_ptr< DirManagermDirManager
 
std::shared_ptr< TrackControlsmpControls
 
std::shared_ptr
< TrackVRulerControls
mpVRulerContols
 
std::shared_ptr
< TrackPanelResizerCell
mpResizer
 
std::weak_ptr< SelectHandlemSelectHandle
 
std::weak_ptr< TimeShiftHandlemTimeShiftHandle
 

Private Member Functions

 WaveTrack (const std::shared_ptr< DirManager > &projDirManager, sampleFormat format=(sampleFormat) 0, double rate=0)
 
 WaveTrack (const WaveTrack &orig)
 
void Init (const WaveTrack &orig)
 
Track::Holder Duplicate () const override
 

Private Attributes

wxCriticalSection mFlushCriticalSection
 
wxCriticalSection mAppendCriticalSection
 
double mLegacyProjectFileOffset
 
int mAutoSaveIdent
 
std::unique_ptr
< SpectrogramSettings
mpSpectrumSettings
 
std::unique_ptr< WaveformSettingsmpWaveformSettings
 
std::weak_ptr< CutlineHandlemCutlineHandle
 
std::weak_ptr< SampleHandlemSampleHandle
 
std::weak_ptr< EnvelopeHandlemEnvelopeHandle
 

Friends

class TrackFactory
 

Additional Inherited Members

- Public Attributes inherited from Track
wxSize vrulerSize
 

Detailed Description

A Track that contains audio waveform data.

Definition at line 60 of file WaveTrack.h.

Member Typedef Documentation

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

Definition at line 90 of file WaveTrack.h.

Definition at line 89 of file WaveTrack.h.

using WaveTrack::LockerBase = std::unique_ptr< const WaveTrack, WaveTrackLockDeleter >

Definition at line 322 of file WaveTrack.h.

Definition at line 531 of file WaveTrack.h.

Member Enumeration Documentation

Enumerator
LinearInterpolate 
StemPlot 

Definition at line 557 of file WaveTrack.h.

Enumerator
Waveform 
MinDisplay 
obsoleteWaveformDBDisplay 
Spectrum 
obsolete1 
obsolete2 
obsolete3 
obsolete4 
MaxDisplay 
NoDisplay 

Definition at line 532 of file WaveTrack.h.

532  : int {
533 
534  // DO NOT REORDER OLD VALUES! Replace obsoletes with placeholders.
535 
536  Waveform = 0,
538 
540 
541  Spectrum,
542 
543  obsolete1, // was SpectrumLogDisplay
544  obsolete2, // was SpectralSelectionDisplay
545  obsolete3, // was SpectralSelectionLogDisplay
546  obsolete4, // was PitchDisplay
547 
548  // Add values here, and update MaxDisplay.
549 
551 
552  NoDisplay, // Preview track has no display
553  };
Enumerator
kZoomToFit 
kZoomToSelection 
kZoomDefault 
kZoomMinutes 
kZoomSeconds 
kZoom5ths 
kZoom10ths 
kZoom20ths 
kZoom50ths 
kZoom100ths 
kZoom500ths 
kZoomMilliSeconds 
kZoomSamples 
kZoom4To1 
kMaxZoom 

Definition at line 563 of file WaveTrack.h.

Constructor & Destructor Documentation

WaveTrack::WaveTrack ( const std::shared_ptr< DirManager > &  projDirManager,
sampleFormat  format = (sampleFormat)0,
double  rate = 0 
)
private

Definition at line 84 of file WaveTrack.cpp.

References TrackInfo::DefaultWaveTrackHeight(), format, GetActiveProject(), TracksPrefs::GetDefaultAudioTrackNamePreference(), AudacityProject::GetDefaultFormat(), Track::GetDefaultName(), GetIndependentWaveformSettings(), AudacityProject::GetRate(), mAutoSaveIdent, mDisplay, mDisplayMax, mDisplayMin, mFormat, mGain, mLastdBRange, mLastScaleType, mLegacyProjectFileOffset, mPan, mRate, mSpectrumMax, mSpectrumMin, mWaveColorIndex, obsoleteWaveformDBDisplay, WaveformSettings::scaleType, Track::SetDefaultName(), Track::SetHeight(), Track::SetName(), WaveformSettings::stLogarithmic, TracksPrefs::ViewModeChoice(), and Waveform.

84  :
85  PlayableTrack(projDirManager)
86 {
87  if (format == (sampleFormat)0)
88  {
90  }
91  if (rate == 0)
92  {
93  rate = GetActiveProject()->GetRate();
94  }
95 
96  // Force creation always:
98 
101  mDisplay = Waveform;
103  }
104 
106 
107  mFormat = format;
108  mRate = (int) rate;
109  mGain = 1.0;
110  mPan = 0.0;
111  mWaveColorIndex = 0;
114  mDisplayMin = -1.0;
115  mDisplayMax = 1.0;
116  mSpectrumMin = mSpectrumMax = -1; // so values will default to settings
117  mLastScaleType = -1;
118  mLastdBRange = -1;
119  mAutoSaveIdent = 0;
120 
122 }
int mAutoSaveIdent
Definition: WaveTrack.h:647
PlayableTrack(const std::shared_ptr< DirManager > &projDirManager)
Definition: Track.h:379
int mLastdBRange
Definition: WaveTrack.h:631
float mDisplayMin
Definition: WaveTrack.h:624
WaveformSettings & GetIndependentWaveformSettings()
Definition: WaveTrack.cpp:754
static wxString GetDefaultAudioTrackNamePreference()
void SetHeight(int h)
Definition: Track.cpp:189
float mSpectrumMax
Definition: WaveTrack.h:627
int mLastScaleType
Definition: WaveTrack.h:630
static unsigned DefaultWaveTrackHeight()
wxString GetDefaultName() const
Definition: Track.h:273
float mSpectrumMin
Definition: WaveTrack.h:626
int format
Definition: ExportPCM.cpp:56
sampleFormat
Definition: Types.h:188
WaveTrackDisplay mDisplay
Definition: WaveTrack.h:629
sampleFormat GetDefaultFormat()
Definition: Project.h:197
static WaveTrack::WaveTrackDisplay ViewModeChoice()
int mRate
Definition: WaveTrack.h:614
float mGain
Definition: WaveTrack.h:615
void SetDefaultName(const wxString &n)
Definition: Track.h:274
sampleFormat mFormat
Definition: WaveTrack.h:613
void SetName(const wxString &n)
Definition: Track.h:272
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
float mPan
Definition: WaveTrack.h:616
double GetRate() const
Definition: Project.h:199
float mDisplayMax
Definition: WaveTrack.h:625
double mLegacyProjectFileOffset
Definition: WaveTrack.h:646
int mWaveColorIndex
Definition: WaveTrack.h:617
Waveform settings, either for one track or as defaults.
WaveTrack::WaveTrack ( const WaveTrack orig)
private

Definition at line 124 of file WaveTrack.cpp.

References Init(), mClips, Track::mDirManager, mLastdBRange, mLastScaleType, and mLegacyProjectFileOffset.

124  :
125  PlayableTrack(orig)
127  ? std::make_unique<SpectrogramSettings>(*orig.mpSpectrumSettings)
128  : nullptr
129  )
131  ? std::make_unique<WaveformSettings>(*orig.mpWaveformSettings)
132  : nullptr
133  )
134 {
135  mLastScaleType = -1;
136  mLastdBRange = -1;
137 
139 
140  Init(orig);
141 
142  for (const auto &clip : orig.mClips)
143  mClips.push_back
144  ( std::make_unique<WaveClip>( *clip, mDirManager, true ) );
145 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:649
PlayableTrack(const std::shared_ptr< DirManager > &projDirManager)
Definition: Track.h:379
int mLastdBRange
Definition: WaveTrack.h:631
int mLastScaleType
Definition: WaveTrack.h:630
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:650
void Init(const WaveTrack &orig)
Definition: WaveTrack.cpp:148
WaveClipHolders mClips
Definition: WaveTrack.h:611
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:232
double mLegacyProjectFileOffset
Definition: WaveTrack.h:646
WaveTrack::~WaveTrack ( )
virtual

Definition at line 211 of file WaveTrack.cpp.

References ODManager::Instance, ODManager::IsInstanceCreated(), and ODManager::RemoveWaveTrack().

212 {
213  //Let the ODManager know this WaveTrack is disappearing.
214  //Deschedules tasks associated with this track.
217 }
static bool IsInstanceCreated()
returns whether or not the singleton instance was created yet
Definition: ODManager.cpp:205
static ODManager *(* Instance)()
Definition: ODManager.h:49
void RemoveWaveTrack(WaveTrack *track)
removes a wavetrack and notifies its associated tasks to stop using its reference.
Definition: ODManager.cpp:372

Member Function Documentation

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

Definition at line 1003 of file WaveTrack.cpp.

References mClips.

Referenced by TimeShiftHandle::Drag(), and EffectReverse::ProcessOneWave().

1004 {
1005  // Uncomment the following line after we correct the problem of zero-length clips
1006  //if (CanInsertClip(clip))
1007  mClips.push_back(std::move(clip)); // transfer ownership
1008 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
void WaveTrack::AddInvalidRegion ( sampleCount  startSample,
sampleCount  endSample 
)

Adds an invalid region to the wavecache so it redraws that portion only.

Definition at line 2594 of file WaveTrack.cpp.

References WaveClip::AddInvalidRegion().

2595 {
2596  for (const auto &clip : mClips)
2597  clip->AddInvalidRegion(startSample, endSample);
2598 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
void WaveTrack::Append ( samplePtr  buffer,
sampleFormat  format,
size_t  len,
unsigned int  stride = 1,
XMLWriter blockFileLog = NULL 
)

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.

Definition at line 1557 of file WaveTrack.cpp.

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

Referenced by BlockGenerator::GenerateTrack(), NyquistEffect::PutCallback(), and EffectNoiseReduction::Worker::ReduceNoise().

1563 {
1564  RightmostOrNewClip()->Append(buffer, format, len, stride,
1565  blockFileLog);
1566 }
WaveClip * RightmostOrNewClip()
Get access to the last (rightmost) clip, or create a clip, if there is not already one...
Definition: WaveTrack.cpp:2246
int format
Definition: ExportPCM.cpp:56
void Append(samplePtr buffer, sampleFormat format, size_t len, unsigned int stride=1, XMLWriter *blockFileLog=NULL)
You must call Flush after the last Append.
Definition: WaveClip.cpp:1393
void WaveTrack::AppendAlias ( const wxString &  fName,
sampleCount  start,
size_t  len,
int  channel,
bool  useOD 
)

Definition at line 1568 of file WaveTrack.cpp.

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

1571 {
1572  RightmostOrNewClip()->AppendAlias(fName, start, len, channel, useOD);
1573 }
WaveClip * RightmostOrNewClip()
Get access to the last (rightmost) clip, or create a clip, if there is not already one...
Definition: WaveTrack.cpp:2246
void AppendAlias(const wxString &fName, sampleCount start, size_t len, int channel, bool useOD)
Definition: WaveClip.cpp:1450
void WaveTrack::AppendCoded ( const wxString &  fName,
sampleCount  start,
size_t  len,
int  channel,
int  decodeType 
)

for use with On-Demand decoding of compressed files. decodeType should be an enum from ODDecodeTask that specifies what Type of encoded file this is, such as eODFLAC

Definition at line 1575 of file WaveTrack.cpp.

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

1578 {
1579  RightmostOrNewClip()->AppendCoded(fName, start, len, channel, decodeType);
1580 }
void AppendCoded(const wxString &fName, sampleCount start, size_t len, int channel, int decodeType)
Definition: WaveClip.cpp:1462
WaveClip * RightmostOrNewClip()
Get access to the last (rightmost) clip, or create a clip, if there is not already one...
Definition: WaveTrack.cpp:2246
bool WaveTrack::CanInsertClip ( WaveClip clip,
double &  slideBy,
double &  tolerance 
)

Definition at line 2342 of file WaveTrack.cpp.

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

Referenced by TimeShiftHandle::Drag().

2343 {
2344  for (const auto &c : mClips)
2345  {
2346  double d1 = c->GetStartTime() - (clip->GetEndTime()+slideBy);
2347  double d2 = (clip->GetStartTime()+slideBy) - c->GetEndTime();
2348  if ( (d1<0) && (d2<0) )
2349  {
2350  // clips overlap.
2351  // Try to rescue it.
2352  // The rescue logic is not perfect, and will typically
2353  // move the clip at most once.
2354  // We divide by 1000 rather than set to 0, to allow for
2355  // a second 'micro move' that is really about rounding error.
2356  if( -d1 < tolerance ){
2357  // right edge of clip overlaps slightly.
2358  // slide clip left a small amount.
2359  slideBy +=d1;
2360  tolerance /=1000;
2361  } else if( -d2 < tolerance ){
2362  // left edge of clip overlaps slightly.
2363  // slide clip right a small amount.
2364  slideBy -= d2;
2365  tolerance /=1000;
2366  }
2367  else
2368  return false; // clips overlap No tolerance left.
2369  }
2370  }
2371 
2372  return true;
2373 }
double GetStartTime() const
Definition: WaveClip.cpp:421
WaveClipHolders mClips
Definition: WaveTrack.h:611
double GetEndTime() const
Definition: WaveClip.cpp:427
bool WaveTrack::CanOffsetClip ( WaveClip clip,
double  amount,
double *  allowedAmount = NULL 
)

Definition at line 2295 of file WaveTrack.cpp.

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

Referenced by TimeShiftHandle::DoSlideHorizontal().

2297 {
2298  if (allowedAmount)
2299  *allowedAmount = amount;
2300 
2301  for (const auto &c: mClips)
2302  {
2303  if (c.get() != clip && c->GetStartTime() < clip->GetEndTime()+amount &&
2304  c->GetEndTime() > clip->GetStartTime()+amount)
2305  {
2306  if (!allowedAmount)
2307  return false; // clips overlap
2308 
2309  if (amount > 0)
2310  {
2311  if (c->GetStartTime()-clip->GetEndTime() < *allowedAmount)
2312  *allowedAmount = c->GetStartTime()-clip->GetEndTime();
2313  if (*allowedAmount < 0)
2314  *allowedAmount = 0;
2315  } else
2316  {
2317  if (c->GetEndTime()-clip->GetStartTime() > *allowedAmount)
2318  *allowedAmount = c->GetEndTime()-clip->GetStartTime();
2319  if (*allowedAmount > 0)
2320  *allowedAmount = 0;
2321  }
2322  }
2323  }
2324 
2325  if (allowedAmount)
2326  {
2327  if (*allowedAmount == amount)
2328  return true;
2329 
2330  // Check if the NEW calculated amount would not violate
2331  // any other constraint
2332  if (!CanOffsetClip(clip, *allowedAmount, NULL)) {
2333  *allowedAmount = 0; // play safe and don't allow anything
2334  return false;
2335  }
2336  else
2337  return true;
2338  } else
2339  return true;
2340 }
double GetStartTime() const
Definition: WaveClip.cpp:421
bool CanOffsetClip(WaveClip *clip, double amount, double *allowedAmount=NULL)
Definition: WaveTrack.cpp:2295
WaveClipHolders mClips
Definition: WaveTrack.h:611
double GetEndTime() const
Definition: WaveClip.cpp:427
void WaveTrack::Clear ( double  t0,
double  t1 
)
override
void WaveTrack::ClearAndAddCutLine ( double  t0,
double  t1 
)

Definition at line 684 of file WaveTrack.cpp.

References HandleClear().

Referenced by AudacityProject::OnCutLabels().

686 {
687  HandleClear(t0, t1, true, false);
688 }
void HandleClear(double t0, double t1, bool addCutLines, bool split)
Definition: WaveTrack.cpp:1010
void WaveTrack::ClearAndPaste ( double  t0,
double  t1,
const Track src,
bool  preserve = true,
bool  merge = true,
const TimeWarper effectWarper = NULL 
)

Definition at line 782 of file WaveTrack.cpp.

References 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 Generator::Process(), EffectChangeSpeed::ProcessOne(), NyquistEffect::ProcessOne(), EffectNoiseReduction::Worker::ProcessOne(), and Effect::ProcessTrack().

792 {
793  double dur = std::min(t1 - t0, src->GetEndTime());
794 
795  // If duration is 0, then it's just a plain paste
796  if (dur == 0.0) {
797  // use WEAK-GUARANTEE
798  Paste(t0, src);
799  return;
800  }
801 
802  std::vector<double> splits;
803  WaveClipHolders cuts;
804 
805  // If provided time warper was NULL, use a default one that does nothing
806  IdentityTimeWarper localWarper;
807  const TimeWarper *warper = (effectWarper ? effectWarper : &localWarper);
808 
809  // Align to a sample
812 
813  // Save the cut/split lines whether preserving or not since merging
814  // needs to know if a clip boundary is being crossed since Paste()
815  // will add split lines around the pasted clip if so.
816  for (const auto &clip : mClips) {
817  double st;
818 
819  // Remember clip boundaries as locations to split
820  st = LongSamplesToTime(TimeToLongSamples(clip->GetStartTime()));
821  if (st >= t0 && st <= t1 && !make_iterator_range(splits).contains(st)) {
822  splits.push_back(st);
823  }
824 
825  st = LongSamplesToTime(TimeToLongSamples(clip->GetEndTime()));
826  if (st >= t0 && st <= t1 && !make_iterator_range(splits).contains(st)) {
827  splits.push_back(st);
828  }
829 
830  // Search for cut lines
831  auto &cutlines = clip->GetCutLines();
832  // May erase from cutlines, so don't use range-for
833  for (auto it = cutlines.begin(); it != cutlines.end(); ) {
834  WaveClip *cut = it->get();
835  double cs = LongSamplesToTime(TimeToLongSamples(clip->GetOffset() +
836  cut->GetOffset()));
837 
838  // Remember cut point
839  if (cs >= t0 && cs <= t1) {
840 
841  // Remember the absolute offset and add to our cuts array.
842  cut->SetOffset(cs);
843  cuts.push_back(std::move(*it)); // transfer ownership!
844  it = cutlines.erase(it);
845  }
846  else
847  ++it;
848  }
849  }
850 
851  const auto tolerance = 2.0 / GetRate();
852 
853  // Now, clear the selection
854  HandleClear(t0, t1, false, false);
855  {
856 
857  // And paste in the NEW data
858  Paste(t0, src);
859  {
860  // First, merge the NEW clip(s) in with the existing clips
861  if (merge && splits.size() > 0)
862  {
863  // Now t1 represents the absolute end of the pasted data.
864  t1 = t0 + src->GetEndTime();
865 
866  // Get a sorted array of the clips
867  auto clips = SortedClipArray();
868 
869  // Scan the sorted clips for the first clip whose start time
870  // exceeds the pasted regions end time.
871  {
872  WaveClip *prev = nullptr;
873  for (const auto clip : clips) {
874  // Merge this clip and the previous clip if the end time
875  // falls within it and this isn't the first clip in the track.
876  if (fabs(t1 - clip->GetStartTime()) < tolerance) {
877  if (prev)
878  MergeClips(GetClipIndex(prev), GetClipIndex(clip));
879  break;
880  }
881  prev = clip;
882  }
883  }
884  }
885 
886  // Refill the array since clips have changed.
887  auto clips = SortedClipArray();
888 
889  {
890  // Scan the sorted clips to look for the start of the pasted
891  // region.
892  WaveClip *prev = nullptr;
893  for (const auto clip : clips) {
894  if (prev) {
895  // It must be that clip is what was pasted and it begins where
896  // prev ends.
897  // use WEAK-GUARANTEE
898  MergeClips(GetClipIndex(prev), GetClipIndex(clip));
899  break;
900  }
901  if (fabs(t0 - clip->GetEndTime()) < tolerance)
902  // Merge this clip and the next clip if the start time
903  // falls within it and this isn't the last clip in the track.
904  prev = clip;
905  else
906  prev = nullptr;
907  }
908  }
909  }
910 
911  // Restore cut/split lines
912  if (preserve) {
913 
914  // Restore the split lines, transforming the position appropriately
915  for (const auto split: splits) {
916  SplitAt(warper->Warp(split));
917  }
918 
919  // Restore the saved cut lines, also transforming if time altered
920  for (const auto &clip : mClips) {
921  double st;
922  double et;
923 
924  st = clip->GetStartTime();
925  et = clip->GetEndTime();
926 
927  // Scan the cuts for any that live within this clip
928  for (auto it = cuts.begin(); it != cuts.end();) {
929  WaveClip *cut = it->get();
930  double cs = cut->GetOffset();
931 
932  // Offset the cut from the start of the clip and add it to
933  // this clips cutlines.
934  if (cs >= st && cs <= et) {
935  cut->SetOffset(warper->Warp(cs) - st);
936  clip->GetCutLines().push_back( std::move(*it) ); // transfer ownership!
937  it = cuts.erase(it);
938  }
939  else
940  ++it;
941  }
942  }
943  }
944  }
945 }
void SplitAt(double t)
Definition: WaveTrack.cpp:2383
No change to time at all.
Definition: TimeWarper.h:68
virtual double GetEndTime() const =0
WaveClipPointers SortedClipArray()
Definition: WaveTrack.cpp:2576
std::vector< WaveClipHolder > WaveClipHolders
Definition: WaveClip.h:122
double GetOffset() const
Definition: WaveClip.h:222
void SetOffset(double offset)
Definition: WaveClip.cpp:392
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:677
void Paste(double t0, const Track *src) override
Definition: WaveTrack.cpp:1192
int min(int a, int b)
void HandleClear(double t0, double t1, bool addCutLines, bool split)
Definition: WaveTrack.cpp:1010
void MergeClips(int clipidx1, int clipidx2)
Definition: WaveTrack.cpp:2533
WaveClipHolders mClips
Definition: WaveTrack.h:611
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1843
virtual double Warp(double originalTime) const =0
Transforms one point in time to another point. For example, a time stretching effect might use one to...
Definition: TimeWarper.h:61
double GetRate() const
Definition: WaveTrack.cpp:398
double LongSamplesToTime(sampleCount pos) const
Convert correctly between an number of samples and an (absolute) time in seconds. ...
Definition: WaveTrack.cpp:1848
int GetClipIndex(const WaveClip *clip) const
Definition: WaveTrack.cpp:2270
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 2587 of file WaveTrack.cpp.

References WaveClip::ClearWaveCache().

2588 {
2589  for (const auto &clip : mClips)
2590  clip->ClearWaveCache();
2591 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
bool WaveTrack::CloseLock ( )

Definition at line 1826 of file WaveTrack.cpp.

References WaveClip::CloseLock(), and mClips.

1827 {
1828  for (const auto &clip : mClips)
1829  clip->CloseLock();
1830 
1831  return true;
1832 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
WaveTrack::WaveTrackDisplay WaveTrack::ConvertLegacyDisplayValue ( int  oldValue)
static

Definition at line 259 of file WaveTrack.cpp.

References obsoleteWaveformDBDisplay, Spectrum, and Waveform.

Referenced by TracksViewModeSetting::Migrate().

260 {
261  // Remap old values.
262  enum OldValues {
263  Waveform,
264  WaveformDB,
265  Spectrogram,
266  SpectrogramLogF,
267  Pitch,
268  };
269 
270  WaveTrackDisplay newValue;
271  switch (oldValue) {
272  default:
273  case Waveform:
274  newValue = WaveTrack::Waveform; break;
275  case WaveformDB:
276  newValue = WaveTrack::obsoleteWaveformDBDisplay; break;
277  case Spectrogram:
278  case SpectrogramLogF:
279  case Pitch:
280  newValue = WaveTrack::Spectrum; break;
281  /*
282  case SpectrogramLogF:
283  newValue = WaveTrack::SpectrumLogDisplay; break;
284  case Pitch:
285  newValue = WaveTrack::PitchDisplay; break;
286  */
287  }
288  return newValue;
289 }
int WaveTrackDisplay
Definition: WaveTrack.h:531
void WaveTrack::ConvertToSampleFormat ( sampleFormat  format)

Definition at line 486 of file WaveTrack.cpp.

References format, mClips, and mFormat.

Referenced by FormatMenuTable::OnFormatChange().

489 {
490  for (const auto &clip : mClips)
491  clip->ConvertToSampleFormat(format);
492  mFormat = format;
493 }
int format
Definition: ExportPCM.cpp:56
sampleFormat mFormat
Definition: WaveTrack.h:613
WaveClipHolders mClips
Definition: WaveTrack.h:611
Track::Holder WaveTrack::Copy ( double  t0,
double  t1,
bool  forClipboard = true 
) const
override

Definition at line 605 of file WaveTrack.cpp.

References GetEndTime(), GetRate(), GetSampleFormat(), GetStartTime(), Init(), mClips, Track::mDirManager, min(), WaveClip::Offset(), safenew, and THROW_INCONSISTENCY_EXCEPTION.

Referenced by CopyNonconst(), Cut(), Effect::Preview(), EffectRepeat::Process(), and SplitCut().

606 {
607  if (t1 < t0)
609 
610  WaveTrack *newTrack;
611  Track::Holder result
612  { newTrack = safenew WaveTrack{ mDirManager } };
613 
614  newTrack->Init(*this);
615 
616  // PRL: Why shouldn't cutlines be copied and pasted too? I don't know, but
617  // that was the old behavior. But this function is also used by the
618  // Duplicate command and I changed its behavior in that case.
619 
620  for (const auto &clip : mClips)
621  {
622  if (t0 <= clip->GetStartTime() && t1 >= clip->GetEndTime())
623  {
624  // Whole clip is in copy region
625  //wxPrintf("copy: clip %i is in copy region\n", (int)clip);
626 
627  newTrack->mClips.push_back
628  (std::make_unique<WaveClip>(*clip, mDirManager, ! forClipboard));
629  WaveClip *const newClip = newTrack->mClips.back().get();
630  newClip->Offset(-t0);
631  }
632  else if (t1 > clip->GetStartTime() && t0 < clip->GetEndTime())
633  {
634  // Clip is affected by command
635  //wxPrintf("copy: clip %i is affected by command\n", (int)clip);
636 
637  const double clip_t0 = std::max(t0, clip->GetStartTime());
638  const double clip_t1 = std::min(t1, clip->GetEndTime());
639 
640  auto newClip = std::make_unique<WaveClip>
641  (*clip, mDirManager, ! forClipboard, clip_t0, clip_t1);
642 
643  //wxPrintf("copy: clip_t0=%f, clip_t1=%f\n", clip_t0, clip_t1);
644 
645  newClip->Offset(-t0);
646  if (newClip->GetOffset() < 0)
647  newClip->SetOffset(0);
648 
649  newTrack->mClips.push_back(std::move(newClip)); // transfer ownership
650  }
651  }
652 
653  // AWD, Oct 2009: If the selection ends in whitespace, create a placeholder
654  // clip representing that whitespace
655  // PRL: Only if we want the track for pasting into other tracks. Not if it
656  // goes directly into a project as in the Duplicate command.
657  if (forClipboard &&
658  newTrack->GetEndTime() + 1.0 / newTrack->GetRate() < t1 - t0)
659  {
660  auto placeholder = std::make_unique<WaveClip>(mDirManager,
661  newTrack->GetSampleFormat(),
662  static_cast<int>(newTrack->GetRate()),
663  0 /*colourindex*/);
664  placeholder->SetIsPlaceholder(true);
665  placeholder->InsertSilence(0, (t1 - t0) - newTrack->GetEndTime());
666  placeholder->Offset(newTrack->GetEndTime());
667  newTrack->mClips.push_back(std::move(placeholder)); // transfer ownership
668  }
669 
670  return result;
671 }
void Offset(double delta)
Definition: WaveClip.h:223
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1873
#define THROW_INCONSISTENCY_EXCEPTION
#define safenew
Definition: Audacity.h:230
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1853
void Init(const WaveTrack &orig)
Definition: WaveTrack.cpp:148
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
int min(int a, int b)
WaveClipHolders mClips
Definition: WaveTrack.h:611
sampleFormat GetSampleFormat() const
Definition: WaveTrack.h:146
std::unique_ptr< Track > Holder
Definition: Track.h:264
double GetRate() const
Definition: WaveTrack.cpp:398
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:232
Track::Holder WaveTrack::CopyNonconst ( double  t0,
double  t1 
)

Definition at line 673 of file WaveTrack.cpp.

References Copy().

Referenced by AudacityProject::OnCopyLabels(), and AudacityProject::OnCutLabels().

674 {
675  return Copy(t0, t1);
676 }
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: WaveTrack.cpp:605
WaveClip * WaveTrack::CreateClip ( )

Definition at line 2229 of file WaveTrack.cpp.

References GetWaveColorIndex(), mClips, Track::mDirManager, mFormat, and mRate.

Referenced by HandleXMLChild(), Join(), NewestOrNewClip(), and RightmostOrNewClip().

2230 {
2231  mClips.push_back(std::make_unique<WaveClip>(mDirManager, mFormat, mRate, GetWaveColorIndex()));
2232  return mClips.back().get();
2233 }
int GetWaveColorIndex() const
Definition: WaveTrack.h:143
int mRate
Definition: WaveTrack.h:614
sampleFormat mFormat
Definition: WaveTrack.h:613
WaveClipHolders mClips
Definition: WaveTrack.h:611
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:232
Track::Holder WaveTrack::Cut ( double  t0,
double  t1 
)
override

Definition at line 517 of file WaveTrack.cpp.

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

Referenced by Paste(), and SyncLockAdjust().

518 {
519  if (t1 < t0)
521 
522  auto tmp = Copy(t0, t1);
523 
524  Clear(t0, t1);
525 
526  return tmp;
527 }
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: WaveTrack.cpp:605
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:678
#define THROW_INCONSISTENCY_EXCEPTION
std::vector< UIHandlePtr > WaveTrack::DetailedHitTest ( const TrackPanelMouseState state,
const AudacityProject pProject,
int  currentTool,
bool  bMultiTool 
)
overridevirtual

Implements Track.

Definition at line 27 of file WaveTrackUI.cpp.

References drawTool, envelopeTool, SampleHandle::HitAnywhere(), EnvelopeHandle::HitAnywhere(), TimeShiftHandle::HitAnywhere(), CutlineHandle::HitTest(), SampleHandle::HitTest(), TimeShiftHandle::HitTest(), TrackPanelMouseState::rect, TrackPanelMouseState::state, Waveform, and EnvelopeHandle::WaveTrackHitTest().

29 {
30  // This is the only override of Track::DetailedHitTest that still
31  // depends on the state of the Tools toolbar.
32  // If that toolbar were eliminated, this could simplify to a sequence of
33  // hit test routines describable by a table.
34 
35  UIHandlePtr result;
36  std::vector<UIHandlePtr> results;
37  bool isWaveform = (GetDisplay() == WaveTrack::Waveform);
38 
39  if (bMultiTool && st.state.CmdDown()) {
40  // Ctrl modifier key in multi-tool overrides everything else
41  // (But this does not do the time shift constrained to the vertical only,
42  // which is what happens when you hold Ctrl in the Time Shift tool mode)
44  mTimeShiftHandle, Pointer(this), false);
45  if (result)
46  results.push_back(result);
47  return results;
48  }
49 
50  // Some special targets are not drawn in spectrogram,
51  // so don't hit them in such views.
52  else if (isWaveform) {
53  UIHandlePtr result;
54  if (NULL != (result = CutlineHandle::HitTest(
55  mCutlineHandle, st.state, st.rect,
56  pProject, Pointer<WaveTrack>(this))))
57  // This overriding test applies in all tools
58  results.push_back(result);
59  if (bMultiTool) {
60  // Conditional hit tests
61  // If Tools toolbar were eliminated, we would keep these
62  // The priority of these, in case more than one might apply at one
63  // point, seems arbitrary
64  if (NULL != (result = EnvelopeHandle::WaveTrackHitTest(
65  mEnvelopeHandle, st.state, st.rect,
66  pProject, Pointer<WaveTrack>(this))))
67  results.push_back(result);
68  if (NULL != (result = TimeShiftHandle::HitTest(
69  mTimeShiftHandle, st.state, st.rect, Pointer(this))))
70  // This is the hit test on the "grips" drawn left and
71  // right in Multi only
72  results.push_back(result);
73  if (NULL != (result = SampleHandle::HitTest(
74  mSampleHandle, st.state, st.rect,
75  pProject, Pointer<WaveTrack>(this))))
76  results.push_back(result);
77  }
78  else {
79  switch ( currentTool ) {
80  // Unconditional hits appropriate to the tool
81  // If tools toolbar were eliminated, we would eliminate these
82  case envelopeTool: {
83  auto envelope = GetEnvelopeAtX( st.state.m_x );
85  mEnvelopeHandle, envelope, false);
86  break;
87  }
88  case drawTool:
90  mSampleHandle, st.state, Pointer<WaveTrack>(this));
91  break;
92  default:
93  result = {};
94  break;
95  }
96  if (result)
97  results.push_back(result);
98  }
99  }
100 
101  return results;
102 }
Envelope * GetEnvelopeAtX(int xcoord)
Definition: WaveTrack.cpp:2211
std::weak_ptr< EnvelopeHandle > mEnvelopeHandle
Definition: WaveTrack.h:654
static UIHandlePtr WaveTrackHitTest(std::weak_ptr< EnvelopeHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveTrack > &wt)
static UIHandlePtr HitAnywhere(std::weak_ptr< TimeShiftHandle > &holder, const std::shared_ptr< Track > &pTrack, bool gripHit)
static UIHandlePtr HitAnywhere(std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const std::shared_ptr< WaveTrack > &pTrack)
std::weak_ptr< TimeShiftHandle > mTimeShiftHandle
Definition: Track.h:358
std::weak_ptr< SampleHandle > mSampleHandle
Definition: WaveTrack.h:653
std::shared_ptr< UIHandle > UIHandlePtr
Definition: TrackPanel.h:59
std::weak_ptr< CutlineHandle > mCutlineHandle
Definition: WaveTrack.h:652
static UIHandlePtr HitTest(std::weak_ptr< TimeShiftHandle > &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
static UIHandlePtr HitAnywhere(std::weak_ptr< EnvelopeHandle > &holder, Envelope *envelope, bool timeTrack)
static UIHandlePtr HitTest(std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveTrack > &pTrack)
WaveTrackDisplay GetDisplay() const
Definition: WaveTrack.h:593
static std::shared_ptr< Subclass > Pointer(Track *t)
Definition: Track.h:137
static UIHandlePtr HitTest(std::weak_ptr< CutlineHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveTrack > &pTrack)
void WaveTrack::Disjoin ( double  t0,
double  t1 
)

Definition at line 1425 of file WaveTrack.cpp.

References sampleCount::as_double(), Region::end, floatSample, WaveClip::GetEndTime(), GetRate(), WaveClip::GetSamples(), WaveClip::GetStartTime(), limitSampleBufferSize(), mClips, Region, SplitDelete(), Region::start, TimeToLongSamples(), WaveClip::TimeToSamplesClip(), and WAVETRACK_MERGE_POINT_TOLERANCE.

Referenced by AudacityProject::OnDisjoinLabels().

1427 {
1429  const size_t maxAtOnce = 1048576;
1430  Floats buffer{ maxAtOnce };
1431  Regions regions;
1432 
1433  wxBusyCursor busy;
1434 
1435  for (const auto &clip : mClips)
1436  {
1437  double startTime = clip->GetStartTime();
1438  double endTime = clip->GetEndTime();
1439 
1440  if( endTime < t0 || startTime > t1 )
1441  continue;
1442 
1443  if( t0 > startTime )
1444  startTime = t0;
1445  if( t1 < endTime )
1446  endTime = t1;
1447 
1448  //simply look for a sequence of zeroes and if the sequence
1449  //is greater than minimum number, split-DELETE the region
1450 
1451  sampleCount seqStart = -1;
1452  sampleCount start, end;
1453  clip->TimeToSamplesClip( startTime, &start );
1454  clip->TimeToSamplesClip( endTime, &end );
1455 
1456  auto len = ( end - start );
1457  for( decltype(len) done = 0; done < len; done += maxAtOnce )
1458  {
1459  auto numSamples = limitSampleBufferSize( maxAtOnce, len - done );
1460 
1461  clip->GetSamples( ( samplePtr )buffer.get(), floatSample, start + done,
1462  numSamples );
1463  for( decltype(numSamples) i = 0; i < numSamples; i++ )
1464  {
1465  auto curSamplePos = start + done + i;
1466 
1467  //start a NEW sequence
1468  if( buffer[ i ] == 0.0 && seqStart == -1 )
1469  seqStart = curSamplePos;
1470  else if( buffer[ i ] != 0.0 || curSamplePos == end - 1 )
1471  {
1472  if( seqStart != -1 )
1473  {
1474  decltype(end) seqEnd;
1475 
1476  //consider the end case, where selection ends in zeroes
1477  if( curSamplePos == end - 1 && buffer[ i ] == 0.0 )
1478  seqEnd = end;
1479  else
1480  seqEnd = curSamplePos;
1481  if( seqEnd - seqStart + 1 > minSamples )
1482  {
1483  regions.push_back(Region(
1484  seqStart.as_double() / GetRate()
1485  + clip->GetStartTime(),
1486  seqEnd.as_double() / GetRate()
1487  + clip->GetStartTime()));
1488  }
1489  seqStart = -1;
1490  }
1491  }
1492  }
1493  }
1494  }
1495 
1496  for( unsigned int i = 0; i < regions.size(); i++ )
1497  {
1498  const Region &region = regions.at(i);
1499  SplitDelete(region.start, region.end );
1500  }
1501 }
double as_double() const
Definition: Types.h:88
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: Types.h:178
void SplitDelete(double t0, double t1)
Definition: WaveTrack.cpp:947
Structure to hold region of a wavetrack and a comparison function for sortability.
Definition: WaveTrack.h:42
#define Region
Definition: VSTControlGTK.h:15
char * samplePtr
Definition: Types.h:203
double start
Definition: WaveTrack.h:47
if(pTrack &&pTrack->GetDisplay()!=WaveTrack::Spectrum)
#define WAVETRACK_MERGE_POINT_TOLERANCE
Definition: WaveTrack.h:38
WaveClipHolders mClips
Definition: WaveTrack.h:611
double end
Definition: WaveTrack.h:47
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1843
double GetRate() const
Definition: WaveTrack.cpp:398
void WaveTrack::DoSetMinimized ( bool  isMinimized)
overridevirtual

Reimplemented from Track.

Definition at line 456 of file WaveTrack.cpp.

References Track::DoSetMinimized(), WaveTrackVRulerControls::DoZoomPreset(), GetVRulerControls(), and gPrefs.

456  {
457 
458 #ifdef EXPERIMENTAL_HALF_WAVE
459  bool bHalfWave;
460  gPrefs->Read(wxT("/GUI/CollapseToHalfWave"), &bHalfWave, false);
461  if( bHalfWave )
462  {
463  // Show half wave on collapse, full on restore.
464  std::shared_ptr<TrackVRulerControls> pTvc = GetVRulerControls();
465 
466  // An awkward workaround for a function that lives 'in the wrong place'.
467  // We use magic numbers, 0 and 1, to tell it to zoom reset or zoom half-wave.
468  WaveTrackVRulerControls * pWtvc = reinterpret_cast<WaveTrackVRulerControls*>(pTvc.get());
469  if( pWtvc )
470  pWtvc->DoZoomPreset( isMinimized ? 1:0);
471  }
472 #endif
473 
474  PlayableTrack::DoSetMinimized( isMinimized );
475 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
virtual void DoSetMinimized(bool isMinimized)
Definition: Track.cpp:239
std::shared_ptr< TrackVRulerControls > GetVRulerControls() override
Track::Holder WaveTrack::Duplicate ( ) const
overrideprivatevirtual

Implements Track.

Definition at line 393 of file WaveTrack.cpp.

References safenew.

Referenced by TrackFactory::DuplicateWaveTrack().

394 {
395  return Track::Holder{ safenew WaveTrack{ *this } };
396 }
#define safenew
Definition: Audacity.h:230
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
std::unique_ptr< Track > Holder
Definition: Track.h:264
void WaveTrack::ExpandCutLine ( double  cutLinePosition,
double *  cutlineStart = NULL,
double *  cutlineEnd = NULL 
)

Definition at line 2473 of file WaveTrack.cpp.

References _(), WaveClip::ExpandCutLine(), WaveClip::FindCutLine(), AudacityPrefs::GetEditClipsCanMove(), WaveClip::GetEndTime(), WaveClip::GetStartTime(), gPrefs, and mClips.

2476 {
2477  bool editClipCanMove = gPrefs->GetEditClipsCanMove();
2478 
2479  // Find clip which contains this cut line
2480  double start = 0, end = 0;
2481  auto pEnd = mClips.end();
2482  auto pClip = std::find_if( mClips.begin(), pEnd,
2483  [&](const WaveClipHolder &clip) {
2484  return clip->FindCutLine(cutLinePosition, &start, &end); } );
2485  if (pClip != pEnd)
2486  {
2487  auto &clip = *pClip;
2488  if (!editClipCanMove)
2489  {
2490  // We are not allowed to move the other clips, so see if there
2491  // is enough room to expand the cut line
2492  for (const auto &clip2: mClips)
2493  {
2494  if (clip2->GetStartTime() > clip->GetStartTime() &&
2495  clip->GetEndTime() + end - start > clip2->GetStartTime())
2496  // STRONG-GUARANTEE in case of this path
2498  _("There is not enough room available to expand the cut line")
2499  };
2500  }
2501  }
2502 
2503  clip->ExpandCutLine(cutLinePosition);
2504 
2505  // STRONG-GUARANTEE provided that the following gives NOFAIL-GUARANTEE
2506 
2507  if (cutlineStart)
2508  *cutlineStart = start;
2509  if (cutlineEnd)
2510  *cutlineEnd = end;
2511 
2512  // Move clips which are to the right of the cut line
2513  if (editClipCanMove)
2514  {
2515  for (const auto &clip2 : mClips)
2516  {
2517  if (clip2->GetStartTime() > clip->GetStartTime())
2518  clip2->Offset(end - start);
2519  }
2520  }
2521  }
2522 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
WaveClipHolders mClips
Definition: WaveTrack.h:611
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
std::shared_ptr< WaveClip > WaveClipHolder
Definition: WaveClip.h:121
bool GetEditClipsCanMove()
Definition: Prefs.cpp:158
void WaveTrack::Flush ( )

Flush must be called after last Append.

Definition at line 1650 of file WaveTrack.cpp.

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

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

1655 {
1656  // After appending, presumably. Do this to the clip that gets appended.
1658 }
WaveClip * RightmostOrNewClip()
Get access to the last (rightmost) clip, or create a clip, if there is not already one...
Definition: WaveTrack.cpp:2246
void Flush()
Flush must be called after last Append.
Definition: WaveClip.cpp:1474
bool WaveTrack::Get ( samplePtr  buffer,
sampleFormat  format,
sampleCount  start,
size_t  len,
fillFormat  fill = fillZero,
bool  mayThrow = true,
sampleCount pNumCopied = nullptr 
) const

MM: Now that each wave track can contain multiple clips, we don't have a continous space of samples anymore, but we simulate it, because there are alot 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 1971 of file WaveTrack.cpp.

References ClearSamples(), fillTwo, fillZero, floatSample, WaveClip::GetEndSample(), WaveClip::GetNumSamples(), WaveClip::GetSamples(), WaveClip::GetStartSample(), mClips, min(), and SAMPLE_SIZE.

Referenced by EffectNormalize::AnalyseDC(), EffectTruncSilence::Analyze(), CompareAudioCommand::Apply(), EffectAutoDuck::ApplyDuckFade(), EffectTruncSilence::DoRemoval(), FreqWindow::GetAudio(), NyquistEffect::GetCallback(), SampleHandle::HitTest(), AudacityProject::NearestZeroCrossing(), VoiceKey::OffBackward(), VoiceKey::OffForward(), VoiceKey::OnBackward(), VoiceKey::OnForward(), AudacityProject::OnPunchAndRoll(), EffectAutoDuck::Process(), EffectRepair::ProcessOne(), EffectSimpleMono::ProcessOne(), EffectStereoToMono::ProcessOne(), EffectPaulstretch::ProcessOne(), EffectFindClipping::ProcessOne(), EffectNormalize::ProcessOne(), EffectClickRemoval::ProcessOne(), EffectChangeSpeed::ProcessOne(), EffectTwoPassSimpleMono::ProcessOne(), EffectEqualization::ProcessOne(), EffectNoiseReduction::Worker::ProcessOne(), EffectReverse::ProcessOneClip(), Effect::ProcessTrack(), SelectHandle::StartSnappingFreqSelection(), VoiceKey::TestDirectionChanges(), VoiceKey::TestEnergy(), VoiceKey::TestSignChanges(), and MixerTrackCluster::UpdateMeter().

1974 {
1975  // Simple optimization: When this buffer is completely contained within one clip,
1976  // don't clear anything (because we won't have to). Otherwise, just clear
1977  // everything to be on the safe side.
1978  bool doClear = true;
1979  bool result = true;
1980  sampleCount samplesCopied = 0;
1981  for (const auto &clip: mClips)
1982  {
1983  if (start >= clip->GetStartSample() && start+len <= clip->GetEndSample())
1984  {
1985  doClear = false;
1986  break;
1987  }
1988  }
1989  if (doClear)
1990  {
1991  // Usually we fill in empty space with zero
1992  if( fill == fillZero )
1993  ClearSamples(buffer, format, 0, len);
1994  // but we don't have to.
1995  else if( fill==fillTwo )
1996  {
1997  wxASSERT( format==floatSample );
1998  float * pBuffer = (float*)buffer;
1999  for(size_t i=0;i<len;i++)
2000  pBuffer[i]=2.0f;
2001  }
2002  else
2003  {
2004  wxFAIL_MSG(wxT("Invalid fill format"));
2005  }
2006  }
2007 
2008  for (const auto &clip: mClips)
2009  {
2010  auto clipStart = clip->GetStartSample();
2011  auto clipEnd = clip->GetEndSample();
2012 
2013  if (clipEnd > start && clipStart < start+len)
2014  {
2015  // Clip sample region and Get/Put sample region overlap
2016  auto samplesToCopy =
2017  std::min( start+len - clipStart, clip->GetNumSamples() );
2018  auto startDelta = clipStart - start;
2019  decltype(startDelta) inclipDelta = 0;
2020  if (startDelta < 0)
2021  {
2022  inclipDelta = -startDelta; // make positive value
2023  samplesToCopy -= inclipDelta;
2024  // samplesToCopy is now either len or
2025  // (clipEnd - clipStart) - (start - clipStart)
2026  // == clipEnd - start > 0
2027  // samplesToCopy is not more than len
2028  //
2029  startDelta = 0;
2030  // startDelta is zero
2031  }
2032  else {
2033  // startDelta is nonnegative and less than than len
2034  // samplesToCopy is positive and not more than len
2035  }
2036 
2037  if (!clip->GetSamples(
2038  (samplePtr)(((char*)buffer) +
2039  startDelta.as_size_t() *
2040  SAMPLE_SIZE(format)),
2041  format, inclipDelta, samplesToCopy.as_size_t(), mayThrow ))
2042  result = false;
2043  else
2044  samplesCopied += samplesToCopy;
2045  }
2046  }
2047  if( pNumCopied )
2048  *pNumCopied = samplesCopied;
2049  return result;
2050 }
#define SAMPLE_SIZE(SampleFormat)
Definition: Types.h:198
int format
Definition: ExportPCM.cpp:56
char * samplePtr
Definition: Types.h:203
if(pTrack &&pTrack->GetDisplay()!=WaveTrack::Spectrum)
int min(int a, int b)
WaveClipHolders mClips
Definition: WaveTrack.h:611
void ClearSamples(samplePtr dst, sampleFormat format, size_t start, size_t len)
IteratorRange< AllClipsIterator > WaveTrack::GetAllClips ( )
inline

Definition at line 435 of file WaveTrack.h.

Referenced by GetAllSeqBlocks().

436  {
437  return { AllClipsIterator{ *this }, AllClipsIterator{ } };
438  }
int WaveTrack::GetAutoSaveIdent ( )

Definition at line 2600 of file WaveTrack.cpp.

References mAutoSaveIdent.

2601 {
2602  return mAutoSaveIdent;
2603 }
int mAutoSaveIdent
Definition: WaveTrack.h:647
size_t WaveTrack::GetBestBlockSize ( sampleCount  t) const

Definition at line 1607 of file WaveTrack.cpp.

References Sequence::GetBestBlockSize(), GetMaxBlockSize(), WaveClip::GetNumSamples(), WaveClip::GetSequence(), WaveClip::GetStartTime(), mClips, and mRate.

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

1608 {
1609  auto bestBlockSize = GetMaxBlockSize();
1610 
1611  for (const auto &clip : mClips)
1612  {
1613  auto startSample = (sampleCount)floor(clip->GetStartTime()*mRate + 0.5);
1614  auto endSample = startSample + clip->GetNumSamples();
1615  if (s >= startSample && s < endSample)
1616  {
1617  bestBlockSize = clip->GetSequence()->GetBestBlockSize(s - startSample);
1618  break;
1619  }
1620  }
1621 
1622  return bestBlockSize;
1623 }
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:1625
int mRate
Definition: WaveTrack.h:614
WaveClipHolders mClips
Definition: WaveTrack.h:611
sampleCount WaveTrack::GetBlockStart ( sampleCount  t) const

Definition at line 1594 of file WaveTrack.cpp.

References Sequence::GetBlockStart(), WaveClip::GetNumSamples(), WaveClip::GetSequence(), WaveClip::GetStartTime(), mClips, and mRate.

1595 {
1596  for (const auto &clip : mClips)
1597  {
1598  const auto startSample = (sampleCount)floor(0.5 + clip->GetStartTime()*mRate);
1599  const auto endSample = startSample + clip->GetNumSamples();
1600  if (s >= startSample && s < endSample)
1601  return startSample + clip->GetSequence()->GetBlockStart(s - startSample);
1602  }
1603 
1604  return -1;
1605 }
int mRate
Definition: WaveTrack.h:614
WaveClipHolders mClips
Definition: WaveTrack.h:611
const std::vector<Location>& WaveTrack::GetCachedLocations ( ) const
inline

Definition at line 502 of file WaveTrack.h.

Referenced by TrackArtist::DrawWaveform().

502 { return mDisplayLocationsCache; }
std::vector< Location > mDisplayLocationsCache
Definition: WaveTrack.h:632
int WaveTrack::GetChannel ( ) const
overridevirtual

Reimplemented from Track.

Definition at line 236 of file WaveTrack.cpp.

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

Referenced by audacityAudioCallback(), WaveTrackMenuTable::InitMenu(), Mixer::Process(), and Effect::ProcessPass().

237 {
239  return mChannel;
240  auto pan = GetPan();
241  if( pan < -0.99 )
242  return Track::LeftChannel;
243  if( pan > 0.99 )
244  return Track::RightChannel;
245  return mChannel;
246 }
float GetPan() const
Definition: WaveTrack.cpp:425
int mChannel
Definition: Track.h:229
float WaveTrack::GetChannelGain ( int  channel) const

Definition at line 440 of file WaveTrack.cpp.

References mGain, and mPan.

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

441 {
442  float left = 1.0;
443  float right = 1.0;
444 
445  if (mPan < 0)
446  right = (mPan + 1.0);
447  else if (mPan > 0)
448  left = 1.0 - mPan;
449 
450  if ((channel%2) == 0)
451  return left*mGain;
452  else
453  return right*mGain;
454 }
float mGain
Definition: WaveTrack.h:615
float mPan
Definition: WaveTrack.h:616
WaveClip * WaveTrack::GetClipAtSample ( sampleCount  sample)

Definition at line 2174 of file WaveTrack.cpp.

References WaveClip::GetNumSamples(), WaveClip::GetStartSample(), and mClips.

Referenced by AudacityProject::OnPunchAndRoll().

2175 {
2176  for (const auto &clip: mClips)
2177  {
2178  auto start = clip->GetStartSample();
2179  auto len = clip->GetNumSamples();
2180 
2181  if (sample >= start && sample < start + len)
2182  return clip.get();
2183  }
2184 
2185  return NULL;
2186 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
WaveClip * WaveTrack::GetClipAtTime ( double  time)

Definition at line 2190 of file WaveTrack.cpp.

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

2191 {
2192 
2193  const auto clips = SortedClipArray();
2194  auto p = std::find_if(clips.rbegin(), clips.rend(), [&] (WaveClip* const& clip) {
2195  return time >= clip->GetStartTime() && time <= clip->GetEndTime(); });
2196 
2197  // When two clips are immediately next to each other, the GetEndTime() of the first clip
2198  // and the GetStartTime() of the second clip may not be exactly equal due to rounding errors.
2199  // If "time" is the end time of the first of two such clips, and the end time is slightly
2200  // less than the start time of the second clip, then the first rather than the
2201  // second clip is found by the above code. So correct this.
2202  if (p != clips.rend() && p != clips.rbegin() &&
2203  time == (*p)->GetEndTime() &&
2204  (*p)->SharesBoundaryWithNextClip(*(p-1))) {
2205  p--;
2206  }
2207 
2208  return p != clips.rend() ? *p : nullptr;
2209 }
WaveClipPointers SortedClipArray()
Definition: WaveTrack.cpp:2576
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
WaveClip * WaveTrack::GetClipAtX ( int  xcoord)

Definition at line 2161 of file WaveTrack.cpp.

References WaveClip::GetDisplayRect(), and mClips.

Referenced by SelectHandle::Click(), TimeShiftHandle::Click(), GetEnvelopeAtX(), and GetSequenceAtX().

2162 {
2163  for (const auto &clip: mClips)
2164  {
2165  wxRect r;
2166  clip->GetDisplayRect(&r);
2167  if (xcoord >= r.x && xcoord < r.x+r.width)
2168  return clip.get();
2169  }
2170 
2171  return NULL;
2172 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
WaveClip * WaveTrack::GetClipByIndex ( int  index)

Definition at line 2277 of file WaveTrack.cpp.

References mClips.

Referenced by GetClipByIndex(), AudacityProject::GetTime(), MergeClips(), and Paste().

2278 {
2279  if(index < (int)mClips.size())
2280  return mClips[index].get();
2281  else
2282  return nullptr;
2283 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
const WaveClip * WaveTrack::GetClipByIndex ( int  index) const

Definition at line 2285 of file WaveTrack.cpp.

References GetClipByIndex().

2286 {
2287  return const_cast<WaveTrack&>(*this).GetClipByIndex(index);
2288 }
WaveClip * GetClipByIndex(int index)
Definition: WaveTrack.cpp:2277
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
int WaveTrack::GetClipIndex ( const WaveClip clip) const

Definition at line 2270 of file WaveTrack.cpp.

References mClips.

Referenced by ClearAndPaste(), and UpdateLocationsCache().

2271 {
2272  int result;
2273  FindClip(mClips, clip, &result);
2274  return result;
2275 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
WaveClipHolders& WaveTrack::GetClips ( )
inline
const WaveClipConstHolders& WaveTrack::GetClips ( ) const
inline

Definition at line 365 of file WaveTrack.h.

366  { return reinterpret_cast< const WaveClipConstHolders& >( mClips ); }
WaveClipHolders mClips
Definition: WaveTrack.h:611
std::vector< std::shared_ptr< const WaveClip > > WaveClipConstHolders
Definition: WaveClip.h:123
std::shared_ptr< TrackControls > WaveTrack::GetControls ( )
overrideprotectedvirtual

Implements Track.

Definition at line 104 of file WaveTrackUI.cpp.

References Track::Pointer().

105 {
106  return std::make_shared<WaveTrackControls>( Pointer( this ) );
107 }
static std::shared_ptr< Subclass > Pointer(Track *t)
Definition: Track.h:137
WaveTrackDisplay WaveTrack::GetDisplay ( ) const
inline
void WaveTrack::GetDisplayBounds ( float *  min,
float *  max 
) const

Definition at line 325 of file WaveTrack.cpp.

References mDisplayMax, and mDisplayMin.

Referenced by EnvelopeHandle::Click(), WaveTrackVZoomHandle::DoZoom(), TrackArtist::DrawClipWaveform(), SampleHandle::HitTest(), and TrackArtist::UpdateVRuler().

326 {
327  *min = mDisplayMin;
328  *max = mDisplayMax;
329 }
float mDisplayMin
Definition: WaveTrack.h:624
int min(int a, int b)
float mDisplayMax
Definition: WaveTrack.h:625
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 1873 of file WaveTrack.cpp.

References WaveClip::GetEndTime(), and mClips.

Referenced by EffectTruncSilence::Analyze(), Copy(), Effect::GetSamples(), AudacityProject::GetTime(), Mixer::MixSameRate(), Mixer::MixVariableRates(), AudacityProject::OnPunchAndRoll(), ControlToolBar::OnRecord(), Paste(), EffectStereoToMono::Process(), EffectFindClipping::Process(), EffectChangeSpeed::Process(), EffectNoiseReduction::Worker::Process(), EffectStereoToMono::ProcessOne(), NyquistEffect::ProcessOne(), SyncLockAdjust(), and Trim().

1874 {
1875  bool found = false;
1876  double best = 0.0;
1877 
1878  if (mClips.empty())
1879  return 0;
1880 
1881  for (const auto &clip : mClips)
1882  if (!found)
1883  {
1884  found = true;
1885  best = clip->GetEndTime();
1886  }
1887  else if (clip->GetEndTime() > best)
1888  best = clip->GetEndTime();
1889 
1890  return best;
1891 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
Envelope * WaveTrack::GetEnvelopeAtX ( int  xcoord)

Definition at line 2211 of file WaveTrack.cpp.

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

Referenced by EnvelopeHandle::Click(), and SampleHandle::HitTest().

2212 {
2213  WaveClip* clip = GetClipAtX(xcoord);
2214  if (clip)
2215  return clip->GetEnvelope();
2216  else
2217  return NULL;
2218 }
Envelope * GetEnvelope()
Definition: WaveClip.h:243
WaveClip * GetClipAtX(int xcoord)
Definition: WaveTrack.cpp:2161
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
void WaveTrack::GetEnvelopeValues ( double *  buffer,
size_t  bufferLen,
double  t0 
) const

Definition at line 2095 of file WaveTrack.cpp.

References WaveClip::GetEndSample(), WaveClip::GetEndTime(), WaveClip::GetEnvelope(), WaveClip::GetStartSample(), WaveClip::GetStartTime(), Envelope::GetValues(), limitSampleBufferSize(), mClips, min(), and mRate.

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

2097 {
2098  // The output buffer corresponds to an unbroken span of time which the callers expect
2099  // to be fully valid. As clips are processed below, the output buffer is updated with
2100  // envelope values from any portion of a clip, start, end, middle, or none at all.
2101  // Since this does not guarantee that the entire buffer is filled with values we need
2102  // to initialize the entire buffer to a default value.
2103  //
2104  // This does mean that, in the cases where a usable clip is located, the buffer value will
2105  // be set twice. Unfortunately, there is no easy way around this since the clips are not
2106  // stored in increasing time order. If they were, we could just track the time as the
2107  // buffer is filled.
2108  for (decltype(bufferLen) i = 0; i < bufferLen; i++)
2109  {
2110  buffer[i] = 1.0;
2111  }
2112 
2113  double startTime = t0;
2114  auto tstep = 1.0 / mRate;
2115  double endTime = t0 + tstep * bufferLen;
2116  for (const auto &clip: mClips)
2117  {
2118  // IF clip intersects startTime..endTime THEN...
2119  auto dClipStartTime = clip->GetStartTime();
2120  auto dClipEndTime = clip->GetEndTime();
2121  if ((dClipStartTime < endTime) && (dClipEndTime > startTime))
2122  {
2123  auto rbuf = buffer;
2124  auto rlen = bufferLen;
2125  auto rt0 = t0;
2126 
2127  if (rt0 < dClipStartTime)
2128  {
2129  // This is not more than the number of samples in
2130  // (endTime - startTime) which is bufferLen:
2131  auto nDiff = (sampleCount)floor((dClipStartTime - rt0) * mRate + 0.5);
2132  auto snDiff = nDiff.as_size_t();
2133  rbuf += snDiff;
2134  wxASSERT(snDiff <= rlen);
2135  rlen -= snDiff;
2136  rt0 = dClipStartTime;
2137  }
2138 
2139  if (rt0 + rlen*tstep > dClipEndTime)
2140  {
2141  auto nClipLen = clip->GetEndSample() - clip->GetStartSample();
2142 
2143  if (nClipLen <= 0) // Testing for bug 641, this problem is consistently '== 0', but doesn't hurt to check <.
2144  return;
2145 
2146  // This check prevents problem cited in http://bugzilla.audacityteam.org/show_bug.cgi?id=528#c11,
2147  // Gale's cross_fade_out project, which was already corrupted by bug 528.
2148  // This conditional prevents the previous write past the buffer end, in clip->GetEnvelope() call.
2149  // Never increase rlen here.
2150  // PRL bug 827: rewrote it again
2151  rlen = limitSampleBufferSize( rlen, nClipLen );
2152  rlen = std::min(rlen, size_t(floor(0.5 + (dClipEndTime - rt0) / tstep)));
2153  }
2154  // Samples are obtained for the purpose of rendering a wave track,
2155  // so quantize time
2156  clip->GetEnvelope()->GetValues(rbuf, rlen, rt0, tstep);
2157  }
2158  }
2159 }
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: Types.h:178
int min(int a, int b)
int mRate
Definition: WaveTrack.h:614
WaveClipHolders mClips
Definition: WaveTrack.h:611
bool WaveTrack::GetErrorOpening ( )
overridevirtual

Reimplemented from Track.

Definition at line 1809 of file WaveTrack.cpp.

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

1810 {
1811  for (const auto &clip : mClips)
1812  if (clip->GetSequence()->GetErrorOpening())
1813  return true;
1814 
1815  return false;
1816 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
float WaveTrack::GetGain ( ) const

Definition at line 415 of file WaveTrack.cpp.

References mGain.

Referenced by TrackInfo::GainSlider(), and AudacityProject::WriteXML().

416 {
417  return mGain;
418 }
float mGain
Definition: WaveTrack.h:615
size_t WaveTrack::GetIdealBlockSize ( )

Definition at line 1645 of file WaveTrack.cpp.

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

Referenced by NyquistEffect::GetCallback().

1646 {
1648 }
Sequence * GetSequence()
Definition: WaveClip.h:250
WaveClip * NewestOrNewClip()
Get access to the most recently added clip, or create a clip, if there is not already one...
Definition: WaveTrack.cpp:2235
size_t GetIdealBlockSize() const
Definition: Sequence.cpp:88
SpectrogramSettings & WaveTrack::GetIndependentSpectrogramSettings ( )

Definition at line 706 of file WaveTrack.cpp.

References SpectrogramSettings::defaults(), and mpSpectrumSettings.

Referenced by SpectrumVRulerMenuTable::OnSpectrumScaleType(), SpectrumPrefs::Preview(), SpectrumPrefs::Rollback(), and UseSpectralPrefs().

707 {
708  if (!mpSpectrumSettings)
710  std::make_unique<SpectrogramSettings>(SpectrogramSettings::defaults());
711  return *mpSpectrumSettings;
712 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:649
static SpectrogramSettings & defaults()
WaveformSettings & WaveTrack::GetIndependentWaveformSettings ( )

Definition at line 754 of file WaveTrack.cpp.

References WaveformSettings::defaults(), and mpWaveformSettings.

Referenced by WaveformPrefs::Commit(), WaveTrackMenuTable::OnSetDisplay(), WaveformVRulerMenuTable::OnWaveformScaleType(), and WaveTrack().

755 {
756  if (!mpWaveformSettings)
757  mpWaveformSettings = std::make_unique<WaveformSettings>(WaveformSettings::defaults());
758  return *mpWaveformSettings;
759 }
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:650
static WaveformSettings & defaults()
int WaveTrack::GetKind ( ) const
inlineoverridevirtual
int WaveTrack::GetLastdBRange ( ) const
inline

Definition at line 590 of file WaveTrack.h.

Referenced by TrackArtist::UpdateVRuler().

590 { return mLastdBRange; }
int mLastdBRange
Definition: WaveTrack.h:631
int WaveTrack::GetLastScaleType ( ) const
inline

Definition at line 587 of file WaveTrack.h.

Referenced by TrackArtist::UpdateVRuler().

587 { return mLastScaleType; }
int mLastScaleType
Definition: WaveTrack.h:630
size_t WaveTrack::GetMaxBlockSize ( ) const

Definition at line 1625 of file WaveTrack.cpp.

References Sequence::GetMaxBlockSize(), WaveClip::GetSequence(), mClips, Track::mDirManager, and mFormat.

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

1626 {
1627  decltype(GetMaxBlockSize()) maxblocksize = 0;
1628  for (const auto &clip : mClips)
1629  {
1630  maxblocksize = std::max(maxblocksize, clip->GetSequence()->GetMaxBlockSize());
1631  }
1632 
1633  if (maxblocksize == 0)
1634  {
1635  // We really need the maximum block size, so create a
1636  // temporary sequence to get it.
1637  maxblocksize = Sequence{ mDirManager, mFormat }.GetMaxBlockSize();
1638  }
1639 
1640  wxASSERT(maxblocksize > 0);
1641 
1642  return maxblocksize;
1643 }
A WaveTrack contains WaveClip(s). A WaveClip contains a Sequence. A Sequence is primarily an interfac...
Definition: Sequence.h:54
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:1625
sampleFormat mFormat
Definition: WaveTrack.h:613
WaveClipHolders mClips
Definition: WaveTrack.h:611
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:232
std::pair< float, float > WaveTrack::GetMinMax ( double  t0,
double  t1,
bool  mayThrow = true 
) const

Definition at line 1898 of file WaveTrack.cpp.

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

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

1900 {
1901  std::pair<float, float> results {
1902  // we need these at extremes to make sure we find true min and max
1903  FLT_MAX, -FLT_MAX
1904  };
1905  bool clipFound = false;
1906 
1907  if (t0 > t1) {
1908  if (mayThrow)
1910  return results;
1911  }
1912 
1913  if (t0 == t1)
1914  return results;
1915 
1916  for (const auto &clip: mClips)
1917  {
1918  if (t1 >= clip->GetStartTime() && t0 <= clip->GetEndTime())
1919  {
1920  clipFound = true;
1921  auto clipResults = clip->GetMinMax(t0, t1, mayThrow);
1922  if (clipResults.first < results.first)
1923  results.first = clipResults.first;
1924  if (clipResults.second > results.second)
1925  results.second = clipResults.second;
1926  }
1927  }
1928 
1929  if(!clipFound)
1930  {
1931  results = { 0.f, 0.f }; // sensible defaults if no clips found
1932  }
1933 
1934  return results;
1935 }
#define THROW_INCONSISTENCY_EXCEPTION
WaveClipHolders mClips
Definition: WaveTrack.h:611
int WaveTrack::GetNumClips ( ) const

Definition at line 2290 of file WaveTrack.cpp.

References mClips.

Referenced by AudacityProject::GetTime(), and Paste().

2291 {
2292  return mClips.size();
2293 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
unsigned int WaveTrack::GetODFlags ( ) const

gets an int with OD flags so that we can determine which ODTasks should be run on this track after save/open, etc.

Definition at line 1583 of file WaveTrack.cpp.

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

Referenced by EffectNormalize::AnalyseTrack().

1584 {
1585  unsigned int ret = 0;
1586  for (const auto &clip : mClips)
1587  {
1588  ret = ret | clip->GetSequence()->GetODFlags();
1589  }
1590  return ret;
1591 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
double WaveTrack::GetOffset ( ) const
overridevirtual

Implements Track.

Definition at line 219 of file WaveTrack.cpp.

References GetStartTime().

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

220 {
221  return GetStartTime();
222 }
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1853
float WaveTrack::GetPan ( ) const

Definition at line 425 of file WaveTrack.cpp.

References mPan.

Referenced by GetChannel(), TrackList::GetNumExportChannels(), TrackInfo::PanSlider(), and AudacityProject::WriteXML().

426 {
427  return mPan;
428 }
float mPan
Definition: WaveTrack.h:616
double WaveTrack::GetRate ( ) const
float WaveTrack::GetRMS ( double  t0,
double  t1,
bool  mayThrow = true 
) const

Definition at line 1937 of file WaveTrack.cpp.

References sampleCount::as_double(), WaveClip::GetEndTime(), WaveClip::GetRMS(), WaveClip::GetStartTime(), mClips, THROW_INCONSISTENCY_EXCEPTION, and WaveClip::TimeToSamplesClip().

Referenced by NyquistEffect::ProcessOne().

1938 {
1939  if (t0 > t1) {
1940  if (mayThrow)
1942  return 0.f;
1943  }
1944 
1945  if (t0 == t1)
1946  return 0.f;
1947 
1948  double sumsq = 0.0;
1949  sampleCount length = 0;
1950 
1951  for (const auto &clip: mClips)
1952  {
1953  // If t1 == clip->GetStartTime() or t0 == clip->GetEndTime(), then the clip
1954  // is not inside the selection, so we don't want it.
1955  // if (t1 >= clip->GetStartTime() && t0 <= clip->GetEndTime())
1956  if (t1 >= clip->GetStartTime() && t0 <= clip->GetEndTime())
1957  {
1958  sampleCount clipStart, clipEnd;
1959 
1960  float cliprms = clip->GetRMS(t0, t1, mayThrow);
1961 
1962  clip->TimeToSamplesClip(wxMax(t0, clip->GetStartTime()), &clipStart);
1963  clip->TimeToSamplesClip(wxMin(t1, clip->GetEndTime()), &clipEnd);
1964  sumsq += cliprms * cliprms * (clipEnd - clipStart).as_float();
1965  length += (clipEnd - clipStart);
1966  }
1967  }
1968  return length > 0 ? sqrt(sumsq / length.as_double()) : 0.0;
1969 }
double as_double() const
Definition: Types.h:88
#define THROW_INCONSISTENCY_EXCEPTION
WaveClipHolders mClips
Definition: WaveTrack.h:611
sampleFormat WaveTrack::GetSampleFormat ( ) const
inline
Sequence * WaveTrack::GetSequenceAtX ( int  xcoord)

Definition at line 2220 of file WaveTrack.cpp.

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

2221 {
2222  WaveClip* clip = GetClipAtX(xcoord);
2223  if (clip)
2224  return clip->GetSequence();
2225  else
2226  return NULL;
2227 }
Sequence * GetSequence()
Definition: WaveClip.h:250
WaveClip * GetClipAtX(int xcoord)
Definition: WaveTrack.cpp:2161
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
const SpectrogramSettings & WaveTrack::GetSpectrogramSettings ( ) const
SpectrogramSettings & WaveTrack::GetSpectrogramSettings ( )

Definition at line 698 of file WaveTrack.cpp.

References SpectrogramSettings::defaults(), and mpSpectrumSettings.

699 {
700  if (mpSpectrumSettings)
701  return *mpSpectrumSettings;
702  else
704 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:649
static SpectrogramSettings & defaults()
void WaveTrack::GetSpectrumBounds ( float *  min,
float *  max 
) const

Definition at line 337 of file WaveTrack.cpp.

References SpectrogramSettings::GetFFTLength(), GetRate(), GetSpectrogramSettings(), SpectrogramSettings::maxFreq, min(), SpectrogramSettings::minFreq, mSpectrumMax, mSpectrumMin, SpectrogramSettings::scaleType, SpectrogramSettings::stLinear, and SpectrogramSettings::stPeriod.

Referenced by WaveTrackVZoomHandle::DoZoom(), TrackArtist::DrawClipSpectrum(), SpectrumPrefs::SpectrumPrefs(), and TrackArtist::UpdateVRuler().

338 {
339  const double rate = GetRate();
340 
341  const SpectrogramSettings &settings = GetSpectrogramSettings();
342  const SpectrogramSettings::ScaleType type = settings.scaleType;
343 
344  const float top = (rate / 2.);
345 
346  float bottom;
347  if (type == SpectrogramSettings::stLinear)
348  bottom = 0.0f;
349  else if (type == SpectrogramSettings::stPeriod) {
350  // special case
351  const auto half = settings.GetFFTLength() / 2;
352  // EAC returns no data for below this frequency:
353  const float bin2 = rate / half;
354  bottom = bin2;
355  }
356  else
357  // logarithmic, etc.
358  bottom = 1.0f;
359 
360  {
361  float spectrumMax = mSpectrumMax;
362  if (spectrumMax < 0)
363  spectrumMax = settings.maxFreq;
364  if (spectrumMax < 0)
365  *max = top;
366  else
367  *max = std::max(bottom, std::min(top, spectrumMax));
368  }
369 
370  {
371  float spectrumMin = mSpectrumMin;
372  if (spectrumMin < 0)
373  spectrumMin = settings.minFreq;
374  if (spectrumMin < 0)
375  *min = std::max(bottom, top / 1000.0f);
376  else
377  *min = std::max(bottom, std::min(top, spectrumMin));
378  }
379 }
Spectrogram settings, either for one track or as defaults.
float mSpectrumMax
Definition: WaveTrack.h:627
size_t GetFFTLength() const
const SpectrogramSettings & GetSpectrogramSettings() const
Definition: WaveTrack.cpp:690
float mSpectrumMin
Definition: WaveTrack.h:626
int min(int a, int b)
double GetRate() const
Definition: WaveTrack.cpp:398
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 1853 of file WaveTrack.cpp.

References WaveClip::GetStartTime(), and mClips.

Referenced by Copy(), GetOffset(), Effect::GetSamples(), Mixer::MixSameRate(), Mixer::MixVariableRates(), Paste(), EffectRepair::Process(), EffectStereoToMono::Process(), EffectFindClipping::Process(), EffectClickRemoval::Process(), EffectChangeSpeed::Process(), EffectEqualization::Process(), EffectNoiseReduction::Worker::Process(), EffectStereoToMono::ProcessOne(), NyquistEffect::ProcessOne(), and Trim().

1854 {
1855  bool found = false;
1856  double best = 0.0;
1857 
1858  if (mClips.empty())
1859  return 0;
1860 
1861  for (const auto &clip : mClips)
1862  if (!found)
1863  {
1864  found = true;
1865  best = clip->GetStartTime();
1866  }
1867  else if (clip->GetStartTime() < best)
1868  best = clip->GetStartTime();
1869 
1870  return best;
1871 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
std::shared_ptr< TrackVRulerControls > WaveTrack::GetVRulerControls ( )
overrideprotectedvirtual

Implements Track.

Definition at line 109 of file WaveTrackUI.cpp.

References Track::Pointer().

Referenced by DoSetMinimized().

110 {
111  return std::make_shared<WaveTrackVRulerControls>( Pointer( this ) );
112 }
static std::shared_ptr< Subclass > Pointer(Track *t)
Definition: Track.h:137
int WaveTrack::GetWaveColorIndex ( ) const
inline

Definition at line 143 of file WaveTrack.h.

Referenced by CreateClip(), WaveColorMenuTable::InitMenu(), InsertSilence(), and Effect::ProcessTrack().

143 { return mWaveColorIndex; };
int mWaveColorIndex
Definition: WaveTrack.h:617
const WaveformSettings & WaveTrack::GetWaveformSettings ( ) const
WaveformSettings & WaveTrack::GetWaveformSettings ( )

Definition at line 746 of file WaveTrack.cpp.

References WaveformSettings::defaults(), and mpWaveformSettings.

747 {
748  if (mpWaveformSettings)
749  return *mpWaveformSettings;
750  else
752 }
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:650
static WaveformSettings & defaults()
void WaveTrack::HandleClear ( double  t0,
double  t1,
bool  addCutLines,
bool  split 
)

Definition at line 1010 of file WaveTrack.cpp.

References WaveClip::AfterClip(), WaveClip::BeforeClip(), WaveClip::Clear(), AudacityPrefs::GetEditClipsCanMove(), WaveClip::GetEndTime(), WaveClip::GetStartTime(), gPrefs, mClips, Track::mDirManager, WaveClip::Offset(), and THROW_INCONSISTENCY_EXCEPTION.

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

1013 {
1014  if (t1 < t0)
1016 
1017  bool editClipCanMove = gPrefs->GetEditClipsCanMove();
1018 
1019  WaveClipPointers clipsToDelete;
1020  WaveClipHolders clipsToAdd;
1021 
1022  // We only add cut lines when deleting in the middle of a single clip
1023  // The cut line code is not really prepared to handle other situations
1024  if (addCutLines)
1025  {
1026  for (const auto &clip : mClips)
1027  {
1028  if (!clip->BeforeClip(t1) && !clip->AfterClip(t0) &&
1029  (clip->BeforeClip(t0) || clip->AfterClip(t1)))
1030  {
1031  addCutLines = false;
1032  break;
1033  }
1034  }
1035  }
1036 
1037  for (const auto &clip : mClips)
1038  {
1039  if (clip->BeforeClip(t0) && clip->AfterClip(t1))
1040  {
1041  // Whole clip must be deleted - remember this
1042  clipsToDelete.push_back(clip.get());
1043  }
1044  else if (!clip->BeforeClip(t1) && !clip->AfterClip(t0))
1045  {
1046  // Clip data is affected by command
1047  if (addCutLines)
1048  {
1049  // Don't modify this clip in place, because we want a strong
1050  // guarantee, and might modify another clip
1051  clipsToDelete.push_back( clip.get() );
1052  auto newClip = std::make_unique<WaveClip>( *clip, mDirManager, true );
1053  newClip->ClearAndAddCutLine( t0, t1 );
1054  clipsToAdd.push_back( std::move( newClip ) );
1055  }
1056  else
1057  {
1058  if (split) {
1059  // Three cases:
1060 
1061  if (clip->BeforeClip(t0)) {
1062  // Delete from the left edge
1063 
1064  // Don't modify this clip in place, because we want a strong
1065  // guarantee, and might modify another clip
1066  clipsToDelete.push_back( clip.get() );
1067  auto newClip = std::make_unique<WaveClip>( *clip, mDirManager, true );
1068  newClip->Clear(clip->GetStartTime(), t1);
1069  newClip->Offset(t1-clip->GetStartTime());
1070 
1071  clipsToAdd.push_back( std::move( newClip ) );
1072  }
1073  else if (clip->AfterClip(t1)) {
1074  // Delete to right edge
1075 
1076  // Don't modify this clip in place, because we want a strong
1077  // guarantee, and might modify another clip
1078  clipsToDelete.push_back( clip.get() );
1079  auto newClip = std::make_unique<WaveClip>( *clip, mDirManager, true );
1080  newClip->Clear(t0, clip->GetEndTime());
1081 
1082  clipsToAdd.push_back( std::move( newClip ) );
1083  }
1084  else {
1085  // Delete in the middle of the clip...we actually create two
1086  // NEW clips out of the left and right halves...
1087 
1088  // left
1089  clipsToAdd.push_back
1090  ( std::make_unique<WaveClip>( *clip, mDirManager, true ) );
1091  clipsToAdd.back()->Clear(t0, clip->GetEndTime());
1092 
1093  // right
1094  clipsToAdd.push_back
1095  ( std::make_unique<WaveClip>( *clip, mDirManager, true ) );
1096  WaveClip *const right = clipsToAdd.back().get();
1097  right->Clear(clip->GetStartTime(), t1);
1098  right->Offset(t1 - clip->GetStartTime());
1099 
1100  clipsToDelete.push_back(clip.get());
1101  }
1102  }
1103  else {
1104  // (We are not doing a split cut)
1105 
1106  // Don't modify this clip in place, because we want a strong
1107  // guarantee, and might modify another clip
1108  clipsToDelete.push_back( clip.get() );
1109  auto newClip = std::make_unique<WaveClip>( *clip, mDirManager, true );
1110 
1111  // clip->Clear keeps points < t0 and >= t1 via Envelope::CollapseRegion
1112  newClip->Clear(t0,t1);
1113 
1114  clipsToAdd.push_back( std::move( newClip ) );
1115  }
1116  }
1117  }
1118  }
1119 
1120  // Only now, change the contents of this track
1121  // use NOFAIL-GUARANTEE for the rest
1122 
1123  for (const auto &clip : mClips)
1124  {
1125  if (clip->BeforeClip(t1))
1126  {
1127  // Clip is "behind" the region -- offset it unless we're splitting
1128  // or we're using the "don't move other clips" mode
1129  if (!split && editClipCanMove)
1130  clip->Offset(-(t1-t0));
1131  }
1132  }
1133 
1134  for (const auto &clip: clipsToDelete)
1135  {
1136  auto myIt = FindClip(mClips, clip);
1137  if (myIt != mClips.end())
1138  mClips.erase(myIt); // deletes the clip!
1139  else
1140  wxASSERT(false);
1141  }
1142 
1143  for (auto &clip: clipsToAdd)
1144  mClips.push_back(std::move(clip)); // transfer ownership
1145 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void Offset(double delta)
Definition: WaveClip.h:223
std::vector< WaveClipHolder > WaveClipHolders
Definition: WaveClip.h:122
#define THROW_INCONSISTENCY_EXCEPTION
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
WaveClipHolders mClips
Definition: WaveTrack.h:611
std::vector< WaveClip * > WaveClipPointers
Definition: WaveClip.h:126
bool GetEditClipsCanMove()
Definition: Prefs.cpp:158
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:232
void Clear(double t0, double t1)
Definition: WaveClip.cpp:1676
XMLTagHandler * WaveTrack::HandleXMLChild ( const wxChar *  tag)
overridevirtual

Implements XMLTagHandler.

Definition at line 1745 of file WaveTrack.cpp.

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

1746 {
1747  //
1748  // This is legacy code (1.2 and previous) and is not called for NEW projects!
1749  //
1750  if (!wxStrcmp(tag, wxT("sequence")) || !wxStrcmp(tag, wxT("envelope")))
1751  {
1752  // This is a legacy project, so set the cached offset
1754 
1755  // Legacy project file tracks are imported as one single wave clip
1756  if (!wxStrcmp(tag, wxT("sequence")))
1757  return NewestOrNewClip()->GetSequence();
1758  else if (!wxStrcmp(tag, wxT("envelope")))
1759  return NewestOrNewClip()->GetEnvelope();
1760  }
1761 
1762  // JKC... for 1.1.0, one step better than what we had, but still badly broken.
1763  //If we see a waveblock at this level, we'd better generate a sequence.
1764  if( !wxStrcmp( tag, wxT("waveblock" )))
1765  {
1766  // This is a legacy project, so set the cached offset
1768  Sequence *pSeq = NewestOrNewClip()->GetSequence();
1769  return pSeq;
1770  }
1771 
1772  //
1773  // This is for the NEW file format (post-1.2)
1774  //
1775  if (!wxStrcmp(tag, wxT("waveclip")))
1776  return CreateClip();
1777  else
1778  return NULL;
1779 }
WaveClip * CreateClip()
Definition: WaveTrack.cpp:2229
Sequence * GetSequence()
Definition: WaveClip.h:250
A WaveTrack contains WaveClip(s). A WaveClip contains a Sequence. A Sequence is primarily an interfac...
Definition: Sequence.h:54
WaveClip * NewestOrNewClip()
Get access to the most recently added clip, or create a clip, if there is not already one...
Definition: WaveTrack.cpp:2235
Envelope * GetEnvelope()
Definition: WaveClip.h:243
void SetOffset(double offset)
Definition: WaveClip.cpp:392
double mLegacyProjectFileOffset
Definition: WaveTrack.h:646
void WaveTrack::HandleXMLEndTag ( const wxChar *  tag)
override

Definition at line 1738 of file WaveTrack.cpp.

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

1739 {
1740  // In case we opened a pre-multiclip project, we need to
1741  // simulate closing the waveclip tag.
1742  NewestOrNewClip()->HandleXMLEndTag(wxT("waveclip"));
1743 }
WaveClip * NewestOrNewClip()
Get access to the most recently added clip, or create a clip, if there is not already one...
Definition: WaveTrack.cpp:2235
void HandleXMLEndTag(const wxChar *tag) override
Definition: WaveClip.cpp:1539
bool WaveTrack::HandleXMLTag ( const wxChar *  tag,
const wxChar **  attrs 
)
overridevirtual

Implements XMLTagHandler.

Definition at line 1660 of file WaveTrack.cpp.

References Internat::CompatibleToDouble(), PlayableTrack::HandleXMLAttribute(), XMLValueChecker::IsGoodInt(), XMLValueChecker::IsGoodString(), XMLValueChecker::IsValidChannel(), lrint, mAutoSaveIdent, Track::mChannel, mGain, Track::mHeight, mLegacyProjectFileOffset, Track::mMinimized, Track::mName, mPan, mRate, mWaveColorIndex, Track::SetLinked(), and Track::SetSelected().

1661 {
1662  if (!wxStrcmp(tag, wxT("wavetrack"))) {
1663  double dblValue;
1664  long nValue;
1665  while(*attrs) {
1666  const wxChar *attr = *attrs++;
1667  const wxChar *value = *attrs++;
1668 
1669  if (!value)
1670  break;
1671 
1672  const wxString strValue = value;
1673  if (!wxStrcmp(attr, wxT("rate")))
1674  {
1675  // mRate is an int, but "rate" in the project file is a float.
1676  if (!XMLValueChecker::IsGoodString(strValue) ||
1677  !Internat::CompatibleToDouble(strValue, &dblValue) ||
1678  (dblValue < 1.0) || (dblValue > 1000000.0)) // allow a large range to be read
1679  return false;
1680  mRate = lrint(dblValue);
1681  }
1682  else if (!wxStrcmp(attr, wxT("offset")) &&
1683  XMLValueChecker::IsGoodString(strValue) &&
1684  Internat::CompatibleToDouble(strValue, &dblValue))
1685  {
1686  // Offset is only relevant for legacy project files. The value
1687  // is cached until the actual WaveClip containing the legacy
1688  // track is created.
1689  mLegacyProjectFileOffset = dblValue;
1690  }
1691  else if (this->PlayableTrack::HandleXMLAttribute(attr, value))
1692  {}
1693  else if (!wxStrcmp(attr, wxT("height")) &&
1694  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
1695  mHeight = nValue;
1696  else if (!wxStrcmp(attr, wxT("minimized")) &&
1697  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
1698  mMinimized = (nValue != 0);
1699  else if (!wxStrcmp(attr, wxT("isSelected")) &&
1700  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
1701  this->SetSelected(nValue != 0);
1702  else if (!wxStrcmp(attr, wxT("gain")) &&
1703  XMLValueChecker::IsGoodString(strValue) &&
1704  Internat::CompatibleToDouble(strValue, &dblValue))
1705  mGain = dblValue;
1706  else if (!wxStrcmp(attr, wxT("pan")) &&
1707  XMLValueChecker::IsGoodString(strValue) &&
1708  Internat::CompatibleToDouble(strValue, &dblValue) &&
1709  (dblValue >= -1.0) && (dblValue <= 1.0))
1710  mPan = dblValue;
1711  else if (!wxStrcmp(attr, wxT("name")) && XMLValueChecker::IsGoodString(strValue))
1712  mName = strValue;
1713  else if (!wxStrcmp(attr, wxT("channel")))
1714  {
1715  if (!XMLValueChecker::IsGoodInt(strValue) || !strValue.ToLong(&nValue) ||
1717  return false;
1718  mChannel = nValue;
1719  }
1720  else if (!wxStrcmp(attr, wxT("linked")) &&
1721  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
1722  SetLinked(nValue != 0);
1723  else if (!wxStrcmp(attr, wxT("autosaveid")) &&
1724  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
1725  mAutoSaveIdent = (int) nValue;
1726  else if (!wxStrcmp(attr, wxT("colorindex")) &&
1727  XMLValueChecker::IsGoodString(strValue) &&
1728  strValue.ToLong(&nValue))
1729  // Don't use SetWaveColorIndex as it sets the clips too.
1730  mWaveColorIndex = nValue;
1731  } // while
1732  return true;
1733  }
1734 
1735  return false;
1736 }
int mAutoSaveIdent
Definition: WaveTrack.h:647
void SetLinked(bool l)
Definition: Track.cpp:244
static bool IsValidChannel(const int nValue)
bool HandleXMLAttribute(const wxChar *attr, const wxChar *value)
Definition: Track.cpp:368
int mHeight
Definition: Track.h:118
static bool IsGoodInt(const wxString &strInt)
Check that the supplied string can be converted to a long (32bit) integer.
virtual void SetSelected(bool s)
Definition: Track.cpp:99
static bool IsGoodString(const wxString &str)
static bool CompatibleToDouble(const wxString &stringToConvert, double *result)
Convert a string to a number.
Definition: Internat.cpp:122
bool mMinimized
Definition: Track.h:125
#define lrint(dbl)
Definition: float_cast.h:136
int mRate
Definition: WaveTrack.h:614
float mGain
Definition: WaveTrack.h:615
float mPan
Definition: WaveTrack.h:616
double mLegacyProjectFileOffset
Definition: WaveTrack.h:646
int mWaveColorIndex
Definition: WaveTrack.h:617
int mChannel
Definition: Track.h:229
wxString mName
Definition: Track.h:119
void WaveTrack::Init ( const WaveTrack orig)
private

Definition at line 148 of file WaveTrack.cpp.

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

Referenced by Copy(), Reinit(), and WaveTrack().

149 {
150  PlayableTrack::Init(orig);
151  mFormat = orig.mFormat;
153  mRate = orig.mRate;
154  mGain = orig.mGain;
155  mPan = orig.mPan;
157  SetName(orig.GetName());
158  mDisplay = orig.mDisplay;
159  mDisplayMin = orig.mDisplayMin;
160  mDisplayMax = orig.mDisplayMax;
161  mSpectrumMin = orig.mSpectrumMin;
162  mSpectrumMax = orig.mSpectrumMax;
163  mDisplayLocationsCache.clear();
164 }
float mDisplayMin
Definition: WaveTrack.h:624
void Init(const PlayableTrack &init)
Definition: Track.cpp:343
float mSpectrumMax
Definition: WaveTrack.h:627
std::vector< Location > mDisplayLocationsCache
Definition: WaveTrack.h:632
wxString GetDefaultName() const
Definition: Track.h:273
float mSpectrumMin
Definition: WaveTrack.h:626
WaveTrackDisplay mDisplay
Definition: WaveTrack.h:629
wxString GetName() const
Definition: Track.h:271
int mRate
Definition: WaveTrack.h:614
float mGain
Definition: WaveTrack.h:615
void SetDefaultName(const wxString &n)
Definition: Track.h:274
sampleFormat mFormat
Definition: WaveTrack.h:613
void SetName(const wxString &n)
Definition: Track.h:272
float mPan
Definition: WaveTrack.h:616
float mDisplayMax
Definition: WaveTrack.h:625
int mWaveColorIndex
Definition: WaveTrack.h:617
void WaveTrack::InsertSilence ( double  t,
double  len 
)
override

Definition at line 1385 of file WaveTrack.cpp.

References WaveClip::BeforeClip(), GetWaveColorIndex(), WaveClip::InsertSilence(), mClips, Track::mDirManager, mFormat, mRate, WaveClip::Offset(), THROW_INCONSISTENCY_EXCEPTION, and WaveClip::WithinClip().

Referenced by EffectSilence::GenerateTrack(), and Effect::GetSamples().

1387 {
1388  // Nothing to do, if length is zero.
1389  // Fixes Bug 1626
1390  if( len == 0 )
1391  return;
1392  if (len <= 0)
1394 
1395  if (mClips.empty())
1396  {
1397  // Special case if there is no clip yet
1398  auto clip = std::make_unique<WaveClip>(mDirManager, mFormat, mRate, this->GetWaveColorIndex());
1399  clip->InsertSilence(0, len);
1400  // use NOFAIL-GUARANTEE
1401  mClips.push_back( std::move( clip ) );
1402  return;
1403  }
1404  else {
1405  // Assume at most one clip contains t
1406  const auto end = mClips.end();
1407  const auto it = std::find_if( mClips.begin(), end,
1408  [&](const WaveClipHolder &clip) { return clip->WithinClip(t); } );
1409 
1410  // use STRONG-GUARANTEE
1411  if (it != end)
1412  it->get()->InsertSilence(t, len);
1413 
1414  // use NOFAIL-GUARANTEE
1415  for (const auto &clip : mClips)
1416  {
1417  if (clip->BeforeClip(t))
1418  clip->Offset(len);
1419  }
1420  }
1421 }
#define THROW_INCONSISTENCY_EXCEPTION
int GetWaveColorIndex() const
Definition: WaveTrack.h:143
int mRate
Definition: WaveTrack.h:614
sampleFormat mFormat
Definition: WaveTrack.h:613
WaveClipHolders mClips
Definition: WaveTrack.h:611
std::shared_ptr< WaveClip > WaveClipHolder
Definition: WaveClip.h:121
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:232
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 495 of file WaveTrack.cpp.

References mClips.

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

496 {
497  if (t0 > t1)
498  return true;
499 
500  //wxPrintf("Searching for overlap in %.6f...%.6f\n", t0, t1);
501  for (const auto &clip : mClips)
502  {
503  if (!clip->BeforeClip(t1) && !clip->AfterClip(t0)) {
504  //wxPrintf("Overlapping clip: %.6f...%.6f\n",
505  // clip->GetStartTime(),
506  // clip->GetEndTime());
507  // We found a clip that overlaps this region
508  return false;
509  }
510  }
511  //wxPrintf("No overlap found\n");
512 
513  // Otherwise, no clips overlap this region
514  return true;
515 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
void WaveTrack::Join ( double  t0,
double  t1 
)

Definition at line 1503 of file WaveTrack.cpp.

References WaveClip::AppendSilence(), CreateClip(), WaveClip::GetEndTime(), WaveClip::GetEnvelope(), WaveClip::GetOffset(), WaveClip::GetStartTime(), Envelope::GetValue(), mClips, mRate, WaveClip::Paste(), and WaveClip::SetOffset().

Referenced by AudacityProject::OnJoinLabels(), and EffectEqualization::ProcessOne().

1505 {
1506  // Merge all WaveClips overlapping selection into one
1507 
1508  WaveClipPointers clipsToDelete;
1509  WaveClip *newClip;
1510 
1511  for (const auto &clip: mClips)
1512  {
1513  if (clip->GetStartTime() < t1-(1.0/mRate) &&
1514  clip->GetEndTime()-(1.0/mRate) > t0) {
1515 
1516  // Put in sorted order
1517  auto it = clipsToDelete.begin(), end = clipsToDelete.end();
1518  for (; it != end; ++it)
1519  if ((*it)->GetStartTime() > clip->GetStartTime())
1520  break;
1521  //wxPrintf("Insert clip %.6f at position %d\n", clip->GetStartTime(), i);
1522  clipsToDelete.insert(it, clip.get());
1523  }
1524  }
1525 
1526  //if there are no clips to DELETE, nothing to do
1527  if( clipsToDelete.size() == 0 )
1528  return;
1529 
1530  newClip = CreateClip();
1531  double t = clipsToDelete[0]->GetOffset();
1532  newClip->SetOffset(t);
1533  for (const auto &clip : clipsToDelete)
1534  {
1535  //wxPrintf("t=%.6f adding clip (offset %.6f, %.6f ... %.6f)\n",
1536  // t, clip->GetOffset(), clip->GetStartTime(), clip->GetEndTime());
1537 
1538  if (clip->GetOffset() - t > (1.0 / mRate)) {
1539  double addedSilence = (clip->GetOffset() - t);
1540  //wxPrintf("Adding %.6f seconds of silence\n");
1541  auto offset = clip->GetOffset();
1542  auto value = clip->GetEnvelope()->GetValue( offset );
1543  newClip->AppendSilence( addedSilence, value );
1544  t += addedSilence;
1545  }
1546 
1547  //wxPrintf("Pasting at %.6f\n", t);
1548  newClip->Paste(t, clip);
1549 
1550  t = newClip->GetEndTime();
1551 
1552  auto it = FindClip(mClips, clip);
1553  mClips.erase(it); // deletes the clip
1554  }
1555 }
WaveClip * CreateClip()
Definition: WaveTrack.cpp:2229
void SetOffset(double offset)
Definition: WaveClip.cpp:392
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
int mRate
Definition: WaveTrack.h:614
WaveClipHolders mClips
Definition: WaveTrack.h:611
double GetEndTime() const
Definition: WaveClip.cpp:427
std::vector< WaveClip * > WaveClipPointers
Definition: WaveClip.h:126
void Paste(double t0, const WaveClip *other)
Paste data from other clip, resampling it if not equal rate.
Definition: WaveClip.cpp:1579
void AppendSilence(double len, double envelopeValue)
Definition: WaveClip.cpp:1669
bool WaveTrack::Lock ( ) const

Definition at line 1818 of file WaveTrack.cpp.

References WaveClip::Lock(), and mClips.

1819 {
1820  for (const auto &clip : mClips)
1821  clip->Lock();
1822 
1823  return true;
1824 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
double WaveTrack::LongSamplesToTime ( sampleCount  pos) const

Convert correctly between an 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 1848 of file WaveTrack.cpp.

References sampleCount::as_double(), and mRate.

Referenced by EffectTruncSilence::Analyze(), CompareAudioCommand::Apply(), EffectAutoDuck::ApplyDuckFade(), ClearAndPaste(), EffectTruncSilence::DoRemoval(), TrackArtist::DrawClipWaveform(), EffectTruncSilence::FindSilences(), AudacityProject::OnSplitNew(), EffectRepeat::Process(), EffectAutoDuck::Process(), EffectFindClipping::ProcessOne(), EffectEqualization::ProcessOne(), EffectReverse::ProcessOneWave(), and SplitAt().

1849 {
1850  return pos.as_double() / mRate;
1851 }
double as_double() const
Definition: Types.h:88
int mRate
Definition: WaveTrack.h:614
void WaveTrack::Merge ( const Track orig)
overridevirtual

Reimplemented from PlayableTrack.

Definition at line 193 of file WaveTrack.cpp.

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

Referenced by WaveTrackMenuTable::OnMergeStereo().

194 {
195  if (orig.GetKind() == Wave)
196  {
197  const WaveTrack &wt = static_cast<const WaveTrack&>(orig);
198  mDisplay = wt.mDisplay;
199  mGain = wt.mGain;
200  mPan = wt.mPan;
204  ? std::make_unique<SpectrogramSettings>(*wt.mpSpectrumSettings) : nullptr);
206  (wt.mpWaveformSettings ? std::make_unique<WaveformSettings>(*wt.mpWaveformSettings) : nullptr);
207  }
208  PlayableTrack::Merge(orig);
209 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:649
void Merge(const Track &init) override
Definition: Track.cpp:350
float mDisplayMin
Definition: WaveTrack.h:624
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:650
void SetSpectrogramSettings(std::unique_ptr< SpectrogramSettings > &&pSettings)
Definition: WaveTrack.cpp:714
virtual int GetKind() const
Definition: Track.h:330
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
WaveTrackDisplay mDisplay
Definition: WaveTrack.h:629
float mGain
Definition: WaveTrack.h:615
float mPan
Definition: WaveTrack.h:616
float mDisplayMax
Definition: WaveTrack.h:625
void SetWaveformSettings(std::unique_ptr< WaveformSettings > &&pSettings)
Definition: WaveTrack.cpp:761
void WaveTrack::MergeClips ( int  clipidx1,
int  clipidx2 
)

Definition at line 2533 of file WaveTrack.cpp.

References GetClipByIndex(), WaveClip::GetEndTime(), mClips, and WaveClip::Paste().

Referenced by ClearAndPaste().

2535 {
2536  WaveClip* clip1 = GetClipByIndex(clipidx1);
2537  WaveClip* clip2 = GetClipByIndex(clipidx2);
2538 
2539  if (!clip1 || !clip2) // Could happen if one track of a linked pair had a split and the other didn't.
2540  return; // Don't throw, just do nothing.
2541 
2542  // Append data from second clip to first clip
2543  // use STRONG-GUARANTEE
2544  clip1->Paste(clip1->GetEndTime(), clip2);
2545 
2546  // use NOFAIL-GUARANTEE for the rest
2547  // Delete second clip
2548  auto it = FindClip(mClips, clip2);
2549  mClips.erase(it);
2550 }
WaveClip * GetClipByIndex(int index)
Definition: WaveTrack.cpp:2277
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
WaveClipHolders mClips
Definition: WaveTrack.h:611
double GetEndTime() const
Definition: WaveClip.cpp:427
void Paste(double t0, const WaveClip *other)
Paste data from other clip, resampling it if not equal rate.
Definition: WaveClip.cpp:1579
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 2235 of file WaveTrack.cpp.

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

Referenced by GetIdealBlockSize(), HandleXMLChild(), RecordingRecoveryHandler::HandleXMLEndTag(), HandleXMLEndTag(), and RecordingRecoveryHandler::HandleXMLTag().

2236 {
2237  if (mClips.empty()) {
2238  WaveClip *clip = CreateClip();
2239  clip->SetOffset(mOffset);
2240  return clip;
2241  }
2242  else
2243  return mClips.back().get();
2244 }
WaveClip * CreateClip()
Definition: WaveTrack.cpp:2229
void SetOffset(double offset)
Definition: WaveClip.cpp:392
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
double mOffset
Definition: Track.h:230
WaveClipHolders mClips
Definition: WaveTrack.h:611
void WaveTrack::Paste ( double  t0,
const Track src 
)
override

Definition at line 1192 of file WaveTrack.cpp.

References _(), Cut(), GetClipByIndex(), AudacityPrefs::GetEditClipsCanMove(), GetEndTime(), WaveClip::GetEndTime(), WaveClip::GetIsPlaceholder(), Track::GetKind(), GetNumClips(), WaveClip::GetStartSample(), GetStartTime(), WaveClip::GetStartTime(), gPrefs, IsEmpty(), mClips, Track::mDirManager, mRate, WaveClip::Offset(), WaveClip::Paste(), TimeToLongSamples(), Track::Wave, and WaveClip::WithinClip().

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

1194 {
1195  bool editClipCanMove = gPrefs->GetEditClipsCanMove();
1196 
1197  if( src == NULL )
1198  // THROW_INCONSISTENCY_EXCEPTION; // ?
1199  return;
1200 
1201  if (src->GetKind() != Track::Wave)
1202  // THROW_INCONSISTENCY_EXCEPTION; // ?
1203  return;
1204 
1205  const WaveTrack* other = static_cast<const WaveTrack*>(src);
1206 
1207  //
1208  // Pasting is a bit complicated, because with the existence of multiclip mode,
1209  // we must guess the behaviour the user wants.
1210  //
1211  // Currently, two modes are implemented:
1212  //
1213  // - If a single clip should be pasted, and it should be pasted inside another
1214  // clip, no NEW clips are generated. The audio is simply inserted.
1215  // This resembles the old (pre-multiclip support) behaviour. However, if
1216  // the clip is pasted outside of any clip, a NEW clip is generated. This is
1217  // the only behaviour which is different to what was done before, but it
1218  // shouldn't confuse users too much.
1219  //
1220  // - If multiple clips should be pasted, or a single clip that does not fill
1221  // the duration of the pasted track, these are always pasted as single
1222  // clips, and the current clip is splitted, when necessary. This may seem
1223  // strange at first, but it probably is better than trying to auto-merge
1224  // anything. The user can still merge the clips by hand (which should be a
1225  // simple command reachable by a hotkey or single mouse click).
1226  //
1227 
1228  if (other->GetNumClips() == 0)
1229  return;
1230 
1231  //wxPrintf("paste: we have at least one clip\n");
1232 
1233  bool singleClipMode = (other->GetNumClips() == 1 &&
1234  other->GetStartTime() == 0.0);
1235 
1236  const double insertDuration = other->GetEndTime();
1237  if( insertDuration != 0 && insertDuration < 1.0/mRate )
1238  // PRL: I added this check to avoid violations of preconditions in other WaveClip and Sequence
1239  // methods, but allow the value 0 so I don't subvert the purpose of commit
1240  // 739422ba70ceb4be0bb1829b6feb0c5401de641e which causes append-recording always to make
1241  // a new clip.
1242  return;
1243 
1244  //wxPrintf("Check if we need to make room for the pasted data\n");
1245 
1246  // Make room for the pasted data
1247  if (editClipCanMove) {
1248  if (!singleClipMode) {
1249  // We need to insert multiple clips, so split the current clip and
1250  // move everything to the right, then try to paste again
1251  if (!IsEmpty(t0, GetEndTime())) {
1252  auto tmp = Cut(t0, GetEndTime()+1.0/mRate);
1253  Paste(t0 + insertDuration, tmp.get());
1254  }
1255  }
1256  else {
1257  // We only need to insert one single clip, so just move all clips
1258  // to the right of the paste point out of the way
1259  for (const auto &clip : mClips)
1260  {
1261  if (clip->GetStartTime() > t0-(1.0/mRate))
1262  clip->Offset(insertDuration);
1263  }
1264  }
1265  }
1266 
1267  if (singleClipMode)
1268  {
1269  // Single clip mode
1270  // wxPrintf("paste: checking for single clip mode!\n");
1271 
1272  WaveClip *insideClip = NULL;
1273 
1274  for (const auto &clip : mClips)
1275  {
1276  if (editClipCanMove)
1277  {
1278  if (clip->WithinClip(t0))
1279  {
1280  //wxPrintf("t0=%.6f: inside clip is %.6f ... %.6f\n",
1281  // t0, clip->GetStartTime(), clip->GetEndTime());
1282  insideClip = clip.get();
1283  break;
1284  }
1285  }
1286  else
1287  {
1288  // If clips are immovable we also allow prepending to clips
1289  if (clip->WithinClip(t0) ||
1290  TimeToLongSamples(t0) == clip->GetStartSample())
1291  {
1292  insideClip = clip.get();
1293  break;
1294  }
1295  }
1296  }
1297 
1298  if (insideClip)
1299  {
1300  // Exhibit traditional behaviour
1301  //wxPrintf("paste: traditional behaviour\n");
1302  if (!editClipCanMove)
1303  {
1304  // We did not move other clips out of the way already, so
1305  // check if we can paste without having to move other clips
1306  for (const auto &clip : mClips)
1307  {
1308  if (clip->GetStartTime() > insideClip->GetStartTime() &&
1309  insideClip->GetEndTime() + insertDuration >
1310  clip->GetStartTime())
1311  // STRONG-GUARANTEE in case of this path
1312  // not that it matters.
1314  _("There is not enough room available to paste the selection")
1315  };
1316  }
1317  }
1318 
1319  insideClip->Paste(t0, other->GetClipByIndex(0));
1320  return;
1321  }
1322 
1323  // Just fall through and exhibit NEW behaviour
1324  }
1325 
1326  // Insert NEW clips
1327  //wxPrintf("paste: multi clip mode!\n");
1328 
1329  if (!editClipCanMove && !IsEmpty(t0, t0+insertDuration-1.0/mRate))
1330  // STRONG-GUARANTEE in case of this path
1331  // not that it matters.
1333  _("There is not enough room available to paste the selection")
1334  };
1335 
1336  for (const auto &clip : other->mClips)
1337  {
1338  // AWD Oct. 2009: Don't actually paste in placeholder clips
1339  if (!clip->GetIsPlaceholder())
1340  {
1341  auto newClip =
1342  std::make_unique<WaveClip>( *clip, mDirManager, true );
1343  newClip->Resample(mRate);
1344  newClip->Offset(t0);
1345  newClip->MarkChanged();
1346  mClips.push_back(std::move(newClip)); // transfer ownership
1347  }
1348  }
1349 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
WaveClip * GetClipByIndex(int index)
Definition: WaveTrack.cpp:2277
double GetStartTime() const
Definition: WaveClip.cpp:421
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1873
virtual int GetKind() const
Definition: Track.h:330
Track::Holder Cut(double t0, double t1) override
Definition: WaveTrack.cpp:517
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1853
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
void Paste(double t0, const Track *src) override
Definition: WaveTrack.cpp:1192
int GetNumClips() const
Definition: WaveTrack.cpp:2290
int mRate
Definition: WaveTrack.h:614
WaveClipHolders mClips
Definition: WaveTrack.h:611
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1843
double GetEndTime() const
Definition: WaveClip.cpp:427
void Paste(double t0, const WaveClip *other)
Paste data from other clip, resampling it if not equal rate.
Definition: WaveClip.cpp:1579
bool IsEmpty(double t0, double t1) const
Returns true if there are no WaveClips in the specified region.
Definition: WaveTrack.cpp:495
bool GetEditClipsCanMove()
Definition: Prefs.cpp:158
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:232
void WaveTrack::Reinit ( const WaveTrack orig)

Definition at line 166 of file WaveTrack.cpp.

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

Referenced by ControlToolBar::DoRecord().

167 {
168  Init(orig);
169 
170  {
171  auto &settings = orig.mpSpectrumSettings;
172  if (settings)
173  mpSpectrumSettings = std::make_unique<SpectrogramSettings>(*settings);
174  else
175  mpSpectrumSettings.reset();
176  }
177 
178  {
179  auto &settings = orig.mpWaveformSettings;
180  if (settings)
181  mpWaveformSettings = std::make_unique<WaveformSettings>(*settings);
182  else
183  mpWaveformSettings.reset();
184  }
185 
186  this->SetOffset(orig.GetOffset());
187 
188 #ifdef EXPERIMENTAL_OUTPUT_DISPLAY
189  // To do: mYv, mHeightV, mPerY, mVirtualStereo
190 #endif
191 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:649
double GetOffset() const override
Definition: WaveTrack.cpp:219
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:650
void Init(const WaveTrack &orig)
Definition: WaveTrack.cpp:148
void SetOffset(double o) override
Definition: WaveTrack.cpp:224
std::shared_ptr< WaveClip > WaveTrack::RemoveAndReturnClip ( WaveClip clip)

Definition at line 990 of file WaveTrack.cpp.

References mClips.

Referenced by EffectReverse::ProcessOneWave().

991 {
992  // Be clear about who owns the clip!!
993  auto it = FindClip(mClips, clip);
994  if (it != mClips.end()) {
995  auto result = std::move(*it); // Array stops owning the clip, before we shrink it
996  mClips.erase(it);
997  return result;
998  }
999  else
1000  return {};
1001 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
bool WaveTrack::RemoveCutLine ( double  cutLinePosition)

Definition at line 2524 of file WaveTrack.cpp.

References mClips, and WaveClip::RemoveCutLine().

2525 {
2526  for (const auto &clip : mClips)
2527  if (clip->RemoveCutLine(cutLinePosition))
2528  return true;
2529 
2530  return false;
2531 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
void WaveTrack::Resample ( int  rate,
ProgressDialog progress = NULL 
)

Definition at line 2552 of file WaveTrack.cpp.

References mClips, mRate, and WaveClip::Resample().

2555 {
2556  for (const auto &clip : mClips)
2557  clip->Resample(rate, progress);
2558 
2559  mRate = rate;
2560 }
int mRate
Definition: WaveTrack.h:614
WaveClipHolders mClips
Definition: WaveTrack.h:611
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

Definition at line 2246 of file WaveTrack.cpp.

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

Referenced by Append(), AppendAlias(), AppendCoded(), and Flush().

2248 {
2249  if (mClips.empty()) {
2250  WaveClip *clip = CreateClip();
2251  clip->SetOffset(mOffset);
2252  return clip;
2253  }
2254  else
2255  {
2256  auto it = mClips.begin();
2257  WaveClip *rightmost = (*it++).get();
2258  double maxOffset = rightmost->GetOffset();
2259  for (auto end = mClips.end(); it != end; ++it)
2260  {
2261  WaveClip *clip = it->get();
2262  double offset = clip->GetOffset();
2263  if (maxOffset < offset)
2264  maxOffset = offset, rightmost = clip;
2265  }
2266  return rightmost;
2267  }
2268 }
WaveClip * CreateClip()
Definition: WaveTrack.cpp:2229
double GetOffset() const
Definition: WaveClip.h:222
void SetOffset(double offset)
Definition: WaveClip.cpp:392
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
double mOffset
Definition: Track.h:230
WaveClipHolders mClips
Definition: WaveTrack.h:611
void WaveTrack::Set ( samplePtr  buffer,
sampleFormat  format,
sampleCount  start,
size_t  len 
)

Definition at line 2052 of file WaveTrack.cpp.

References WaveClip::GetEndSample(), WaveClip::GetNumSamples(), WaveClip::GetStartSample(), WaveClip::MarkChanged(), mClips, min(), SAMPLE_SIZE, and WaveClip::SetSamples().

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

2055 {
2056  for (const auto &clip: mClips)
2057  {
2058  auto clipStart = clip->GetStartSample();
2059  auto clipEnd = clip->GetEndSample();
2060 
2061  if (clipEnd > start && clipStart < start+len)
2062  {
2063  // Clip sample region and Get/Put sample region overlap
2064  auto samplesToCopy =
2065  std::min( start+len - clipStart, clip->GetNumSamples() );
2066  auto startDelta = clipStart - start;
2067  decltype(startDelta) inclipDelta = 0;
2068  if (startDelta < 0)
2069  {
2070  inclipDelta = -startDelta; // make positive value
2071  samplesToCopy -= inclipDelta;
2072  // samplesToCopy is now either len or
2073  // (clipEnd - clipStart) - (start - clipStart)
2074  // == clipEnd - start > 0
2075  // samplesToCopy is not more than len
2076  //
2077  startDelta = 0;
2078  // startDelta is zero
2079  }
2080  else {
2081  // startDelta is nonnegative and less than than len
2082  // samplesToCopy is positive and not more than len
2083  }
2084 
2085  clip->SetSamples(
2086  (samplePtr)(((char*)buffer) +
2087  startDelta.as_size_t() *
2088  SAMPLE_SIZE(format)),
2089  format, inclipDelta, samplesToCopy.as_size_t() );
2090  clip->MarkChanged();
2091  }
2092  }
2093 }
#define SAMPLE_SIZE(SampleFormat)
Definition: Types.h:198
int format
Definition: ExportPCM.cpp:56
char * samplePtr
Definition: Types.h:203
if(pTrack &&pTrack->GetDisplay()!=WaveTrack::Spectrum)
int min(int a, int b)
WaveClipHolders mClips
Definition: WaveTrack.h:611
void WaveTrack::SetAutoSaveIdent ( int  id)

Definition at line 2605 of file WaveTrack.cpp.

References ident(), and mAutoSaveIdent.

Referenced by AudacityProject::WriteXML().

2606 {
2608 }
static CommandHandlerObject & ident(AudacityProject &project)
Definition: Menus.cpp:298
int mAutoSaveIdent
Definition: WaveTrack.h:647
void WaveTrack::SetDisplay ( WaveTrackDisplay  display)
inline

Definition at line 594 of file WaveTrack.h.

Referenced by WaveformPrefs::Commit(), WaveTrackMenuTable::OnSetDisplay(), SpectrumPrefs::Preview(), and SpectrumPrefs::Rollback().

594 { mDisplay = display; }
WaveTrackDisplay mDisplay
Definition: WaveTrack.h:629
void WaveTrack::SetDisplayBounds ( float  min,
float  max 
) const

Definition at line 331 of file WaveTrack.cpp.

References mDisplayMax, mDisplayMin, and min().

Referenced by WaveTrackVZoomHandle::DoZoom(), and TrackArtist::UpdateVRuler().

332 {
333  mDisplayMin = min;
334  mDisplayMax = max;
335 }
float mDisplayMin
Definition: WaveTrack.h:624
int min(int a, int b)
float mDisplayMax
Definition: WaveTrack.h:625
void WaveTrack::SetGain ( float  newGain)
void WaveTrack::SetLastdBRange ( ) const

Definition at line 320 of file WaveTrack.cpp.

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

Referenced by TrackArtist::UpdateVRuler().

321 {
323 }
int mLastdBRange
Definition: WaveTrack.h:631
const WaveformSettings & GetWaveformSettings() const
Definition: WaveTrack.cpp:738
void WaveTrack::SetLastScaleType ( ) const

Definition at line 315 of file WaveTrack.cpp.

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

Referenced by WaveTrackMenuTable::OnSetDisplay(), and TrackArtist::UpdateVRuler().

316 {
318 }
const WaveformSettings & GetWaveformSettings() const
Definition: WaveTrack.cpp:738
int mLastScaleType
Definition: WaveTrack.h:630
void WaveTrack::SetOffset ( double  o)
overridevirtual

Reimplemented from Track.

Definition at line 224 of file WaveTrack.cpp.

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

Referenced by Reinit().

226 {
227  double delta = o - GetOffset();
228 
229  for (const auto &clip : mClips)
230  // assume NOFAIL-GUARANTEE
231  clip->SetOffset(clip->GetOffset() + delta);
232 
233  mOffset = o;
234 }
double GetOffset() const override
Definition: WaveTrack.cpp:219
double mOffset
Definition: Track.h:230
WaveClipHolders mClips
Definition: WaveTrack.h:611
void WaveTrack::SetPan ( float  newPan)
overridevirtual

Reimplemented from Track.

Definition at line 430 of file WaveTrack.cpp.

References mPan.

Referenced by MixerTrackCluster::HandleSliderPan(), WaveTrackMenuTable::OnMergeStereo(), AudacityProject::OnPanTracks(), AudacityProject::SaveCopyWaveTracks(), SetPanFromChannelType(), AudacityProject::SetTrackPan(), and PanSliderHandle::SetValue().

431 {
432  if (newPan > 1.0)
433  mPan = 1.0;
434  else if (newPan < -1.0)
435  mPan = -1.0;
436  else
437  mPan = newPan;
438 }
float mPan
Definition: WaveTrack.h:616
void WaveTrack::SetPanFromChannelType ( )
overridevirtual

Reimplemented from Track.

Definition at line 248 of file WaveTrack.cpp.

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

Referenced by WaveTrackMenuTable::SplitStereo().

249 {
251  SetPan( -1.0f );
252  else if( mChannel == Track::RightChannel )
253  SetPan( 1.0f );
254 };
void SetPan(float newPan) override
Definition: WaveTrack.cpp:430
int mChannel
Definition: Track.h:229
void WaveTrack::SetRate ( double  newRate)

Definition at line 403 of file WaveTrack.cpp.

References mClips, and mRate.

Referenced by RateMenuTable::SetRate().

404 {
405  wxASSERT( newRate > 0 );
406  newRate = std::max( 1.0, newRate );
407  auto ratio = mRate / newRate;
408  mRate = (int) newRate;
409  for (const auto &clip : mClips) {
410  clip->SetRate((int)newRate);
411  clip->SetOffset( clip->GetOffset() * ratio );
412  }
413 }
int mRate
Definition: WaveTrack.h:614
WaveClipHolders mClips
Definition: WaveTrack.h:611
void WaveTrack::SetSpectrogramSettings ( std::unique_ptr< SpectrogramSettings > &&  pSettings)

Definition at line 714 of file WaveTrack.cpp.

References mpSpectrumSettings.

Referenced by Merge(), SpectrumPrefs::Preview(), and SpectrumPrefs::Rollback().

715 {
716  if (mpSpectrumSettings != pSettings) {
717  mpSpectrumSettings = std::move(pSettings);
718  }
719 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:649
void WaveTrack::SetSpectrumBounds ( float  min,
float  max 
) const

Definition at line 381 of file WaveTrack.cpp.

References min(), mSpectrumMax, and mSpectrumMin.

Referenced by WaveTrackVZoomHandle::DoZoom(), SpectrumPrefs::Preview(), and SpectrumPrefs::Rollback().

382 {
383  mSpectrumMin = min;
384  mSpectrumMax = max;
385 }
float mSpectrumMax
Definition: WaveTrack.h:627
float mSpectrumMin
Definition: WaveTrack.h:626
int min(int a, int b)
void WaveTrack::SetWaveColorIndex ( int  colorIndex)

Definition at line 477 of file WaveTrack.cpp.

References mClips, and mWaveColorIndex.

Referenced by SetTrackVisualsCommand::ApplyInner(), WaveColorMenuTable::OnWaveColorChange(), and NyquistEffect::ProcessOne().

479 {
480  for (const auto &clip : mClips)
481  clip->SetColourIndex( colorIndex );
482  mWaveColorIndex = colorIndex;
483 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
int mWaveColorIndex
Definition: WaveTrack.h:617
void WaveTrack::SetWaveformSettings ( std::unique_ptr< WaveformSettings > &&  pSettings)

Definition at line 761 of file WaveTrack.cpp.

References mpWaveformSettings.

Referenced by WaveformPrefs::Commit(), and Merge().

762 {
763  if (mpWaveformSettings != pSettings) {
764  mpWaveformSettings = std::move(pSettings);
765  }
766 }
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:650
void WaveTrack::Silence ( double  t0,
double  t1 
)
override

Definition at line 1351 of file WaveTrack.cpp.

References WaveClip::GetEndSample(), WaveClip::GetNumSamples(), WaveClip::GetSequence(), WaveClip::GetStartSample(), WaveClip::MarkChanged(), mClips, mRate, Sequence::SetSilence(), and THROW_INCONSISTENCY_EXCEPTION.

Referenced by AudacityProject::OnSilenceLabels().

1352 {
1353  if (t1 < t0)
1355 
1356  auto start = (sampleCount)floor(t0 * mRate + 0.5);
1357  auto len = (sampleCount)floor(t1 * mRate + 0.5) - start;
1358 
1359  for (const auto &clip : mClips)
1360  {
1361  auto clipStart = clip->GetStartSample();
1362  auto clipEnd = clip->GetEndSample();
1363 
1364  if (clipEnd > start && clipStart < start+len)
1365  {
1366  // Clip sample region and Get/Put sample region overlap
1367  auto samplesToCopy = start+len - clipStart;
1368  if (samplesToCopy > clip->GetNumSamples())
1369  samplesToCopy = clip->GetNumSamples();
1370  auto startDelta = clipStart - start;
1371  decltype(startDelta) inclipDelta = 0;
1372  if (startDelta < 0)
1373  {
1374  inclipDelta = -startDelta; // make positive value
1375  samplesToCopy -= inclipDelta;
1376  startDelta = 0;
1377  }
1378 
1379  clip->GetSequence()->SetSilence(inclipDelta, samplesToCopy);
1380  clip->MarkChanged();
1381  }
1382  }
1383 }
#define THROW_INCONSISTENCY_EXCEPTION
if(pTrack &&pTrack->GetDisplay()!=WaveTrack::Spectrum)
int mRate
Definition: WaveTrack.h:614
WaveClipHolders mClips
Definition: WaveTrack.h:611
WaveClipPointers WaveTrack::SortedClipArray ( )
WaveClipConstPointers WaveTrack::SortedClipArray ( ) const

Definition at line 2581 of file WaveTrack.cpp.

References mClips.

2582 {
2583  return FillSortedClipArray<WaveClipConstPointers>(mClips);
2584 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
void WaveTrack::Split ( double  t0,
double  t1 
)

Definition at line 2375 of file WaveTrack.cpp.

References SplitAt().

Referenced by AudacityProject::OnSplit(), and AudacityProject::OnSplitLabels().

2377 {
2378  SplitAt( t0 );
2379  if( t0 != t1 )
2380  SplitAt( t1 );
2381 }
void SplitAt(double t)
Definition: WaveTrack.cpp:2383
void WaveTrack::SplitAt ( double  t)

Definition at line 2383 of file WaveTrack.cpp.

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

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

2385 {
2386  for (const auto &c : mClips)
2387  {
2388  if (c->WithinClip(t))
2389  {
2390  t = LongSamplesToTime(TimeToLongSamples(t)); // put t on a sample
2391  auto newClip = std::make_unique<WaveClip>( *c, mDirManager, true );
2392  c->Clear(t, c->GetEndTime());
2393  newClip->Clear(c->GetStartTime(), t);
2394 
2395  //offset the NEW clip by the splitpoint (noting that it is already offset to c->GetStartTime())
2396  sampleCount here = llrint(floor(((t - c->GetStartTime()) * mRate) + 0.5));
2397  newClip->Offset(here.as_double()/(double)mRate);
2398  // This could invalidate the iterators for the loop! But we return
2399  // at once so it's okay
2400  mClips.push_back(std::move(newClip)); // transfer ownership
2401  return;
2402  }
2403  }
2404 }
double as_double() const
Definition: Types.h:88
int mRate
Definition: WaveTrack.h:614
WaveClipHolders mClips
Definition: WaveTrack.h:611
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1843
double LongSamplesToTime(sampleCount pos) const
Convert correctly between an number of samples and an (absolute) time in seconds. ...
Definition: WaveTrack.cpp:1848
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:232
Track::Holder WaveTrack::SplitCut ( double  t0,
double  t1 
)

Definition at line 529 of file WaveTrack.cpp.

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

Referenced by AudacityProject::OnSplitCutLabels().

531 {
532  if (t1 < t0)
534 
535  // SplitCut is the same as 'Copy', then 'SplitDelete'
536  auto tmp = Copy(t0, t1);
537 
538  SplitDelete(t0, t1);
539 
540  return tmp;
541 }
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: WaveTrack.cpp:605
#define THROW_INCONSISTENCY_EXCEPTION
void SplitDelete(double t0, double t1)
Definition: WaveTrack.cpp:947
void WaveTrack::SplitDelete ( double  t0,
double  t1 
)

Definition at line 947 of file WaveTrack.cpp.

References HandleClear().

Referenced by Disjoin(), AudacityProject::OnSplitDeleteLabels(), SplitCut(), and Trim().

949 {
950  bool addCutLines = false;
951  bool split = true;
952  HandleClear(t0, t1, addCutLines, split);
953 }
void HandleClear(double t0, double t1, bool addCutLines, bool split)
Definition: WaveTrack.cpp:1010
void WaveTrack::SyncLockAdjust ( double  oldT1,
double  newT1 
)
overridevirtual

Reimplemented from Track.

Definition at line 1147 of file WaveTrack.cpp.

References Clear(), Cut(), GetActiveProject(), GetEndTime(), GetRate(), GetSampleFormat(), AudacityProject::GetTrackFactory(), gPrefs, IsEmpty(), TrackFactory::NewWaveTrack(), Paste(), and THROW_INCONSISTENCY_EXCEPTION.

1148 {
1149  if (newT1 > oldT1) {
1150  // Insert space within the track
1151 
1152  // JKC: This is a rare case where using >= rather than > on a float matters.
1153  // GetEndTime() looks through the clips and may give us EXACTLY the same
1154  // value as T1, when T1 was set to be at the end of one of those clips.
1155  if (oldT1 >= GetEndTime())
1156  return;
1157 
1158  // If track is empty at oldT1 insert whitespace; otherwise, silence
1159  if (IsEmpty(oldT1, oldT1))
1160  {
1161  // Check if clips can move
1162  bool clipsCanMove = true;
1163  gPrefs->Read(wxT("/GUI/EditClipCanMove"), &clipsCanMove);
1164  if (clipsCanMove) {
1165  auto tmp = Cut (oldT1, GetEndTime() + 1.0/GetRate());
1166 
1167  Paste(newT1, tmp.get());
1168  }
1169  return;
1170  }
1171  else {
1172  // AWD: Could just use InsertSilence() on its own here, but it doesn't
1173  // follow EditClipCanMove rules (Paste() does it right)
1175  if (!p)
1177  TrackFactory *f = p->GetTrackFactory();
1178  if (!f)
1180  auto tmp = f->NewWaveTrack(GetSampleFormat(), GetRate());
1181 
1182  tmp->InsertSilence(0.0, newT1 - oldT1);
1183  tmp->Flush();
1184  Paste(oldT1, tmp.get());
1185  }
1186  }
1187  else if (newT1 < oldT1) {
1188  Clear(newT1, oldT1);
1189  }
1190 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:678
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1873
#define THROW_INCONSISTENCY_EXCEPTION
Used to create a WaveTrack, or a LabelTrack.. Implementation of the functions of this class are dispe...
Definition: Track.h:863
Track::Holder Cut(double t0, double t1) override
Definition: WaveTrack.cpp:517
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
void Paste(double t0, const Track *src) override
Definition: WaveTrack.cpp:1192
std::unique_ptr< WaveTrack > NewWaveTrack(sampleFormat format=(sampleFormat) 0, double rate=0)
Definition: WaveTrack.cpp:78
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
sampleFormat GetSampleFormat() const
Definition: WaveTrack.h:146
double GetRate() const
Definition: WaveTrack.cpp:398
bool IsEmpty(double t0, double t1) const
Returns true if there are no WaveClips in the specified region.
Definition: WaveTrack.cpp:495
TrackFactory * GetTrackFactory()
Definition: Project.cpp:1434
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 1843 of file WaveTrack.cpp.

References mRate.

Referenced by EffectNormalize::AnalyseDC(), EffectTruncSilence::Analyze(), CompareAudioCommand::Apply(), EffectAutoDuck::ApplyDuckFade(), EffectTruncSilence::CalcPreviewInputLength(), ClearAndPaste(), Disjoin(), EffectTruncSilence::DoRemoval(), TrackArtist::DrawClipWaveform(), EffectTruncSilence::FindSilences(), BlockGenerator::GenerateTrack(), FreqWindow::GetAudio(), Effect::GetSamples(), Mixer::MixVariableRates(), AudacityProject::NearestZeroCrossing(), AudacityProject::OnPunchAndRoll(), Paste(), EffectReverse::Process(), EffectStereoToMono::Process(), EffectRepeat::Process(), EffectFindClipping::Process(), EffectAutoDuck::Process(), EffectChangeSpeed::Process(), EffectNoiseReduction::Worker::Process(), EffectPaulstretch::ProcessOne(), EffectNormalize::ProcessOne(), NyquistEffect::ProcessOne(), EffectReverse::ProcessOneWave(), Effect::ProcessPass(), SplitAt(), and SelectHandle::StartSnappingFreqSelection().

1844 {
1845  return sampleCount( floor(t0 * mRate + 0.5) );
1846 }
int mRate
Definition: WaveTrack.h:614
void WaveTrack::Trim ( double  t0,
double  t1 
)

Definition at line 562 of file WaveTrack.cpp.

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

564 {
565  bool inside0 = false;
566  bool inside1 = false;
567  //Keeps track of the offset of the first clip greater than
568  // the left selection t0.
569  double firstGreaterOffset = -1;
570 
571  for (const auto &clip : mClips)
572  {
573  //Find the first clip greater than the offset.
574  //If we end up clipping the entire track, this is useful.
575  if(firstGreaterOffset < 0 &&
576  clip->GetStartTime() >= t0)
577  firstGreaterOffset = clip->GetStartTime();
578 
579  if(t1 > clip->GetStartTime() && t1 < clip->GetEndTime())
580  {
581  clip->Clear(t1,clip->GetEndTime());
582  inside1 = true;
583  }
584 
585  if(t0 > clip->GetStartTime() && t0 < clip->GetEndTime())
586  {
587  clip->Clear(clip->GetStartTime(),t0);
588  clip->SetOffset(t0);
589  inside0 = true;
590  }
591  }
592 
593  //if inside0 is false, then the left selector was between
594  //clips, so DELETE everything to its left.
595  if(!inside1 && t1 < GetEndTime())
596  Clear(t1,GetEndTime());
597 
598  if(!inside0 && t0 > GetStartTime())
599  SplitDelete(GetStartTime(), t0);
600 }
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:678
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1873
void SplitDelete(double t0, double t1)
Definition: WaveTrack.cpp:947
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1853
WaveClipHolders mClips
Definition: WaveTrack.h:611
bool WaveTrack::Unlock ( ) const

Definition at line 1835 of file WaveTrack.cpp.

References mClips, and WaveClip::Unlock().

Referenced by WaveTrack::WaveTrackLockDeleter::operator()().

1836 {
1837  for (const auto &clip : mClips)
1838  clip->Unlock();
1839 
1840  return true;
1841 }
WaveClipHolders mClips
Definition: WaveTrack.h:611
void WaveTrack::UpdateLocationsCache ( ) const

Definition at line 2406 of file WaveTrack.cpp.

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

Referenced by TrackArtist::DrawWaveform().

2407 {
2408  auto clips = SortedClipArray();
2409 
2410  mDisplayLocationsCache.clear();
2411 
2412  // Count number of display locations
2413  int num = 0;
2414  {
2415  const WaveClip *prev = nullptr;
2416  for (const auto clip : clips)
2417  {
2418  num += clip->NumCutLines();
2419 
2420  if (prev && fabs(prev->GetEndTime() -
2421  clip->GetStartTime()) < WAVETRACK_MERGE_POINT_TOLERANCE)
2422  ++num;
2423 
2424  prev = clip;
2425  }
2426  }
2427 
2428  if (num == 0)
2429  return;
2430 
2431  // Alloc necessary number of display locations
2432  mDisplayLocationsCache.reserve(num);
2433 
2434  // Add all display locations to cache
2435  int curpos = 0;
2436 
2437  const WaveClip *previousClip = nullptr;
2438  for (const auto clip: clips)
2439  {
2440  for (const auto &cc : clip->GetCutLines())
2441  {
2442  // Add cut line expander point
2444  clip->GetOffset() + cc->GetOffset(),
2446  });
2447  curpos++;
2448  }
2449 
2450  if (previousClip)
2451  {
2452  if (fabs(previousClip->GetEndTime() - clip->GetStartTime())
2454  {
2455  // Add merge point
2457  previousClip->GetEndTime(),
2459  GetClipIndex(previousClip),
2460  GetClipIndex(clip)
2461  });
2462  curpos++;
2463  }
2464  }
2465 
2466  previousClip = clip;
2467  }
2468 
2469  wxASSERT(curpos == num);
2470 }
size_t NumCutLines() const
Definition: WaveClip.h:317
WaveClipPointers SortedClipArray()
Definition: WaveTrack.cpp:2576
std::vector< Location > mDisplayLocationsCache
Definition: WaveTrack.h:632
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
#define WAVETRACK_MERGE_POINT_TOLERANCE
Definition: WaveTrack.h:38
double GetEndTime() const
Definition: WaveClip.cpp:427
int GetClipIndex(const WaveClip *clip) const
Definition: WaveTrack.cpp:2270
void WaveTrack::UseSpectralPrefs ( bool  bUse = true)

Definition at line 721 of file WaveTrack.cpp.

References GetIndependentSpectrogramSettings(), and mpSpectrumSettings.

722 {
723  if( bUse ){
724  if( !mpSpectrumSettings )
725  return;
726  // reset it, and next we will be getting the defaults.
727  mpSpectrumSettings.reset();
728  }
729  else {
730  if( mpSpectrumSettings )
731  return;
733  }
734 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:649
SpectrogramSettings & GetIndependentSpectrogramSettings()
Definition: WaveTrack.cpp:706
WaveTrack::WaveTrackDisplay WaveTrack::ValidateWaveTrackDisplay ( WaveTrackDisplay  display)
static

Definition at line 293 of file WaveTrack.cpp.

References MinDisplay, obsolete1, obsolete2, obsolete3, obsolete4, obsoleteWaveformDBDisplay, Spectrum, and Waveform.

Referenced by TracksViewModeSetting::Migrate().

294 {
295  switch (display) {
296  // non-obsolete codes
297  case Waveform:
299  case Spectrum:
300  return display;
301 
302  // obsolete codes
303  case obsolete1: // was SpectrumLogDisplay
304  case obsolete2: // was SpectralSelectionDisplay
305  case obsolete3: // was SpectralSelectionLogDisplay
306  case obsolete4: // was PitchDisplay
307  return Spectrum;
308 
309  // codes out of bounds (from future prefs files?)
310  default:
311  return MinDisplay;
312  }
313 }
void WaveTrack::WriteXML ( XMLWriter xmlFile) const
overridevirtual

Implements Track.

Definition at line 1781 of file WaveTrack.cpp.

References WaveClip::WriteXML(), and PlayableTrack::WriteXMLAttributes().

1783 {
1784  xmlFile.StartTag(wxT("wavetrack"));
1785  if (mAutoSaveIdent)
1786  {
1787  xmlFile.WriteAttr(wxT("autosaveid"), mAutoSaveIdent);
1788  }
1789  xmlFile.WriteAttr(wxT("name"), mName);
1790  xmlFile.WriteAttr(wxT("channel"), mChannel);
1791  xmlFile.WriteAttr(wxT("linked"), mLinked);
1792  this->PlayableTrack::WriteXMLAttributes(xmlFile);
1793  xmlFile.WriteAttr(wxT("height"), this->GetActualHeight());
1794  xmlFile.WriteAttr(wxT("minimized"), this->GetMinimized());
1795  xmlFile.WriteAttr(wxT("isSelected"), this->GetSelected());
1796  xmlFile.WriteAttr(wxT("rate"), mRate);
1797  xmlFile.WriteAttr(wxT("gain"), (double)mGain);
1798  xmlFile.WriteAttr(wxT("pan"), (double)mPan);
1799  xmlFile.WriteAttr(wxT("colorindex"), mWaveColorIndex );
1800 
1801  for (const auto &clip : mClips)
1802  {
1803  clip->WriteXML(xmlFile);
1804  }
1805 
1806  xmlFile.EndTag(wxT("wavetrack"));
1807 }
int GetActualHeight() const
Definition: Track.h:193
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:78
int mAutoSaveIdent
Definition: WaveTrack.h:647
virtual void WriteAttr(const wxString &name, const wxString &value)
Definition: XMLWriter.cpp:131
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:101
bool GetSelected() const
Definition: Track.h:276
bool GetMinimized() const
Definition: Track.cpp:214
void WriteXMLAttributes(XMLWriter &xmlFile) const
Definition: Track.cpp:360
int mRate
Definition: WaveTrack.h:614
float mGain
Definition: WaveTrack.h:615
bool mLinked
Definition: Track.h:124
WaveClipHolders mClips
Definition: WaveTrack.h:611
float mPan
Definition: WaveTrack.h:616
int mWaveColorIndex
Definition: WaveTrack.h:617
int mChannel
Definition: Track.h:229
wxString mName
Definition: Track.h:119
int WaveTrack::ZeroLevelYCoordinate ( wxRect  rect) const

Definition at line 387 of file WaveTrack.cpp.

References mDisplayMax, and mDisplayMin.

Referenced by TrackArtist::DrawClipWaveform().

388 {
389  return rect.GetTop() +
390  (int)((mDisplayMax / (mDisplayMax - mDisplayMin)) * rect.height);
391 }
float mDisplayMin
Definition: WaveTrack.h:624
float mDisplayMax
Definition: WaveTrack.h:625

Friends And Related Function Documentation

friend class TrackFactory
friend

Definition at line 85 of file WaveTrack.h.

Member Data Documentation

wxCriticalSection WaveTrack::mAppendCriticalSection
private

Definition at line 645 of file WaveTrack.h.

int WaveTrack::mAutoSaveIdent
private

Definition at line 647 of file WaveTrack.h.

Referenced by GetAutoSaveIdent(), HandleXMLTag(), SetAutoSaveIdent(), and WaveTrack().

WaveClipHolders WaveTrack::mClips
protected
std::weak_ptr<CutlineHandle> WaveTrack::mCutlineHandle
private

Definition at line 652 of file WaveTrack.h.

WaveTrackDisplay WaveTrack::mDisplay
protected

Definition at line 629 of file WaveTrack.h.

Referenced by Init(), Merge(), and WaveTrack().

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

Definition at line 632 of file WaveTrack.h.

Referenced by Init(), and UpdateLocationsCache().

float WaveTrack::mDisplayMax
mutableprotected
float WaveTrack::mDisplayMin
mutableprotected
std::weak_ptr<EnvelopeHandle> WaveTrack::mEnvelopeHandle
private

Definition at line 654 of file WaveTrack.h.

wxCriticalSection WaveTrack::mFlushCriticalSection
private

Definition at line 644 of file WaveTrack.h.

sampleFormat WaveTrack::mFormat
protected
float WaveTrack::mGain
protected

Definition at line 615 of file WaveTrack.h.

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

int WaveTrack::mLastdBRange
mutableprotected

Definition at line 631 of file WaveTrack.h.

Referenced by SetLastdBRange(), and WaveTrack().

int WaveTrack::mLastScaleType
mutableprotected

Definition at line 630 of file WaveTrack.h.

Referenced by SetLastScaleType(), and WaveTrack().

double WaveTrack::mLegacyProjectFileOffset
private

Definition at line 646 of file WaveTrack.h.

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

float WaveTrack::mPan
protected

Definition at line 616 of file WaveTrack.h.

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

std::unique_ptr<SpectrogramSettings> WaveTrack::mpSpectrumSettings
private
std::unique_ptr<WaveformSettings> WaveTrack::mpWaveformSettings
private
int WaveTrack::mRate
protected
std::weak_ptr<SampleHandle> WaveTrack::mSampleHandle
private

Definition at line 653 of file WaveTrack.h.

float WaveTrack::mSpectrumMax
mutableprotected

Definition at line 627 of file WaveTrack.h.

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

float WaveTrack::mSpectrumMin
mutableprotected

Definition at line 626 of file WaveTrack.h.

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

int WaveTrack::mWaveColorIndex
protected

Definition at line 617 of file WaveTrack.h.

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


The documentation for this class was generated from the following files: