Audacity  3.0.3
Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions | Private Attributes | List of all members
WaveClip Class Referencefinal

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

#include <WaveClip.h>

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

Public Member Functions

 WaveClip (const SampleBlockFactoryPtr &factory, sampleFormat format, int rate, int colourIndex)
 
 WaveClip (const WaveClip &orig, const SampleBlockFactoryPtr &factory, bool copyCutlines)
 
 WaveClip (const WaveClip &orig, const SampleBlockFactoryPtr &factory, bool copyCutlines, double t0, double t1)
 
virtual ~WaveClip ()
 
void ConvertToSampleFormat (sampleFormat format, const std::function< void(size_t)> &progressReport={})
 
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 IsClipStartAfterClip (double t) const
 
bool GetSamples (samplePtr buffer, sampleFormat format, sampleCount start, size_t len, bool mayThrow=true) const
 
void SetSamples (constSamplePtr buffer, sampleFormat format, sampleCount start, size_t len)
 
EnvelopeGetEnvelope ()
 
const EnvelopeGetEnvelope () const
 
BlockArrayGetSequenceBlockArray ()
 
const BlockArrayGetSequenceBlockArray () const
 
SequenceGetSequence ()
 
const SequenceGetSequence () const
 
void MarkChanged ()
 
bool GetWaveDisplay (WaveDisplay &display, double t0, double pixelsPerSecond) 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 UpdateEnvelopeTrackLen ()
 
std::shared_ptr< SampleBlockAppendNewBlock (samplePtr buffer, sampleFormat format, size_t len)
 For use in importing pre-version-3 projects to preserve sharing of blocks. More...
 
void AppendSharedBlock (const std::shared_ptr< SampleBlock > &pBlock)
 For use in importing pre-version-3 projects to preserve sharing of blocks. More...
 
bool Append (constSamplePtr buffer, sampleFormat format, size_t len, unsigned int stride)
 
void Flush ()
 Flush must be called after last Append. More...
 
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 CloseLock ()
 
void ClearWaveCache ()
 Delete the wave cache - force redraw. Thread-safe. 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
 
void SetName (const wxString &name)
 
const wxString & GetName () 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

double mOffset { 0 }
 
int mRate
 
int mDirty { 0 }
 
int mColourIndex
 
std::unique_ptr< SequencemSequence
 
std::unique_ptr< EnvelopemEnvelope
 
std::unique_ptr< WaveCachemWaveCache
 
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
 

Private Attributes

wxString mName
 

Detailed Description

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

Definition at line 172 of file WaveClip.h.

Constructor & Destructor Documentation

◆ WaveClip() [1/4]

WaveClip::WaveClip ( const WaveClip )
private

◆ WaveClip() [2/4]

WaveClip::WaveClip ( const SampleBlockFactoryPtr factory,
sampleFormat  format,
int  rate,
int  colourIndex 
)

Definition at line 121 of file WaveClip.cpp.

123 {
124  mRate = rate;
125  mColourIndex = colourIndex;
126  mSequence = std::make_unique<Sequence>(factory, format);
127 
128  mEnvelope = std::make_unique<Envelope>(true, 1e-7, 2.0, 1.0);
129 
130  mWaveCache = std::make_unique<WaveCache>();
131  mSpecCache = std::make_unique<SpecCache>();
132  mSpecPxCache = std::make_unique<SpecPxCache>(1);
133 }

References factory, format, mColourIndex, mEnvelope, mRate, mSequence, mSpecCache, mSpecPxCache, and mWaveCache.

◆ WaveClip() [3/4]

WaveClip::WaveClip ( const WaveClip orig,
const SampleBlockFactoryPtr factory,
bool  copyCutlines 
)

Definition at line 135 of file WaveClip.cpp.

138 {
139  // essentially a copy constructor - but you must pass in the
140  // current sample block factory, because we might be copying
141  // from one project to another
142 
143  mOffset = orig.mOffset;
144  mRate = orig.mRate;
145  mColourIndex = orig.mColourIndex;
146  mSequence = std::make_unique<Sequence>(*orig.mSequence, factory);
147 
148  mEnvelope = std::make_unique<Envelope>(*orig.mEnvelope);
149 
150  mWaveCache = std::make_unique<WaveCache>();
151  mSpecCache = std::make_unique<SpecCache>();
152  mSpecPxCache = std::make_unique<SpecPxCache>(1);
153 
154  mName = orig.mName;
155 
156  if ( copyCutlines )
157  for (const auto &clip: orig.mCutLines)
158  mCutLines.push_back
159  ( std::make_unique<WaveClip>( *clip, factory, true ) );
160 
162 }

References factory, GetIsPlaceholder(), mColourIndex, mCutLines, mEnvelope, mIsPlaceholder, mName, mOffset, mRate, mSequence, mSpecCache, mSpecPxCache, and mWaveCache.

Here is the call graph for this function:

◆ WaveClip() [4/4]

WaveClip::WaveClip ( const WaveClip orig,
const SampleBlockFactoryPtr factory,
bool  copyCutlines,
double  t0,
double  t1 
)

Definition at line 164 of file WaveClip.cpp.

168 {
169  // Copy only a range of the other WaveClip
170 
171  mOffset = orig.mOffset;
172  mRate = orig.mRate;
173  mColourIndex = orig.mColourIndex;
174 
175  mWaveCache = std::make_unique<WaveCache>();
176  mSpecCache = std::make_unique<SpecCache>();
177  mSpecPxCache = std::make_unique<SpecPxCache>(1);
178 
180 
181  sampleCount s0, s1;
182 
183  orig.TimeToSamplesClip(t0, &s0);
184  orig.TimeToSamplesClip(t1, &s1);
185 
186  mSequence = orig.mSequence->Copy(factory, s0, s1);
187 
188  mEnvelope = std::make_unique<Envelope>(
189  *orig.mEnvelope,
190  mOffset + s0.as_double()/mRate,
191  mOffset + s1.as_double()/mRate
192  );
193 
194  if ( copyCutlines )
195  // Copy cutline clips that fall in the range
196  for (const auto &ppClip : orig.mCutLines)
197  {
198  const WaveClip* clip = ppClip.get();
199  double cutlinePosition = orig.mOffset + clip->GetOffset();
200  if (cutlinePosition >= t0 && cutlinePosition <= t1)
201  {
202  auto newCutLine =
203  std::make_unique< WaveClip >( *clip, factory, true );
204  newCutLine->SetOffset( cutlinePosition - t0 );
205  mCutLines.push_back(std::move(newCutLine));
206  }
207  }
208 }

References sampleCount::as_double(), factory, GetIsPlaceholder(), GetOffset(), mColourIndex, mCutLines, mEnvelope, mIsPlaceholder, mOffset, mRate, mSequence, mSpecCache, mSpecPxCache, mWaveCache, and TimeToSamplesClip().

Here is the call graph for this function:

◆ ~WaveClip()

WaveClip::~WaveClip ( )
virtual

Definition at line 211 of file WaveClip.cpp.

212 {
213 }

Member Function Documentation

◆ AfterClip()

bool WaveClip::AfterClip ( double  t) const

Definition at line 298 of file WaveClip.cpp.

299 {
300  auto ts = (sampleCount)floor(t * mRate + 0.5);
301  return ts >= GetEndSample() + mAppendBufferLen;
302 }

References GetEndSample(), mAppendBufferLen, and mRate.

Here is the call graph for this function:

◆ Append()

bool WaveClip::Append ( constSamplePtr  buffer,
sampleFormat  format,
size_t  len,
unsigned int  stride 
)

You must call Flush after the last Append

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

Definition at line 1208 of file WaveClip.cpp.

1210 {
1211  //wxLogDebug(wxT("Append: len=%lli"), (long long) len);
1212  bool result = false;
1213 
1214  auto maxBlockSize = mSequence->GetMaxBlockSize();
1215  auto blockSize = mSequence->GetIdealAppendLen();
1216  sampleFormat seqFormat = mSequence->GetSampleFormat();
1217 
1218  if (!mAppendBuffer.ptr())
1219  mAppendBuffer.Allocate(maxBlockSize, seqFormat);
1220 
1221  auto cleanup = finally( [&] {
1222  // use No-fail-guarantee
1224  MarkChanged();
1225  } );
1226 
1227  for(;;) {
1228  if (mAppendBufferLen >= blockSize) {
1229  // flush some previously appended contents
1230  // use Strong-guarantee
1231  mSequence->Append(mAppendBuffer.ptr(), seqFormat, blockSize);
1232  result = true;
1233 
1234  // use No-fail-guarantee for rest of this "if"
1235  memmove(mAppendBuffer.ptr(),
1236  mAppendBuffer.ptr() + blockSize * SAMPLE_SIZE(seqFormat),
1237  (mAppendBufferLen - blockSize) * SAMPLE_SIZE(seqFormat));
1238  mAppendBufferLen -= blockSize;
1239  blockSize = mSequence->GetIdealAppendLen();
1240  }
1241 
1242  if (len == 0)
1243  break;
1244 
1245  // use No-fail-guarantee for rest of this "for"
1246  wxASSERT(mAppendBufferLen <= maxBlockSize);
1247  auto toCopy = std::min(len, maxBlockSize - mAppendBufferLen);
1248 
1249  CopySamples(buffer, format,
1250  mAppendBuffer.ptr() + mAppendBufferLen * SAMPLE_SIZE(seqFormat),
1251  seqFormat,
1252  toCopy,
1254  stride);
1255 
1256  mAppendBufferLen += toCopy;
1257  buffer += toCopy * SAMPLE_SIZE(format) * stride;
1258  len -= toCopy;
1259  }
1260 
1261  return result;
1262 }

References SampleBuffer::Allocate(), CopySamples(), format, gHighQualityDither, mAppendBuffer, mAppendBufferLen, MarkChanged(), min(), mSequence, SampleBuffer::ptr(), SAMPLE_SIZE, and UpdateEnvelopeTrackLen().

Referenced by WaveTrack::Append().

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

◆ AppendNewBlock()

std::shared_ptr< SampleBlock > WaveClip::AppendNewBlock ( samplePtr  buffer,
sampleFormat  format,
size_t  len 
)

For use in importing pre-version-3 projects to preserve sharing of blocks.

Exception safety guarantee:
Strong

Definition at line 1193 of file WaveClip.cpp.

1195 {
1196  return mSequence->AppendNewBlock( buffer, format, len );
1197 }

References format, and mSequence.

◆ AppendSharedBlock()

void WaveClip::AppendSharedBlock ( const std::shared_ptr< SampleBlock > &  pBlock)

For use in importing pre-version-3 projects to preserve sharing of blocks.

Exception safety guarantee:
Strong

Definition at line 1200 of file WaveClip.cpp.

1201 {
1202  mSequence->AppendSharedBlock( pBlock );
1203 }

References mSequence.

◆ AppendSilence()

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

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

Exception safety guarantee:
Strong

Definition at line 1467 of file WaveClip.cpp.

1468 {
1469  auto t = GetEndTime();
1470  InsertSilence( t, len, &envelopeValue );
1471 }

References GetEndTime(), and InsertSilence().

Here is the call graph for this function:

◆ BeforeClip()

bool WaveClip::BeforeClip ( double  t) const

Definition at line 292 of file WaveClip.cpp.

293 {
294  auto ts = (sampleCount)floor(t * mRate + 0.5);
295  return ts <= GetStartSample();
296 }

References GetStartSample(), and mRate.

Here is the call graph for this function:

◆ Clear()

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

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

Exception safety guarantee:
Strong

Definition at line 1474 of file WaveClip.cpp.

1475 {
1476  sampleCount s0, s1;
1477 
1478  TimeToSamplesClip(t0, &s0);
1479  TimeToSamplesClip(t1, &s1);
1480 
1481  // use Strong-guarantee
1482  GetSequence()->Delete(s0, s1-s0);
1483 
1484  // use No-fail-guarantee in the remaining
1485 
1486  // msmeyer
1487  //
1488  // Delete all cutlines that are within the given area, if any.
1489  //
1490  // Note that when cutlines are active, two functions are used:
1491  // Clear() and ClearAndAddCutLine(). ClearAndAddCutLine() is called
1492  // whenever the user directly calls a command that removes some audio, e.g.
1493  // "Cut" or "Clear" from the menu. This command takes care about recursive
1494  // preserving of cutlines within clips. Clear() is called when internal
1495  // operations want to remove audio. In the latter case, it is the right
1496  // thing to just remove all cutlines within the area.
1497  //
1498  double clip_t0 = t0;
1499  double clip_t1 = t1;
1500  if (clip_t0 < GetStartTime())
1501  clip_t0 = GetStartTime();
1502  if (clip_t1 > GetEndTime())
1503  clip_t1 = GetEndTime();
1504 
1505  // May DELETE as we iterate, so don't use range-for
1506  for (auto it = mCutLines.begin(); it != mCutLines.end();)
1507  {
1508  WaveClip* clip = it->get();
1509  double cutlinePosition = mOffset + clip->GetOffset();
1510  if (cutlinePosition >= t0 && cutlinePosition <= t1)
1511  {
1512  // This cutline is within the area, DELETE it
1513  it = mCutLines.erase(it);
1514  }
1515  else
1516  {
1517  if (cutlinePosition >= t1)
1518  {
1519  clip->Offset(clip_t0 - clip_t1);
1520  }
1521  ++it;
1522  }
1523  }
1524 
1525  // Collapse envelope
1526  auto sampleTime = 1.0 / GetRate();
1527  GetEnvelope()->CollapseRegion( t0, t1, sampleTime );
1528  if (t0 < GetStartTime())
1529  Offset(-(GetStartTime() - t0));
1530 
1531  MarkChanged();
1532 }

References Envelope::CollapseRegion(), Sequence::Delete(), GetEndTime(), GetEnvelope(), GetOffset(), GetRate(), GetSequence(), GetStartTime(), MarkChanged(), mCutLines, mOffset, Offset(), and TimeToSamplesClip().

Here is the call graph for this function:

◆ ClearAndAddCutLine()

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

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

Exception safety guarantee:
Weak – This WaveClip remains destructible in case of AudacityException. But some cutlines may be deleted

Definition at line 1537 of file WaveClip.cpp.

1538 {
1539  if (t0 > GetEndTime() || t1 < GetStartTime())
1540  return; // time out of bounds
1541 
1542  const double clip_t0 = std::max( t0, GetStartTime() );
1543  const double clip_t1 = std::min( t1, GetEndTime() );
1544 
1545  auto newClip = std::make_unique< WaveClip >
1546  (*this, mSequence->GetFactory(), true, clip_t0, clip_t1);
1547 
1548  newClip->SetOffset( clip_t0 - mOffset );
1549 
1550  // Remove cutlines from this clip that were in the selection, shift
1551  // left those that were after the selection
1552  // May DELETE as we iterate, so don't use range-for
1553  for (auto it = mCutLines.begin(); it != mCutLines.end();)
1554  {
1555  WaveClip* clip = it->get();
1556  double cutlinePosition = mOffset + clip->GetOffset();
1557  if (cutlinePosition >= t0 && cutlinePosition <= t1)
1558  it = mCutLines.erase(it);
1559  else
1560  {
1561  if (cutlinePosition >= t1)
1562  {
1563  clip->Offset(clip_t0 - clip_t1);
1564  }
1565  ++it;
1566  }
1567  }
1568 
1569  // Clear actual audio data
1570  sampleCount s0, s1;
1571 
1572  TimeToSamplesClip(t0, &s0);
1573  TimeToSamplesClip(t1, &s1);
1574 
1575  // use Weak-guarantee
1576  GetSequence()->Delete(s0, s1-s0);
1577 
1578  // Collapse envelope
1579  auto sampleTime = 1.0 / GetRate();
1580  GetEnvelope()->CollapseRegion( t0, t1, sampleTime );
1581  if (t0 < GetStartTime())
1582  Offset(-(GetStartTime() - t0));
1583 
1584  MarkChanged();
1585 
1586  mCutLines.push_back(std::move(newClip));
1587 }

References Envelope::CollapseRegion(), Sequence::Delete(), GetEndTime(), GetEnvelope(), GetOffset(), GetRate(), GetSequence(), GetStartTime(), MarkChanged(), mCutLines, min(), mOffset, mSequence, Offset(), and TimeToSamplesClip().

Here is the call graph for this function:

◆ ClearWaveCache()

void WaveClip::ClearWaveCache ( )

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

Definition at line 315 of file WaveClip.cpp.

316 {
317  mWaveCache = std::make_unique<WaveCache>();
318 }

References mWaveCache.

◆ CloseLock()

void WaveClip::CloseLock ( )

Definition at line 1666 of file WaveClip.cpp.

1667 {
1668  GetSequence()->CloseLock();
1669  for (const auto &cutline: mCutLines)
1670  cutline->CloseLock();
1671 }

References Sequence::CloseLock(), GetSequence(), and mCutLines.

Here is the call graph for this function:

◆ ConvertToSampleFormat()

void WaveClip::ConvertToSampleFormat ( sampleFormat  format,
const std::function< void(size_t)> &  progressReport = {} 
)

Definition at line 1163 of file WaveClip.cpp.

1165 {
1166  // Note: it is not necessary to do this recursively to cutlines.
1167  // They get converted as needed when they are expanded.
1168 
1169  auto bChanged = mSequence->ConvertToSampleFormat(format, progressReport);
1170  if (bChanged)
1171  MarkChanged();
1172 }

References format, MarkChanged(), and mSequence.

Referenced by Paste().

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

◆ ExpandCutLine()

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 successfully expanded, false otherwise

Exception safety guarantee:
Strong

Definition at line 1609 of file WaveClip.cpp.

1610 {
1611  auto end = mCutLines.end();
1612  auto it = std::find_if( mCutLines.begin(), end,
1613  [&](const WaveClipHolder &cutline) {
1614  return fabs(mOffset + cutline->GetOffset() - cutLinePosition) < 0.0001;
1615  } );
1616 
1617  if ( it != end ) {
1618  auto cutline = it->get();
1619  // assume Strong-guarantee from Paste
1620 
1621  // Envelope::Paste takes offset into account, WaveClip::Paste doesn't!
1622  // Do this to get the right result:
1623  cutline->mEnvelope->SetOffset(0);
1624 
1625  Paste(mOffset+cutline->GetOffset(), cutline);
1626  // Now erase the cutline,
1627  // but be careful to find it again, because Paste above may
1628  // have modified the array of cutlines (if our cutline contained
1629  // another cutline!), invalidating the iterator we had.
1630  end = mCutLines.end();
1631  it = std::find_if(mCutLines.begin(), end,
1632  [=](const WaveClipHolder &p) { return p.get() == cutline; });
1633  if (it != end)
1634  mCutLines.erase(it); // deletes cutline!
1635  else {
1636  wxASSERT(false);
1637  }
1638  }
1639 }

References mCutLines, mOffset, and Paste().

Here is the call graph for this function:

◆ FindCutLine()

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.

Definition at line 1589 of file WaveClip.cpp.

1592 {
1593  for (const auto &cutline: mCutLines)
1594  {
1595  if (fabs(mOffset + cutline->GetOffset() - cutLinePosition) < 0.0001)
1596  {
1597  if (cutlineStart)
1598  *cutlineStart = mOffset+cutline->GetStartTime();
1599  if (cutlineEnd)
1600  *cutlineEnd = mOffset+cutline->GetEndTime();
1601  return true;
1602  }
1603  }
1604 
1605  return false;
1606 }

References mCutLines, and mOffset.

◆ Flush()

void WaveClip::Flush ( )

Flush must be called after last Append.

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

Definition at line 1269 of file WaveClip.cpp.

1270 {
1271  //wxLogDebug(wxT("WaveClip::Flush"));
1272  //wxLogDebug(wxT(" mAppendBufferLen=%lli"), (long long) mAppendBufferLen);
1273  //wxLogDebug(wxT(" previous sample count %lli"), (long long) mSequence->GetNumSamples());
1274 
1275  if (mAppendBufferLen > 0) {
1276 
1277  auto cleanup = finally( [&] {
1278  // Blow away the append buffer even in case of failure. May lose some
1279  // data but don't leave the track in an un-flushed state.
1280 
1281  // Use No-fail-guarantee of these steps.
1282  mAppendBufferLen = 0;
1284  MarkChanged();
1285  } );
1286 
1287  mSequence->Append(mAppendBuffer.ptr(), mSequence->GetSampleFormat(),
1289  }
1290 
1291  //wxLogDebug(wxT("now sample count %lli"), (long long) mSequence->GetNumSamples());
1292 }

References mAppendBuffer, mAppendBufferLen, MarkChanged(), mSequence, SampleBuffer::ptr(), and UpdateEnvelopeTrackLen().

Referenced by WaveTrack::Flush().

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

◆ GetColourIndex()

int WaveClip::GetColourIndex ( ) const
inline

Definition at line 218 of file WaveClip.h.

218 { return mColourIndex;};

Referenced by anonymous_namespace{WaveformView.cpp}::DrawClipWaveform().

Here is the caller graph for this function:

◆ GetCutLines() [1/2]

WaveClipHolders& WaveClip::GetCutLines ( )
inline

Get access to cut lines list.

Definition at line 312 of file WaveClip.h.

312 { return mCutLines; }

◆ GetCutLines() [2/2]

const WaveClipConstHolders& WaveClip::GetCutLines ( ) const
inline

Definition at line 313 of file WaveClip.h.

314  { return reinterpret_cast< const WaveClipConstHolders& >( mCutLines ); }

◆ GetEndSample()

sampleCount WaveClip::GetEndSample ( ) const

Definition at line 271 of file WaveClip.cpp.

272 {
273  return GetStartSample() + mSequence->GetNumSamples();
274 }

References GetStartSample(), and mSequence.

Referenced by AfterClip(), IsClipStartAfterClip(), EffectReverse::ProcessOneWave(), and WithinClip().

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

◆ GetEndTime()

double WaveClip::GetEndTime ( ) const

Definition at line 255 of file WaveClip.cpp.

256 {
257  auto numSamples = mSequence->GetNumSamples();
258 
259  double maxLen = mOffset + (numSamples+mAppendBufferLen).as_double()/mRate;
260  // JS: calculated value is not the length;
261  // it is a maximum value and can be negative; no clipping to 0
262 
263  return maxLen;
264 }

References mAppendBufferLen, mOffset, mRate, and mSequence.

Referenced by AUPImportFileHandle::AddSilence(), AppendSilence(), SetClipCommand::ApplyInner(), SetEnvelopeCommand::ApplyInner(), WaveTrack::CanInsertClip(), Clear(), ClearAndAddCutLine(), ClipParameters::ClipParameters(), ClipParameters::GetClipRect(), WaveTrack::MergeClips(), anonymous_namespace{WaveTrackAffordanceControls.cpp}::NextClipLooped(), WaveTrack::Paste(), Paste(), and WaveTrack::UpdateLocationsCache().

Here is the caller graph for this function:

◆ GetEnvelope() [1/2]

Envelope* WaveClip::GetEnvelope ( )
inline

Definition at line 243 of file WaveClip.h.

243 { return mEnvelope.get(); }

Referenced by SetEnvelopeCommand::ApplyInner(), Clear(), ClearAndAddCutLine(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), anonymous_namespace{WaveformView.cpp}::DrawIndividualSamples(), WaveTrack::GetEnvelopeAtTime(), AUPImportFileHandle::HandleEnvelope(), WaveTrack::HandleXMLChild(), and InsertSilence().

Here is the caller graph for this function:

◆ GetEnvelope() [2/2]

const Envelope* WaveClip::GetEnvelope ( ) const
inline

Definition at line 244 of file WaveClip.h.

244 { return mEnvelope.get(); }

◆ GetIsPlaceholder()

bool WaveClip::GetIsPlaceholder ( ) const
inline

Definition at line 351 of file WaveClip.h.

351 { return mIsPlaceholder; }

Referenced by WaveClip().

Here is the caller graph for this function:

◆ GetMinMax()

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

Definition at line 1121 of file WaveClip.cpp.

1123 {
1124  if (t0 > t1) {
1125  if (mayThrow)
1127  return {
1128  0.f, // harmless, but unused since Sequence::GetMinMax does not use these values
1129  0.f // harmless, but unused since Sequence::GetMinMax does not use these values
1130  };
1131  }
1132 
1133  if (t0 == t1)
1134  return{ 0.f, 0.f };
1135 
1136  sampleCount s0, s1;
1137 
1138  TimeToSamplesClip(t0, &s0);
1139  TimeToSamplesClip(t1, &s1);
1140 
1141  return mSequence->GetMinMax(s0, s1-s0, mayThrow);
1142 }

References mSequence, THROW_INCONSISTENCY_EXCEPTION, and TimeToSamplesClip().

Here is the call graph for this function:

◆ GetName()

const wxString & WaveClip::GetName ( ) const

Definition at line 1788 of file WaveClip.cpp.

1789 {
1790  return mName;
1791 }

References mName.

◆ GetNumSamples()

sampleCount WaveClip::GetNumSamples ( ) const

Definition at line 276 of file WaveClip.cpp.

277 {
278  return mSequence->GetNumSamples();
279 }

References mSequence.

Referenced by anonymous_namespace{WaveTrack.cpp}::AreAligned(), anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), anonymous_namespace{WaveformView.cpp}::DrawIndividualSamples(), and SharesBoundaryWithNextClip().

Here is the caller graph for this function:

◆ GetOffset()

double WaveClip::GetOffset ( ) const
inline

Definition at line 220 of file WaveClip.h.

220 { return mOffset; }

Referenced by Clear(), ClearAndAddCutLine(), WaveTrack::ClearAndPaste(), ClipParameters::ClipParameters(), anonymous_namespace{WaveformView.cpp}::DrawIndividualSamples(), ClipParameters::GetClipRect(), WaveTrack::Join(), WaveTrack::RightmostOrNewClip(), SharesBoundaryWithNextClip(), and WaveClip().

Here is the caller graph for this function:

◆ GetRate()

int WaveClip::GetRate ( ) const
inline

Definition at line 208 of file WaveClip.h.

208 { return mRate; }

Referenced by Clear(), ClearAndAddCutLine(), ClipParameters::ClipParameters(), anonymous_namespace{WaveformView.cpp}::DrawIndividualSamples(), ClipParameters::GetClipRect(), InsertSilence(), Paste(), SharesBoundaryWithNextClip(), and UpdateEnvelopeTrackLen().

Here is the caller graph for this function:

◆ GetRMS()

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

Definition at line 1144 of file WaveClip.cpp.

1145 {
1146  if (t0 > t1) {
1147  if (mayThrow)
1149  return 0.f;
1150  }
1151 
1152  if (t0 == t1)
1153  return 0.f;
1154 
1155  sampleCount s0, s1;
1156 
1157  TimeToSamplesClip(t0, &s0);
1158  TimeToSamplesClip(t1, &s1);
1159 
1160  return mSequence->GetRMS(s0, s1-s0, mayThrow);
1161 }

References mSequence, THROW_INCONSISTENCY_EXCEPTION, and TimeToSamplesClip().

Here is the call graph for this function:

◆ GetSamples()

bool WaveClip::GetSamples ( samplePtr  buffer,
sampleFormat  format,
sampleCount  start,
size_t  len,
bool  mayThrow = true 
) const

Definition at line 222 of file WaveClip.cpp.

224 {
225  return mSequence->Get(buffer, format, start, len, mayThrow);
226 }

References format, and mSequence.

Referenced by anonymous_namespace{WaveformView.cpp}::DrawIndividualSamples().

Here is the caller graph for this function:

◆ GetSequence() [1/2]

Sequence* WaveClip::GetSequence ( )
inline

Definition at line 251 of file WaveClip.h.

251 { return mSequence.get(); }

Referenced by WaveTrack::AddClip(), Clear(), ClearAndAddCutLine(), CloseLock(), WaveTrack::GetIdealBlockSize(), WaveTrack::GetSequenceAtTime(), AUPImportFileHandle::HandleSequence(), WaveTrack::HandleXMLChild(), and InsertSilence().

Here is the caller graph for this function:

◆ GetSequence() [2/2]

const Sequence* WaveClip::GetSequence ( ) const
inline

Definition at line 252 of file WaveClip.h.

252 { return mSequence.get(); }

◆ GetSequenceBlockArray() [1/2]

BlockArray * WaveClip::GetSequenceBlockArray ( )

Definition at line 239 of file WaveClip.cpp.

240 {
241  return &mSequence->GetBlockArray();
242 }

References mSequence.

◆ GetSequenceBlockArray() [2/2]

const BlockArray * WaveClip::GetSequenceBlockArray ( ) const

Definition at line 244 of file WaveClip.cpp.

245 {
246  return &mSequence->GetBlockArray();
247 }

References mSequence.

◆ GetSpectrogram()

bool WaveClip::GetSpectrogram ( WaveTrackCache cache,
const float *&  spectrogram,
const sampleCount *&  where,
size_t  numPixels,
double  t0,
double  pixelsPerSecond 
) const

Definition at line 1010 of file WaveClip.cpp.

1015 {
1016  const WaveTrack *const track = waveTrackCache.GetTrack().get();
1018 
1019  bool match =
1020  mSpecCache &&
1021  mSpecCache->len > 0 &&
1022  mSpecCache->Matches
1023  (mDirty, pixelsPerSecond, settings, mRate);
1024 
1025  if (match &&
1026  mSpecCache->start == t0 &&
1027  mSpecCache->len >= numPixels) {
1028  spectrogram = &mSpecCache->freq[0];
1029  where = &mSpecCache->where[0];
1030 
1031  return false; //hit cache completely
1032  }
1033 
1034  // Caching is not implemented for reassignment, unless for
1035  // a complete hit, because of the complications of time reassignment
1037  match = false;
1038 
1039  // Free the cache when it won't cause a major stutter.
1040  // If the window size changed, we know there is nothing to be copied
1041  // If we zoomed out, or resized, we can give up memory. But not too much -
1042  // up to 2x extra is needed at the end of the clip to prevent stutter.
1043  if (mSpecCache->freq.capacity() > 2.1 * mSpecCache->freq.size() ||
1044  mSpecCache->windowSize*mSpecCache->zeroPaddingFactor <
1045  settings.WindowSize()*settings.ZeroPaddingFactor())
1046  {
1047  match = false;
1048  mSpecCache = std::make_unique<SpecCache>();
1049  }
1050 
1051  const double tstep = 1.0 / pixelsPerSecond;
1052  const double samplesPerPixel = mRate * tstep;
1053 
1054  int oldX0 = 0;
1055  double correction = 0.0;
1056 
1057  int copyBegin = 0, copyEnd = 0;
1058  if (match) {
1059  findCorrection(mSpecCache->where, mSpecCache->len, numPixels,
1060  t0, mRate, samplesPerPixel,
1061  oldX0, correction);
1062  // Remember our first pixel maps to oldX0 in the old cache,
1063  // possibly out of bounds.
1064  // For what range of pixels can data be copied?
1065  copyBegin = std::min((int)numPixels, std::max(0, -oldX0));
1066  copyEnd = std::min((int)numPixels, std::max(0,
1067  (int)mSpecCache->len - oldX0
1068  ));
1069  }
1070 
1071  // Resize the cache, keep the contents unchanged.
1072  mSpecCache->Grow(numPixels, settings, pixelsPerSecond, t0);
1073  auto nBins = settings.NBins();
1074 
1075  // Optimization: if the old cache is good and overlaps
1076  // with the current one, re-use as much of the cache as
1077  // possible
1078  if (copyEnd > copyBegin)
1079  {
1080  // memmove is required since dst/src overlap
1081  memmove(&mSpecCache->freq[nBins * copyBegin],
1082  &mSpecCache->freq[nBins * (copyBegin + oldX0)],
1083  nBins * (copyEnd - copyBegin) * sizeof(float));
1084  }
1085 
1086  // Reassignment accumulates, so it needs a zeroed buffer
1088  {
1089  // The cache could theoretically copy from the middle, resulting
1090  // in two regions to update. This won't happen in zoom, since
1091  // old cache doesn't match. It won't happen in resize, since the
1092  // spectrum view is pinned to left side of window.
1093  wxASSERT(
1094  (copyBegin >= 0 && copyEnd == (int)numPixels) || // copied the end
1095  (copyBegin == 0 && copyEnd <= (int)numPixels) // copied the beginning
1096  );
1097 
1098  int zeroBegin = copyBegin > 0 ? 0 : copyEnd-copyBegin;
1099  int zeroEnd = copyBegin > 0 ? copyBegin : numPixels;
1100 
1101  memset(&mSpecCache->freq[nBins*zeroBegin], 0, nBins*(zeroEnd-zeroBegin)*sizeof(float));
1102  }
1103 
1104  // purposely offset the display 1/2 sample to the left (as compared
1105  // to waveform display) to properly center response of the FFT
1106  fillWhere(mSpecCache->where, numPixels, 0.5, correction,
1107  t0, mRate, samplesPerPixel);
1108 
1109  mSpecCache->Populate
1110  (settings, waveTrackCache, copyBegin, copyEnd, numPixels,
1111  mSequence->GetNumSamples(),
1112  mOffset, mRate, pixelsPerSecond);
1113 
1114  mSpecCache->dirty = mDirty;
1115  spectrogram = &mSpecCache->freq[0];
1116  where = &mSpecCache->where[0];
1117 
1118  return true;
1119 }

References SpectrogramSettings::algReassignment, anonymous_namespace{WaveClip.cpp}::fillWhere(), anonymous_namespace{WaveClip.cpp}::findCorrection(), WaveTrack::GetSpectrogramSettings(), WaveTrackCache::GetTrack(), mDirty, min(), mOffset, mRate, mSequence, mSpecCache, and settings().

Referenced by anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum().

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

◆ GetStartSample()

sampleCount WaveClip::GetStartSample ( ) const

Definition at line 266 of file WaveClip.cpp.

267 {
268  return sampleCount( floor(mOffset * mRate + 0.5) );
269 }

References mOffset, and mRate.

Referenced by BeforeClip(), WaveTrack::GetClipAtSample(), GetEndSample(), EffectReverse::ProcessOneWave(), and WithinClip().

Here is the caller graph for this function:

◆ GetStartTime()

double WaveClip::GetStartTime ( ) const

Definition at line 249 of file WaveClip.cpp.

250 {
251  // JS: mOffset is the minimum value and it is returned; no clipping to 0
252  return mOffset;
253 }

References mOffset.

Referenced by SetClipCommand::ApplyInner(), SetEnvelopeCommand::ApplyInner(), anonymous_namespace{WaveTrack.cpp}::AreAligned(), WaveTrack::CanInsertClip(), Clear(), ClearAndAddCutLine(), ClipParameters::ClipParameters(), anonymous_namespace{WaveTrackAffordanceControls.cpp}::NextClipLooped(), WaveTrack::Paste(), and Paste().

Here is the caller graph for this function:

◆ GetWaveDisplay()

bool WaveClip::GetWaveDisplay ( WaveDisplay display,
double  t0,
double  pixelsPerSecond 
) const

Getting high-level data for screen display and clipping calculations and Contrast

Definition at line 384 of file WaveClip.cpp.

386 {
387  const bool allocated = (display.where != 0);
388 
389  const size_t numPixels = (int)display.width;
390 
391  size_t p0 = 0; // least column requiring computation
392  size_t p1 = numPixels; // greatest column requiring computation, plus one
393 
394  float *min;
395  float *max;
396  float *rms;
397  int *bl;
398  std::vector<sampleCount> *pWhere;
399 
400  if (allocated) {
401  // assume ownWhere is filled.
402  min = &display.min[0];
403  max = &display.max[0];
404  rms = &display.rms[0];
405  bl = &display.bl[0];
406  pWhere = &display.ownWhere;
407  }
408  else {
409  const double tstep = 1.0 / pixelsPerSecond;
410  const double samplesPerPixel = mRate * tstep;
411 
412  // Make a tolerant comparison of the pps values in this wise:
413  // accumulated difference of times over the number of pixels is less than
414  // a sample period.
415  const bool ppsMatch = mWaveCache &&
416  (fabs(tstep - 1.0 / mWaveCache->pps) * numPixels < (1.0 / mRate));
417 
418  const bool match =
419  mWaveCache &&
420  ppsMatch &&
421  mWaveCache->len > 0 &&
422  mWaveCache->dirty == mDirty;
423 
424  if (match &&
425  mWaveCache->start == t0 &&
426  mWaveCache->len >= numPixels) {
427 
428  // Satisfy the request completely from the cache
429  display.min = &mWaveCache->min[0];
430  display.max = &mWaveCache->max[0];
431  display.rms = &mWaveCache->rms[0];
432  display.bl = &mWaveCache->bl[0];
433  display.where = &mWaveCache->where[0];
434  return true;
435  }
436 
437  std::unique_ptr<WaveCache> oldCache(std::move(mWaveCache));
438 
439  int oldX0 = 0;
440  double correction = 0.0;
441  size_t copyBegin = 0, copyEnd = 0;
442  if (match) {
443  findCorrection(oldCache->where, oldCache->len, numPixels,
444  t0, mRate, samplesPerPixel,
445  oldX0, correction);
446  // Remember our first pixel maps to oldX0 in the old cache,
447  // possibly out of bounds.
448  // For what range of pixels can data be copied?
449  copyBegin = std::min<size_t>(numPixels, std::max(0, -oldX0));
450  copyEnd = std::min<size_t>(numPixels, std::max(0,
451  (int)oldCache->len - oldX0
452  ));
453  }
454  if (!(copyEnd > copyBegin))
455  oldCache.reset(0);
456 
457  mWaveCache = std::make_unique<WaveCache>(numPixels, pixelsPerSecond, mRate, t0, mDirty);
458  min = &mWaveCache->min[0];
459  max = &mWaveCache->max[0];
460  rms = &mWaveCache->rms[0];
461  bl = &mWaveCache->bl[0];
462  pWhere = &mWaveCache->where;
463 
464  fillWhere(*pWhere, numPixels, 0.0, correction,
465  t0, mRate, samplesPerPixel);
466 
467  // The range of pixels we must fetch from the Sequence:
468  p0 = (copyBegin > 0) ? 0 : copyEnd;
469  p1 = (copyEnd >= numPixels) ? copyBegin : numPixels;
470 
471  // Optimization: if the old cache is good and overlaps
472  // with the current one, re-use as much of the cache as
473  // possible
474 
475  if (oldCache) {
476 
477  // Copy what we can from the old cache.
478  const int length = copyEnd - copyBegin;
479  const size_t sizeFloats = length * sizeof(float);
480  const int srcIdx = (int)copyBegin + oldX0;
481  memcpy(&min[copyBegin], &oldCache->min[srcIdx], sizeFloats);
482  memcpy(&max[copyBegin], &oldCache->max[srcIdx], sizeFloats);
483  memcpy(&rms[copyBegin], &oldCache->rms[srcIdx], sizeFloats);
484  memcpy(&bl[copyBegin], &oldCache->bl[srcIdx], length * sizeof(int));
485  }
486  }
487 
488  if (p1 > p0) {
489  // Cache was not used or did not satisfy the whole request
490  std::vector<sampleCount> &where = *pWhere;
491 
492  /* handle values in the append buffer */
493 
494  auto numSamples = mSequence->GetNumSamples();
495  auto a = p0;
496 
497  // Not all of the required columns might be in the sequence.
498  // Some might be in the append buffer.
499  for (; a < p1; ++a) {
500  if (where[a + 1] > numSamples)
501  break;
502  }
503 
504  // Handle the columns that land in the append buffer.
505  //compute the values that are outside the overlap from scratch.
506  if (a < p1) {
507  sampleFormat seqFormat = mSequence->GetSampleFormat();
508  bool didUpdate = false;
509  for(auto i = a; i < p1; i++) {
510  auto left = std::max(sampleCount{ 0 },
511  where[i] - numSamples);
512  auto right = std::min(sampleCount{ mAppendBufferLen },
513  where[i + 1] - numSamples);
514 
515  //wxCriticalSectionLocker locker(mAppendCriticalSection);
516 
517  if (right > left) {
518  Floats b;
519  float *pb{};
520  // left is nonnegative and at most mAppendBufferLen:
521  auto sLeft = left.as_size_t();
522  // The difference is at most mAppendBufferLen:
523  size_t len = ( right - left ).as_size_t();
524 
525  if (seqFormat == floatSample)
526  pb = &((float *)mAppendBuffer.ptr())[sLeft];
527  else {
528  b.reinit(len);
529  pb = b.get();
531  mAppendBuffer.ptr() + sLeft * SAMPLE_SIZE(seqFormat),
532  seqFormat, pb, len);
533  }
534 
535  float theMax, theMin, sumsq;
536  {
537  const float val = pb[0];
538  theMax = theMin = val;
539  sumsq = val * val;
540  }
541  for(decltype(len) j = 1; j < len; j++) {
542  const float val = pb[j];
543  theMax = std::max(theMax, val);
544  theMin = std::min(theMin, val);
545  sumsq += val * val;
546  }
547 
548  min[i] = theMin;
549  max[i] = theMax;
550  rms[i] = (float)sqrt(sumsq / len);
551  bl[i] = 1; //for now just fake it.
552 
553  didUpdate=true;
554  }
555  }
556 
557  // Shrink the right end of the range to fetch from Sequence
558  if(didUpdate)
559  p1 = a;
560  }
561 
562  // Done with append buffer, now fetch the rest of the cache miss
563  // from the sequence
564  if (p1 > p0) {
565  if (!mSequence->GetWaveDisplay(&min[p0],
566  &max[p0],
567  &rms[p0],
568  &bl[p0],
569  p1-p0,
570  &where[p0]))
571  {
572  return false;
573  }
574  }
575  }
576 
577  if (!allocated) {
578  // Now report the results
579  display.min = min;
580  display.max = max;
581  display.rms = rms;
582  display.bl = bl;
583  display.where = &(*pWhere)[0];
584  }
585 
586  return true;
587 }

References WaveCache::bl, WaveDisplay::bl, anonymous_namespace{WaveClip.cpp}::fillWhere(), anonymous_namespace{WaveClip.cpp}::findCorrection(), floatSample, WaveCache::len, mAppendBuffer, mAppendBufferLen, WaveCache::max, WaveDisplay::max, mDirty, min(), WaveCache::min, WaveDisplay::min, mRate, mSequence, mWaveCache, WaveDisplay::ownWhere, SampleBuffer::ptr(), ArrayOf< X >::reinit(), WaveCache::rms, WaveDisplay::rms, SAMPLE_SIZE, SamplesToFloats(), WaveCache::where, WaveDisplay::where, and WaveDisplay::width.

Referenced by anonymous_namespace{WaveformView.cpp}::DrawClipWaveform().

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

◆ HandleXMLChild()

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

Implements XMLTagHandler.

Definition at line 1341 of file WaveClip.cpp.

1342 {
1343  if (!wxStrcmp(tag, wxT("sequence")))
1344  return mSequence.get();
1345  else if (!wxStrcmp(tag, wxT("envelope")))
1346  return mEnvelope.get();
1347  else if (!wxStrcmp(tag, wxT("waveclip")))
1348  {
1349  // Nested wave clips are cut lines
1350  mCutLines.push_back(
1351  std::make_unique<WaveClip>(mSequence->GetFactory(),
1352  mSequence->GetSampleFormat(), mRate, 0 /*colourindex*/));
1353  return mCutLines.back().get();
1354  }
1355  else
1356  return NULL;
1357 }

References mCutLines, mEnvelope, mRate, and mSequence.

Referenced by AUPImportFileHandle::HandleWaveClip().

Here is the caller graph for this function:

◆ HandleXMLEndTag()

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

Definition at line 1335 of file WaveClip.cpp.

1336 {
1337  if (!wxStrcmp(tag, wxT("waveclip")))
1339 }

References UpdateEnvelopeTrackLen().

Referenced by WaveTrack::HandleXMLEndTag().

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

◆ HandleXMLTag()

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

Implements XMLTagHandler.

Definition at line 1294 of file WaveClip.cpp.

1295 {
1296  if (!wxStrcmp(tag, wxT("waveclip")))
1297  {
1298  double dblValue;
1299  long longValue;
1300  while (*attrs)
1301  {
1302  const wxChar *attr = *attrs++;
1303  const wxChar *value = *attrs++;
1304 
1305  if (!value)
1306  break;
1307 
1308  const wxString strValue = value;
1309  if (!wxStrcmp(attr, wxT("offset")))
1310  {
1311  if (!XMLValueChecker::IsGoodString(strValue) ||
1312  !Internat::CompatibleToDouble(strValue, &dblValue))
1313  return false;
1314  SetOffset(dblValue);
1315  }
1316  else if (!wxStrcmp(attr, wxT("name")))
1317  {
1318  if(XMLValueChecker::IsGoodLongString(strValue))
1319  SetName(strValue);
1320  }
1321  else if (!wxStrcmp(attr, wxT("colorindex")))
1322  {
1323  if (!XMLValueChecker::IsGoodString(strValue) ||
1324  !strValue.ToLong( &longValue))
1325  return false;
1326  SetColourIndex(longValue);
1327  }
1328  }
1329  return true;
1330  }
1331 
1332  return false;
1333 }

References Internat::CompatibleToDouble(), XMLValueChecker::IsGoodLongString(), XMLValueChecker::IsGoodString(), SetColourIndex(), SetName(), and SetOffset().

Here is the call graph for this function:

◆ InsertSilence()

void WaveClip::InsertSilence ( double  t,
double  len,
double *  pEnvelopeValue = nullptr 
)

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

Exception safety guarantee:
Strong

Definition at line 1434 of file WaveClip.cpp.

1435 {
1436  sampleCount s0;
1437  TimeToSamplesClip(t, &s0);
1438  auto slen = (sampleCount)floor(len * mRate + 0.5);
1439 
1440  // use Strong-guarantee
1441  GetSequence()->InsertSilence(s0, slen);
1442 
1443  // use No-fail-guarantee
1444  OffsetCutLines(t, len);
1445 
1446  const auto sampleTime = 1.0 / GetRate();
1447  auto pEnvelope = GetEnvelope();
1448  if ( pEnvelopeValue ) {
1449 
1450  // Preserve limit value at the end
1451  auto oldLen = pEnvelope->GetTrackLen();
1452  auto newLen = oldLen + len;
1453  pEnvelope->Cap( sampleTime );
1454 
1455  // Ramp across the silence to the given value
1456  pEnvelope->SetTrackLen( newLen, sampleTime );
1457  pEnvelope->InsertOrReplace
1458  ( pEnvelope->GetOffset() + newLen, *pEnvelopeValue );
1459  }
1460  else
1461  pEnvelope->InsertSpace( t, len );
1462 
1463  MarkChanged();
1464 }

References GetEnvelope(), GetRate(), GetSequence(), Sequence::InsertSilence(), MarkChanged(), mRate, OffsetCutLines(), and TimeToSamplesClip().

Referenced by AUPImportFileHandle::AddSilence(), and AppendSilence().

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

◆ IsClipStartAfterClip()

bool WaveClip::IsClipStartAfterClip ( double  t) const

Definition at line 307 of file WaveClip.cpp.

308 {
309  auto ts = (sampleCount)floor(t * mRate + 0.5);
310  return ts >= GetEndSample() + mAppendBufferLen;
311 }

References GetEndSample(), mAppendBufferLen, and mRate.

Here is the call graph for this function:

◆ MarkChanged()

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.

Exception safety guarantee:
No-fail

Definition at line 258 of file WaveClip.h.

259  { mDirty++; }

Referenced by Append(), Clear(), ClearAndAddCutLine(), ConvertToSampleFormat(), Flush(), InsertSilence(), Paste(), SetRate(), and SetSamples().

Here is the caller graph for this function:

◆ NumCutLines()

size_t WaveClip::NumCutLines ( ) const
inline

Definition at line 315 of file WaveClip.h.

315 { return mCutLines.size(); }

Referenced by WaveTrack::UpdateLocationsCache().

Here is the caller graph for this function:

◆ Offset()

void WaveClip::Offset ( double  delta)
inline
Exception safety guarantee:
No-fail

Definition at line 222 of file WaveClip.h.

223  { SetOffset(GetOffset() + delta); }

Referenced by Clear(), ClearAndAddCutLine(), WaveTrack::Copy(), and Paste().

Here is the caller graph for this function:

◆ OffsetCutLines()

void WaveClip::OffsetCutLines ( double  t0,
double  len 
)

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

Exception safety guarantee:
No-fail

Definition at line 1657 of file WaveClip.cpp.

1658 {
1659  for (const auto &cutLine : mCutLines)
1660  {
1661  if (mOffset + cutLine->GetOffset() >= t0)
1662  cutLine->Offset(len);
1663  }
1664 }

References mCutLines, and mOffset.

Referenced by InsertSilence(), and Paste().

Here is the caller graph for this function:

◆ operator=()

WaveClip& WaveClip::operator= ( const WaveClip )
private

◆ Paste()

void WaveClip::Paste ( double  t0,
const WaveClip other 
)

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

Exception safety guarantee:
Strong

Definition at line 1377 of file WaveClip.cpp.

1378 {
1379  const bool clipNeedsResampling = other->mRate != mRate;
1380  const bool clipNeedsNewFormat =
1381  other->mSequence->GetSampleFormat() != mSequence->GetSampleFormat();
1382  std::unique_ptr<WaveClip> newClip;
1383  const WaveClip* pastedClip;
1384 
1385  if (clipNeedsResampling || clipNeedsNewFormat)
1386  {
1387  newClip =
1388  std::make_unique<WaveClip>(*other, mSequence->GetFactory(), true);
1389  if (clipNeedsResampling)
1390  // The other clip's rate is different from ours, so resample
1391  newClip->Resample(mRate);
1392  if (clipNeedsNewFormat)
1393  // Force sample formats to match.
1394  newClip->ConvertToSampleFormat(mSequence->GetSampleFormat());
1395  pastedClip = newClip.get();
1396  }
1397  else
1398  {
1399  // No resampling or format change needed, just use original clip without making a copy
1400  pastedClip = other;
1401  }
1402 
1403  // Paste cut lines contained in pasted clip
1404  WaveClipHolders newCutlines;
1405  for (const auto &cutline: pastedClip->mCutLines)
1406  {
1407  newCutlines.push_back(
1408  std::make_unique<WaveClip>
1409  ( *cutline, mSequence->GetFactory(),
1410  // Recursively copy cutlines of cutlines. They don't need
1411  // their offsets adjusted.
1412  true));
1413  newCutlines.back()->Offset(t0 - mOffset);
1414  }
1415 
1416  sampleCount s0;
1417  TimeToSamplesClip(t0, &s0);
1418 
1419  // Assume Strong-guarantee from Sequence::Paste
1420  mSequence->Paste(s0, pastedClip->mSequence.get());
1421 
1422  // Assume No-fail-guarantee in the remaining
1423  MarkChanged();
1424  auto sampleTime = 1.0 / GetRate();
1425  mEnvelope->PasteEnvelope
1426  (s0.as_double()/mRate + mOffset, pastedClip->mEnvelope.get(), sampleTime);
1427  OffsetCutLines(t0, pastedClip->GetEndTime() - pastedClip->GetStartTime());
1428 
1429  for (auto &holder : newCutlines)
1430  mCutLines.push_back(std::move(holder));
1431 }

References sampleCount::as_double(), ConvertToSampleFormat(), GetEndTime(), GetRate(), GetStartTime(), MarkChanged(), mCutLines, mEnvelope, mOffset, mRate, mSequence, Offset(), OffsetCutLines(), Resample(), and TimeToSamplesClip().

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

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

◆ RemoveCutLine()

bool WaveClip::RemoveCutLine ( double  cutLinePosition)

Remove cut line, without expanding the audio in it.

Definition at line 1641 of file WaveClip.cpp.

1642 {
1643  for (auto it = mCutLines.begin(); it != mCutLines.end(); ++it)
1644  {
1645  const auto &cutline = *it;
1646  if (fabs(mOffset + cutline->GetOffset() - cutLinePosition) < 0.0001)
1647  {
1648  mCutLines.erase(it); // deletes cutline!
1649  return true;
1650  }
1651  }
1652 
1653  return false;
1654 }

References mCutLines, and mOffset.

◆ Resample()

void WaveClip::Resample ( int  rate,
ProgressDialog progress = NULL 
)
Exception safety guarantee:
Strong

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)

Definition at line 1682 of file WaveClip.cpp.

1683 {
1684  // Note: it is not necessary to do this recursively to cutlines.
1685  // They get resampled as needed when they are expanded.
1686 
1687  if (rate == mRate)
1688  return; // Nothing to do
1689 
1690  double factor = (double)rate / (double)mRate;
1691  ::Resample resample(true, factor, factor); // constant rate resampling
1692 
1693  const size_t bufsize = 65536;
1694  Floats inBuffer{ bufsize };
1695  Floats outBuffer{ bufsize };
1696  sampleCount pos = 0;
1697  bool error = false;
1698  int outGenerated = 0;
1699  auto numSamples = mSequence->GetNumSamples();
1700 
1701  auto newSequence =
1702  std::make_unique<Sequence>(mSequence->GetFactory(), mSequence->GetSampleFormat());
1703 
1709  while (pos < numSamples || outGenerated > 0)
1710  {
1711  const auto inLen = limitSampleBufferSize( bufsize, numSamples - pos );
1712 
1713  bool isLast = ((pos + inLen) == numSamples);
1714 
1715  if (!mSequence->Get((samplePtr)inBuffer.get(), floatSample, pos, inLen, true))
1716  {
1717  error = true;
1718  break;
1719  }
1720 
1721  const auto results = resample.Process(factor, inBuffer.get(), inLen, isLast,
1722  outBuffer.get(), bufsize);
1723  outGenerated = results.second;
1724 
1725  pos += results.first;
1726 
1727  if (outGenerated < 0)
1728  {
1729  error = true;
1730  break;
1731  }
1732 
1733  newSequence->Append((samplePtr)outBuffer.get(), floatSample,
1734  outGenerated);
1735 
1736  if (progress)
1737  {
1738  auto updateResult = progress->Update(
1739  pos.as_long_long(),
1740  numSamples.as_long_long()
1741  );
1742  error = (updateResult != ProgressResult::Success);
1743  if (error)
1744  throw UserException{};
1745  }
1746  }
1747 
1748  if (error)
1751  XO("Resampling failed."),
1752  XO("Warning"),
1753  "Error:_Resampling"
1754  };
1755  else
1756  {
1757  // Use No-fail-guarantee in these steps
1758 
1759  // Invalidate wave display cache
1760  mWaveCache = std::make_unique<WaveCache>();
1761  // Invalidate the spectrum display cache
1762  mSpecCache = std::make_unique<SpecCache>();
1763 
1764  mSequence = std::move(newSequence);
1765  mRate = rate;
1766  }
1767 }

References floatSample, Internal, limitSampleBufferSize(), mRate, mSequence, mSpecCache, mWaveCache, Resample::Process(), BasicUI::Success, ProgressDialog::Update(), and XO.

Referenced by Paste().

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

◆ SetColourIndex()

void WaveClip::SetColourIndex ( int  index)
inline

Definition at line 217 of file WaveClip.h.

217 { mColourIndex = index;};

Referenced by SetClipCommand::ApplyInner(), and HandleXMLTag().

Here is the caller graph for this function:

◆ SetIsPlaceholder()

void WaveClip::SetIsPlaceholder ( bool  val)
inline

Definition at line 352 of file WaveClip.h.

352 { mIsPlaceholder = val; }

◆ SetName()

void WaveClip::SetName ( const wxString &  name)

Definition at line 1783 of file WaveClip.cpp.

1784 {
1785  mName = name;
1786 }

References mName, and name.

Referenced by SetClipCommand::ApplyInner(), and HandleXMLTag().

Here is the caller graph for this function:

◆ SetOffset()

void WaveClip::SetOffset ( double  offset)
Exception safety guarantee:
No-fail

Definition at line 216 of file WaveClip.cpp.

217 {
218  mOffset = offset;
219  mEnvelope->SetOffset(mOffset);
220 }

References mEnvelope, and mOffset.

Referenced by SetClipCommand::ApplyInner(), WaveTrack::ClearAndPaste(), WaveTrack::HandleXMLChild(), and HandleXMLTag().

Here is the caller graph for this function:

◆ SetRate()

void WaveClip::SetRate ( int  rate)

Definition at line 1673 of file WaveClip.cpp.

1674 {
1675  mRate = rate;
1676  auto newLength = mSequence->GetNumSamples().as_double() / mRate;
1677  mEnvelope->RescaleTimes( newLength );
1678  MarkChanged();
1679 }

References MarkChanged(), mEnvelope, mRate, and mSequence.

Here is the call graph for this function:

◆ SetSamples()

void WaveClip::SetSamples ( constSamplePtr  buffer,
sampleFormat  format,
sampleCount  start,
size_t  len 
)
Exception safety guarantee:
Strong

Definition at line 229 of file WaveClip.cpp.

231 {
232  // use Strong-guarantee
233  mSequence->SetSamples(buffer, format, start, len);
234 
235  // use No-fail-guarantee
236  MarkChanged();
237 }

References format, MarkChanged(), and mSequence.

Here is the call graph for this function:

◆ SharesBoundaryWithNextClip()

bool WaveClip::SharesBoundaryWithNextClip ( const WaveClip next) const

Definition at line 1773 of file WaveClip.cpp.

1774 {
1775  double endThis = GetRate() * GetOffset() + GetNumSamples().as_double();
1776  double startNext = next->GetRate() * next->GetOffset();
1777 
1778  // given that a double has about 15 significant digits, using a criterion
1779  // of half a sample should be safe in all normal usage.
1780  return fabs(startNext - endThis) < 0.5;
1781 }

References sampleCount::as_double(), GetNumSamples(), GetOffset(), and GetRate().

Here is the call graph for this function:

◆ TimeToSamplesClip()

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

Definition at line 1182 of file WaveClip.cpp.

1183 {
1184  if (t0 < mOffset)
1185  *s0 = 0;
1186  else if (t0 > mOffset + mSequence->GetNumSamples().as_double()/mRate)
1187  *s0 = mSequence->GetNumSamples();
1188  else
1189  *s0 = sampleCount( floor(((t0 - mOffset) * mRate) + 0.5) );
1190 }

References mOffset, mRate, and mSequence.

Referenced by Clear(), ClearAndAddCutLine(), GetMinMax(), GetRMS(), InsertSilence(), Paste(), and WaveClip().

Here is the caller graph for this function:

◆ UpdateEnvelopeTrackLen()

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.

Exception safety guarantee:
No-fail

Definition at line 1175 of file WaveClip.cpp.

1176 {
1177  auto len = (mSequence->GetNumSamples().as_double()) / mRate;
1178  if (len != mEnvelope->GetTrackLen())
1179  mEnvelope->SetTrackLen(len, 1.0 / GetRate());
1180 }

References GetRate(), mEnvelope, mRate, and mSequence.

Referenced by Append(), Flush(), and HandleXMLEndTag().

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

◆ WithinClip()

bool WaveClip::WithinClip ( double  t) const

Definition at line 286 of file WaveClip.cpp.

287 {
288  auto ts = (sampleCount)floor(t * mRate + 0.5);
289  return ts > GetStartSample() && ts < GetEndSample() + mAppendBufferLen;
290 }

References GetEndSample(), GetStartSample(), mAppendBufferLen, and mRate.

Here is the call graph for this function:

◆ WriteXML()

void WaveClip::WriteXML ( XMLWriter xmlFile) const

Definition at line 1359 of file WaveClip.cpp.

1361 {
1362  xmlFile.StartTag(wxT("waveclip"));
1363  xmlFile.WriteAttr(wxT("offset"), mOffset, 8);
1364  xmlFile.WriteAttr(wxT("name"), mName);
1365  xmlFile.WriteAttr(wxT("colorindex"), mColourIndex );
1366 
1367  mSequence->WriteXML(xmlFile);
1368  mEnvelope->WriteXML(xmlFile);
1369 
1370  for (const auto &clip: mCutLines)
1371  clip->WriteXML(xmlFile);
1372 
1373  xmlFile.EndTag(wxT("waveclip"));
1374 }

Member Data Documentation

◆ mAppendBuffer

SampleBuffer WaveClip::mAppendBuffer {}
protected

Definition at line 375 of file WaveClip.h.

Referenced by Append(), Flush(), and GetWaveDisplay().

◆ mAppendBufferLen

size_t WaveClip::mAppendBufferLen { 0 }
protected

◆ mColourIndex

int WaveClip::mColourIndex
protected

Definition at line 368 of file WaveClip.h.

Referenced by WaveClip().

◆ mCutLines

WaveClipHolders WaveClip::mCutLines {}
protected

◆ mDirty

int WaveClip::mDirty { 0 }
protected

Definition at line 367 of file WaveClip.h.

Referenced by GetSpectrogram(), and GetWaveDisplay().

◆ mEnvelope

std::unique_ptr<Envelope> WaveClip::mEnvelope
protected

Definition at line 371 of file WaveClip.h.

Referenced by HandleXMLChild(), Paste(), SetOffset(), SetRate(), UpdateEnvelopeTrackLen(), and WaveClip().

◆ mIsPlaceholder

bool WaveClip::mIsPlaceholder { false }
protected

Definition at line 383 of file WaveClip.h.

Referenced by WaveClip().

◆ mName

wxString WaveClip::mName
private

Definition at line 386 of file WaveClip.h.

Referenced by GetName(), SetName(), and WaveClip().

◆ mOffset

double WaveClip::mOffset { 0 }
protected

◆ mRate

int WaveClip::mRate
protected

◆ mSequence

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

◆ mSpecCache

std::unique_ptr<SpecCache> WaveClip::mSpecCache
mutableprotected

Definition at line 374 of file WaveClip.h.

Referenced by GetSpectrogram(), Resample(), and WaveClip().

◆ mSpecPxCache

std::unique_ptr<SpecPxCache> WaveClip::mSpecPxCache
mutable

◆ mWaveCache

std::unique_ptr<WaveCache> WaveClip::mWaveCache
mutableprotected

Definition at line 373 of file WaveClip.h.

Referenced by ClearWaveCache(), GetWaveDisplay(), Resample(), and WaveClip().


The documentation for this class was generated from the following files:
XMLWriter::EndTag
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:99
SampleBuffer::Allocate
SampleBuffer & Allocate(size_t count, sampleFormat format)
Definition: SampleFormat.h:84
SpectrogramSettings
Spectrogram settings, either for one track or as defaults.
Definition: SpectrogramSettings.h:27
Sequence::CloseLock
bool CloseLock()
Definition: Sequence.cpp:86
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
WaveClip::mEnvelope
std::unique_ptr< Envelope > mEnvelope
Definition: WaveClip.h:371
BasicUI::ProgressResult::Success
@ Success
Sequence::Delete
void Delete(sampleCount start, sampleCount len)
Definition: Sequence.cpp:1633
WaveClip::UpdateEnvelopeTrackLen
void UpdateEnvelopeTrackLen()
Definition: WaveClip.cpp:1175
UserException
Can be thrown when user cancels operations, as with a progress dialog. Delayed handler does nothing.
Definition: UserException.h:17
WaveClip::GetEnvelope
Envelope * GetEnvelope()
Definition: WaveClip.h:243
WaveDisplay::ownWhere
std::vector< sampleCount > ownWhere
Definition: WaveClip.h:135
WaveClip::GetNumSamples
sampleCount GetNumSamples() const
Definition: WaveClip.cpp:276
WaveClip::GetOffset
double GetOffset() const
Definition: WaveClip.h:220
WaveClip::Paste
void Paste(double t0, const WaveClip *other)
Paste data from other clip, resampling it if not equal rate.
Definition: WaveClip.cpp:1377
WaveClip::GetRate
int GetRate() const
Definition: WaveClip.h:208
ArrayOf::reinit
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:57
WaveClip::SetOffset
void SetOffset(double offset)
Definition: WaveClip.cpp:216
anonymous_namespace{WaveClip.cpp}::findCorrection
void findCorrection(const std::vector< sampleCount > &oldWhere, size_t oldLen, size_t newLen, double t0, double rate, double samplesPerPixel, int &oldX0, double &correction)
Definition: WaveClip.cpp:323
WaveClip::GetEndTime
double GetEndTime() const
Definition: WaveClip.cpp:255
SAMPLE_SIZE
#define SAMPLE_SIZE(SampleFormat)
Definition: SampleFormat.h:44
XO
#define XO(s)
Definition: Internat.h:31
SamplesToFloats
void SamplesToFloats(constSamplePtr src, sampleFormat srcFormat, float *dst, size_t len, size_t srcStride, size_t dstStride)
Copy samples from any format into the widest format, which is 32 bit float, with no dithering.
Definition: SampleFormat.cpp:102
WaveClip::mWaveCache
std::unique_ptr< WaveCache > mWaveCache
Definition: WaveClip.h:373
WaveTrack::GetSpectrogramSettings
const SpectrogramSettings & GetSpectrogramSettings() const
Definition: WaveTrack.cpp:762
WaveClipHolders
std::vector< WaveClipHolder > WaveClipHolders
Definition: WaveClip.h:122
XMLValueChecker::IsGoodString
static bool IsGoodString(const wxString &str)
Definition: XMLTagHandler.cpp:38
WaveClip::GetStartSample
sampleCount GetStartSample() const
Definition: WaveClip.cpp:266
WaveClip::GetStartTime
double GetStartTime() const
Definition: WaveClip.cpp:249
WaveClip::GetSequence
Sequence * GetSequence()
Definition: WaveClip.h:251
floatSample
@ floatSample
Definition: SampleFormat.h:34
WaveClip::mColourIndex
int mColourIndex
Definition: WaveClip.h:368
WaveClip
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:173
factory
static RegisteredToolbarFactory factory
Definition: ControlToolBar.cpp:806
sampleCount::as_double
double as_double() const
Definition: SampleCount.h:45
WaveDisplay::max
float * max
Definition: WaveClip.h:132
CopySamples
void CopySamples(constSamplePtr src, sampleFormat srcFormat, samplePtr dst, sampleFormat dstFormat, size_t len, DitherType ditherType, unsigned int srcStride, unsigned int dstStride)
Copy samples from any format to any other format; apply dithering only if narrowing the format.
Definition: SampleFormat.cpp:111
WaveClip::TimeToSamplesClip
void TimeToSamplesClip(double t0, sampleCount *s0) const
Definition: WaveClip.cpp:1182
WaveClip::Offset
void Offset(double delta)
Definition: WaveClip.h:222
name
const TranslatableString name
Definition: Distortion.cpp:98
WaveClip::mName
wxString mName
Definition: WaveClip.h:386
WaveDisplay::width
int width
Definition: WaveClip.h:130
format
int format
Definition: ExportPCM.cpp:56
ProgressDialog::Update
ProgressResult Update(int value, const TranslatableString &message={})
Definition: ProgressDialog.cpp:1327
WaveClip::SetName
void SetName(const wxString &name)
Definition: WaveClip.cpp:1783
WaveClip::mRate
int mRate
Definition: WaveClip.h:366
THROW_INCONSISTENCY_EXCEPTION
#define THROW_INCONSISTENCY_EXCEPTION
Throw InconsistencyException, using C++ preprocessor to identify the source code location.
Definition: InconsistencyException.h:79
WaveClip::SetColourIndex
void SetColourIndex(int index)
Definition: WaveClip.h:217
Resample
Interface to libsoxr.
Definition: Resample.h:27
WaveClipHolder
std::shared_ptr< WaveClip > WaveClipHolder
Definition: WaveClip.h:121
WaveClip::mDirty
int mDirty
Definition: WaveClip.h:367
sampleFormat
sampleFormat
Definition: SampleFormat.h:29
samplePtr
char * samplePtr
Definition: SampleFormat.h:49
WaveClip::GetIsPlaceholder
bool GetIsPlaceholder() const
Definition: WaveClip.h:351
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
Sequence::InsertSilence
void InsertSilence(sampleCount s0, sampleCount len)
Definition: Sequence.cpp:682
WaveClip::OffsetCutLines
void OffsetCutLines(double t0, double len)
Offset cutlines right to time 't0' by time amount 'len'.
Definition: WaveClip.cpp:1657
WaveClip::mAppendBuffer
SampleBuffer mAppendBuffer
Definition: WaveClip.h:375
XMLValueChecker::IsGoodLongString
static bool IsGoodLongString(const wxString &str)
Definition: XMLTagHandler.cpp:51
WaveClip::mIsPlaceholder
bool mIsPlaceholder
Definition: WaveClip.h:383
WaveClip::ConvertToSampleFormat
void ConvertToSampleFormat(sampleFormat format, const std::function< void(size_t)> &progressReport={})
Definition: WaveClip.cpp:1163
sampleCount
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
WaveDisplay::rms
float * rms
Definition: WaveClip.h:132
WaveClipConstHolders
std::vector< std::shared_ptr< const WaveClip > > WaveClipConstHolders
Definition: WaveClip.h:123
SpectrogramSettings::algReassignment
@ algReassignment
Definition: SpectrogramSettings.h:158
XMLWriter::WriteAttr
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:34
ExceptionType::Internal
@ Internal
Indicates internal failure from Audacity.
WaveClip::GetEndSample
sampleCount GetEndSample() const
Definition: WaveClip.cpp:271
WaveClip::mSpecPxCache
std::unique_ptr< SpecPxCache > mSpecPxCache
Definition: WaveClip.h:362
gHighQualityDither
DitherType gHighQualityDither
Definition: SampleFormat.cpp:50
WaveClip::mCutLines
WaveClipHolders mCutLines
Definition: WaveClip.h:380
WaveDisplay::min
float * min
Definition: WaveClip.h:132
WaveClip::mSpecCache
std::unique_ptr< SpecCache > mSpecCache
Definition: WaveClip.h:374
WaveClip::InsertSilence
void InsertSilence(double t, double len, double *pEnvelopeValue=nullptr)
Definition: WaveClip.cpp:1434
WaveClip::mOffset
double mOffset
Definition: WaveClip.h:365
WaveClip::mSequence
std::unique_ptr< Sequence > mSequence
Definition: WaveClip.h:370
WaveClip::mAppendBufferLen
size_t mAppendBufferLen
Definition: WaveClip.h:376
settings
static Settings & settings()
Definition: TrackInfo.cpp:86
WaveClip::MarkChanged
void MarkChanged()
Definition: WaveClip.h:258
WaveClip::Resample
void Resample(int rate, ProgressDialog *progress=NULL)
Definition: WaveClip.cpp:1682
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:23
SimpleMessageBoxException
A MessageBoxException that shows a given, unvarying string.
Definition: AudacityException.h:95
anonymous_namespace{WaveClip.cpp}::fillWhere
void fillWhere(std::vector< sampleCount > &where, size_t len, double bias, double correction, double t0, double rate, double samplesPerPixel)
Definition: WaveClip.cpp:367
ArrayOf< float >
XMLWriter::StartTag
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:76
WaveDisplay::where
sampleCount * where
Definition: WaveClip.h:131
WaveDisplay::bl
int * bl
Definition: WaveClip.h:133
Internat::CompatibleToDouble
static bool CompatibleToDouble(const wxString &stringToConvert, double *result)
Convert a string to a number.
Definition: Internat.cpp:134
SampleBuffer::ptr
samplePtr ptr() const
Definition: SampleFormat.h:98
Envelope::CollapseRegion
void CollapseRegion(double t0, double t1, double sampleDur)
Definition: Envelope.cpp:376