Audacity  2.3.1
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  ChannelType { LeftChannel = 0, RightChannel = 1, MonoChannel = 2 }
 
enum  : unsigned { DefaultHeight = 150 }
 
using Holder = std::unique_ptr< Track >
 
template<typename R = void>
using Continuation = std::function< R() >
 
using Fallthrough = Continuation<>
 

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 ChannelType GetChannelIgnoringPan () const
 
ChannelType GetChannel () const override
 
virtual void SetPanFromChannelType () override
 
double GetStartTime () const override
 Get the time at which the first clip in the track starts. More...
 
double GetEndTime () const override
 Get the time at which the last clip in the track ends, plus recorded stuff. More...
 
double GetRate () const
 
void SetRate (double newRate)
 
float GetGain () const
 
void SetGain (float newGain)
 
float GetPan () const
 
void SetPan (float newPan) override
 
float GetChannelGain (int channel) const
 
float GetOldChannelGain (int channel) const
 
void SetOldChannelGain (int channel, float gain)
 
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::shared_ptr< const TrackSubstitutePendingChangedTrack () const
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &, const AudacityProject *pProject) finaloverride
 
std::shared_ptr< TrackPanelCellContextMenuDelegate () override
 
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)
 
bool LinkConsistencyCheck ()
 
 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)
 
void Offset (double t)
 
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 SameKindAs (const Track &track) const
 
template<typename R = void, typename... Functions>
TypeSwitch (const Functions &...functions)
 
template<typename R = void, typename... Functions>
TypeSwitch (const Functions &...functions) const
 
bool IsSyncLockSelected () const
 
bool Any () const
 
bool IsSelected () const
 
bool IsSelectedOrSyncLockSelected () const
 
bool IsLeader () const
 
bool IsSelectedLeader () const
 
- Public Member Functions inherited from CommonTrackPanelCell
 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
HitTestPreview DefaultPreview (const TrackPanelMouseState &, const AudacityProject *) override
 
- 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)
 
static void FinishCopy (const Track *n, Track *dest)
 

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 mOldGain [2]
 
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
 
ChannelType 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
 
TrackKind GetKind () 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 326 of file WaveTrack.h.

Definition at line 535 of file WaveTrack.h.

Member Enumeration Documentation

Enumerator
LinearInterpolate 
StemPlot 

Definition at line 561 of file WaveTrack.h.

Enumerator
Waveform 
MinDisplay 
obsoleteWaveformDBDisplay 
Spectrum 
obsolete1 
obsolete2 
obsolete3 
obsolete4 
MaxDisplay 
NoDisplay 

Definition at line 536 of file WaveTrack.h.

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

Definition at line 567 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, mOldGain, 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  mOldGain[0] = 0.0;
112  mOldGain[1] = 0.0;
113  mWaveColorIndex = 0;
116  mDisplayMin = -1.0;
117  mDisplayMax = 1.0;
118  mSpectrumMin = mSpectrumMax = -1; // so values will default to settings
119  mLastScaleType = -1;
120  mLastdBRange = -1;
121  mAutoSaveIdent = 0;
122 
124 }
int mAutoSaveIdent
Definition: WaveTrack.h:654
PlayableTrack(const std::shared_ptr< DirManager > &projDirManager)
Definition: Track.h:760
int mLastdBRange
Definition: WaveTrack.h:636
float mDisplayMin
Definition: WaveTrack.h:629
WaveformSettings & GetIndependentWaveformSettings()
Definition: WaveTrack.cpp:770
static wxString GetDefaultAudioTrackNamePreference()
void SetHeight(int h)
Definition: Track.cpp:179
float mSpectrumMax
Definition: WaveTrack.h:632
int mLastScaleType
Definition: WaveTrack.h:635
static unsigned DefaultWaveTrackHeight()
wxString GetDefaultName() const
Definition: Track.h:371
float mSpectrumMin
Definition: WaveTrack.h:631
int format
Definition: ExportPCM.cpp:56
sampleFormat
Definition: Types.h:188
WaveTrackDisplay mDisplay
Definition: WaveTrack.h:634
sampleFormat GetDefaultFormat()
Definition: Project.h:197
float mOldGain[2]
Definition: WaveTrack.h:622
static WaveTrack::WaveTrackDisplay ViewModeChoice()
int mRate
Definition: WaveTrack.h:618
float mGain
Definition: WaveTrack.h:619
void SetDefaultName(const wxString &n)
Definition: Track.h:372
sampleFormat mFormat
Definition: WaveTrack.h:617
void SetName(const wxString &n)
Definition: Track.h:370
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:312
float mPan
Definition: WaveTrack.h:620
double GetRate() const
Definition: Project.h:199
float mDisplayMax
Definition: WaveTrack.h:630
double mLegacyProjectFileOffset
Definition: WaveTrack.h:653
int mWaveColorIndex
Definition: WaveTrack.h:621
Waveform settings, either for one track or as defaults.
WaveTrack::WaveTrack ( const WaveTrack orig)
private

Definition at line 126 of file WaveTrack.cpp.

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

126  :
127  PlayableTrack(orig)
129  ? std::make_unique<SpectrogramSettings>(*orig.mpSpectrumSettings)
130  : nullptr
131  )
133  ? std::make_unique<WaveformSettings>(*orig.mpWaveformSettings)
134  : nullptr
135  )
136 {
137  mLastScaleType = -1;
138  mLastdBRange = -1;
139 
141 
142  Init(orig);
143 
144  for (const auto &clip : orig.mClips)
145  mClips.push_back
146  ( std::make_unique<WaveClip>( *clip, mDirManager, true ) );
147 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:656
PlayableTrack(const std::shared_ptr< DirManager > &projDirManager)
Definition: Track.h:760
int mLastdBRange
Definition: WaveTrack.h:636
int mLastScaleType
Definition: WaveTrack.h:635
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:657
void Init(const WaveTrack &orig)
Definition: WaveTrack.cpp:150
WaveClipHolders mClips
Definition: WaveTrack.h:615
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:349
double mLegacyProjectFileOffset
Definition: WaveTrack.h:653
WaveTrack::~WaveTrack ( )
virtual

Definition at line 210 of file WaveTrack.cpp.

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

211 {
212  //Let the ODManager know this WaveTrack is disappearing.
213  //Deschedules tasks associated with this track.
216 }
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 1019 of file WaveTrack.cpp.

References mClips.

Referenced by EffectReverse::ProcessOneWave().

1020 {
1021  // Uncomment the following line after we correct the problem of zero-length clips
1022  //if (CanInsertClip(clip))
1023  mClips.push_back(std::move(clip)); // transfer ownership
1024 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
void WaveTrack::AddInvalidRegion ( sampleCount  startSample,
sampleCount  endSample 
)

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

Definition at line 2609 of file WaveTrack.cpp.

References WaveClip::AddInvalidRegion().

2610 {
2611  for (const auto &clip : mClips)
2612  clip->AddInvalidRegion(startSample, endSample);
2613 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
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 1572 of file WaveTrack.cpp.

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

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

1578 {
1579  RightmostOrNewClip()->Append(buffer, format, len, stride,
1580  blockFileLog);
1581 }
WaveClip * RightmostOrNewClip()
Get access to the last (rightmost) clip, or create a clip, if there is not already one...
Definition: WaveTrack.cpp:2261
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 1583 of file WaveTrack.cpp.

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

1586 {
1587  RightmostOrNewClip()->AppendAlias(fName, start, len, channel, useOD);
1588 }
WaveClip * RightmostOrNewClip()
Get access to the last (rightmost) clip, or create a clip, if there is not already one...
Definition: WaveTrack.cpp:2261
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 1590 of file WaveTrack.cpp.

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

1593 {
1594  RightmostOrNewClip()->AppendCoded(fName, start, len, channel, decodeType);
1595 }
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:2261
bool WaveTrack::CanInsertClip ( WaveClip clip,
double &  slideBy,
double &  tolerance 
)

Definition at line 2357 of file WaveTrack.cpp.

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

2358 {
2359  for (const auto &c : mClips)
2360  {
2361  double d1 = c->GetStartTime() - (clip->GetEndTime()+slideBy);
2362  double d2 = (clip->GetStartTime()+slideBy) - c->GetEndTime();
2363  if ( (d1<0) && (d2<0) )
2364  {
2365  // clips overlap.
2366  // Try to rescue it.
2367  // The rescue logic is not perfect, and will typically
2368  // move the clip at most once.
2369  // We divide by 1000 rather than set to 0, to allow for
2370  // a second 'micro move' that is really about rounding error.
2371  if( -d1 < tolerance ){
2372  // right edge of clip overlaps slightly.
2373  // slide clip left a small amount.
2374  slideBy +=d1;
2375  tolerance /=1000;
2376  } else if( -d2 < tolerance ){
2377  // left edge of clip overlaps slightly.
2378  // slide clip right a small amount.
2379  slideBy -= d2;
2380  tolerance /=1000;
2381  }
2382  else
2383  return false; // clips overlap No tolerance left.
2384  }
2385  }
2386 
2387  return true;
2388 }
double GetStartTime() const
Definition: WaveClip.cpp:421
WaveClipHolders mClips
Definition: WaveTrack.h:615
double GetEndTime() const
Definition: WaveClip.cpp:427
bool WaveTrack::CanOffsetClip ( WaveClip clip,
double  amount,
double *  allowedAmount = NULL 
)

Definition at line 2310 of file WaveTrack.cpp.

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

2312 {
2313  if (allowedAmount)
2314  *allowedAmount = amount;
2315 
2316  for (const auto &c: mClips)
2317  {
2318  if (c.get() != clip && c->GetStartTime() < clip->GetEndTime()+amount &&
2319  c->GetEndTime() > clip->GetStartTime()+amount)
2320  {
2321  if (!allowedAmount)
2322  return false; // clips overlap
2323 
2324  if (amount > 0)
2325  {
2326  if (c->GetStartTime()-clip->GetEndTime() < *allowedAmount)
2327  *allowedAmount = c->GetStartTime()-clip->GetEndTime();
2328  if (*allowedAmount < 0)
2329  *allowedAmount = 0;
2330  } else
2331  {
2332  if (c->GetEndTime()-clip->GetStartTime() > *allowedAmount)
2333  *allowedAmount = c->GetEndTime()-clip->GetStartTime();
2334  if (*allowedAmount > 0)
2335  *allowedAmount = 0;
2336  }
2337  }
2338  }
2339 
2340  if (allowedAmount)
2341  {
2342  if (*allowedAmount == amount)
2343  return true;
2344 
2345  // Check if the NEW calculated amount would not violate
2346  // any other constraint
2347  if (!CanOffsetClip(clip, *allowedAmount, NULL)) {
2348  *allowedAmount = 0; // play safe and don't allow anything
2349  return false;
2350  }
2351  else
2352  return true;
2353  } else
2354  return true;
2355 }
double GetStartTime() const
Definition: WaveClip.cpp:421
bool CanOffsetClip(WaveClip *clip, double amount, double *allowedAmount=NULL)
Definition: WaveTrack.cpp:2310
WaveClipHolders mClips
Definition: WaveTrack.h:615
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 700 of file WaveTrack.cpp.

References HandleClear().

Referenced by MenuCommandHandler::OnCut(), and MenuCommandHandler::OnCutLabels().

702 {
703  HandleClear(t0, t1, true, false);
704 }
void HandleClear(double t0, double t1, bool addCutLines, bool split)
Definition: WaveTrack.cpp:1026
void WaveTrack::ClearAndPaste ( double  t0,
double  t1,
const Track src,
bool  preserve = true,
bool  merge = true,
const TimeWarper effectWarper = NULL 
)

Definition at line 798 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 MenuCommandHandler::OnPaste(), Generator::Process(), EffectChangeSpeed::ProcessOne(), NyquistEffect::ProcessOne(), EffectNoiseReduction::Worker::ProcessOne(), and Effect::ProcessTrack().

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

References WaveClip::ClearWaveCache().

2603 {
2604  for (const auto &clip : mClips)
2605  clip->ClearWaveCache();
2606 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
bool WaveTrack::CloseLock ( )

Definition at line 1841 of file WaveTrack.cpp.

References WaveClip::CloseLock(), and mClips.

1842 {
1843  for (const auto &clip : mClips)
1844  clip->CloseLock();
1845 
1846  return true;
1847 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
WaveTrack::WaveTrackDisplay WaveTrack::ConvertLegacyDisplayValue ( int  oldValue)
static

Definition at line 262 of file WaveTrack.cpp.

References obsoleteWaveformDBDisplay, Spectrum, and Waveform.

Referenced by TracksViewModeSetting::Migrate().

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

Definition at line 502 of file WaveTrack.cpp.

References format, mClips, and mFormat.

505 {
506  for (const auto &clip : mClips)
507  clip->ConvertToSampleFormat(format);
508  mFormat = format;
509 }
int format
Definition: ExportPCM.cpp:56
sampleFormat mFormat
Definition: WaveTrack.h:617
WaveClipHolders mClips
Definition: WaveTrack.h:615
Track::Holder WaveTrack::Copy ( double  t0,
double  t1,
bool  forClipboard = true 
) const
override

Definition at line 621 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(), MenuCommandHandler::OnSplitCut(), EffectRepeat::Process(), and SplitCut().

622 {
623  if (t1 < t0)
625 
626  WaveTrack *newTrack;
627  Track::Holder result
628  { newTrack = safenew WaveTrack{ mDirManager } };
629 
630  newTrack->Init(*this);
631 
632  // PRL: Why shouldn't cutlines be copied and pasted too? I don't know, but
633  // that was the old behavior. But this function is also used by the
634  // Duplicate command and I changed its behavior in that case.
635 
636  for (const auto &clip : mClips)
637  {
638  if (t0 <= clip->GetStartTime() && t1 >= clip->GetEndTime())
639  {
640  // Whole clip is in copy region
641  //wxPrintf("copy: clip %i is in copy region\n", (int)clip);
642 
643  newTrack->mClips.push_back
644  (std::make_unique<WaveClip>(*clip, mDirManager, ! forClipboard));
645  WaveClip *const newClip = newTrack->mClips.back().get();
646  newClip->Offset(-t0);
647  }
648  else if (t1 > clip->GetStartTime() && t0 < clip->GetEndTime())
649  {
650  // Clip is affected by command
651  //wxPrintf("copy: clip %i is affected by command\n", (int)clip);
652 
653  const double clip_t0 = std::max(t0, clip->GetStartTime());
654  const double clip_t1 = std::min(t1, clip->GetEndTime());
655 
656  auto newClip = std::make_unique<WaveClip>
657  (*clip, mDirManager, ! forClipboard, clip_t0, clip_t1);
658 
659  //wxPrintf("copy: clip_t0=%f, clip_t1=%f\n", clip_t0, clip_t1);
660 
661  newClip->Offset(-t0);
662  if (newClip->GetOffset() < 0)
663  newClip->SetOffset(0);
664 
665  newTrack->mClips.push_back(std::move(newClip)); // transfer ownership
666  }
667  }
668 
669  // AWD, Oct 2009: If the selection ends in whitespace, create a placeholder
670  // clip representing that whitespace
671  // PRL: Only if we want the track for pasting into other tracks. Not if it
672  // goes directly into a project as in the Duplicate command.
673  if (forClipboard &&
674  newTrack->GetEndTime() + 1.0 / newTrack->GetRate() < t1 - t0)
675  {
676  auto placeholder = std::make_unique<WaveClip>(mDirManager,
677  newTrack->GetSampleFormat(),
678  static_cast<int>(newTrack->GetRate()),
679  0 /*colourindex*/);
680  placeholder->SetIsPlaceholder(true);
681  placeholder->InsertSilence(0, (t1 - t0) - newTrack->GetEndTime());
682  placeholder->Offset(newTrack->GetEndTime());
683  newTrack->mClips.push_back(std::move(placeholder)); // transfer ownership
684  }
685 
686  return result;
687 }
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:1888
#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:1868
void Init(const WaveTrack &orig)
Definition: WaveTrack.cpp:150
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:615
sampleFormat GetSampleFormat() const
Definition: WaveTrack.h:150
std::unique_ptr< Track > Holder
Definition: Track.h:362
double GetRate() const
Definition: WaveTrack.cpp:401
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:349
Track::Holder WaveTrack::CopyNonconst ( double  t0,
double  t1 
)

Definition at line 689 of file WaveTrack.cpp.

References Copy().

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

690 {
691  return Copy(t0, t1);
692 }
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: WaveTrack.cpp:621
WaveClip * WaveTrack::CreateClip ( )

Definition at line 2244 of file WaveTrack.cpp.

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

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

2245 {
2246  mClips.push_back(std::make_unique<WaveClip>(mDirManager, mFormat, mRate, GetWaveColorIndex()));
2247  return mClips.back().get();
2248 }
int GetWaveColorIndex() const
Definition: WaveTrack.h:147
int mRate
Definition: WaveTrack.h:618
sampleFormat mFormat
Definition: WaveTrack.h:617
WaveClipHolders mClips
Definition: WaveTrack.h:615
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:349
Track::Holder WaveTrack::Cut ( double  t0,
double  t1 
)
override

Definition at line 533 of file WaveTrack.cpp.

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

Referenced by Paste(), and SyncLockAdjust().

534 {
535  if (t1 < t0)
537 
538  auto tmp = Copy(t0, t1);
539 
540  Clear(t0, t1);
541 
542  return tmp;
543 }
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: WaveTrack.cpp:621
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:694
#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 
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 }
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:25
Envelope * GetEnvelopeAtX(int xcoord)
Definition: WaveTrack.cpp:2226
std::weak_ptr< EnvelopeHandle > mEnvelopeHandle
Definition: WaveTrack.h:661
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:739
std::weak_ptr< SampleHandle > mSampleHandle
Definition: WaveTrack.h:660
std::weak_ptr< CutlineHandle > mCutlineHandle
Definition: WaveTrack.h:659
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:597
static std::shared_ptr< Subclass > Pointer(Track *t)
Definition: Track.h:230
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 1440 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 MenuCommandHandler::OnDisjoinLabels().

1442 {
1444  const size_t maxAtOnce = 1048576;
1445  Floats buffer{ maxAtOnce };
1446  Regions regions;
1447 
1448  wxBusyCursor busy;
1449 
1450  for (const auto &clip : mClips)
1451  {
1452  double startTime = clip->GetStartTime();
1453  double endTime = clip->GetEndTime();
1454 
1455  if( endTime < t0 || startTime > t1 )
1456  continue;
1457 
1458  if( t0 > startTime )
1459  startTime = t0;
1460  if( t1 < endTime )
1461  endTime = t1;
1462 
1463  //simply look for a sequence of zeroes and if the sequence
1464  //is greater than minimum number, split-DELETE the region
1465 
1466  sampleCount seqStart = -1;
1467  sampleCount start, end;
1468  clip->TimeToSamplesClip( startTime, &start );
1469  clip->TimeToSamplesClip( endTime, &end );
1470 
1471  auto len = ( end - start );
1472  for( decltype(len) done = 0; done < len; done += maxAtOnce )
1473  {
1474  auto numSamples = limitSampleBufferSize( maxAtOnce, len - done );
1475 
1476  clip->GetSamples( ( samplePtr )buffer.get(), floatSample, start + done,
1477  numSamples );
1478  for( decltype(numSamples) i = 0; i < numSamples; i++ )
1479  {
1480  auto curSamplePos = start + done + i;
1481 
1482  //start a NEW sequence
1483  if( buffer[ i ] == 0.0 && seqStart == -1 )
1484  seqStart = curSamplePos;
1485  else if( buffer[ i ] != 0.0 || curSamplePos == end - 1 )
1486  {
1487  if( seqStart != -1 )
1488  {
1489  decltype(end) seqEnd;
1490 
1491  //consider the end case, where selection ends in zeroes
1492  if( curSamplePos == end - 1 && buffer[ i ] == 0.0 )
1493  seqEnd = end;
1494  else
1495  seqEnd = curSamplePos;
1496  if( seqEnd - seqStart + 1 > minSamples )
1497  {
1498  regions.push_back(Region(
1499  seqStart.as_double() / GetRate()
1500  + clip->GetStartTime(),
1501  seqEnd.as_double() / GetRate()
1502  + clip->GetStartTime()));
1503  }
1504  seqStart = -1;
1505  }
1506  }
1507  }
1508  }
1509  }
1510 
1511  for( unsigned int i = 0; i < regions.size(); i++ )
1512  {
1513  const Region &region = regions.at(i);
1514  SplitDelete(region.start, region.end );
1515  }
1516 }
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:963
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:615
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:1858
double GetRate() const
Definition: WaveTrack.cpp:401
void WaveTrack::DoSetMinimized ( bool  isMinimized)
overridevirtual

Reimplemented from Track.

Definition at line 471 of file WaveTrack.cpp.

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

471  {
472 
473 #ifdef EXPERIMENTAL_HALF_WAVE
474  bool bHalfWave;
475  gPrefs->Read(wxT("/GUI/CollapseToHalfWave"), &bHalfWave, false);
476  if( bHalfWave )
477  {
478  // Show half wave on collapse, full on restore.
479  std::shared_ptr<TrackVRulerControls> pTvc = GetVRulerControls();
480 
481  // An awkward workaround for a function that lives 'in the wrong place'.
482  // We use magic numbers, 0 and 1, to tell it to zoom reset or zoom half-wave.
483  WaveTrackVRulerControls * pWtvc =
484  static_cast<WaveTrackVRulerControls*>(pTvc.get());
485  if( pWtvc )
486  pWtvc->DoZoomPreset( isMinimized ? 1:0);
487  }
488 #endif
489 
490  PlayableTrack::DoSetMinimized( isMinimized );
491 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
virtual void DoSetMinimized(bool isMinimized)
Definition: Track.cpp:229
std::shared_ptr< TrackVRulerControls > GetVRulerControls() override
Track::Holder WaveTrack::Duplicate ( ) const
overrideprivatevirtual

Implements Track.

Definition at line 396 of file WaveTrack.cpp.

References safenew.

Referenced by TrackFactory::DuplicateWaveTrack().

397 {
398  return Track::Holder{ safenew WaveTrack{ *this } };
399 }
#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:362
void WaveTrack::ExpandCutLine ( double  cutLinePosition,
double *  cutlineStart = NULL,
double *  cutlineEnd = NULL 
)

Definition at line 2488 of file WaveTrack.cpp.

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

2491 {
2492  bool editClipCanMove = gPrefs->GetEditClipsCanMove();
2493 
2494  // Find clip which contains this cut line
2495  double start = 0, end = 0;
2496  auto pEnd = mClips.end();
2497  auto pClip = std::find_if( mClips.begin(), pEnd,
2498  [&](const WaveClipHolder &clip) {
2499  return clip->FindCutLine(cutLinePosition, &start, &end); } );
2500  if (pClip != pEnd)
2501  {
2502  auto &clip = *pClip;
2503  if (!editClipCanMove)
2504  {
2505  // We are not allowed to move the other clips, so see if there
2506  // is enough room to expand the cut line
2507  for (const auto &clip2: mClips)
2508  {
2509  if (clip2->GetStartTime() > clip->GetStartTime() &&
2510  clip->GetEndTime() + end - start > clip2->GetStartTime())
2511  // STRONG-GUARANTEE in case of this path
2513  _("There is not enough room available to expand the cut line")
2514  };
2515  }
2516  }
2517 
2518  clip->ExpandCutLine(cutLinePosition);
2519 
2520  // STRONG-GUARANTEE provided that the following gives NOFAIL-GUARANTEE
2521 
2522  if (cutlineStart)
2523  *cutlineStart = start;
2524  if (cutlineEnd)
2525  *cutlineEnd = end;
2526 
2527  // Move clips which are to the right of the cut line
2528  if (editClipCanMove)
2529  {
2530  for (const auto &clip2 : mClips)
2531  {
2532  if (clip2->GetStartTime() > clip->GetStartTime())
2533  clip2->Offset(end - start);
2534  }
2535  }
2536  }
2537 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
WaveClipHolders mClips
Definition: WaveTrack.h:615
_("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 1665 of file WaveTrack.cpp.

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

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

1670 {
1671  // After appending, presumably. Do this to the clip that gets appended.
1673 }
WaveClip * RightmostOrNewClip()
Get access to the last (rightmost) clip, or create a clip, if there is not already one...
Definition: WaveTrack.cpp:2261
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 1986 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::AnalyseTrackData(), EffectTruncSilence::Analyze(), CompareAudioCommand::Apply(), EffectAutoDuck::ApplyDuckFade(), EffectTruncSilence::DoRemoval(), NyquistEffect::GetCallback(), VoiceKey::OffBackward(), VoiceKey::OffForward(), VoiceKey::OnBackward(), VoiceKey::OnForward(), MenuCommandHandler::OnPunchAndRoll(), EffectAutoDuck::Process(), EffectRepair::ProcessOne(), EffectSimpleMono::ProcessOne(), EffectStereoToMono::ProcessOne(), EffectFindClipping::ProcessOne(), EffectPaulstretch::ProcessOne(), EffectClickRemoval::ProcessOne(), EffectChangeSpeed::ProcessOne(), EffectNormalize::ProcessOne(), EffectTwoPassSimpleMono::ProcessOne(), EffectEqualization::ProcessOne(), EffectNoiseReduction::Worker::ProcessOne(), EffectReverse::ProcessOneClip(), Effect::ProcessTrack(), SelectHandle::StartSnappingFreqSelection(), VoiceKey::TestDirectionChanges(), VoiceKey::TestEnergy(), VoiceKey::TestSignChanges(), and MixerTrackCluster::UpdateMeter().

1989 {
1990  // Simple optimization: When this buffer is completely contained within one clip,
1991  // don't clear anything (because we won't have to). Otherwise, just clear
1992  // everything to be on the safe side.
1993  bool doClear = true;
1994  bool result = true;
1995  sampleCount samplesCopied = 0;
1996  for (const auto &clip: mClips)
1997  {
1998  if (start >= clip->GetStartSample() && start+len <= clip->GetEndSample())
1999  {
2000  doClear = false;
2001  break;
2002  }
2003  }
2004  if (doClear)
2005  {
2006  // Usually we fill in empty space with zero
2007  if( fill == fillZero )
2008  ClearSamples(buffer, format, 0, len);
2009  // but we don't have to.
2010  else if( fill==fillTwo )
2011  {
2012  wxASSERT( format==floatSample );
2013  float * pBuffer = (float*)buffer;
2014  for(size_t i=0;i<len;i++)
2015  pBuffer[i]=2.0f;
2016  }
2017  else
2018  {
2019  wxFAIL_MSG(wxT("Invalid fill format"));
2020  }
2021  }
2022 
2023  for (const auto &clip: mClips)
2024  {
2025  auto clipStart = clip->GetStartSample();
2026  auto clipEnd = clip->GetEndSample();
2027 
2028  if (clipEnd > start && clipStart < start+len)
2029  {
2030  // Clip sample region and Get/Put sample region overlap
2031  auto samplesToCopy =
2032  std::min( start+len - clipStart, clip->GetNumSamples() );
2033  auto startDelta = clipStart - start;
2034  decltype(startDelta) inclipDelta = 0;
2035  if (startDelta < 0)
2036  {
2037  inclipDelta = -startDelta; // make positive value
2038  samplesToCopy -= inclipDelta;
2039  // samplesToCopy is now either len or
2040  // (clipEnd - clipStart) - (start - clipStart)
2041  // == clipEnd - start > 0
2042  // samplesToCopy is not more than len
2043  //
2044  startDelta = 0;
2045  // startDelta is zero
2046  }
2047  else {
2048  // startDelta is nonnegative and less than than len
2049  // samplesToCopy is positive and not more than len
2050  }
2051 
2052  if (!clip->GetSamples(
2053  (samplePtr)(((char*)buffer) +
2054  startDelta.as_size_t() *
2055  SAMPLE_SIZE(format)),
2056  format, inclipDelta, samplesToCopy.as_size_t(), mayThrow ))
2057  result = false;
2058  else
2059  samplesCopied += samplesToCopy;
2060  }
2061  }
2062  if( pNumCopied )
2063  *pNumCopied = samplesCopied;
2064  return result;
2065 }
#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:615
void ClearSamples(samplePtr dst, sampleFormat format, size_t start, size_t len)
IteratorRange< AllClipsIterator > WaveTrack::GetAllClips ( )
inline

Definition at line 439 of file WaveTrack.h.

440  {
441  return { AllClipsIterator{ *this }, AllClipsIterator{ } };
442  }
int WaveTrack::GetAutoSaveIdent ( )

Definition at line 2615 of file WaveTrack.cpp.

References mAutoSaveIdent.

2616 {
2617  return mAutoSaveIdent;
2618 }
int mAutoSaveIdent
Definition: WaveTrack.h:654
size_t WaveTrack::GetBestBlockSize ( sampleCount  t) const

Definition at line 1622 of file WaveTrack.cpp.

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

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

1623 {
1624  auto bestBlockSize = GetMaxBlockSize();
1625 
1626  for (const auto &clip : mClips)
1627  {
1628  auto startSample = (sampleCount)floor(clip->GetStartTime()*mRate + 0.5);
1629  auto endSample = startSample + clip->GetNumSamples();
1630  if (s >= startSample && s < endSample)
1631  {
1632  bestBlockSize = clip->GetSequence()->GetBestBlockSize(s - startSample);
1633  break;
1634  }
1635  }
1636 
1637  return bestBlockSize;
1638 }
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:1640
int mRate
Definition: WaveTrack.h:618
WaveClipHolders mClips
Definition: WaveTrack.h:615
sampleCount WaveTrack::GetBlockStart ( sampleCount  t) const

Definition at line 1609 of file WaveTrack.cpp.

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

1610 {
1611  for (const auto &clip : mClips)
1612  {
1613  const auto startSample = (sampleCount)floor(0.5 + clip->GetStartTime()*mRate);
1614  const auto endSample = startSample + clip->GetNumSamples();
1615  if (s >= startSample && s < endSample)
1616  return startSample + clip->GetSequence()->GetBlockStart(s - startSample);
1617  }
1618 
1619  return -1;
1620 }
int mRate
Definition: WaveTrack.h:618
WaveClipHolders mClips
Definition: WaveTrack.h:615
const std::vector<Location>& WaveTrack::GetCachedLocations ( ) const
inline

Definition at line 506 of file WaveTrack.h.

Referenced by TrackArtist::DrawWaveform().

506 { return mDisplayLocationsCache; }
std::vector< Location > mDisplayLocationsCache
Definition: WaveTrack.h:637
auto WaveTrack::GetChannel ( ) const
overridevirtual

Reimplemented from Track.

Definition at line 239 of file WaveTrack.cpp.

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

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

240 {
242  return mChannel;
243  auto pan = GetPan();
244  if( pan < -0.99 )
245  return Track::LeftChannel;
246  if( pan > 0.99 )
247  return Track::RightChannel;
248  return mChannel;
249 }
float GetPan() const
Definition: WaveTrack.cpp:428
ChannelType mChannel
Definition: Track.h:346
float WaveTrack::GetChannelGain ( int  channel) const

Definition at line 443 of file WaveTrack.cpp.

References mGain, and mPan.

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

444 {
445  float left = 1.0;
446  float right = 1.0;
447 
448  if (mPan < 0)
449  right = (mPan + 1.0);
450  else if (mPan > 0)
451  left = 1.0 - mPan;
452 
453  if ((channel%2) == 0)
454  return left*mGain;
455  else
456  return right*mGain;
457 }
float mGain
Definition: WaveTrack.h:619
float mPan
Definition: WaveTrack.h:620
auto WaveTrack::GetChannelIgnoringPan ( ) const
virtual

Definition at line 235 of file WaveTrack.cpp.

References Track::mChannel.

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

235  {
236  return mChannel;
237 }
ChannelType mChannel
Definition: Track.h:346
WaveClip * WaveTrack::GetClipAtSample ( sampleCount  sample)

Definition at line 2189 of file WaveTrack.cpp.

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

Referenced by MenuCommandHandler::OnPunchAndRoll().

2190 {
2191  for (const auto &clip: mClips)
2192  {
2193  auto start = clip->GetStartSample();
2194  auto len = clip->GetNumSamples();
2195 
2196  if (sample >= start && sample < start + len)
2197  return clip.get();
2198  }
2199 
2200  return NULL;
2201 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
WaveClip * WaveTrack::GetClipAtTime ( double  time)

Definition at line 2205 of file WaveTrack.cpp.

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

2206 {
2207 
2208  const auto clips = SortedClipArray();
2209  auto p = std::find_if(clips.rbegin(), clips.rend(), [&] (WaveClip* const& clip) {
2210  return time >= clip->GetStartTime() && time <= clip->GetEndTime(); });
2211 
2212  // When two clips are immediately next to each other, the GetEndTime() of the first clip
2213  // and the GetStartTime() of the second clip may not be exactly equal due to rounding errors.
2214  // If "time" is the end time of the first of two such clips, and the end time is slightly
2215  // less than the start time of the second clip, then the first rather than the
2216  // second clip is found by the above code. So correct this.
2217  if (p != clips.rend() && p != clips.rbegin() &&
2218  time == (*p)->GetEndTime() &&
2219  (*p)->SharesBoundaryWithNextClip(*(p-1))) {
2220  p--;
2221  }
2222 
2223  return p != clips.rend() ? *p : nullptr;
2224 }
WaveClipPointers SortedClipArray()
Definition: WaveTrack.cpp:2591
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
WaveClip * WaveTrack::GetClipAtX ( int  xcoord)

Definition at line 2176 of file WaveTrack.cpp.

References WaveClip::GetDisplayRect(), and mClips.

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

2177 {
2178  for (const auto &clip: mClips)
2179  {
2180  wxRect r;
2181  clip->GetDisplayRect(&r);
2182  if (xcoord >= r.x && xcoord < r.x+r.width)
2183  return clip.get();
2184  }
2185 
2186  return NULL;
2187 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
WaveClip * WaveTrack::GetClipByIndex ( int  index)

Definition at line 2292 of file WaveTrack.cpp.

References mClips.

Referenced by AudacityProject::AddImportedTracks(), GetClipByIndex(), and MergeClips().

2293 {
2294  if(index < (int)mClips.size())
2295  return mClips[index].get();
2296  else
2297  return nullptr;
2298 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
const WaveClip * WaveTrack::GetClipByIndex ( int  index) const

Definition at line 2300 of file WaveTrack.cpp.

References GetClipByIndex().

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

Definition at line 2285 of file WaveTrack.cpp.

References mClips.

Referenced by ClearAndPaste(), and UpdateLocationsCache().

2286 {
2287  int result;
2288  FindClip(mClips, clip, &result);
2289  return result;
2290 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
WaveClipHolders& WaveTrack::GetClips ( )
inline
const WaveClipConstHolders& WaveTrack::GetClips ( ) const
inline

Definition at line 369 of file WaveTrack.h.

370  { return reinterpret_cast< const WaveClipConstHolders& >( mClips ); }
WaveClipHolders mClips
Definition: WaveTrack.h:615
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:230
WaveTrackDisplay WaveTrack::GetDisplay ( ) const
inline
void WaveTrack::GetDisplayBounds ( float *  min,
float *  max 
) const

Definition at line 328 of file WaveTrack.cpp.

References mDisplayMax, and mDisplayMin.

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

329 {
330  *min = mDisplayMin;
331  *max = mDisplayMax;
332 }
float mDisplayMin
Definition: WaveTrack.h:629
int min(int a, int b)
float mDisplayMax
Definition: WaveTrack.h:630
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 1888 of file WaveTrack.cpp.

References WaveClip::GetEndTime(), and mClips.

Referenced by EffectTruncSilence::Analyze(), Copy(), Effect::GetSamples(), Mixer::MixSameRate(), Mixer::MixVariableRates(), MenuCommandHandler::OnPunchAndRoll(), Paste(), EffectStereoToMono::Process(), EffectChangeSpeed::Process(), EffectStereoToMono::ProcessOne(), NyquistEffect::ProcessOne(), GetInfoCommand::SendTracks(), SyncLockAdjust(), and Trim().

1889 {
1890  bool found = false;
1891  double best = 0.0;
1892 
1893  if (mClips.empty())
1894  return 0;
1895 
1896  for (const auto &clip : mClips)
1897  if (!found)
1898  {
1899  found = true;
1900  best = clip->GetEndTime();
1901  }
1902  else if (clip->GetEndTime() > best)
1903  best = clip->GetEndTime();
1904 
1905  return best;
1906 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
Envelope * WaveTrack::GetEnvelopeAtX ( int  xcoord)

Definition at line 2226 of file WaveTrack.cpp.

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

2227 {
2228  WaveClip* clip = GetClipAtX(xcoord);
2229  if (clip)
2230  return clip->GetEnvelope();
2231  else
2232  return NULL;
2233 }
Envelope * GetEnvelope()
Definition: WaveClip.h:243
WaveClip * GetClipAtX(int xcoord)
Definition: WaveTrack.cpp:2176
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 2110 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().

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

Reimplemented from Track.

Definition at line 1824 of file WaveTrack.cpp.

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

1825 {
1826  for (const auto &clip : mClips)
1827  if (clip->GetSequence()->GetErrorOpening())
1828  return true;
1829 
1830  return false;
1831 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
float WaveTrack::GetGain ( ) const

Definition at line 418 of file WaveTrack.cpp.

References mGain.

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

419 {
420  return mGain;
421 }
float mGain
Definition: WaveTrack.h:619
size_t WaveTrack::GetIdealBlockSize ( )

Definition at line 1660 of file WaveTrack.cpp.

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

Referenced by NyquistEffect::GetCallback().

1661 {
1663 }
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:2250
size_t GetIdealBlockSize() const
Definition: Sequence.cpp:88
SpectrogramSettings & WaveTrack::GetIndependentSpectrogramSettings ( )

Definition at line 722 of file WaveTrack.cpp.

References SpectrogramSettings::defaults(), and mpSpectrumSettings.

Referenced by UseSpectralPrefs().

723 {
724  if (!mpSpectrumSettings)
726  std::make_unique<SpectrogramSettings>(SpectrogramSettings::defaults());
727  return *mpSpectrumSettings;
728 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:656
static SpectrogramSettings & defaults()
WaveformSettings & WaveTrack::GetIndependentWaveformSettings ( )

Definition at line 770 of file WaveTrack.cpp.

References WaveformSettings::defaults(), and mpWaveformSettings.

Referenced by WaveTrack().

771 {
772  if (!mpWaveformSettings)
773  mpWaveformSettings = std::make_unique<WaveformSettings>(WaveformSettings::defaults());
774  return *mpWaveformSettings;
775 }
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:657
static WaveformSettings & defaults()
TrackKind WaveTrack::GetKind ( ) const
inlineoverrideprivatevirtual

Reimplemented from Track.

Definition at line 645 of file WaveTrack.h.

References Wave.

645 { return TrackKind::Wave; }
int WaveTrack::GetLastdBRange ( ) const
inline

Definition at line 594 of file WaveTrack.h.

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

Definition at line 591 of file WaveTrack.h.

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

Definition at line 1640 of file WaveTrack.cpp.

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

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

1641 {
1642  decltype(GetMaxBlockSize()) maxblocksize = 0;
1643  for (const auto &clip : mClips)
1644  {
1645  maxblocksize = std::max(maxblocksize, clip->GetSequence()->GetMaxBlockSize());
1646  }
1647 
1648  if (maxblocksize == 0)
1649  {
1650  // We really need the maximum block size, so create a
1651  // temporary sequence to get it.
1652  maxblocksize = Sequence{ mDirManager, mFormat }.GetMaxBlockSize();
1653  }
1654 
1655  wxASSERT(maxblocksize > 0);
1656 
1657  return maxblocksize;
1658 }
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:1640
sampleFormat mFormat
Definition: WaveTrack.h:617
WaveClipHolders mClips
Definition: WaveTrack.h:615
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:349
std::pair< float, float > WaveTrack::GetMinMax ( double  t0,
double  t1,
bool  mayThrow = true 
) const

Definition at line 1913 of file WaveTrack.cpp.

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

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

1915 {
1916  std::pair<float, float> results {
1917  // we need these at extremes to make sure we find true min and max
1918  FLT_MAX, -FLT_MAX
1919  };
1920  bool clipFound = false;
1921 
1922  if (t0 > t1) {
1923  if (mayThrow)
1925  return results;
1926  }
1927 
1928  if (t0 == t1)
1929  return results;
1930 
1931  for (const auto &clip: mClips)
1932  {
1933  if (t1 >= clip->GetStartTime() && t0 <= clip->GetEndTime())
1934  {
1935  clipFound = true;
1936  auto clipResults = clip->GetMinMax(t0, t1, mayThrow);
1937  if (clipResults.first < results.first)
1938  results.first = clipResults.first;
1939  if (clipResults.second > results.second)
1940  results.second = clipResults.second;
1941  }
1942  }
1943 
1944  if(!clipFound)
1945  {
1946  results = { 0.f, 0.f }; // sensible defaults if no clips found
1947  }
1948 
1949  return results;
1950 }
#define THROW_INCONSISTENCY_EXCEPTION
WaveClipHolders mClips
Definition: WaveTrack.h:615
int WaveTrack::GetNumClips ( ) const

Definition at line 2305 of file WaveTrack.cpp.

References mClips.

2306 {
2307  return mClips.size();
2308 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
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 1598 of file WaveTrack.cpp.

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

Referenced by EffectNormalize::AnalyseTrack().

1599 {
1600  unsigned int ret = 0;
1601  for (const auto &clip : mClips)
1602  {
1603  ret = ret | clip->GetSequence()->GetODFlags();
1604  }
1605  return ret;
1606 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
double WaveTrack::GetOffset ( ) const
overridevirtual

Implements Track.

Definition at line 218 of file WaveTrack.cpp.

References GetStartTime().

Referenced by TranscriptionToolBar::GetSamples(), MenuCommandHandler::OnSplitNew(), Reinit(), SetOffset(), and AudacityProject::WriteXML().

219 {
220  return GetStartTime();
221 }
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1868
float WaveTrack::GetOldChannelGain ( int  channel) const

Definition at line 459 of file WaveTrack.cpp.

References mOldGain.

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

460 {
461  return mOldGain[channel%2];
462 }
float mOldGain[2]
Definition: WaveTrack.h:622
float WaveTrack::GetPan ( ) const

Definition at line 428 of file WaveTrack.cpp.

References mPan.

Referenced by GetChannel(), MixAndRender(), TrackInfo::PanSlider(), GetInfoCommand::SendTracks(), and AudacityProject::WriteXML().

429 {
430  return mPan;
431 }
float mPan
Definition: WaveTrack.h:620
double WaveTrack::GetRate ( ) const
float WaveTrack::GetRMS ( double  t0,
double  t1,
bool  mayThrow = true 
) const

Definition at line 1952 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().

1953 {
1954  if (t0 > t1) {
1955  if (mayThrow)
1957  return 0.f;
1958  }
1959 
1960  if (t0 == t1)
1961  return 0.f;
1962 
1963  double sumsq = 0.0;
1964  sampleCount length = 0;
1965 
1966  for (const auto &clip: mClips)
1967  {
1968  // If t1 == clip->GetStartTime() or t0 == clip->GetEndTime(), then the clip
1969  // is not inside the selection, so we don't want it.
1970  // if (t1 >= clip->GetStartTime() && t0 <= clip->GetEndTime())
1971  if (t1 >= clip->GetStartTime() && t0 <= clip->GetEndTime())
1972  {
1973  sampleCount clipStart, clipEnd;
1974 
1975  float cliprms = clip->GetRMS(t0, t1, mayThrow);
1976 
1977  clip->TimeToSamplesClip(wxMax(t0, clip->GetStartTime()), &clipStart);
1978  clip->TimeToSamplesClip(wxMin(t1, clip->GetEndTime()), &clipEnd);
1979  sumsq += cliprms * cliprms * (clipEnd - clipStart).as_float();
1980  length += (clipEnd - clipStart);
1981  }
1982  }
1983  return length > 0 ? sqrt(sumsq / length.as_double()) : 0.0;
1984 }
double as_double() const
Definition: Types.h:88
#define THROW_INCONSISTENCY_EXCEPTION
WaveClipHolders mClips
Definition: WaveTrack.h:615
sampleFormat WaveTrack::GetSampleFormat ( ) const
inline
Sequence * WaveTrack::GetSequenceAtX ( int  xcoord)

Definition at line 2235 of file WaveTrack.cpp.

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

2236 {
2237  WaveClip* clip = GetClipAtX(xcoord);
2238  if (clip)
2239  return clip->GetSequence();
2240  else
2241  return NULL;
2242 }
Sequence * GetSequence()
Definition: WaveClip.h:250
WaveClip * GetClipAtX(int xcoord)
Definition: WaveTrack.cpp:2176
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 714 of file WaveTrack.cpp.

References SpectrogramSettings::defaults(), and mpSpectrumSettings.

715 {
716  if (mpSpectrumSettings)
717  return *mpSpectrumSettings;
718  else
720 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:656
static SpectrogramSettings & defaults()
void WaveTrack::GetSpectrumBounds ( float *  min,
float *  max 
) const

Definition at line 340 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(), and SpectrumPrefs::SpectrumPrefs().

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

References WaveClip::GetStartTime(), and mClips.

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

1869 {
1870  bool found = false;
1871  double best = 0.0;
1872 
1873  if (mClips.empty())
1874  return 0;
1875 
1876  for (const auto &clip : mClips)
1877  if (!found)
1878  {
1879  found = true;
1880  best = clip->GetStartTime();
1881  }
1882  else if (clip->GetStartTime() < best)
1883  best = clip->GetStartTime();
1884 
1885  return best;
1886 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
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:230
int WaveTrack::GetWaveColorIndex ( ) const
inline

Definition at line 147 of file WaveTrack.h.

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

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

Definition at line 762 of file WaveTrack.cpp.

References WaveformSettings::defaults(), and mpWaveformSettings.

763 {
764  if (mpWaveformSettings)
765  return *mpWaveformSettings;
766  else
768 }
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:657
static WaveformSettings & defaults()
void WaveTrack::HandleClear ( double  t0,
double  t1,
bool  addCutLines,
bool  split 
)

Definition at line 1026 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().

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

Implements XMLTagHandler.

Definition at line 1760 of file WaveTrack.cpp.

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

1761 {
1762  //
1763  // This is legacy code (1.2 and previous) and is not called for NEW projects!
1764  //
1765  if (!wxStrcmp(tag, wxT("sequence")) || !wxStrcmp(tag, wxT("envelope")))
1766  {
1767  // This is a legacy project, so set the cached offset
1769 
1770  // Legacy project file tracks are imported as one single wave clip
1771  if (!wxStrcmp(tag, wxT("sequence")))
1772  return NewestOrNewClip()->GetSequence();
1773  else if (!wxStrcmp(tag, wxT("envelope")))
1774  return NewestOrNewClip()->GetEnvelope();
1775  }
1776 
1777  // JKC... for 1.1.0, one step better than what we had, but still badly broken.
1778  //If we see a waveblock at this level, we'd better generate a sequence.
1779  if( !wxStrcmp( tag, wxT("waveblock" )))
1780  {
1781  // This is a legacy project, so set the cached offset
1783  Sequence *pSeq = NewestOrNewClip()->GetSequence();
1784  return pSeq;
1785  }
1786 
1787  //
1788  // This is for the NEW file format (post-1.2)
1789  //
1790  if (!wxStrcmp(tag, wxT("waveclip")))
1791  return CreateClip();
1792  else
1793  return NULL;
1794 }
WaveClip * CreateClip()
Definition: WaveTrack.cpp:2244
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:2250
Envelope * GetEnvelope()
Definition: WaveClip.h:243
void SetOffset(double offset)
Definition: WaveClip.cpp:392
double mLegacyProjectFileOffset
Definition: WaveTrack.h:653
void WaveTrack::HandleXMLEndTag ( const wxChar *  tag)
override

Definition at line 1753 of file WaveTrack.cpp.

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

1754 {
1755  // In case we opened a pre-multiclip project, we need to
1756  // simulate closing the waveclip tag.
1757  NewestOrNewClip()->HandleXMLEndTag(wxT("waveclip"));
1758 }
WaveClip * NewestOrNewClip()
Get access to the most recently added clip, or create a clip, if there is not already one...
Definition: WaveTrack.cpp:2250
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 1675 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().

1676 {
1677  if (!wxStrcmp(tag, wxT("wavetrack"))) {
1678  double dblValue;
1679  long nValue;
1680  while(*attrs) {
1681  const wxChar *attr = *attrs++;
1682  const wxChar *value = *attrs++;
1683 
1684  if (!value)
1685  break;
1686 
1687  const wxString strValue = value;
1688  if (!wxStrcmp(attr, wxT("rate")))
1689  {
1690  // mRate is an int, but "rate" in the project file is a float.
1691  if (!XMLValueChecker::IsGoodString(strValue) ||
1692  !Internat::CompatibleToDouble(strValue, &dblValue) ||
1693  (dblValue < 1.0) || (dblValue > 1000000.0)) // allow a large range to be read
1694  return false;
1695  mRate = lrint(dblValue);
1696  }
1697  else if (!wxStrcmp(attr, wxT("offset")) &&
1698  XMLValueChecker::IsGoodString(strValue) &&
1699  Internat::CompatibleToDouble(strValue, &dblValue))
1700  {
1701  // Offset is only relevant for legacy project files. The value
1702  // is cached until the actual WaveClip containing the legacy
1703  // track is created.
1704  mLegacyProjectFileOffset = dblValue;
1705  }
1706  else if (this->PlayableTrack::HandleXMLAttribute(attr, value))
1707  {}
1708  else if (!wxStrcmp(attr, wxT("height")) &&
1709  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
1710  mHeight = nValue;
1711  else if (!wxStrcmp(attr, wxT("minimized")) &&
1712  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
1713  mMinimized = (nValue != 0);
1714  else if (!wxStrcmp(attr, wxT("isSelected")) &&
1715  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
1716  this->SetSelected(nValue != 0);
1717  else if (!wxStrcmp(attr, wxT("gain")) &&
1718  XMLValueChecker::IsGoodString(strValue) &&
1719  Internat::CompatibleToDouble(strValue, &dblValue))
1720  mGain = dblValue;
1721  else if (!wxStrcmp(attr, wxT("pan")) &&
1722  XMLValueChecker::IsGoodString(strValue) &&
1723  Internat::CompatibleToDouble(strValue, &dblValue) &&
1724  (dblValue >= -1.0) && (dblValue <= 1.0))
1725  mPan = dblValue;
1726  else if (!wxStrcmp(attr, wxT("name")) && XMLValueChecker::IsGoodString(strValue))
1727  mName = strValue;
1728  else if (!wxStrcmp(attr, wxT("channel")))
1729  {
1730  if (!XMLValueChecker::IsGoodInt(strValue) || !strValue.ToLong(&nValue) ||
1732  return false;
1733  mChannel = static_cast<Track::ChannelType>( nValue );
1734  }
1735  else if (!wxStrcmp(attr, wxT("linked")) &&
1736  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
1737  SetLinked(nValue != 0);
1738  else if (!wxStrcmp(attr, wxT("autosaveid")) &&
1739  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
1740  mAutoSaveIdent = (int) nValue;
1741  else if (!wxStrcmp(attr, wxT("colorindex")) &&
1742  XMLValueChecker::IsGoodString(strValue) &&
1743  strValue.ToLong(&nValue))
1744  // Don't use SetWaveColorIndex as it sets the clips too.
1745  mWaveColorIndex = nValue;
1746  } // while
1747  return true;
1748  }
1749 
1750  return false;
1751 }
int mAutoSaveIdent
Definition: WaveTrack.h:654
void SetLinked(bool l)
Definition: Track.cpp:234
static bool IsValidChannel(const int nValue)
bool HandleXMLAttribute(const wxChar *attr, const wxChar *value)
Definition: Track.cpp:379
int mHeight
Definition: Track.h:204
ChannelType mChannel
Definition: Track.h:346
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:94
ChannelType
Definition: Track.h:215
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:211
#define lrint(dbl)
Definition: float_cast.h:136
int mRate
Definition: WaveTrack.h:618
float mGain
Definition: WaveTrack.h:619
float mPan
Definition: WaveTrack.h:620
double mLegacyProjectFileOffset
Definition: WaveTrack.h:653
int mWaveColorIndex
Definition: WaveTrack.h:621
wxString mName
Definition: Track.h:205
void WaveTrack::Init ( const WaveTrack orig)
private

Definition at line 150 of file WaveTrack.cpp.

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

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

151 {
152  PlayableTrack::Init(orig);
153  mFormat = orig.mFormat;
155  mRate = orig.mRate;
156  mGain = orig.mGain;
157  mPan = orig.mPan;
158  mOldGain[0] = 0.0;
159  mOldGain[1] = 0.0;
161  SetName(orig.GetName());
162  mDisplay = orig.mDisplay;
163  mDisplayMin = orig.mDisplayMin;
164  mDisplayMax = orig.mDisplayMax;
165  mSpectrumMin = orig.mSpectrumMin;
166  mSpectrumMax = orig.mSpectrumMax;
167  mDisplayLocationsCache.clear();
168 }
float mDisplayMin
Definition: WaveTrack.h:629
void Init(const PlayableTrack &init)
Definition: Track.cpp:354
float mSpectrumMax
Definition: WaveTrack.h:632
std::vector< Location > mDisplayLocationsCache
Definition: WaveTrack.h:637
wxString GetDefaultName() const
Definition: Track.h:371
float mSpectrumMin
Definition: WaveTrack.h:631
WaveTrackDisplay mDisplay
Definition: WaveTrack.h:634
wxString GetName() const
Definition: Track.h:369
float mOldGain[2]
Definition: WaveTrack.h:622
int mRate
Definition: WaveTrack.h:618
float mGain
Definition: WaveTrack.h:619
void SetDefaultName(const wxString &n)
Definition: Track.h:372
sampleFormat mFormat
Definition: WaveTrack.h:617
void SetName(const wxString &n)
Definition: Track.h:370
float mPan
Definition: WaveTrack.h:620
float mDisplayMax
Definition: WaveTrack.h:630
int mWaveColorIndex
Definition: WaveTrack.h:621
void WaveTrack::InsertSilence ( double  t,
double  len 
)
override

Definition at line 1400 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().

1402 {
1403  // Nothing to do, if length is zero.
1404  // Fixes Bug 1626
1405  if( len == 0 )
1406  return;
1407  if (len <= 0)
1409 
1410  if (mClips.empty())
1411  {
1412  // Special case if there is no clip yet
1413  auto clip = std::make_unique<WaveClip>(mDirManager, mFormat, mRate, this->GetWaveColorIndex());
1414  clip->InsertSilence(0, len);
1415  // use NOFAIL-GUARANTEE
1416  mClips.push_back( std::move( clip ) );
1417  return;
1418  }
1419  else {
1420  // Assume at most one clip contains t
1421  const auto end = mClips.end();
1422  const auto it = std::find_if( mClips.begin(), end,
1423  [&](const WaveClipHolder &clip) { return clip->WithinClip(t); } );
1424 
1425  // use STRONG-GUARANTEE
1426  if (it != end)
1427  it->get()->InsertSilence(t, len);
1428 
1429  // use NOFAIL-GUARANTEE
1430  for (const auto &clip : mClips)
1431  {
1432  if (clip->BeforeClip(t))
1433  clip->Offset(len);
1434  }
1435  }
1436 }
#define THROW_INCONSISTENCY_EXCEPTION
int GetWaveColorIndex() const
Definition: WaveTrack.h:147
int mRate
Definition: WaveTrack.h:618
sampleFormat mFormat
Definition: WaveTrack.h:617
WaveClipHolders mClips
Definition: WaveTrack.h:615
std::shared_ptr< WaveClip > WaveClipHolder
Definition: WaveClip.h:121
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:349
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 511 of file WaveTrack.cpp.

References mClips.

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

512 {
513  if (t0 > t1)
514  return true;
515 
516  //wxPrintf("Searching for overlap in %.6f...%.6f\n", t0, t1);
517  for (const auto &clip : mClips)
518  {
519  if (!clip->BeforeClip(t1) && !clip->AfterClip(t0)) {
520  //wxPrintf("Overlapping clip: %.6f...%.6f\n",
521  // clip->GetStartTime(),
522  // clip->GetEndTime());
523  // We found a clip that overlaps this region
524  return false;
525  }
526  }
527  //wxPrintf("No overlap found\n");
528 
529  // Otherwise, no clips overlap this region
530  return true;
531 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
void WaveTrack::Join ( double  t0,
double  t1 
)

Definition at line 1518 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 MenuCommandHandler::OnJoinLabels(), and EffectEqualization::ProcessOne().

1520 {
1521  // Merge all WaveClips overlapping selection into one
1522 
1523  WaveClipPointers clipsToDelete;
1524  WaveClip *newClip;
1525 
1526  for (const auto &clip: mClips)
1527  {
1528  if (clip->GetStartTime() < t1-(1.0/mRate) &&
1529  clip->GetEndTime()-(1.0/mRate) > t0) {
1530 
1531  // Put in sorted order
1532  auto it = clipsToDelete.begin(), end = clipsToDelete.end();
1533  for (; it != end; ++it)
1534  if ((*it)->GetStartTime() > clip->GetStartTime())
1535  break;
1536  //wxPrintf("Insert clip %.6f at position %d\n", clip->GetStartTime(), i);
1537  clipsToDelete.insert(it, clip.get());
1538  }
1539  }
1540 
1541  //if there are no clips to DELETE, nothing to do
1542  if( clipsToDelete.size() == 0 )
1543  return;
1544 
1545  newClip = CreateClip();
1546  double t = clipsToDelete[0]->GetOffset();
1547  newClip->SetOffset(t);
1548  for (const auto &clip : clipsToDelete)
1549  {
1550  //wxPrintf("t=%.6f adding clip (offset %.6f, %.6f ... %.6f)\n",
1551  // t, clip->GetOffset(), clip->GetStartTime(), clip->GetEndTime());
1552 
1553  if (clip->GetOffset() - t > (1.0 / mRate)) {
1554  double addedSilence = (clip->GetOffset() - t);
1555  //wxPrintf("Adding %.6f seconds of silence\n");
1556  auto offset = clip->GetOffset();
1557  auto value = clip->GetEnvelope()->GetValue( offset );
1558  newClip->AppendSilence( addedSilence, value );
1559  t += addedSilence;
1560  }
1561 
1562  //wxPrintf("Pasting at %.6f\n", t);
1563  newClip->Paste(t, clip);
1564 
1565  t = newClip->GetEndTime();
1566 
1567  auto it = FindClip(mClips, clip);
1568  mClips.erase(it); // deletes the clip
1569  }
1570 }
WaveClip * CreateClip()
Definition: WaveTrack.cpp:2244
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:618
WaveClipHolders mClips
Definition: WaveTrack.h:615
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 1833 of file WaveTrack.cpp.

References WaveClip::Lock(), and mClips.

1834 {
1835  for (const auto &clip : mClips)
1836  clip->Lock();
1837 
1838  return true;
1839 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
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 1863 of file WaveTrack.cpp.

References sampleCount::as_double(), and mRate.

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

1864 {
1865  return pos.as_double() / mRate;
1866 }
double as_double() const
Definition: Types.h:88
int mRate
Definition: WaveTrack.h:618
void WaveTrack::Merge ( const Track orig)
overridevirtual

Reimplemented from PlayableTrack.

Definition at line 193 of file WaveTrack.cpp.

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

Referenced by WaveTrackMenuTable::OnMergeStereo().

194 {
195  orig.TypeSwitch( [&](const WaveTrack *pwt) {
196  const WaveTrack &wt = *pwt;
197  mDisplay = wt.mDisplay;
198  mGain = wt.mGain;
199  mPan = wt.mPan;
203  ? std::make_unique<SpectrogramSettings>(*wt.mpSpectrumSettings) : nullptr);
205  (wt.mpWaveformSettings ? std::make_unique<WaveformSettings>(*wt.mpWaveformSettings) : nullptr);
206  });
207  PlayableTrack::Merge(orig);
208 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:656
void Merge(const Track &init) override
Definition: Track.cpp:361
R TypeSwitch(const Functions &...functions)
Definition: Track.h:623
float mDisplayMin
Definition: WaveTrack.h:629
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:657
void SetSpectrogramSettings(std::unique_ptr< SpectrogramSettings > &&pSettings)
Definition: WaveTrack.cpp:730
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
WaveTrackDisplay mDisplay
Definition: WaveTrack.h:634
float mGain
Definition: WaveTrack.h:619
float mPan
Definition: WaveTrack.h:620
float mDisplayMax
Definition: WaveTrack.h:630
void SetWaveformSettings(std::unique_ptr< WaveformSettings > &&pSettings)
Definition: WaveTrack.cpp:777
void WaveTrack::MergeClips ( int  clipidx1,
int  clipidx2 
)

Definition at line 2548 of file WaveTrack.cpp.

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

Referenced by ClearAndPaste().

2550 {
2551  WaveClip* clip1 = GetClipByIndex(clipidx1);
2552  WaveClip* clip2 = GetClipByIndex(clipidx2);
2553 
2554  if (!clip1 || !clip2) // Could happen if one track of a linked pair had a split and the other didn't.
2555  return; // Don't throw, just do nothing.
2556 
2557  // Append data from second clip to first clip
2558  // use STRONG-GUARANTEE
2559  clip1->Paste(clip1->GetEndTime(), clip2);
2560 
2561  // use NOFAIL-GUARANTEE for the rest
2562  // Delete second clip
2563  auto it = FindClip(mClips, clip2);
2564  mClips.erase(it);
2565 }
WaveClip * GetClipByIndex(int index)
Definition: WaveTrack.cpp:2292
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
WaveClipHolders mClips
Definition: WaveTrack.h:615
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 2250 of file WaveTrack.cpp.

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

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

2251 {
2252  if (mClips.empty()) {
2253  WaveClip *clip = CreateClip();
2254  clip->SetOffset(mOffset);
2255  return clip;
2256  }
2257  else
2258  return mClips.back().get();
2259 }
WaveClip * CreateClip()
Definition: WaveTrack.cpp:2244
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:347
WaveClipHolders mClips
Definition: WaveTrack.h:615
void WaveTrack::Paste ( double  t0,
const Track src 
)
override

Definition at line 1208 of file WaveTrack.cpp.

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

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

1210 {
1211  bool editClipCanMove = gPrefs->GetEditClipsCanMove();
1212 
1213  bool bOk = src && src->TypeSwitch< bool >( [&](const WaveTrack *other) {
1214 
1215  //
1216  // Pasting is a bit complicated, because with the existence of multiclip mode,
1217  // we must guess the behaviour the user wants.
1218  //
1219  // Currently, two modes are implemented:
1220  //
1221  // - If a single clip should be pasted, and it should be pasted inside another
1222  // clip, no NEW clips are generated. The audio is simply inserted.
1223  // This resembles the old (pre-multiclip support) behaviour. However, if
1224  // the clip is pasted outside of any clip, a NEW clip is generated. This is
1225  // the only behaviour which is different to what was done before, but it
1226  // shouldn't confuse users too much.
1227  //
1228  // - If multiple clips should be pasted, or a single clip that does not fill
1229  // the duration of the pasted track, these are always pasted as single
1230  // clips, and the current clip is splitted, when necessary. This may seem
1231  // strange at first, but it probably is better than trying to auto-merge
1232  // anything. The user can still merge the clips by hand (which should be a
1233  // simple command reachable by a hotkey or single mouse click).
1234  //
1235 
1236  if (other->GetNumClips() == 0)
1237  return true;
1238 
1239  //wxPrintf("paste: we have at least one clip\n");
1240 
1241  bool singleClipMode = (other->GetNumClips() == 1 &&
1242  other->GetStartTime() == 0.0);
1243 
1244  const double insertDuration = other->GetEndTime();
1245  if( insertDuration != 0 && insertDuration < 1.0/mRate )
1246  // PRL: I added this check to avoid violations of preconditions in other WaveClip and Sequence
1247  // methods, but allow the value 0 so I don't subvert the purpose of commit
1248  // 739422ba70ceb4be0bb1829b6feb0c5401de641e which causes append-recording always to make
1249  // a new clip.
1250  return true;
1251 
1252  //wxPrintf("Check if we need to make room for the pasted data\n");
1253 
1254  // Make room for the pasted data
1255  if (editClipCanMove) {
1256  if (!singleClipMode) {
1257  // We need to insert multiple clips, so split the current clip and
1258  // move everything to the right, then try to paste again
1259  if (!IsEmpty(t0, GetEndTime())) {
1260  auto tmp = Cut(t0, GetEndTime()+1.0/mRate);
1261  Paste(t0 + insertDuration, tmp.get());
1262  }
1263  }
1264  else {
1265  // We only need to insert one single clip, so just move all clips
1266  // to the right of the paste point out of the way
1267  for (const auto &clip : mClips)
1268  {
1269  if (clip->GetStartTime() > t0-(1.0/mRate))
1270  clip->Offset(insertDuration);
1271  }
1272  }
1273  }
1274 
1275  if (singleClipMode)
1276  {
1277  // Single clip mode
1278  // wxPrintf("paste: checking for single clip mode!\n");
1279 
1280  WaveClip *insideClip = NULL;
1281 
1282  for (const auto &clip : mClips)
1283  {
1284  if (editClipCanMove)
1285  {
1286  if (clip->WithinClip(t0))
1287  {
1288  //wxPrintf("t0=%.6f: inside clip is %.6f ... %.6f\n",
1289  // t0, clip->GetStartTime(), clip->GetEndTime());
1290  insideClip = clip.get();
1291  break;
1292  }
1293  }
1294  else
1295  {
1296  // If clips are immovable we also allow prepending to clips
1297  if (clip->WithinClip(t0) ||
1298  TimeToLongSamples(t0) == clip->GetStartSample())
1299  {
1300  insideClip = clip.get();
1301  break;
1302  }
1303  }
1304  }
1305 
1306  if (insideClip)
1307  {
1308  // Exhibit traditional behaviour
1309  //wxPrintf("paste: traditional behaviour\n");
1310  if (!editClipCanMove)
1311  {
1312  // We did not move other clips out of the way already, so
1313  // check if we can paste without having to move other clips
1314  for (const auto &clip : mClips)
1315  {
1316  if (clip->GetStartTime() > insideClip->GetStartTime() &&
1317  insideClip->GetEndTime() + insertDuration >
1318  clip->GetStartTime())
1319  // STRONG-GUARANTEE in case of this path
1320  // not that it matters.
1322  _("There is not enough room available to paste the selection")
1323  };
1324  }
1325  }
1326 
1327  insideClip->Paste(t0, other->GetClipByIndex(0));
1328  return true;
1329  }
1330 
1331  // Just fall through and exhibit NEW behaviour
1332 
1333  }
1334 
1335  // Insert NEW clips
1336  //wxPrintf("paste: multi clip mode!\n");
1337 
1338  if (!editClipCanMove && !IsEmpty(t0, t0+insertDuration-1.0/mRate))
1339  // STRONG-GUARANTEE in case of this path
1340  // not that it matters.
1342  _("There is not enough room available to paste the selection")
1343  };
1344 
1345  for (const auto &clip : other->mClips)
1346  {
1347  // AWD Oct. 2009: Don't actually paste in placeholder clips
1348  if (!clip->GetIsPlaceholder())
1349  {
1350  auto newClip =
1351  std::make_unique<WaveClip>( *clip, mDirManager, true );
1352  newClip->Resample(mRate);
1353  newClip->Offset(t0);
1354  newClip->MarkChanged();
1355  mClips.push_back(std::move(newClip)); // transfer ownership
1356  }
1357  }
1358  return true;
1359  } );
1360 
1361  if( !bOk )
1362  // THROW_INCONSISTENCY_EXCEPTION; // ?
1363  (void)0;// Empty if intentional.
1364 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
R TypeSwitch(const Functions &...functions)
Definition: Track.h:623
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:1888
Track::Holder Cut(double t0, double t1) override
Definition: WaveTrack.cpp:533
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:1208
int mRate
Definition: WaveTrack.h:618
WaveClipHolders mClips
Definition: WaveTrack.h:615
_("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:1858
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:511
bool GetEditClipsCanMove()
Definition: Prefs.cpp:158
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:349
void WaveTrack::Reinit ( const WaveTrack orig)

Definition at line 170 of file WaveTrack.cpp.

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

Referenced by ControlToolBar::DoRecord().

171 {
172  Init(orig);
173 
174  {
175  auto &settings = orig.mpSpectrumSettings;
176  if (settings)
177  mpSpectrumSettings = std::make_unique<SpectrogramSettings>(*settings);
178  else
179  mpSpectrumSettings.reset();
180  }
181 
182  {
183  auto &settings = orig.mpWaveformSettings;
184  if (settings)
185  mpWaveformSettings = std::make_unique<WaveformSettings>(*settings);
186  else
187  mpWaveformSettings.reset();
188  }
189 
190  this->SetOffset(orig.GetOffset());
191 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:656
double GetOffset() const override
Definition: WaveTrack.cpp:218
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:657
void Init(const WaveTrack &orig)
Definition: WaveTrack.cpp:150
void SetOffset(double o) override
Definition: WaveTrack.cpp:223
std::shared_ptr< WaveClip > WaveTrack::RemoveAndReturnClip ( WaveClip clip)

Definition at line 1006 of file WaveTrack.cpp.

References mClips.

Referenced by EffectReverse::ProcessOneWave().

1007 {
1008  // Be clear about who owns the clip!!
1009  auto it = FindClip(mClips, clip);
1010  if (it != mClips.end()) {
1011  auto result = std::move(*it); // Array stops owning the clip, before we shrink it
1012  mClips.erase(it);
1013  return result;
1014  }
1015  else
1016  return {};
1017 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
bool WaveTrack::RemoveCutLine ( double  cutLinePosition)

Definition at line 2539 of file WaveTrack.cpp.

References mClips, and WaveClip::RemoveCutLine().

2540 {
2541  for (const auto &clip : mClips)
2542  if (clip->RemoveCutLine(cutLinePosition))
2543  return true;
2544 
2545  return false;
2546 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
void WaveTrack::Resample ( int  rate,
ProgressDialog progress = NULL 
)

Definition at line 2567 of file WaveTrack.cpp.

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

Referenced by MenuCommandHandler::OnResample().

2570 {
2571  for (const auto &clip : mClips)
2572  clip->Resample(rate, progress);
2573 
2574  mRate = rate;
2575 }
int mRate
Definition: WaveTrack.h:618
WaveClipHolders mClips
Definition: WaveTrack.h:615
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 2261 of file WaveTrack.cpp.

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

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

2263 {
2264  if (mClips.empty()) {
2265  WaveClip *clip = CreateClip();
2266  clip->SetOffset(mOffset);
2267  return clip;
2268  }
2269  else
2270  {
2271  auto it = mClips.begin();
2272  WaveClip *rightmost = (*it++).get();
2273  double maxOffset = rightmost->GetOffset();
2274  for (auto end = mClips.end(); it != end; ++it)
2275  {
2276  WaveClip *clip = it->get();
2277  double offset = clip->GetOffset();
2278  if (maxOffset < offset)
2279  maxOffset = offset, rightmost = clip;
2280  }
2281  return rightmost;
2282  }
2283 }
WaveClip * CreateClip()
Definition: WaveTrack.cpp:2244
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:347
WaveClipHolders mClips
Definition: WaveTrack.h:615
void WaveTrack::Set ( samplePtr  buffer,
sampleFormat  format,
sampleCount  start,
size_t  len 
)

Definition at line 2067 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(), EffectClickRemoval::ProcessOne(), EffectNormalize::ProcessOne(), EffectTwoPassSimpleMono::ProcessOne(), EffectReverse::ProcessOneClip(), and Effect::ProcessTrack().

2070 {
2071  for (const auto &clip: mClips)
2072  {
2073  auto clipStart = clip->GetStartSample();
2074  auto clipEnd = clip->GetEndSample();
2075 
2076  if (clipEnd > start && clipStart < start+len)
2077  {
2078  // Clip sample region and Get/Put sample region overlap
2079  auto samplesToCopy =
2080  std::min( start+len - clipStart, clip->GetNumSamples() );
2081  auto startDelta = clipStart - start;
2082  decltype(startDelta) inclipDelta = 0;
2083  if (startDelta < 0)
2084  {
2085  inclipDelta = -startDelta; // make positive value
2086  samplesToCopy -= inclipDelta;
2087  // samplesToCopy is now either len or
2088  // (clipEnd - clipStart) - (start - clipStart)
2089  // == clipEnd - start > 0
2090  // samplesToCopy is not more than len
2091  //
2092  startDelta = 0;
2093  // startDelta is zero
2094  }
2095  else {
2096  // startDelta is nonnegative and less than than len
2097  // samplesToCopy is positive and not more than len
2098  }
2099 
2100  clip->SetSamples(
2101  (samplePtr)(((char*)buffer) +
2102  startDelta.as_size_t() *
2103  SAMPLE_SIZE(format)),
2104  format, inclipDelta, samplesToCopy.as_size_t() );
2105  clip->MarkChanged();
2106  }
2107  }
2108 }
#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:615
void WaveTrack::SetAutoSaveIdent ( int  id)

Definition at line 2620 of file WaveTrack.cpp.

References mAutoSaveIdent.

Referenced by AudacityProject::WriteXML().

2621 {
2622  mAutoSaveIdent = ident;
2623 }
int mAutoSaveIdent
Definition: WaveTrack.h:654
void WaveTrack::SetDisplay ( WaveTrackDisplay  display)
inline

Definition at line 598 of file WaveTrack.h.

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

Definition at line 334 of file WaveTrack.cpp.

References mDisplayMax, mDisplayMin, and min().

335 {
336  mDisplayMin = min;
337  mDisplayMax = max;
338 }
float mDisplayMin
Definition: WaveTrack.h:629
int min(int a, int b)
float mDisplayMax
Definition: WaveTrack.h:630
void WaveTrack::SetGain ( float  newGain)

Definition at line 423 of file WaveTrack.cpp.

References mGain.

Referenced by MixerTrackCluster::HandleSliderGain().

424 {
425  mGain = newGain;
426 }
float mGain
Definition: WaveTrack.h:619
void WaveTrack::SetLastdBRange ( ) const

Definition at line 323 of file WaveTrack.cpp.

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

324 {
326 }
int mLastdBRange
Definition: WaveTrack.h:636
const WaveformSettings & GetWaveformSettings() const
Definition: WaveTrack.cpp:754
void WaveTrack::SetLastScaleType ( ) const

Definition at line 318 of file WaveTrack.cpp.

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

319 {
321 }
const WaveformSettings & GetWaveformSettings() const
Definition: WaveTrack.cpp:754
int mLastScaleType
Definition: WaveTrack.h:635
void WaveTrack::SetOffset ( double  o)
overridevirtual

Reimplemented from Track.

Definition at line 223 of file WaveTrack.cpp.

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

Referenced by Reinit().

225 {
226  double delta = o - GetOffset();
227 
228  for (const auto &clip : mClips)
229  // assume NOFAIL-GUARANTEE
230  clip->SetOffset(clip->GetOffset() + delta);
231 
232  mOffset = o;
233 }
double GetOffset() const override
Definition: WaveTrack.cpp:218
double mOffset
Definition: Track.h:347
WaveClipHolders mClips
Definition: WaveTrack.h:615
void WaveTrack::SetOldChannelGain ( int  channel,
float  gain 
)

Definition at line 464 of file WaveTrack.cpp.

References mOldGain.

Referenced by AudioIoCallback::AddToOutputChannel().

465 {
466  mOldGain[channel % 2] = gain;
467 }
float mOldGain[2]
Definition: WaveTrack.h:622
void WaveTrack::SetPan ( float  newPan)
overridevirtual

Reimplemented from Track.

Definition at line 433 of file WaveTrack.cpp.

References mPan.

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

434 {
435  if (newPan > 1.0)
436  mPan = 1.0;
437  else if (newPan < -1.0)
438  mPan = -1.0;
439  else
440  mPan = newPan;
441 }
float mPan
Definition: WaveTrack.h:620
void WaveTrack::SetPanFromChannelType ( )
overridevirtual

Reimplemented from Track.

Definition at line 251 of file WaveTrack.cpp.

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

252 {
254  SetPan( -1.0f );
255  else if( mChannel == Track::RightChannel )
256  SetPan( 1.0f );
257 };
ChannelType mChannel
Definition: Track.h:346
void SetPan(float newPan) override
Definition: WaveTrack.cpp:433
void WaveTrack::SetRate ( double  newRate)

Definition at line 406 of file WaveTrack.cpp.

References mClips, and mRate.

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

Definition at line 730 of file WaveTrack.cpp.

References mpSpectrumSettings.

Referenced by Merge().

731 {
732  if (mpSpectrumSettings != pSettings) {
733  mpSpectrumSettings = std::move(pSettings);
734  }
735 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:656
void WaveTrack::SetSpectrumBounds ( float  min,
float  max 
) const

Definition at line 384 of file WaveTrack.cpp.

References min(), mSpectrumMax, and mSpectrumMin.

385 {
386  mSpectrumMin = min;
387  mSpectrumMax = max;
388 }
float mSpectrumMax
Definition: WaveTrack.h:632
float mSpectrumMin
Definition: WaveTrack.h:631
int min(int a, int b)
void WaveTrack::SetWaveColorIndex ( int  colorIndex)

Definition at line 493 of file WaveTrack.cpp.

References mClips, and mWaveColorIndex.

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

495 {
496  for (const auto &clip : mClips)
497  clip->SetColourIndex( colorIndex );
498  mWaveColorIndex = colorIndex;
499 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
int mWaveColorIndex
Definition: WaveTrack.h:621
void WaveTrack::SetWaveformSettings ( std::unique_ptr< WaveformSettings > &&  pSettings)

Definition at line 777 of file WaveTrack.cpp.

References mpWaveformSettings.

Referenced by Merge().

778 {
779  if (mpWaveformSettings != pSettings) {
780  mpWaveformSettings = std::move(pSettings);
781  }
782 }
std::unique_ptr< WaveformSettings > mpWaveformSettings
Definition: WaveTrack.h:657
void WaveTrack::Silence ( double  t0,
double  t1 
)
override

Definition at line 1366 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 MenuCommandHandler::OnSilenceLabels(), and MenuCommandHandler::OnSplitCut().

1367 {
1368  if (t1 < t0)
1370 
1371  auto start = (sampleCount)floor(t0 * mRate + 0.5);
1372  auto len = (sampleCount)floor(t1 * mRate + 0.5) - start;
1373 
1374  for (const auto &clip : mClips)
1375  {
1376  auto clipStart = clip->GetStartSample();
1377  auto clipEnd = clip->GetEndSample();
1378 
1379  if (clipEnd > start && clipStart < start+len)
1380  {
1381  // Clip sample region and Get/Put sample region overlap
1382  auto samplesToCopy = start+len - clipStart;
1383  if (samplesToCopy > clip->GetNumSamples())
1384  samplesToCopy = clip->GetNumSamples();
1385  auto startDelta = clipStart - start;
1386  decltype(startDelta) inclipDelta = 0;
1387  if (startDelta < 0)
1388  {
1389  inclipDelta = -startDelta; // make positive value
1390  samplesToCopy -= inclipDelta;
1391  startDelta = 0;
1392  }
1393 
1394  clip->GetSequence()->SetSilence(inclipDelta, samplesToCopy);
1395  clip->MarkChanged();
1396  }
1397  }
1398 }
#define THROW_INCONSISTENCY_EXCEPTION
if(pTrack &&pTrack->GetDisplay()!=WaveTrack::Spectrum)
int mRate
Definition: WaveTrack.h:618
WaveClipHolders mClips
Definition: WaveTrack.h:615
WaveClipPointers WaveTrack::SortedClipArray ( )
WaveClipConstPointers WaveTrack::SortedClipArray ( ) const

Definition at line 2596 of file WaveTrack.cpp.

References mClips.

2597 {
2598  return FillSortedClipArray<WaveClipConstPointers>(mClips);
2599 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
void WaveTrack::Split ( double  t0,
double  t1 
)

Definition at line 2390 of file WaveTrack.cpp.

References SplitAt().

Referenced by MenuCommandHandler::OnSplitLabels().

2392 {
2393  SplitAt( t0 );
2394  if( t0 != t1 )
2395  SplitAt( t1 );
2396 }
void SplitAt(double t)
Definition: WaveTrack.cpp:2398
void WaveTrack::SplitAt ( double  t)

Definition at line 2398 of file WaveTrack.cpp.

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

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

2400 {
2401  for (const auto &c : mClips)
2402  {
2403  if (c->WithinClip(t))
2404  {
2405  t = LongSamplesToTime(TimeToLongSamples(t)); // put t on a sample
2406  auto newClip = std::make_unique<WaveClip>( *c, mDirManager, true );
2407  c->Clear(t, c->GetEndTime());
2408  newClip->Clear(c->GetStartTime(), t);
2409 
2410  //offset the NEW clip by the splitpoint (noting that it is already offset to c->GetStartTime())
2411  sampleCount here = llrint(floor(((t - c->GetStartTime()) * mRate) + 0.5));
2412  newClip->Offset(here.as_double()/(double)mRate);
2413  // This could invalidate the iterators for the loop! But we return
2414  // at once so it's okay
2415  mClips.push_back(std::move(newClip)); // transfer ownership
2416  return;
2417  }
2418  }
2419 }
double as_double() const
Definition: Types.h:88
int mRate
Definition: WaveTrack.h:618
WaveClipHolders mClips
Definition: WaveTrack.h:615
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Definition: WaveTrack.cpp:1858
double LongSamplesToTime(sampleCount pos) const
Convert correctly between an number of samples and an (absolute) time in seconds. ...
Definition: WaveTrack.cpp:1863
std::shared_ptr< DirManager > mDirManager
Definition: Track.h:349
Track::Holder WaveTrack::SplitCut ( double  t0,
double  t1 
)

Definition at line 545 of file WaveTrack.cpp.

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

Referenced by MenuCommandHandler::OnSplitCut(), MenuCommandHandler::OnSplitCutLabels(), and MenuCommandHandler::OnSplitNew().

547 {
548  if (t1 < t0)
550 
551  // SplitCut is the same as 'Copy', then 'SplitDelete'
552  auto tmp = Copy(t0, t1);
553 
554  SplitDelete(t0, t1);
555 
556  return tmp;
557 }
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: WaveTrack.cpp:621
#define THROW_INCONSISTENCY_EXCEPTION
void SplitDelete(double t0, double t1)
Definition: WaveTrack.cpp:963
void WaveTrack::SplitDelete ( double  t0,
double  t1 
)

Definition at line 963 of file WaveTrack.cpp.

References HandleClear().

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

965 {
966  bool addCutLines = false;
967  bool split = true;
968  HandleClear(t0, t1, addCutLines, split);
969 }
void HandleClear(double t0, double t1, bool addCutLines, bool split)
Definition: WaveTrack.cpp:1026
void WaveTrack::SyncLockAdjust ( double  oldT1,
double  newT1 
)
overridevirtual

Reimplemented from Track.

Definition at line 1163 of file WaveTrack.cpp.

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

1164 {
1165  if (newT1 > oldT1) {
1166  // Insert space within the track
1167 
1168  // JKC: This is a rare case where using >= rather than > on a float matters.
1169  // GetEndTime() looks through the clips and may give us EXACTLY the same
1170  // value as T1, when T1 was set to be at the end of one of those clips.
1171  if (oldT1 >= GetEndTime())
1172  return;
1173 
1174  // If track is empty at oldT1 insert whitespace; otherwise, silence
1175  if (IsEmpty(oldT1, oldT1))
1176  {
1177  // Check if clips can move
1178  bool clipsCanMove = true;
1179  gPrefs->Read(wxT("/GUI/EditClipCanMove"), &clipsCanMove);
1180  if (clipsCanMove) {
1181  auto tmp = Cut (oldT1, GetEndTime() + 1.0/GetRate());
1182 
1183  Paste(newT1, tmp.get());
1184  }
1185  return;
1186  }
1187  else {
1188  // AWD: Could just use InsertSilence() on its own here, but it doesn't
1189  // follow EditClipCanMove rules (Paste() does it right)
1191  if (!p)
1193  TrackFactory *f = p->GetTrackFactory();
1194  if (!f)
1196  auto tmp = f->NewWaveTrack(GetSampleFormat(), GetRate());
1197 
1198  tmp->InsertSilence(0.0, newT1 - oldT1);
1199  tmp->Flush();
1200  Paste(oldT1, tmp.get());
1201  }
1202  }
1203  else if (newT1 < oldT1) {
1204  Clear(newT1, oldT1);
1205  }
1206 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:694
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1888
#define THROW_INCONSISTENCY_EXCEPTION
Used to create a WaveTrack, or a LabelTrack.. Implementation of the functions of this class are dispe...
Definition: Track.h:1563
Track::Holder Cut(double t0, double t1) override
Definition: WaveTrack.cpp:533
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:175
void Paste(double t0, const Track *src) override
Definition: WaveTrack.cpp:1208
std::unique_ptr< WaveTrack > NewWaveTrack(sampleFormat format=(sampleFormat) 0, double rate=0)
Definition: WaveTrack.cpp:78
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:312
sampleFormat GetSampleFormat() const
Definition: WaveTrack.h:150
double GetRate() const
Definition: WaveTrack.cpp:401
bool IsEmpty(double t0, double t1) const
Returns true if there are no WaveClips in the specified region.
Definition: WaveTrack.cpp:511
TrackFactory * GetTrackFactory()
Definition: Project.cpp:1442
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 1858 of file WaveTrack.cpp.

References mRate.

Referenced by EffectNormalize::AnalyseTrackData(), EffectTruncSilence::Analyze(), CompareAudioCommand::Apply(), EffectAutoDuck::ApplyDuckFade(), ClearAndPaste(), Disjoin(), EffectTruncSilence::DoRemoval(), TrackArtist::DrawClipWaveform(), BlockGenerator::GenerateTrack(), Effect::GetSamples(), Mixer::MixVariableRates(), MenuCommandHandler::OnPunchAndRoll(), MenuCommandHandler::OnSplitNew(), Paste(), EffectReverse::Process(), EffectStereoToMono::Process(), EffectRepeat::Process(), EffectAutoDuck::Process(), EffectChangeSpeed::Process(), NyquistEffect::Process(), EffectPaulstretch::ProcessOne(), EffectNormalize::ProcessOne(), NyquistEffect::ProcessOne(), EffectReverse::ProcessOneWave(), Effect::ProcessPass(), SplitAt(), and SelectHandle::StartSnappingFreqSelection().

1859 {
1860  return sampleCount( floor(t0 * mRate + 0.5) );
1861 }
int mRate
Definition: WaveTrack.h:618
void WaveTrack::Trim ( double  t0,
double  t1 
)

Definition at line 578 of file WaveTrack.cpp.

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

580 {
581  bool inside0 = false;
582  bool inside1 = false;
583  //Keeps track of the offset of the first clip greater than
584  // the left selection t0.
585  double firstGreaterOffset = -1;
586 
587  for (const auto &clip : mClips)
588  {
589  //Find the first clip greater than the offset.
590  //If we end up clipping the entire track, this is useful.
591  if(firstGreaterOffset < 0 &&
592  clip->GetStartTime() >= t0)
593  firstGreaterOffset = clip->GetStartTime();
594 
595  if(t1 > clip->GetStartTime() && t1 < clip->GetEndTime())
596  {
597  clip->Clear(t1,clip->GetEndTime());
598  inside1 = true;
599  }
600 
601  if(t0 > clip->GetStartTime() && t0 < clip->GetEndTime())
602  {
603  clip->Clear(clip->GetStartTime(),t0);
604  clip->SetOffset(t0);
605  inside0 = true;
606  }
607  }
608 
609  //if inside0 is false, then the left selector was between
610  //clips, so DELETE everything to its left.
611  if(!inside1 && t1 < GetEndTime())
612  Clear(t1,GetEndTime());
613 
614  if(!inside0 && t0 > GetStartTime())
615  SplitDelete(GetStartTime(), t0);
616 }
void Clear(double t0, double t1) override
Definition: WaveTrack.cpp:694
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:1888
void SplitDelete(double t0, double t1)
Definition: WaveTrack.cpp:963
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1868
WaveClipHolders mClips
Definition: WaveTrack.h:615
bool WaveTrack::Unlock ( ) const

Definition at line 1850 of file WaveTrack.cpp.

References mClips, and WaveClip::Unlock().

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

1851 {
1852  for (const auto &clip : mClips)
1853  clip->Unlock();
1854 
1855  return true;
1856 }
WaveClipHolders mClips
Definition: WaveTrack.h:615
void WaveTrack::UpdateLocationsCache ( ) const

Definition at line 2421 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().

2422 {
2423  auto clips = SortedClipArray();
2424 
2425  mDisplayLocationsCache.clear();
2426 
2427  // Count number of display locations
2428  int num = 0;
2429  {
2430  const WaveClip *prev = nullptr;
2431  for (const auto clip : clips)
2432  {
2433  num += clip->NumCutLines();
2434 
2435  if (prev && fabs(prev->GetEndTime() -
2436  clip->GetStartTime()) < WAVETRACK_MERGE_POINT_TOLERANCE)
2437  ++num;
2438 
2439  prev = clip;
2440  }
2441  }
2442 
2443  if (num == 0)
2444  return;
2445 
2446  // Alloc necessary number of display locations
2447  mDisplayLocationsCache.reserve(num);
2448 
2449  // Add all display locations to cache
2450  int curpos = 0;
2451 
2452  const WaveClip *previousClip = nullptr;
2453  for (const auto clip: clips)
2454  {
2455  for (const auto &cc : clip->GetCutLines())
2456  {
2457  // Add cut line expander point
2459  clip->GetOffset() + cc->GetOffset(),
2461  });
2462  curpos++;
2463  }
2464 
2465  if (previousClip)
2466  {
2467  if (fabs(previousClip->GetEndTime() - clip->GetStartTime())
2469  {
2470  // Add merge point
2472  previousClip->GetEndTime(),
2474  GetClipIndex(previousClip),
2475  GetClipIndex(clip)
2476  });
2477  curpos++;
2478  }
2479  }
2480 
2481  previousClip = clip;
2482  }
2483 
2484  wxASSERT(curpos == num);
2485 }
size_t NumCutLines() const
Definition: WaveClip.h:317
WaveClipPointers SortedClipArray()
Definition: WaveTrack.cpp:2591
std::vector< Location > mDisplayLocationsCache
Definition: WaveTrack.h:637
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:2285
void WaveTrack::UseSpectralPrefs ( bool  bUse = true)

Definition at line 737 of file WaveTrack.cpp.

References GetIndependentSpectrogramSettings(), and mpSpectrumSettings.

738 {
739  if( bUse ){
740  if( !mpSpectrumSettings )
741  return;
742  // reset it, and next we will be getting the defaults.
743  mpSpectrumSettings.reset();
744  }
745  else {
746  if( mpSpectrumSettings )
747  return;
749  }
750 }
std::unique_ptr< SpectrogramSettings > mpSpectrumSettings
Definition: WaveTrack.h:656
SpectrogramSettings & GetIndependentSpectrogramSettings()
Definition: WaveTrack.cpp:722
WaveTrack::WaveTrackDisplay WaveTrack::ValidateWaveTrackDisplay ( WaveTrackDisplay  display)
static

Definition at line 296 of file WaveTrack.cpp.

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

Referenced by TracksViewModeSetting::Migrate().

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

Implements Track.

Definition at line 1796 of file WaveTrack.cpp.

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

Referenced by AudacityProject::WriteXML().

1798 {
1799  xmlFile.StartTag(wxT("wavetrack"));
1800  if (mAutoSaveIdent)
1801  {
1802  xmlFile.WriteAttr(wxT("autosaveid"), mAutoSaveIdent);
1803  }
1804  xmlFile.WriteAttr(wxT("name"), mName);
1805  xmlFile.WriteAttr(wxT("channel"), mChannel);
1806  xmlFile.WriteAttr(wxT("linked"), mLinked);
1807  this->PlayableTrack::WriteXMLAttributes(xmlFile);
1808  xmlFile.WriteAttr(wxT("height"), this->GetActualHeight());
1809  xmlFile.WriteAttr(wxT("minimized"), this->GetMinimized());
1810  xmlFile.WriteAttr(wxT("isSelected"), this->GetSelected());
1811  xmlFile.WriteAttr(wxT("rate"), mRate);
1812  xmlFile.WriteAttr(wxT("gain"), (double)mGain);
1813  xmlFile.WriteAttr(wxT("pan"), (double)mPan);
1814  xmlFile.WriteAttr(wxT("colorindex"), mWaveColorIndex );
1815 
1816  for (const auto &clip : mClips)
1817  {
1818  clip->WriteXML(xmlFile);
1819  }
1820 
1821  xmlFile.EndTag(wxT("wavetrack"));
1822 }
int GetActualHeight() const
Definition: Track.h:294
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:78
int mAutoSaveIdent
Definition: WaveTrack.h:654
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:374
ChannelType mChannel
Definition: Track.h:346
bool GetMinimized() const
Definition: Track.cpp:204
void WriteXMLAttributes(XMLWriter &xmlFile) const
Definition: Track.cpp:371
int mRate
Definition: WaveTrack.h:618
float mGain
Definition: WaveTrack.h:619
bool mLinked
Definition: Track.h:210
WaveClipHolders mClips
Definition: WaveTrack.h:615
float mPan
Definition: WaveTrack.h:620
int mWaveColorIndex
Definition: WaveTrack.h:621
wxString mName
Definition: Track.h:205
int WaveTrack::ZeroLevelYCoordinate ( wxRect  rect) const

Definition at line 390 of file WaveTrack.cpp.

References mDisplayMax, and mDisplayMin.

Referenced by TrackArtist::DrawClipWaveform().

391 {
392  return rect.GetTop() +
393  (int)((mDisplayMax / (mDisplayMax - mDisplayMin)) * rect.height);
394 }
float mDisplayMin
Definition: WaveTrack.h:629
float mDisplayMax
Definition: WaveTrack.h:630

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 652 of file WaveTrack.h.

int WaveTrack::mAutoSaveIdent
private

Definition at line 654 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 659 of file WaveTrack.h.

WaveTrackDisplay WaveTrack::mDisplay
protected

Definition at line 634 of file WaveTrack.h.

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

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

Definition at line 637 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 661 of file WaveTrack.h.

wxCriticalSection WaveTrack::mFlushCriticalSection
private

Definition at line 651 of file WaveTrack.h.

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

Definition at line 619 of file WaveTrack.h.

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

int WaveTrack::mLastdBRange
mutableprotected

Definition at line 636 of file WaveTrack.h.

Referenced by SetLastdBRange(), and WaveTrack().

int WaveTrack::mLastScaleType
mutableprotected

Definition at line 635 of file WaveTrack.h.

Referenced by SetLastScaleType(), and WaveTrack().

double WaveTrack::mLegacyProjectFileOffset
private

Definition at line 653 of file WaveTrack.h.

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

float WaveTrack::mOldGain[2]
protected

Definition at line 622 of file WaveTrack.h.

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

float WaveTrack::mPan
protected

Definition at line 620 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 660 of file WaveTrack.h.

float WaveTrack::mSpectrumMax
mutableprotected

Definition at line 632 of file WaveTrack.h.

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

float WaveTrack::mSpectrumMin
mutableprotected

Definition at line 631 of file WaveTrack.h.

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

int WaveTrack::mWaveColorIndex
protected

Definition at line 621 of file WaveTrack.h.

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


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