Audacity  2.2.0
WaveClip Class Referencefinal

This allows multiple clips to be a part of one WaveTrack. More...

#include <WaveClip.h>

Inheritance diagram for WaveClip:
XMLTagHandler

Public Member Functions

 WaveClip (const std::shared_ptr< DirManager > &projDirManager, sampleFormat format, int rate, int colourIndex)
 
 WaveClip (const WaveClip &orig, const std::shared_ptr< DirManager > &projDirManager, bool copyCutlines)
 
 WaveClip (const WaveClip &orig, const std::shared_ptr< DirManager > &projDirManager, bool copyCutlines, double t0, double t1)
 
virtual ~WaveClip ()
 
void ConvertToSampleFormat (sampleFormat format)
 
void TimeToSamplesClip (double t0, sampleCount *s0) const
 
int GetRate () const
 
void SetRate (int rate)
 
void Resample (int rate, ProgressDialog *progress=NULL)
 
void SetColourIndex (int index)
 
int GetColourIndex () const
 
void SetOffset (double offset)
 
double GetOffset () const
 
void Offset (double delta)
 
double GetStartTime () const
 
double GetEndTime () const
 
sampleCount GetStartSample () const
 
sampleCount GetEndSample () const
 
sampleCount GetNumSamples () const
 
bool WithinClip (double t) const
 
bool BeforeClip (double t) const
 
bool AfterClip (double t) const
 
bool GetSamples (samplePtr buffer, sampleFormat format, sampleCount start, size_t len, bool mayThrow=true) const
 
void SetSamples (samplePtr buffer, sampleFormat format, sampleCount start, size_t len)
 
EnvelopeGetEnvelope ()
 
const EnvelopeGetEnvelope () const
 
BlockArrayGetSequenceBlockArray ()
 
SequenceGetSequence ()
 
void MarkChanged ()
 
bool GetWaveDisplay (WaveDisplay &display, double t0, double pixelsPerSecond, bool &isLoadingOD) const
 
bool GetSpectrogram (WaveTrackCache &cache, const float *&spectrogram, const sampleCount *&where, size_t numPixels, double t0, double pixelsPerSecond) const
 
std::pair< float, float > GetMinMax (double t0, double t1, bool mayThrow=true) const
 
float GetRMS (double t0, double t1, bool mayThrow=true) const
 
void ClearDisplayRect () const
 
void SetDisplayRect (const wxRect &r) const
 
void GetDisplayRect (wxRect *r)
 
void UpdateEnvelopeTrackLen ()
 
void Append (samplePtr buffer, sampleFormat format, size_t len, unsigned int stride=1, XMLWriter *blockFileLog=NULL)
 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)
 
void Clear (double t0, double t1)
 
void ClearAndAddCutLine (double t0, double t1)
 Clear, and add cut line that starts at t0 and contains everything until t1. More...
 
void Paste (double t0, const WaveClip *other)
 Paste data from other clip, resampling it if not equal rate. More...
 
void InsertSilence (double t, double len, double *pEnvelopeValue=nullptr)
 
void AppendSilence (double len, double envelopeValue)
 
WaveClipHoldersGetCutLines ()
 Get access to cut lines list. More...
 
const WaveClipConstHoldersGetCutLines () const
 
size_t NumCutLines () const
 
bool FindCutLine (double cutLinePosition, double *cutLineStart=NULL, double *cutLineEnd=NULL) const
 
void ExpandCutLine (double cutLinePosition)
 
bool RemoveCutLine (double cutLinePosition)
 Remove cut line, without expanding the audio in it. More...
 
void OffsetCutLines (double t0, double len)
 Offset cutlines right to time 't0' by time amount 'len'. More...
 
void Lock ()
 Lock all blockfiles. More...
 
void Unlock ()
 Unlock all blockfiles. More...
 
void CloseLock ()
 
void ClearWaveCache ()
 Delete the wave cache - force redraw. Thread-safe. More...
 
void AddInvalidRegion (sampleCount startSample, sampleCount endSample)
 Adds an invalid region to the wavecache so it redraws that portion only. More...
 
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
 
bool GetIsPlaceholder () const
 
void SetIsPlaceholder (bool val)
 
bool SharesBoundaryWithNextClip (const WaveClip *next) const
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual void HandleXMLEndTag (const wxChar *WXUNUSED(tag))
 
virtual void HandleXMLContent (const wxString &WXUNUSED(content))
 
bool ReadXMLTag (const char *tag, const char **attrs)
 
void ReadXMLEndTag (const char *tag)
 
void ReadXMLContent (const char *s, int len)
 
XMLTagHandlerReadXMLChild (const char *tag)
 

Public Attributes

std::unique_ptr< SpecPxCachemSpecPxCache
 

Protected Attributes

wxRect mDisplayRect {}
 
double mOffset { 0 }
 
int mRate
 
int mDirty { 0 }
 
int mColourIndex
 
std::unique_ptr< SequencemSequence
 
std::unique_ptr< EnvelopemEnvelope
 
std::unique_ptr< WaveCachemWaveCache
 
ODLock mWaveCacheMutex {}
 
std::unique_ptr< SpecCachemSpecCache
 
SampleBuffer mAppendBuffer {}
 
size_t mAppendBufferLen { 0 }
 
WaveClipHolders mCutLines {}
 
bool mIsPlaceholder { false }
 

Private Member Functions

 WaveClip (const WaveClip &) PROHIBITED
 
WaveClipoperator= (const WaveClip &) PROHIBITED
 

Detailed Description

This allows multiple clips to be a part of one WaveTrack.

Constructor & Destructor Documentation

WaveClip::WaveClip ( const WaveClip )
private
WaveClip::WaveClip ( const std::shared_ptr< DirManager > &  projDirManager,
sampleFormat  format,
int  rate,
int  colourIndex 
)

References format, and WaveCache::rate.

WaveClip::WaveClip ( const WaveClip orig,
const std::shared_ptr< DirManager > &  projDirManager,
bool  copyCutlines 
)
WaveClip::WaveClip ( const WaveClip orig,
const std::shared_ptr< DirManager > &  projDirManager,
bool  copyCutlines,
double  t0,
double  t1 
)
WaveClip::~WaveClip ( )
virtual

Member Function Documentation

void WaveClip::AddInvalidRegion ( sampleCount  startSample,
sampleCount  endSample 
)

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

Referenced by WaveTrack::AddInvalidRegion().

bool WaveClip::AfterClip ( double  t) const

Referenced by WaveTrack::HandleClear().

void WaveClip::Append ( samplePtr  buffer,
sampleFormat  format,
size_t  len,
unsigned int  stride = 1,
XMLWriter blockFileLog = NULL 
)

You must call Flush after the last Append.

References CopySamples(), and min().

Referenced by WaveTrack::Append().

void WaveClip::AppendAlias ( const wxString &  fName,
sampleCount  start,
size_t  len,
int  channel,
bool  useOD 
)

Referenced by WaveTrack::AppendAlias().

void WaveClip::AppendCoded ( const wxString &  fName,
sampleCount  start,
size_t  len,
int  channel,
int  decodeType 
)

Referenced by WaveTrack::AppendCoded().

void WaveClip::AppendSilence ( double  len,
double  envelopeValue 
)

Insert silence at the end, and causes the envelope to ramp linearly to the given value

Referenced by WaveTrack::Join().

bool WaveClip::BeforeClip ( double  t) const
void WaveClip::Clear ( double  t0,
double  t1 
)

This name is consistent with WaveTrack::Clear. It performs a "Cut" operation (but without putting the cutted audio to the clipboard)

References GetOffset(), and Offset().

Referenced by WaveTrack::HandleClear().

void WaveClip::ClearAndAddCutLine ( double  t0,
double  t1 
)

Clear, and add cut line that starts at t0 and contains everything until t1.

References GetOffset(), min(), and Offset().

void WaveClip::ClearDisplayRect ( ) const
void WaveClip::ClearWaveCache ( )

Delete the wave cache - force redraw. Thread-safe.

Referenced by WaveTrack::ClearWaveCaches().

void WaveClip::CloseLock ( )

Referenced by WaveTrack::CloseLock().

void WaveClip::ConvertToSampleFormat ( sampleFormat  format)

Referenced by Paste().

void WaveClip::ExpandCutLine ( double  cutLinePosition)

Expand cut line (that is, re-insert audio, then DELETE audio saved in cut line). Returns true if a cut line could be found and sucessfully expanded, false otherwise

Referenced by WaveTrack::ExpandCutLine().

bool WaveClip::FindCutLine ( double  cutLinePosition,
double *  cutLineStart = NULL,
double *  cutLineEnd = NULL 
) const

Find cut line at (approximately) this position. Returns true and fills in cutLineStart and cutLineEnd (if specified) if a cut line at this position could be found. Return false otherwise.

Referenced by WaveTrack::ExpandCutLine().

void WaveClip::Flush ( )

Flush must be called after last Append.

Referenced by WaveTrack::Flush().

int WaveClip::GetColourIndex ( ) const
inline
WaveClipHolders& WaveClip::GetCutLines ( )
inline

Get access to cut lines list.

Referenced by WaveTrack::UpdateLocationsCache().

const WaveClipConstHolders& WaveClip::GetCutLines ( ) const
inline
void WaveClip::GetDisplayRect ( wxRect *  r)

Referenced by WaveTrack::GetClipAtX().

const Envelope* WaveClip::GetEnvelope ( ) const
inline
bool WaveClip::GetIsPlaceholder ( ) const
inline

Referenced by WaveTrack::Paste(), and WaveClip().

std::pair< float, float > WaveClip::GetMinMax ( double  t0,
double  t1,
bool  mayThrow = true 
) const
int WaveClip::GetRate ( ) const
inline
float WaveClip::GetRMS ( double  t0,
double  t1,
bool  mayThrow = true 
) const
bool WaveClip::GetSamples ( samplePtr  buffer,
sampleFormat  format,
sampleCount  start,
size_t  len,
bool  mayThrow = true 
) const
BlockArray * WaveClip::GetSequenceBlockArray ( )
bool WaveClip::GetSpectrogram ( WaveTrackCache cache,
const float *&  spectrogram,
const sampleCount *&  where,
size_t  numPixels,
double  t0,
double  pixelsPerSecond 
) const
bool WaveClip::GetWaveDisplay ( WaveDisplay display,
double  t0,
double  pixelsPerSecond,
bool &  isLoadingOD 
) const
XMLTagHandler * WaveClip::HandleXMLChild ( const wxChar *  tag)
overridevirtual

Implements XMLTagHandler.

void WaveClip::HandleXMLEndTag ( const wxChar *  tag)
override
bool WaveClip::HandleXMLTag ( const wxChar *  tag,
const wxChar **  attrs 
)
overridevirtual
void WaveClip::InsertSilence ( double  t,
double  len,
double *  pEnvelopeValue = nullptr 
)

Insert silence - note that this is an efficient operation for large amounts of silence

References WaveCache::len.

Referenced by WaveTrack::InsertSilence().

void WaveClip::Lock ( )

Lock all blockfiles.

Referenced by WaveTrack::Lock().

void WaveClip::MarkChanged ( )
inline

WaveTrack calls this whenever data in the wave clip changes. It is called automatically when WaveClip has a chance to know that something has changed, like when member functions SetSamples() etc. are called.

Referenced by TimeShiftHandle::Release(), WaveTrack::Set(), and WaveTrack::Silence().

size_t WaveClip::NumCutLines ( ) const
inline
void WaveClip::OffsetCutLines ( double  t0,
double  len 
)

Offset cutlines right to time 't0' by time amount 'len'.

WaveClip& WaveClip::operator= ( const WaveClip )
private
void WaveClip::Paste ( double  t0,
const WaveClip other 
)

Paste data from other clip, resampling it if not equal rate.

References ConvertToSampleFormat(), GetEndTime(), GetStartTime(), mCutLines, mEnvelope, mRate, mSequence, Offset(), and Resample().

Referenced by WaveTrack::Join(), WaveTrack::MergeClips(), and WaveTrack::Paste().

bool WaveClip::RemoveCutLine ( double  cutLinePosition)

Remove cut line, without expanding the audio in it.

Referenced by WaveTrack::RemoveCutLine().

void WaveClip::Resample ( int  rate,
ProgressDialog progress = NULL 
)

We want to keep going as long as we have something to feed the resampler with OR as long as the resampler spews out samples (which could continue for a few iterations after we stop feeding it)

References _(), Resample::Process(), WaveCache::rate, Success, and ProgressDialog::Update().

Referenced by Paste(), TimeShiftHandle::Release(), and WaveTrack::Resample().

void WaveClip::SetColourIndex ( int  index)
inline
void WaveClip::SetDisplayRect ( const wxRect &  r) const
void WaveClip::SetIsPlaceholder ( bool  val)
inline
void WaveClip::SetRate ( int  rate)

References WaveCache::rate.

void WaveClip::SetSamples ( samplePtr  buffer,
sampleFormat  format,
sampleCount  start,
size_t  len 
)

Referenced by WaveTrack::Set().

bool WaveClip::SharesBoundaryWithNextClip ( const WaveClip next) const

References GetOffset(), and GetRate().

void WaveClip::TimeToSamplesClip ( double  t0,
sampleCount *  s0 
) const
void WaveClip::Unlock ( )

Unlock all blockfiles.

Referenced by WaveTrack::Unlock().

void WaveClip::UpdateEnvelopeTrackLen ( )

Whenever you do an operation to the sequence that will change the number of samples (that is, the length of the clip), you will want to call this function to tell the envelope about it.

Referenced by RecordingRecoveryHandler::HandleXMLTag().

bool WaveClip::WithinClip ( double  t) const
void WaveClip::WriteXML ( XMLWriter xmlFile) const

Referenced by WaveTrack::WriteXML().

Member Data Documentation

SampleBuffer WaveClip::mAppendBuffer {}
protected
size_t WaveClip::mAppendBufferLen { 0 }
protected
int WaveClip::mColourIndex
protected

Referenced by WaveClip().

WaveClipHolders WaveClip::mCutLines {}
protected

Referenced by Paste(), and WaveClip().

int WaveClip::mDirty { 0 }
protected
wxRect WaveClip::mDisplayRect {}
mutableprotected
std::unique_ptr<Envelope> WaveClip::mEnvelope
protected

Referenced by Paste(), and WaveClip().

bool WaveClip::mIsPlaceholder { false }
protected
double WaveClip::mOffset { 0 }
protected

Referenced by WaveClip().

int WaveClip::mRate
protected

Referenced by Paste(), and WaveClip().

std::unique_ptr<Sequence> WaveClip::mSequence
protected

Referenced by Paste(), and WaveClip().

std::unique_ptr<SpecCache> WaveClip::mSpecCache
mutableprotected
std::unique_ptr<SpecPxCache> WaveClip::mSpecPxCache
mutable
std::unique_ptr<WaveCache> WaveClip::mWaveCache
mutableprotected
ODLock WaveClip::mWaveCacheMutex {}
mutableprotected

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