Skip to content

Commit

Permalink
Param To/From string correct in VST3
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
baconpaul committed Sep 7, 2023
1 parent f7a55fd commit 0b17ad8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/wrapasvst3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <locale>
#include <sstream>

#include <iostream>

#if WIN
#include <tchar.h>
#define S16(x) reinterpret_cast<const Steinberg::Vst::TChar*>(_T(x))
Expand Down Expand Up @@ -240,12 +242,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);
}
Expand All @@ -255,14 +258,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;

}

Expand Down

0 comments on commit 0b17ad8

Please sign in to comment.