vst3 map
This commit is contained in:
parent
2eaf36dfd6
commit
fded17eedb
@ -61,14 +61,10 @@
|
|||||||
lv2:shortName "{{=p.shortName.substring(0, 16)}}" ;
|
lv2:shortName "{{=p.shortName.substring(0, 16)}}" ;
|
||||||
{{?}}
|
{{?}}
|
||||||
lv2:symbol "{{=p.symbol}}" ;
|
lv2:symbol "{{=p.symbol}}" ;
|
||||||
{{?"defaultValue" in p}}
|
{{?p.type == "control"}}
|
||||||
lv2:default {{=p.defaultValue.toExponential()}} ;
|
|
||||||
{{?}}
|
|
||||||
{{?"minimum" in p}}
|
|
||||||
lv2:minimum {{=p.minimum.toExponential()}} ;
|
lv2:minimum {{=p.minimum.toExponential()}} ;
|
||||||
{{?}}
|
|
||||||
{{?"maximum" in p}}
|
|
||||||
lv2:maximum {{=p.maximum.toExponential()}} ;
|
lv2:maximum {{=p.maximum.toExponential()}} ;
|
||||||
|
lv2:default {{=p.defaultValue.toExponential()}} ;
|
||||||
{{?}}
|
{{?}}
|
||||||
{{?p.sidechain}}
|
{{?p.sidechain}}
|
||||||
lv2:portProperty lv2:isSideChain ;
|
lv2:portProperty lv2:isSideChain ;
|
||||||
|
@ -112,8 +112,8 @@ static struct Steinberg_Vst_ParameterInfo parameterInfo[DATA_PRODUCT_PARAMETERS_
|
|||||||
/* .title = */ { {{~Array.from(p.name) :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 },
|
/* .title = */ { {{~Array.from(p.name) :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 },
|
||||||
/* .shortTitle = */ { {{~Array.from(p.shortName) :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 },
|
/* .shortTitle = */ { {{~Array.from(p.shortName) :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 },
|
||||||
/* .units = */ { {{~Array.from(p.unit in it.tibia.vst3.units ? it.tibia.vst3.units[p.unit] : "") :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 },
|
/* .units = */ { {{~Array.from(p.unit in it.tibia.vst3.units ? it.tibia.vst3.units[p.unit] : "") :c}}0x{{=c.charCodeAt(0).toString(16)}}, {{~}}0 },
|
||||||
/* .stepCount = */ {{?p.toggled}}1{{??p.list && p.scalePoints.length > 1}}Number(1 / (p.scalePoints.length - 1)).toExponential(){{??p.integer && "maximum" in p && "minimum" in p}}Number(p.maximum - p.minimum).toExponential(){{??}}0{{?}},
|
/* .stepCount = */ {{?p.toggled}}1{{??p.list && p.scalePoints.length > 1}}Number(1 / (p.scalePoints.length - 1)).toExponential(){{??p.integer}}Number(p.maximum - p.minimum).toExponential(){{??}}0{{?}},
|
||||||
/* .defaultNormalizedValue = */ {{="defaultValue" in p && "maximum" in p && "minimum" in p ? Number((p.defaultValue - p.minimum) / (p.maximum - p.minimum)).toExponential() : 0.0}},
|
/* .defaultNormalizedValue = */ {{=Number((p.defaultValue - p.minimum) / (p.maximum - p.minimum)).toExponential()}},
|
||||||
/* .unitId = */ 0,
|
/* .unitId = */ 0,
|
||||||
/* .flags = */ {{?p.direction == "input"}}Steinberg_Vst_ParameterInfo_ParameterFlags_kCanAutomate{{??}}Steinberg_Vst_ParameterInfo_ParameterFlags_kIsReadOnly{{?}}
|
/* .flags = */ {{?p.direction == "input"}}Steinberg_Vst_ParameterInfo_ParameterFlags_kCanAutomate{{??}}Steinberg_Vst_ParameterInfo_ParameterFlags_kIsReadOnly{{?}}
|
||||||
{{?}}
|
{{?}}
|
||||||
@ -129,14 +129,16 @@ static struct {
|
|||||||
size_t index;
|
size_t index;
|
||||||
double min;
|
double min;
|
||||||
double max;
|
double max;
|
||||||
|
double def;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
// scalePoints?
|
// scalePoints?
|
||||||
} parameterData[DATA_PRODUCT_PARAMETERS_N] = {
|
} parameterData[DATA_PRODUCT_PARAMETERS_N] = {
|
||||||
{{~it.product.parameters.filter(x => !x.isLatency) :p:i}}
|
{{~it.product.parameters.filter(x => !x.isLatency) :p:i}}
|
||||||
{
|
{
|
||||||
/* .index = */ {{=p.paramIndex}},
|
/* .index = */ {{=p.paramIndex}},
|
||||||
/* .min = */ {{="minimum" in p ? p.minimum.toExponential() : 0.0}},
|
/* .min = */ {{=p.minimum.toExponential()}},
|
||||||
/* .max = */ {{="maximum" in p ? p.maximum.toExponential() : 0.0}},
|
/* .max = */ {{=p.maximum.toExponential()}},
|
||||||
|
/* .def = */ {{=p.defaultValue.toExponential()}},
|
||||||
/* .flags = */ {{?p.isBypass}}DATA_PARAM_BYPASS{{??}}0{{?p.toggled}} | DATA_PARAM_TOGGLED{{?}}{{?p.integer}} | DATA_PARAM_INTEGER{{?}}{{?}}
|
/* .flags = */ {{?p.isBypass}}DATA_PARAM_BYPASS{{??}}0{{?p.toggled}} | DATA_PARAM_TOGGLED{{?}}{{?p.integer}} | DATA_PARAM_INTEGER{{?}}{{?}}
|
||||||
},
|
},
|
||||||
{{~}}
|
{{~}}
|
||||||
|
@ -469,7 +469,7 @@ static Steinberg_tresult controllerInitialize(void* thisInterface, struct Steinb
|
|||||||
c->context = context;
|
c->context = context;
|
||||||
#if DATA_PRODUCT_PARAMETERS_N > 0
|
#if DATA_PRODUCT_PARAMETERS_N > 0
|
||||||
for (int i = 0; i < DATA_PRODUCT_PARAMETERS_N; i++)
|
for (int i = 0; i < DATA_PRODUCT_PARAMETERS_N; i++)
|
||||||
c->parameters[i] = parameterInfo[i].defaultNormalizedValue;
|
c->parameters[i] = parameterData[i].def;
|
||||||
#endif
|
#endif
|
||||||
return Steinberg_kResultOk;
|
return Steinberg_kResultOk;
|
||||||
}
|
}
|
||||||
@ -481,13 +481,12 @@ static Steinberg_tresult controllerTerminate(void* thisInterface) {
|
|||||||
return Steinberg_kResultOk;
|
return Steinberg_kResultOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Steinberg_tresult controllerSetParamNormalized(void* thisInterface, Steinberg_Vst_ParamID id, Steinberg_Vst_ParamValue value);
|
|
||||||
|
|
||||||
static Steinberg_tresult controllerSetComponentState(void* thisInterface, struct Steinberg_IBStream* state) {
|
static Steinberg_tresult controllerSetComponentState(void* thisInterface, struct Steinberg_IBStream* state) {
|
||||||
TRACE("controller set component state %p %p\n", thisInterface, (void *)state);
|
TRACE("controller set component state %p %p\n", thisInterface, (void *)state);
|
||||||
if (state == NULL)
|
if (state == NULL)
|
||||||
return Steinberg_kResultFalse;
|
return Steinberg_kResultFalse;
|
||||||
#if DATA_PRODUCT_PARAMETERS_N > 0
|
#if DATA_PRODUCT_PARAMETERS_N > 0
|
||||||
|
controller *c = (controller *)thisInterface;
|
||||||
for (size_t i = 0; i < DATA_PRODUCT_PARAMETERS_N; i++) {
|
for (size_t i = 0; i < DATA_PRODUCT_PARAMETERS_N; i++) {
|
||||||
if (parameterInfo[i].flags & Steinberg_Vst_ParameterInfo_ParameterFlags_kIsReadOnly)
|
if (parameterInfo[i].flags & Steinberg_Vst_ParameterInfo_ParameterFlags_kIsReadOnly)
|
||||||
continue;
|
continue;
|
||||||
@ -498,7 +497,7 @@ static Steinberg_tresult controllerSetComponentState(void* thisInterface, struct
|
|||||||
return Steinberg_kResultFalse;
|
return Steinberg_kResultFalse;
|
||||||
if (IS_BIG_ENDIAN)
|
if (IS_BIG_ENDIAN)
|
||||||
v.u = SWAP_UINT32(v.u);
|
v.u = SWAP_UINT32(v.u);
|
||||||
controllerSetParamNormalized(thisInterface, i, v.f);
|
c->parameters[i] = v.f;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
TRACE(" ok\n");
|
TRACE(" ok\n");
|
||||||
@ -570,12 +569,19 @@ static void dToStr(double v, Steinberg_Vst_String128 s, int precision) {
|
|||||||
s[i] = '\0';
|
s[i] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static double parameterMap(Steinberg_Vst_ParamID id, double v) {
|
||||||
|
return parameterData[id].min + (parameterData[id].max - parameterData[id].min) * v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static double parameterUnmap(Steinberg_Vst_ParamID id, double v) {
|
||||||
|
return (v - parameterData[id].min) / (parameterData[id].max - parameterData[id].min);
|
||||||
|
}
|
||||||
|
|
||||||
static Steinberg_tresult controllerGetParamStringByValue(void* thisInterface, Steinberg_Vst_ParamID id, Steinberg_Vst_ParamValue valueNormalized, Steinberg_Vst_String128 string) {
|
static Steinberg_tresult controllerGetParamStringByValue(void* thisInterface, Steinberg_Vst_ParamID id, Steinberg_Vst_ParamValue valueNormalized, Steinberg_Vst_String128 string) {
|
||||||
TRACE("controller get param string by value\n");
|
TRACE("controller get param string by value\n");
|
||||||
if (id >= DATA_PRODUCT_PARAMETERS_N)
|
if (id >= DATA_PRODUCT_PARAMETERS_N)
|
||||||
return Steinberg_kResultFalse;
|
return Steinberg_kResultFalse;
|
||||||
//mapping TBD
|
dToStr(parameterMap(id, valueNormalized), string, 2);
|
||||||
dToStr(valueNormalized, string, 2);
|
|
||||||
return Steinberg_kResultTrue;
|
return Steinberg_kResultTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,28 +617,27 @@ static Steinberg_tresult controllerGetParamValueByString(void* thisInterface, St
|
|||||||
TRACE("controller get param value by string\n");
|
TRACE("controller get param value by string\n");
|
||||||
if (id >= DATA_PRODUCT_PARAMETERS_N)
|
if (id >= DATA_PRODUCT_PARAMETERS_N)
|
||||||
return Steinberg_kResultFalse;
|
return Steinberg_kResultFalse;
|
||||||
//mapping TBD
|
double v;
|
||||||
TCharToD(string, valueNormalized);
|
TCharToD(string, &v);
|
||||||
|
*valueNormalized = parameterUnmap(id, v);
|
||||||
return Steinberg_kResultTrue;
|
return Steinberg_kResultTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Steinberg_Vst_ParamValue controllerNormalizedParamToPlain(void* thisInterface, Steinberg_Vst_ParamID id, Steinberg_Vst_ParamValue valueNormalized) {
|
static Steinberg_Vst_ParamValue controllerNormalizedParamToPlain(void* thisInterface, Steinberg_Vst_ParamID id, Steinberg_Vst_ParamValue valueNormalized) {
|
||||||
TRACE("controller normalized param to plain\n");
|
TRACE("controller normalized param to plain\n");
|
||||||
//mapping TBD
|
return parameterMap(id, valueNormalized);
|
||||||
return valueNormalized;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Steinberg_Vst_ParamValue controllerPlainParamToNormalized(void* thisInterface, Steinberg_Vst_ParamID id, Steinberg_Vst_ParamValue plainValue) {
|
static Steinberg_Vst_ParamValue controllerPlainParamToNormalized(void* thisInterface, Steinberg_Vst_ParamID id, Steinberg_Vst_ParamValue plainValue) {
|
||||||
TRACE("controller plain param to normalized\n");
|
TRACE("controller plain param to normalized\n");
|
||||||
//mapping TBD
|
return parameterUnmap(id, plainValue);
|
||||||
return plainValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Steinberg_Vst_ParamValue controllerGetParamNormalized(void* thisInterface, Steinberg_Vst_ParamID id) {
|
static Steinberg_Vst_ParamValue controllerGetParamNormalized(void* thisInterface, Steinberg_Vst_ParamID id) {
|
||||||
TRACE("controller get param normalized\n");
|
TRACE("controller get param normalized\n");
|
||||||
#if DATA_PRODUCT_PARAMETERS_N > 0
|
#if DATA_PRODUCT_PARAMETERS_N > 0
|
||||||
controller *c = (controller *)thisInterface;
|
controller *c = (controller *)thisInterface;
|
||||||
return c->parameters[id];
|
return parameterMap(id, c->parameters[id]);
|
||||||
#else
|
#else
|
||||||
return 0.0;
|
return 0.0;
|
||||||
#endif
|
#endif
|
||||||
@ -644,7 +649,7 @@ static Steinberg_tresult controllerSetParamNormalized(void* thisInterface, Stein
|
|||||||
if (id >= DATA_PRODUCT_PARAMETERS_N)
|
if (id >= DATA_PRODUCT_PARAMETERS_N)
|
||||||
return Steinberg_kResultFalse;
|
return Steinberg_kResultFalse;
|
||||||
controller *c = (controller *)thisInterface;
|
controller *c = (controller *)thisInterface;
|
||||||
c->parameters[id] = value;
|
c->parameters[id] = parameterMap(id, value);
|
||||||
return Steinberg_kResultTrue;
|
return Steinberg_kResultTrue;
|
||||||
#else
|
#else
|
||||||
return Steinberg_kResultFalse;
|
return Steinberg_kResultFalse;
|
||||||
|
Loading…
Reference in New Issue
Block a user