Adapt the block size of the effect bus to the one of the Synth
This commit is contained in:
parent
49a182d90f
commit
9d3364889b
3 changed files with 19 additions and 2 deletions
|
|
@ -124,10 +124,16 @@ void EffectBus::mixOutputsTo(float* const mainOutput[], float* const mixOutput[]
|
|||
const float gainToMix = _gainToMix;
|
||||
|
||||
for (unsigned c = 0; c < EffectChannels; ++c) {
|
||||
absl::Span<const float> fxOut = _outputs.getConstSpan(c);
|
||||
auto fxOut = _outputs.getConstSpan(c);
|
||||
sfz::multiplyAdd(gainToMain, fxOut, absl::Span<float>(mainOutput[c], nframes));
|
||||
sfz::multiplyAdd(gainToMix, fxOut, absl::Span<float>(mixOutput[c], nframes));
|
||||
}
|
||||
}
|
||||
|
||||
void EffectBus::setSamplesPerBlock(int samplesPerBlock) noexcept
|
||||
{
|
||||
_inputs.resize(samplesPerBlock);
|
||||
_outputs.resize(samplesPerBlock);
|
||||
}
|
||||
|
||||
} // namespace sfz
|
||||
|
|
|
|||
|
|
@ -136,10 +136,17 @@ public:
|
|||
*/
|
||||
void mixOutputsTo(float* const mainOutput[], float* const mixOutput[], unsigned nframes);
|
||||
|
||||
/**
|
||||
* @brief Sets the maximum number of frames to render at a time. The actual value can be lower
|
||||
* but should never be higher.
|
||||
*
|
||||
*/
|
||||
void setSamplesPerBlock(int samplesPerBlock) noexcept;
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Effect>> _effects;
|
||||
AudioBuffer<float> _inputs { EffectChannels, config::defaultSamplesPerBlock };
|
||||
AudioBuffer<float> _outputs { EffectChannels, config::defaultSamplesPerBlock };
|
||||
AudioBuffer<float> _outputs { EffectChannels, config::defaultSamplesPerBlock };
|
||||
float _gainToMain = 0.0;
|
||||
float _gainToMix = 0.0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -125,6 +125,8 @@ void sfz::Synth::clear()
|
|||
effectBuses.clear();
|
||||
effectBuses.emplace_back(new EffectBus);
|
||||
effectBuses[0]->setGainToMain(1.0);
|
||||
effectBuses[0]->setSamplesPerBlock(samplesPerBlock);
|
||||
effectBuses[0]->init(sampleRate);
|
||||
resources.filePool.clear();
|
||||
resources.logger.clear();
|
||||
numGroups = 0;
|
||||
|
|
@ -463,6 +465,8 @@ void sfz::Synth::setSamplesPerBlock(int samplesPerBlock) noexcept
|
|||
this->tempMixNodeBuffer.resize(samplesPerBlock);
|
||||
for (auto& voice : voices)
|
||||
voice->setSamplesPerBlock(samplesPerBlock);
|
||||
for (auto& bus: effectBuses)
|
||||
bus->setSamplesPerBlock(samplesPerBlock);
|
||||
}
|
||||
|
||||
void sfz::Synth::setSampleRate(float sampleRate) noexcept
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue