Corrected the bug ; the reloading procedures did not take the current oversampling parameter into account.

This commit is contained in:
Paul Ferrand 2019-12-02 12:25:21 +01:00
parent e69781ff6b
commit c00f5174b1

View file

@ -173,7 +173,7 @@ void sfz::FilePool::setPreloadSize(uint32_t preloadSize) noexcept
{
// Update all the preloaded sizes
for (auto& preloadedFile : preloadedFiles) {
const auto numFrames = preloadedFile.second.preloadedData->getNumFrames();
const auto numFrames = preloadedFile.second.preloadedData->getNumFrames() / oversamplingFactor;
const uint32_t maxOffset = numFrames > this->preloadSize ? numFrames - this->preloadSize : 0;
fs::path file { rootDirectory / std::string(preloadedFile.first) };
SndfileHandle sndFile(reinterpret_cast<const char*>(file.c_str()));
@ -246,7 +246,7 @@ void sfz::FilePool::setOversamplingFactor(sfz::Oversampling factor) noexcept
{
float samplerateChange { static_cast<float>(factor) / static_cast<float>(this->oversamplingFactor) };
for (auto& preloadedFile : preloadedFiles) {
const auto numFrames = preloadedFile.second.preloadedData->getNumFrames();
const auto numFrames = preloadedFile.second.preloadedData->getNumFrames() / this->oversamplingFactor;
const uint32_t maxOffset = numFrames > this->preloadSize ? numFrames - this->preloadSize : 0;
fs::path file { rootDirectory / std::string(preloadedFile.first) };
SndfileHandle sndFile(reinterpret_cast<const char*>(file.c_str()));