1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-28 15:38:48 +01:00

Some comments to avoid further confusions using WaveTrack::Get().

This commit is contained in:
Paul Licameli
2020-03-21 15:45:50 -04:00
parent 7ae5c65580
commit 7aa2667c33
2 changed files with 11 additions and 5 deletions

View File

@@ -1858,7 +1858,7 @@ float WaveTrack::GetRMS(double t0, double t1, bool mayThrow) const
bool WaveTrack::Get(samplePtr buffer, sampleFormat format, bool WaveTrack::Get(samplePtr buffer, sampleFormat format,
sampleCount start, size_t len, fillFormat fill, sampleCount start, size_t len, fillFormat fill,
bool mayThrow, sampleCount * pNumCopied) const bool mayThrow, sampleCount * pNumWithinClips) const
{ {
// Simple optimization: When this buffer is completely contained within one clip, // Simple optimization: When this buffer is completely contained within one clip,
// don't clear anything (because we won't have to). Otherwise, just clear // don't clear anything (because we won't have to). Otherwise, just clear
@@ -1893,6 +1893,7 @@ bool WaveTrack::Get(samplePtr buffer, sampleFormat format,
} }
} }
// Iterate the clips. They are not necessarily sorted by time.
for (const auto &clip: mClips) for (const auto &clip: mClips)
{ {
auto clipStart = clip->GetStartSample(); auto clipStart = clip->GetStartSample();
@@ -1932,8 +1933,8 @@ bool WaveTrack::Get(samplePtr buffer, sampleFormat format,
samplesCopied += samplesToCopy; samplesCopied += samplesToCopy;
} }
} }
if( pNumCopied ) if( pNumWithinClips )
*pNumCopied = samplesCopied; *pNumWithinClips = samplesCopied;
return result; return result;
} }

View File

@@ -239,8 +239,13 @@ private:
/// guaranteed that the same samples are affected. /// guaranteed that the same samples are affected.
/// ///
bool Get(samplePtr buffer, sampleFormat format, bool Get(samplePtr buffer, sampleFormat format,
sampleCount start, size_t len, sampleCount start, size_t len,
fillFormat fill = fillZero, bool mayThrow = true, sampleCount * pNumCopied = nullptr) const; fillFormat fill = fillZero,
bool mayThrow = true,
// Report how many samples were copied from within clips, rather than
// filled according to fillFormat; but these were not necessarily one
// contiguous range.
sampleCount * pNumWithinClips = nullptr) const;
void Set(samplePtr buffer, sampleFormat format, void Set(samplePtr buffer, sampleFormat format,
sampleCount start, size_t len); sampleCount start, size_t len);