diff --git a/src/common/Resampler.cpp b/src/common/Resampler.cpp index 99b173d..1b213c5 100644 --- a/src/common/Resampler.cpp +++ b/src/common/Resampler.cpp @@ -695,7 +695,7 @@ D_SRC::resampleInterleaved(float *const BQ_R__ out, // expected output, and (b) when the ratio has just changed, we // should aim to supply a shortish block next - if (outcount > int(ceil(incount * ratio) + 5)) { + if (!final && (outcount > int(ceil(incount * ratio) + 5))) { outcount = int(ceil(incount * ratio) + 5); } @@ -754,6 +754,10 @@ D_SRC::resampleInterleaved(float *const BQ_R__ out, #endif } +// cerr << "Resampler::process: final = " << final << ", incount = " +// << incount << ", outcount = " << outcount << ", ratio = " +// << ratio << ", gen = " << data.output_frames_gen << endl; + return (int)data.output_frames_gen; } diff --git a/src/finer/R3Stretcher.cpp b/src/finer/R3Stretcher.cpp index 9055bb2..8918af3 100644 --- a/src/finer/R3Stretcher.cpp +++ b/src/finer/R3Stretcher.cpp @@ -771,7 +771,7 @@ R3Stretcher::process(const float *const *input, size_t samples, bool final) if (resampleInput == 0) resampleInput = 1; prepareInput(input, inputIx, resampleInput); - + int resampleOutput = m_resampler->resample (m_channelAssembly.resampled.data(), maxResampleOutput, @@ -1008,13 +1008,18 @@ R3Stretcher::consume() m_channelAssembly.mixdown[c] = cd->mixdown.data(); m_channelAssembly.resampled[c] = cd->resampled.data(); } + + bool final = (m_mode == ProcessMode::Finished && + readSpace < inhop && + cd0->scales.at(longest)->accumulatorFill <= outhop); + resampledCount = m_resampler->resample (m_channelAssembly.resampled.data(), m_channelData[0]->resampled.size(), m_channelAssembly.mixdown.data(), outhop, 1.0 / m_pitchScale, - m_mode == ProcessMode::Finished && readSpace < inhop); + final); } // Emit