From 79dd7cfd4af4d9c81e104d8d3788a003b1267bea Mon Sep 17 00:00:00 2001 From: Micah Johnston Date: Sat, 30 Nov 2024 21:03:32 -0600 Subject: [PATCH] vst3: remove separate view-specific set of param values Instead of maintaining a separate set of parameter values for the View and using it for IEditController::setParamNormalized/getParamNormalized, just use Plugin::set_param/get_param. --- src/format/vst3/component.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/format/vst3/component.rs b/src/format/vst3/component.rs index e485bd5..ac7415b 100644 --- a/src/format/vst3/component.rs +++ b/src/format/vst3/component.rs @@ -39,7 +39,6 @@ fn speaker_arrangement_to_format(speaker_arrangement: SpeakerArrangement) -> Opt pub struct MainThreadState { pub config: Config, pub plugin: P, - pub view_params: Vec, pub view_host: Rc, pub view: Option, } @@ -95,8 +94,6 @@ impl Component

{ max_buffer_size: 0, }; - let view_params = info.params.iter().map(|p| p.default).collect(); - let scratch_buffers = ScratchBuffers::new(input_bus_map.len(), output_bus_map.len()); let host = Arc::new(Vst3Host::new()); @@ -113,7 +110,6 @@ impl Component

{ main_thread_state: Arc::new(UnsafeCell::new(MainThreadState { config: config.clone(), plugin: P::new(Host::from_inner(host)), - view_params, view_host: Rc::new(Vst3ViewHost::new()), view: None, })), @@ -314,7 +310,6 @@ impl IComponentTrait for Component

{ for (index, param) in self.info.params.iter().enumerate() { let value = main_thread_state.plugin.get_param(param.id); self.engine_params.set(index, value); - main_thread_state.view_params[index] = value; if let Some(view) = &mut main_thread_state.view { view.param_changed(param.id, value); @@ -674,8 +669,8 @@ impl IEditControllerTrait for Component

{ unsafe fn getParamNormalized(&self, id: ParamID) -> ParamValue { let main_thread_state = &*self.main_thread_state.get(); - if let Some(&index) = self.param_map.get(&id) { - return main_thread_state.view_params[index]; + if self.param_map.contains_key(&id) { + return main_thread_state.plugin.get_param(id); } 0.0 @@ -684,8 +679,8 @@ impl IEditControllerTrait for Component

{ unsafe fn setParamNormalized(&self, id: ParamID, value: ParamValue) -> tresult { let main_thread_state = &mut *self.main_thread_state.get(); - if let Some(&index) = self.param_map.get(&id) { - main_thread_state.view_params[index] = value; + if self.param_map.contains_key(&id) { + main_thread_state.plugin.set_param(id, value); if let Some(view) = &mut main_thread_state.view { view.param_changed(id, value);