From d2965e048d9a61d3cb7e8f8d9ff41f6f2b943673 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 23 May 2021 15:55:29 +0200 Subject: [PATCH] No longer zero out VST3 audio buffers Apparently we also never did this for VST2 plugins, so this should be safe. Filling the vectors with zeroes here had a non-negligible performance impact according to perf. --- CHANGELOG.md | 4 ++++ src/common/serialization/vst3/process-data.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd3dca38..397306f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,10 @@ Versioning](https://semver.org/spec/v2.0.0.html). unions yabridge uses to differentiate between single and double precision floating point audio buffers, undoing all of our efforts at reusing objects and preventing memory allocations in the process. +- VST3 output audio buffers are no longer zeroed out for the plugin. We did this + for VST3 plugins, but not for VST2 plugins. Since not doing this never caused + any issues with VST2 plugins it should also be safe to do the same thing for + VST3 plugins. This further reduces the overhead of VST3 audio processing. - Further optimized VST3 audio processing by preallocating small vectors for event and parameter change queues. - VST2 audio processing also received the same small vector optimization to get diff --git a/src/common/serialization/vst3/process-data.cpp b/src/common/serialization/vst3/process-data.cpp index 899ac59e..dee47284 100644 --- a/src/common/serialization/vst3/process-data.cpp +++ b/src/common/serialization/vst3/process-data.cpp @@ -33,7 +33,7 @@ void YaAudioBusBuffers::clear(int32 sample_size, std::get>>(buffers); vector_buffers.resize(num_channels); for (size_t i = 0; i < vector_buffers.size(); i++) { - vector_buffers[i].assign(num_samples, 0.0); + vector_buffers[i].resize(num_samples); } } else { if (!std::holds_alternative>>(buffers)) { @@ -44,7 +44,7 @@ void YaAudioBusBuffers::clear(int32 sample_size, std::get>>(buffers); vector_buffers.resize(num_channels); for (size_t i = 0; i < vector_buffers.size(); i++) { - vector_buffers[i].assign(num_samples, 0.0f); + vector_buffers[i].resize(num_samples); } } }