Audacity  3.0.3
Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions | 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
 
- 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
 

Detailed Description

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

Definition at line 171 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  if ( copyCutlines )
155  for (const auto &clip: orig.mCutLines)
156  mCutLines.push_back
157  ( std::make_unique<WaveClip>( *clip, factory, true ) );
158 
160 }

References factory, GetIsPlaceholder(), mColourIndex, mCutLines, mEnvelope, mIsPlaceholder, 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 162 of file WaveClip.cpp.

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

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 209 of file WaveClip.cpp.

210 {
211 }

Member Function Documentation

◆ AfterClip()

bool WaveClip::AfterClip ( double  t) const

Definition at line 296 of file WaveClip.cpp.

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

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 1206 of file WaveClip.cpp.

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

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 1191 of file WaveClip.cpp.

1193 {
1194  return mSequence->AppendNewBlock( buffer, format, len );
1195 }

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 1198 of file WaveClip.cpp.

1199 {
1200  mSequence->AppendSharedBlock( pBlock );
1201 }

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 1459 of file WaveClip.cpp.

1460 {
1461  auto t = GetEndTime();
1462  InsertSilence( t, len, &envelopeValue );
1463 }

References GetEndTime(), and InsertSilence().

Referenced by WaveTrack::Join().

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

◆ BeforeClip()

bool WaveClip::BeforeClip ( double  t) const

Definition at line 290 of file WaveClip.cpp.

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

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 1466 of file WaveClip.cpp.

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

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

Referenced by WaveTrack::HandleClear().

Here is the call graph for this function:
Here is the caller 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 1529 of file WaveClip.cpp.

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

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 313 of file WaveClip.cpp.

314 {
315  mWaveCache = std::make_unique<WaveCache>();
316 }

References mWaveCache.

◆ CloseLock()

void WaveClip::CloseLock ( )

Definition at line 1658 of file WaveClip.cpp.

1659 {
1660  GetSequence()->CloseLock();
1661  for (const auto &cutline: mCutLines)
1662  cutline->CloseLock();
1663 }

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 1161 of file WaveClip.cpp.

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

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 1601 of file WaveClip.cpp.

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

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 1581 of file WaveClip.cpp.

1584 {
1585  for (const auto &cutline: mCutLines)
1586  {
1587  if (fabs(mOffset + cutline->GetOffset() - cutLinePosition) < 0.0001)
1588  {
1589  if (cutlineStart)
1590  *cutlineStart = mOffset+cutline->GetStartTime();
1591  if (cutlineEnd)
1592  *cutlineEnd = mOffset+cutline->GetEndTime();
1593  return true;
1594  }
1595  }
1596 
1597  return false;
1598 }

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 1267 of file WaveClip.cpp.

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

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 217 of file WaveClip.h.

217 { 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 311 of file WaveClip.h.

311 { return mCutLines; }

◆ GetCutLines() [2/2]

const WaveClipConstHolders& WaveClip::GetCutLines ( ) const
inline

Definition at line 312 of file WaveClip.h.

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

◆ GetEndSample()

sampleCount WaveClip::GetEndSample ( ) const

Definition at line 269 of file WaveClip.cpp.

270 {
271  return GetStartSample() + mSequence->GetNumSamples();
272 }

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 253 of file WaveClip.cpp.

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

References mAppendBufferLen, mOffset, mRate, and mSequence.

Referenced by AUPImportFileHandle::AddSilence(), AppendSilence(), SetClipCommand::ApplyInner(), SetEnvelopeCommand::ApplyInner(), WaveTrack::CanInsertClip(), Clear(), ClearAndAddCutLine(), ClipParameters::ClipParameters(), WaveTrack::Join(), WaveTrack::MergeClips(), WaveTrack::Paste(), Paste(), and WaveTrack::UpdateLocationsCache().

Here is the caller graph for this function:

◆ GetEnvelope() [1/2]

Envelope* WaveClip::GetEnvelope ( )
inline

Definition at line 242 of file WaveClip.h.

242 { 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(), InsertSilence(), and EffectEqualization::ProcessOne().

Here is the caller graph for this function:

◆ GetEnvelope() [2/2]

const Envelope* WaveClip::GetEnvelope ( ) const
inline

Definition at line 243 of file WaveClip.h.

243 { return mEnvelope.get(); }

◆ GetIsPlaceholder()

bool WaveClip::GetIsPlaceholder ( ) const
inline

Definition at line 350 of file WaveClip.h.

350 { 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 1119 of file WaveClip.cpp.

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

References mSequence, THROW_INCONSISTENCY_EXCEPTION, and TimeToSamplesClip().

Here is the call graph for this function:

◆ GetNumSamples()

sampleCount WaveClip::GetNumSamples ( ) const

Definition at line 274 of file WaveClip.cpp.

275 {
276  return mSequence->GetNumSamples();
277 }

References mSequence.

Referenced by 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 219 of file WaveClip.h.

219 { return mOffset; }

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

Here is the caller graph for this function:

◆ GetRate()

int WaveClip::GetRate ( ) const
inline

Definition at line 207 of file WaveClip.h.

207 { return mRate; }

Referenced by Clear(), ClearAndAddCutLine(), ClipParameters::ClipParameters(), anonymous_namespace{WaveformView.cpp}::DrawIndividualSamples(), 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 1142 of file WaveClip.cpp.

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

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 220 of file WaveClip.cpp.

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

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 250 of file WaveClip.h.

250 { 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 251 of file WaveClip.h.

251 { return mSequence.get(); }

◆ GetSequenceBlockArray() [1/2]

BlockArray * WaveClip::GetSequenceBlockArray ( )

Definition at line 237 of file WaveClip.cpp.

238 {
239  return &mSequence->GetBlockArray();
240 }

References mSequence.

◆ GetSequenceBlockArray() [2/2]

const BlockArray * WaveClip::GetSequenceBlockArray ( ) const

Definition at line 242 of file WaveClip.cpp.

243 {
244  return &mSequence->GetBlockArray();
245 }

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 1008 of file WaveClip.cpp.

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

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 264 of file WaveClip.cpp.

265 {
266  return sampleCount( floor(mOffset * mRate + 0.5) );
267 }

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 247 of file WaveClip.cpp.

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

References mOffset.

Referenced by SetClipCommand::ApplyInner(), SetEnvelopeCommand::ApplyInner(), WaveTrack::CanInsertClip(), Clear(), ClearAndAddCutLine(), ClipParameters::ClipParameters(), 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 382 of file WaveClip.cpp.

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

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 1334 of file WaveClip.cpp.

1335 {
1336  if (!wxStrcmp(tag, wxT("sequence")))
1337  return mSequence.get();
1338  else if (!wxStrcmp(tag, wxT("envelope")))
1339  return mEnvelope.get();
1340  else if (!wxStrcmp(tag, wxT("waveclip")))
1341  {
1342  // Nested wave clips are cut lines
1343  mCutLines.push_back(
1344  std::make_unique<WaveClip>(mSequence->GetFactory(),
1345  mSequence->GetSampleFormat(), mRate, 0 /*colourindex*/));
1346  return mCutLines.back().get();
1347  }
1348  else
1349  return NULL;
1350 }

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 1328 of file WaveClip.cpp.

1329 {
1330  if (!wxStrcmp(tag, wxT("waveclip")))
1332 }

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 1292 of file WaveClip.cpp.

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

References Internat::CompatibleToDouble(), XMLValueChecker::IsGoodString(), SetColourIndex(), 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 1426 of file WaveClip.cpp.

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

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 305 of file WaveClip.cpp.

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

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 257 of file WaveClip.h.

258  { 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 314 of file WaveClip.h.

314 { 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 221 of file WaveClip.h.

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

Referenced by Clear(), ClearAndAddCutLine(), WaveTrack::Copy(), WaveTrack::HandleClear(), 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 1649 of file WaveClip.cpp.

1650 {
1651  for (const auto &cutLine : mCutLines)
1652  {
1653  if (mOffset + cutLine->GetOffset() >= t0)
1654  cutLine->Offset(len);
1655  }
1656 }

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 1369 of file WaveClip.cpp.

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

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

Referenced by ExpandCutLine(), WaveTrack::Join(), 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 1633 of file WaveClip.cpp.

1634 {
1635  for (auto it = mCutLines.begin(); it != mCutLines.end(); ++it)
1636  {
1637  const auto &cutline = *it;
1638  if (fabs(mOffset + cutline->GetOffset() - cutLinePosition) < 0.0001)
1639  {
1640  mCutLines.erase(it); // deletes cutline!
1641  return true;
1642  }
1643  }
1644 
1645  return false;
1646 }

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 1674 of file WaveClip.cpp.

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

References floatSample, Internal, limitSampleBufferSize(), mRate, mSequence, mSpecCache, mWaveCache, Resample::Process(), 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 216 of file WaveClip.h.

216 { 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 351 of file WaveClip.h.

351 { mIsPlaceholder = val; }

◆ SetOffset()

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

Definition at line 214 of file WaveClip.cpp.

215 {
216  mOffset = offset;
217  mEnvelope->SetOffset(mOffset);
218 }

References mEnvelope, and mOffset.

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

Here is the caller graph for this function:

◆ SetRate()

void WaveClip::SetRate ( int  rate)

Definition at line 1665 of file WaveClip.cpp.

1666 {
1667  mRate = rate;
1668  auto newLength = mSequence->GetNumSamples().as_double() / mRate;
1669  mEnvelope->RescaleTimes( newLength );
1670  MarkChanged();
1671 }

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 227 of file WaveClip.cpp.

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

References format, MarkChanged(), and mSequence.

Here is the call graph for this function:

◆ SharesBoundaryWithNextClip()

bool WaveClip::SharesBoundaryWithNextClip ( const WaveClip next) const

Definition at line 1765 of file WaveClip.cpp.

1766 {
1767  double endThis = GetRate() * GetOffset() + GetNumSamples().as_double();
1768  double startNext = next->GetRate() * next->GetOffset();
1769 
1770  // given that a double has about 15 significant digits, using a criterion
1771  // of half a sample should be safe in all normal usage.
1772  return fabs(startNext - endThis) < 0.5;
1773 }

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 1180 of file WaveClip.cpp.

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

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 1173 of file WaveClip.cpp.

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

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 284 of file WaveClip.cpp.

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

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

Here is the call graph for this function:

◆ WriteXML()

void WaveClip::WriteXML ( XMLWriter xmlFile) const

Definition at line 1352 of file WaveClip.cpp.

1354 {
1355  xmlFile.StartTag(wxT("waveclip"));
1356  xmlFile.WriteAttr(wxT("offset"), mOffset, 8);
1357  xmlFile.WriteAttr(wxT("colorindex"), mColourIndex );
1358 
1359  mSequence->WriteXML(xmlFile);
1360  mEnvelope->WriteXML(xmlFile);
1361 
1362  for (const auto &clip: mCutLines)
1363  clip->WriteXML(xmlFile);
1364 
1365  xmlFile.EndTag(wxT("waveclip"));
1366 }

Member Data Documentation

◆ mAppendBuffer

SampleBuffer WaveClip::mAppendBuffer {}
protected

Definition at line 371 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 364 of file WaveClip.h.

Referenced by WaveClip().

◆ mCutLines

WaveClipHolders WaveClip::mCutLines {}
protected

◆ mDirty

int WaveClip::mDirty { 0 }
protected

Definition at line 363 of file WaveClip.h.

Referenced by GetSpectrogram(), and GetWaveDisplay().

◆ mEnvelope

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

Definition at line 367 of file WaveClip.h.

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

◆ mIsPlaceholder

bool WaveClip::mIsPlaceholder { false }
protected

Definition at line 379 of file WaveClip.h.

Referenced by 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 370 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 369 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:100
SampleBuffer::Allocate
SampleBuffer & Allocate(size_t count, sampleFormat format)
Definition: SampleFormat.h:72
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:68
WaveClip::mEnvelope
std::unique_ptr< Envelope > mEnvelope
Definition: WaveClip.h:367
Sequence::Delete
void Delete(sampleCount start, sampleCount len)
Definition: Sequence.cpp:1633
WaveClip::UpdateEnvelopeTrackLen
void UpdateEnvelopeTrackLen()
Definition: WaveClip.cpp:1173
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:242
WaveDisplay::ownWhere
std::vector< sampleCount > ownWhere
Definition: WaveClip.h:134
WaveClip::GetNumSamples
sampleCount GetNumSamples() const
Definition: WaveClip.cpp:274
WaveClip::GetOffset
double GetOffset() const
Definition: WaveClip.h:219
WaveClip::Paste
void Paste(double t0, const WaveClip *other)
Paste data from other clip, resampling it if not equal rate.
Definition: WaveClip.cpp:1369
WaveClip::GetRate
int GetRate() const
Definition: WaveClip.h:207
ArrayOf::reinit
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:56
WaveClip::SetOffset
void SetOffset(double offset)
Definition: WaveClip.cpp:214
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:321
WaveClip::GetEndTime
double GetEndTime() const
Definition: WaveClip.cpp:253
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:101
floatSample
@ floatSample
Definition: Types.h:199
WaveClip::mWaveCache
std::unique_ptr< WaveCache > mWaveCache
Definition: WaveClip.h:369
WaveTrack::GetSpectrogramSettings
const SpectrogramSettings & GetSpectrogramSettings() const
Definition: WaveTrack.cpp:665
WaveClipHolders
std::vector< WaveClipHolder > WaveClipHolders
Definition: WaveClip.h:121
XMLValueChecker::IsGoodString
static bool IsGoodString(const wxString &str)
Definition: XMLTagHandler.cpp:39
WaveClip::GetStartSample
sampleCount GetStartSample() const
Definition: WaveClip.cpp:264
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: Types.h:183
WaveClip::GetStartTime
double GetStartTime() const
Definition: WaveClip.cpp:247
WaveClip::GetSequence
Sequence * GetSequence()
Definition: WaveClip.h:250
WaveClip::mColourIndex
int mColourIndex
Definition: WaveClip.h:364
WaveClip
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:172
samplePtr
char * samplePtr
Definition: Types.h:214
sampleFormat
sampleFormat
Definition: Types.h:194
factory
static RegisteredToolbarFactory factory
Definition: ControlToolBar.cpp:807
sampleCount::as_double
double as_double() const
Definition: Types.h:93
WaveDisplay::max
float * max
Definition: WaveClip.h:131
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:110
ProgressResult::Success
@ Success
WaveClip::TimeToSamplesClip
void TimeToSamplesClip(double t0, sampleCount *s0) const
Definition: WaveClip.cpp:1180
WaveClip::Offset
void Offset(double delta)
Definition: WaveClip.h:221
WaveDisplay::width
int width
Definition: WaveClip.h:129
format
int format
Definition: ExportPCM.cpp:54
ProgressDialog::Update
ProgressResult Update(int value, const TranslatableString &message={})
Definition: ProgressDialog.cpp:1327
WaveClip::mRate
int mRate
Definition: WaveClip.h:362
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:216
Resample
Interface to libsoxr.
Definition: Resample.h:29
WaveClipHolder
std::shared_ptr< WaveClip > WaveClipHolder
Definition: WaveClip.h:120
WaveClip::mDirty
int mDirty
Definition: WaveClip.h:363
WaveClip::GetIsPlaceholder
bool GetIsPlaceholder() const
Definition: WaveClip.h:350
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:1649
WaveClip::mAppendBuffer
SampleBuffer mAppendBuffer
Definition: WaveClip.h:371
WaveClip::mIsPlaceholder
bool mIsPlaceholder
Definition: WaveClip.h:379
WaveClip::ConvertToSampleFormat
void ConvertToSampleFormat(sampleFormat format, const std::function< void(size_t)> &progressReport={})
Definition: WaveClip.cpp:1161
sampleCount
Definition: Types.h:66
WaveDisplay::rms
float * rms
Definition: WaveClip.h:131
WaveClipConstHolders
std::vector< std::shared_ptr< const WaveClip > > WaveClipConstHolders
Definition: WaveClip.h:122
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:269
WaveClip::mSpecPxCache
std::unique_ptr< SpecPxCache > mSpecPxCache
Definition: WaveClip.h:358
gHighQualityDither
DitherType gHighQualityDither
Definition: SampleFormat.cpp:49
WaveClip::mCutLines
WaveClipHolders mCutLines
Definition: WaveClip.h:376
WaveDisplay::min
float * min
Definition: WaveClip.h:131
WaveClip::mSpecCache
std::unique_ptr< SpecCache > mSpecCache
Definition: WaveClip.h:370
WaveClip::InsertSilence
void InsertSilence(double t, double len, double *pEnvelopeValue=nullptr)
Definition: WaveClip.cpp:1426
WaveClip::mOffset
double mOffset
Definition: WaveClip.h:361
WaveClip::mSequence
std::unique_ptr< Sequence > mSequence
Definition: WaveClip.h:366
WaveClip::mAppendBufferLen
size_t mAppendBufferLen
Definition: WaveClip.h:372
settings
static Settings & settings()
Definition: TrackInfo.cpp:87
WaveClip::MarkChanged
void MarkChanged()
Definition: WaveClip.h:257
WaveClip::Resample
void Resample(int rate, ProgressDialog *progress=NULL)
Definition: WaveClip.cpp:1674
SimpleMessageBoxException
A MessageBoxException that shows a given, unvarying string.
Definition: AudacityException.h:91
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:365
ArrayOf< float >
XMLWriter::StartTag
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:77
WaveDisplay::where
sampleCount * where
Definition: WaveClip.h:130
SAMPLE_SIZE
#define SAMPLE_SIZE(SampleFormat)
Definition: Types.h:209
WaveDisplay::bl
int * bl
Definition: WaveClip.h:132
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:86
Envelope::CollapseRegion
void CollapseRegion(double t0, double t1, double sampleDur)
Definition: Envelope.cpp:375