diff --git a/src/effects/ChangeSpeed.cpp b/src/effects/ChangeSpeed.cpp index 619d5e22b..b8db45ed4 100644 --- a/src/effects/ChangeSpeed.cpp +++ b/src/effects/ChangeSpeed.cpp @@ -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); diff --git a/src/effects/ClickRemoval.cpp b/src/effects/ClickRemoval.cpp index d820bd871..6f9f24294 100644 --- a/src/effects/ClickRemoval.cpp +++ b/src/effects/ClickRemoval.cpp @@ -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); diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 0a4fa97dc..5e9bd7906 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -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 diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index 8342213ff..ad05e8bf7 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -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);