More uses of limitSampleBufferSize

This commit is contained in:
Paul Licameli 2016-08-26 22:02:58 -04:00
parent 156e77fcc7
commit 3b04bb1726
4 changed files with 8 additions and 20 deletions

View File

@ -502,11 +502,10 @@ bool EffectChangeSpeed::ProcessOne(WaveTrack * track,
auto samplePos = start;
while (samplePos < end) {
//Get a blockSize of samples (smaller than the size of the buffer)
auto blockSize = track->GetBestBlockSize(samplePos);
//Adjust the block size if it is the final block in the track
if (samplePos + blockSize > end)
blockSize = end - samplePos;
auto blockSize = limitSampleBufferSize(
track->GetBestBlockSize(samplePos),
end - samplePos
);
//Get the samples from the track and put them in the buffer
track->Get((samplePtr) inBuffer, floatSample, samplePos, blockSize);

View File

@ -217,9 +217,7 @@ bool EffectClickRemoval::ProcessOne(int count, WaveTrack * track, sampleCount st
float *datawindow = new float[windowSize];
while ((s < len) && ((len - s) > windowSize/2))
{
auto block = idealBlockLen;
if (s + block > len)
block = len - s;
auto block = limitSampleBufferSize( idealBlockLen, len - s );
track->Get((samplePtr) buffer, floatSample, start + s, block);

View File

@ -1627,10 +1627,7 @@ bool Effect::ProcessTrack(int count,
if (delayRemaining != 0)
{
// Don't use more than needed
if (delayRemaining < cnt)
{
cnt = delayRemaining;
}
cnt = limitSampleBufferSize(cnt, delayRemaining);
delayRemaining -= cnt;
curBlockSize += cnt;
}
@ -1640,11 +1637,7 @@ bool Effect::ProcessTrack(int count,
else if (delayRemaining != 0)
{
// Calculate the number of samples to process
curBlockSize = mBlockSize;
if (curBlockSize > delayRemaining)
{
curBlockSize = delayRemaining;
}
curBlockSize = limitSampleBufferSize( mBlockSize, delayRemaining );
delayRemaining -= curBlockSize;
// From this point on, we only want to feed zeros to the plugin

View File

@ -1086,9 +1086,7 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t,
while (len != 0)
{
auto block = idealBlockLen;
if (block > len)
block = len;
auto block = limitSampleBufferSize( idealBlockLen, len );
t->Get((samplePtr)buffer, floatSample, s, block);