From 3d1fdd05ee92642d8a7ba0f2853c607aee825b3b Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Sat, 13 Jul 2024 18:42:06 +0200 Subject: [PATCH] vst3 sync param values between custom and generated UIs in Reaper --- templates/vst3/src/vst3.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/templates/vst3/src/vst3.c b/templates/vst3/src/vst3.c index 29dc96e..45296b2 100644 --- a/templates/vst3/src/vst3.c +++ b/templates/vst3/src/vst3.c @@ -1096,12 +1096,17 @@ static void plugViewUpdateAllParameters(plugView *view) { } static void plugViewSetParameterCb(void *handle, size_t index, float value) { - plugView *v = (plugView *)handle; + TRACE("set parameter cb\n"); + # ifdef DATA_PARAM_LATENCY_INDEX + if (index == DATA_PARAM_LATENCY_INDEX) + return; index = index >= DATA_PARAM_LATENCY_INDEX ? index - 1 : index; # endif + plugView *v = (plugView *)handle; + v->ctrl->parameters[index] = parameterAdjust(index, value); // let Reaper find the updated value v->ctrl->componentHandler->lpVtbl->beginEdit(v->ctrl->componentHandler, parameterInfo[index].id); - v->ctrl->componentHandler->lpVtbl->performEdit(v->ctrl->componentHandler, parameterInfo[index].id, parameterUnmap(index, parameterAdjust(index, value))); + v->ctrl->componentHandler->lpVtbl->performEdit(v->ctrl->componentHandler, parameterInfo[index].id, parameterUnmap(index, v->ctrl->parameters[index])); v->ctrl->componentHandler->lpVtbl->endEdit(v->ctrl->componentHandler, parameterInfo[index].id); } # endif