diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 4e68bbaf..ec44a516 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -506,10 +506,9 @@ void sfz::Synth::setSamplesPerBlock(int samplesPerBlock) noexcept } this->samplesPerBlock = samplesPerBlock; - this->tempBuffer.resize(samplesPerBlock); - this->tempMixNodeBuffer.resize(samplesPerBlock); for (auto& voice : voices) voice->setSamplesPerBlock(samplesPerBlock); + resources.setSamplesPerBlock(samplesPerBlock); for (auto& bus : effectBuses) { @@ -549,8 +548,15 @@ void sfz::Synth::renderBlock(AudioSpan buffer) noexcept return; size_t numFrames = buffer.getNumFrames(); - auto temp = AudioSpan(tempBuffer).first(numFrames); - auto tempMixNode = AudioSpan(tempMixNodeBuffer).first(numFrames); + auto tempBuffer = resources.bufferPool.getStereoBuffer(numFrames); + auto tempMixNodeBuffer = resources.bufferPool.getStereoBuffer(numFrames); + if (!tempBuffer || !tempMixNodeBuffer) { + DBG("[sfizz] Could not get a temporary buffer; exiting callback... "); + return; + } + + auto temp = AudioSpan(*tempBuffer).first(numFrames); + auto tempMixNode = AudioSpan(*tempMixNodeBuffer).first(numFrames); CallbackBreakdown callbackBreakdown; diff --git a/src/sfizz/Synth.h b/src/sfizz/Synth.h index 2eded30a..a9ce64ab 100644 --- a/src/sfizz/Synth.h +++ b/src/sfizz/Synth.h @@ -516,10 +516,6 @@ private: // Curves CurveSet curves; - // Intermediate buffers - AudioBuffer tempBuffer { 2, config::defaultSamplesPerBlock }; - AudioBuffer tempMixNodeBuffer { 2, config::defaultSamplesPerBlock }; - int samplesPerBlock { config::defaultSamplesPerBlock }; float sampleRate { config::defaultSampleRate }; float volume { Default::globalVolume };