From 3de72052a1c05ddf25f4a131c752ffdefb2e0f8b Mon Sep 17 00:00:00 2001 From: tim Date: Thu, 7 Sep 2023 16:54:47 +0200 Subject: [PATCH 1/2] fixing the erase-remove idiom and notify the host only when appropriate --- src/detail/vst3/process.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/detail/vst3/process.cpp b/src/detail/vst3/process.cpp index fc9ebf0b..a73471ea 100644 --- a/src/detail/vst3/process.cpp +++ b/src/detail/vst3/process.cpp @@ -680,8 +680,12 @@ namespace Clap auto ev = (clap_event_param_gesture*)event; auto param = (Vst3Parameter*)this->parameters->getParameter(ev->param_id & 0x7FFFFFFF); - _automation->onEndEdit(param->getInfo().id); - _gesturedParameters.erase(std::remove(_gesturedParameters.begin(), _gesturedParameters.end(), param->getInfo().id)); + auto n = std::remove(_gesturedParameters.begin(), _gesturedParameters.end(), param->getInfo().id); + if (n != _gesturedParameters.end()) + { + _gesturedParameters.erase(n, _gesturedParameters.end()); + _automation->onEndEdit(param->getInfo().id); + } } return true; break; From aba2292a9753070c3ff52f5d453e2e3b98166395 Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 11 Sep 2023 15:57:38 +0200 Subject: [PATCH 2/2] checking if there is an output queue object, fixing https://github.com/free-audio/clap-wrapper/issues/127 --- src/detail/vst3/process.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/detail/vst3/process.cpp b/src/detail/vst3/process.cpp index cdf1f034..12313630 100644 --- a/src/detail/vst3/process.cpp +++ b/src/detail/vst3/process.cpp @@ -698,15 +698,21 @@ bool ProcessAdapter::enqueueOutputEvent(const clap_event_header_t* event) Steinberg::int32 index = 0; // addParameterData() does check if there is already a queue and returns it, // actually, it should be called getParameterQueue() - auto list = _vstdata->outputParameterChanges->addParameterData(param_id, index); - // the implementation of addParameterData() in the SDK always returns a queue, but Cubase 12 (perhaps others, too) - // sometimes don't return a queue object during the first bunch of process calls. I (df) haven't figured out, why. - // therefore we have to check if there is an output queue at all - if (list) + // the vst3 validator from the VST3 SDK does not provide always an object to output parameters, probably other hosts won't to that, too + // therefore we are cautious. + if (_vstdata->outputParameterChanges) { - Steinberg::int32 index2 = 0; - list->addPoint(ev->header.time, param->asVst3Value(ev->value), index2); + auto list = _vstdata->outputParameterChanges->addParameterData(param_id, index); + + // the implementation of addParameterData() in the SDK always returns a queue, but Cubase 12 (perhaps others, too) + // sometimes don't return a queue object during the first bunch of process calls. I (df) haven't figured out, why. + // therefore we have to check if there is an output queue at all + if (list) + { + Steinberg::int32 index2 = 0; + list->addPoint(ev->header.time, param->asVst3Value(ev->value), index2); + } } } }