Skip to content

Commit

Permalink
fixes #86
Browse files Browse the repository at this point in the history
  • Loading branch information
defiantnerd committed Sep 5, 2023
1 parent 8a4ffc4 commit 0c85452
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/detail/vst3/parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ bool Vst3Parameter::setNormalized(Steinberg::Vst::ParamValue v)
return super::setNormalized(v);
}

#if 0
void Vst3Parameter::toString(Steinberg::Vst::ParamValue valueNormalized, Steinberg::Vst::String128 string) const
{
super::toString(valueNormalized, string);
}
/** Converts a string to a normalized value. */
bool Vst3Parameter::fromString(const Steinberg::Vst::TChar* string, Steinberg::Vst::ParamValue& valueNormalized) const
{
return super::fromString(string, valueNormalized);
}
#endif

Vst3Parameter* Vst3Parameter::create(const clap_param_info_t* info, std::function<Steinberg::Vst::UnitID(const char* modulepath)> getUnitId)
{
Vst::ParameterInfo v;
Expand Down
12 changes: 12 additions & 0 deletions src/detail/vst3/parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ class Vst3Parameter : public Steinberg::Vst::Parameter
public:
virtual ~Vst3Parameter();
bool setNormalized(Steinberg::Vst::ParamValue v) override;

#if 0
// toString/fromString from VST3 parameter should actually be overloaded, but the wrapper will not call them
// for the conversion, the _plugin instance is needed and we don't want to keep a copy in each parameter
// the IEditController will be called anyway from the host, therefore the conversion will take place there.

/** Converts a normalized value to a string. */
void toString(Steinberg::Vst::ParamValue valueNormalized, Steinberg::Vst::String128 string) const override;
/** Converts a string to a normalized value. */
bool fromString(const Steinberg::Vst::TChar* string, Steinberg::Vst::ParamValue& valueNormalized) const override;
#endif

inline double asClapValue(double vst3value) const
{
return vst3value * (max_value - min_value) + min_value;
Expand Down
32 changes: 32 additions & 0 deletions src/wrapasvst3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,38 @@ IPlugView* PLUGIN_API ClapAsVst3::createView(FIDString name)
return nullptr;
}

tresult PLUGIN_API ClapAsVst3::getParamStringByValue(Vst::ParamID id, Vst::ParamValue valueNormalized, Vst::String128 string)
{
auto param = (Vst3Parameter*)this->getParameterObject(id);
auto val = param->asClapValue(valueNormalized);

char outbuf[128];
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 super::getParamStringByValue(id, valueNormalized, string);
}

tresult PLUGIN_API ClapAsVst3::getParamValueByString(Vst::ParamID id, Vst::TChar* string, Vst::ParamValue& valueNormalized)
{
auto param = (Vst3Parameter*)this->getParameterObject(id);
Steinberg::String m(string);
char inbuf[128];
auto l = m.copyTo8(inbuf);
double out = 0.;
if (this->_plugin->_ext._params->text_to_value(_plugin->_plugin, param->id, inbuf, &out))
{
valueNormalized = out;
return true;
}
return false;

}

tresult PLUGIN_API ClapAsVst3::activateBus(Vst::MediaType type, Vst::BusDirection dir, int32 index, TBool state)
{
return super::activateBus(type, dir, index, state);
Expand Down
4 changes: 4 additions & 0 deletions src/wrapasvst3.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ class ClapAsVst3 : public Steinberg::Vst::SingleComponentEffect

//----from IEditControllerEx1--------------------------------
IPlugView* PLUGIN_API createView(FIDString name) override;
/** Gets for a given paramID and normalized value its associated string representation. */
tresult PLUGIN_API getParamStringByValue(Vst::ParamID id, Vst::ParamValue valueNormalized /*in*/, Vst::String128 string /*out*/) override;
/** Gets for a given paramID and string its normalized value. */
tresult PLUGIN_API getParamValueByString(Vst::ParamID id, Vst::TChar* string /*in*/, Vst::ParamValue& valueNormalized /*out*/) override;

//----from IMidiMapping--------------------------------------
tresult PLUGIN_API getMidiControllerAssignment(int32 busIndex, int16 channel,
Expand Down

0 comments on commit 0c85452

Please sign in to comment.