Skip to content

Commit 79dd7cf

Browse files
committed
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.
1 parent d8733d9 commit 79dd7cf

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/format/vst3/component.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ fn speaker_arrangement_to_format(speaker_arrangement: SpeakerArrangement) -> Opt
3939
pub struct MainThreadState<P: Plugin> {
4040
pub config: Config,
4141
pub plugin: P,
42-
pub view_params: Vec<f64>,
4342
pub view_host: Rc<Vst3ViewHost>,
4443
pub view: Option<P::View>,
4544
}
@@ -95,8 +94,6 @@ impl<P: Plugin> Component<P> {
9594
max_buffer_size: 0,
9695
};
9796

98-
let view_params = info.params.iter().map(|p| p.default).collect();
99-
10097
let scratch_buffers = ScratchBuffers::new(input_bus_map.len(), output_bus_map.len());
10198

10299
let host = Arc::new(Vst3Host::new());
@@ -113,7 +110,6 @@ impl<P: Plugin> Component<P> {
113110
main_thread_state: Arc::new(UnsafeCell::new(MainThreadState {
114111
config: config.clone(),
115112
plugin: P::new(Host::from_inner(host)),
116-
view_params,
117113
view_host: Rc::new(Vst3ViewHost::new()),
118114
view: None,
119115
})),
@@ -314,7 +310,6 @@ impl<P: Plugin> IComponentTrait for Component<P> {
314310
for (index, param) in self.info.params.iter().enumerate() {
315311
let value = main_thread_state.plugin.get_param(param.id);
316312
self.engine_params.set(index, value);
317-
main_thread_state.view_params[index] = value;
318313

319314
if let Some(view) = &mut main_thread_state.view {
320315
view.param_changed(param.id, value);
@@ -674,8 +669,8 @@ impl<P: Plugin> IEditControllerTrait for Component<P> {
674669
unsafe fn getParamNormalized(&self, id: ParamID) -> ParamValue {
675670
let main_thread_state = &*self.main_thread_state.get();
676671

677-
if let Some(&index) = self.param_map.get(&id) {
678-
return main_thread_state.view_params[index];
672+
if self.param_map.contains_key(&id) {
673+
return main_thread_state.plugin.get_param(id);
679674
}
680675

681676
0.0
@@ -684,8 +679,8 @@ impl<P: Plugin> IEditControllerTrait for Component<P> {
684679
unsafe fn setParamNormalized(&self, id: ParamID, value: ParamValue) -> tresult {
685680
let main_thread_state = &mut *self.main_thread_state.get();
686681

687-
if let Some(&index) = self.param_map.get(&id) {
688-
main_thread_state.view_params[index] = value;
682+
if self.param_map.contains_key(&id) {
683+
main_thread_state.plugin.set_param(id, value);
689684

690685
if let Some(view) = &mut main_thread_state.view {
691686
view.param_changed(id, value);

0 commit comments

Comments
 (0)