From 4587c1405ffa081475c52af9209c4c6852955aa3 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 18 May 2022 19:41:43 +0200 Subject: [PATCH] Move VST3 buffer initialization This was left over from the last commit. --- src/wrapper/vst3/wrapper.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/wrapper/vst3/wrapper.rs b/src/wrapper/vst3/wrapper.rs index 316823eb..28722dfa 100644 --- a/src/wrapper/vst3/wrapper.rs +++ b/src/wrapper/vst3/wrapper.rs @@ -243,6 +243,11 @@ impl IComponent for Wrapper

{ // custom channel layout overrides we need to initialize here. match (state != 0, self.inner.current_buffer_config.load()) { (true, Some(buffer_config)) => { + // Befure initializing the plugin, make sure all smoothers are set the the default values + for param in self.inner.param_by_hash.values() { + param.update_smoother(buffer_config.sample_rate, true); + } + let bus_config = self.inner.current_bus_config.load(); let mut plugin = self.inner.plugin.write(); if plugin.initialize( @@ -266,9 +271,6 @@ impl IComponent for Wrapper

{ .resize_with(bus_config.num_output_channels as usize, || &mut []) }); - // Also store this for later, so we can reinitialize the plugin after restoring state - self.inner.current_buffer_config.store(Some(buffer_config)); - kResultOk } else { kResultFalse @@ -682,16 +684,11 @@ impl IAudioProcessor for Wrapper

{ vst3_sys::vst::SymbolicSampleSizes::kSample32 as i32 ); - let bus_config = self.inner.current_bus_config.load(); - let buffer_config = BufferConfig { + // This is needed when activating the plugin and when restoring state + self.inner.current_buffer_config.store(Some(BufferConfig { sample_rate: setup.sample_rate as f32, max_buffer_size: setup.max_samples_per_block as u32, - }; - - // Befure initializing the plugin, make sure all smoothers are set the the default values - for param in self.inner.param_by_hash.values() { - param.update_smoother(buffer_config.sample_rate, true); - } + })); // Initializing the plugin happens in `IAudioProcessor::set_active()` because the host may // still change the channel layouts at this point