From 0c2bc259b3a34d7bad9b9e25b6ab1a5a44c905be Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Thu, 7 Sep 2023 17:48:42 -0400 Subject: [PATCH] Param To/From string correct in VST3 1. A tresult means don't return true false. Because those are false/true respectively. 2. The fromString requires a normalized value as the output 3. Use the memory guarded copy8 to get the data from a wstring in to value, and no longer copy the unused return value. --- src/wrapasvst3.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wrapasvst3.cpp b/src/wrapasvst3.cpp index b9a4b3af..79fad4b9 100644 --- a/src/wrapasvst3.cpp +++ b/src/wrapasvst3.cpp @@ -240,12 +240,13 @@ tresult PLUGIN_API ClapAsVst3::getParamStringByValue(Vst::ParamID id, Vst::Param auto val = param->asClapValue(valueNormalized); char outbuf[128]; + memset(outbuf, 0, sizeof(outbuf)); if (this->_plugin->_ext._params->value_to_text(_plugin->_plugin, param->id, val, outbuf, 127)) { UString wrapper(&string[0], str16BufferSize(Steinberg::Vst::String128)); wrapper.assign(outbuf,sizeof(outbuf)); - return true; + return kResultOk; } return super::getParamStringByValue(id, valueNormalized, string); } @@ -255,14 +256,14 @@ tresult PLUGIN_API ClapAsVst3::getParamValueByString(Vst::ParamID id, Vst::TChar auto param = (Vst3Parameter*)this->getParameterObject(id); Steinberg::String m(string); char inbuf[128]; - auto l = m.copyTo8(inbuf); + m.copyTo8(inbuf, 0, 128); double out = 0.; if (this->_plugin->_ext._params->text_to_value(_plugin->_plugin, param->id, inbuf, &out)) { - valueNormalized = out; - return true; + valueNormalized = param->asVst3Value(out); + return kResultOk; } - return false; + return Steinberg::kResultFalse; }