now with minimum and maximum

This commit is contained in:
Stefano D'Angelo 2024-01-05 15:35:39 +01:00
parent 4a7cbd79ab
commit 2cb60340d0
5 changed files with 26 additions and 8 deletions

View File

@ -19,8 +19,14 @@
{{?p.direction == "input"}}lv2:InputPort{{??}}lv2:OutputPort{{?}} ;
lv2:name "{{=p.name}}" ;
lv2:symbol "{{=p.symbol}}" ;
{{?p.defaultValue}}
{{?"defaultValue" in p}}
lv2:default {{=p.defaultValue.toExponential()}} ;
{{?}}
{{?"minimum" in p}}
lv2:minimum {{=p.minimum.toExponential()}} ;
{{?}}
{{?"maximum" in p}}
lv2:maximum {{=p.maximum.toExponential()}} ;
{{?}}
lv2:index {{=i}}
{{?i < it.tibia.lv2.ports.length - 1}}

View File

@ -41,7 +41,13 @@ module.exports = function (data, api) {
for (var i = 0; i < data.product.parameters.length; i++) {
var p = data.product.parameters[i];
var e = { type: "control", direction: p.direction, name: p.name, defaultValue: p.defaultValue };
var e = { type: "control", direction: p.direction, name: p.name };
if ("defaultValue" in p)
e.defaultValue = p.defaultValue;
if ("minimum" in p)
e.minimum = p.minimum;
if ("maximum" in p)
e.maximum = p.maximum;
e.symbol = getSymbol(p.shortName);
data.tibia.lv2.ports.push(e);
}

View File

@ -1,7 +1,7 @@
{
"lv2": {
"prefixes": {
"example": "https://www.example.com/"
"example": "http://www.example.com/"
},
"uri": "@example:tibia_test",
"project": "@example:project",

View File

@ -1,3 +1,5 @@
#include <math.h>
typedef struct plugin {
float gain;
char bypass;
@ -29,7 +31,7 @@ void plugin_set_parameter(plugin *instance, size_t index, float value) {
}
void plugin_process(plugin *instance, const float **inputs, float **outputs, size_t n_samples) {
for (size_t i = 0; i < n_samples; i++) {
outputs[0][i] = instance->bypass ? inputs[0][i] : instance->gain * inputs[0][i];
}
const float g = instance->bypass ? 1.f : powf(10.f, 0.05f * instance->gain);
for (size_t i = 0; i < n_samples; i++)
outputs[0][i] = g * inputs[0][i];
}

View File

@ -30,7 +30,9 @@
"steps": 0,
"direction": "input",
"isBypass": false,
"defaultValue": 1.0
"defaultValue": 0.0,
"minimum": -60.0,
"maximum": 12.0
},
{
"name": "Bypass",
@ -39,7 +41,9 @@
"steps": 1,
"direction": "input",
"isBypass": true,
"defaultValue": 0.0
"defaultValue": 0.0,
"minimum": 0,
"maximum": 1
}
]
}