From 2cb60340d0d041c4310578e0d4a9da28f3a8d6d9 Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Fri, 5 Jan 2024 15:35:39 +0100 Subject: [PATCH] now with minimum and maximum --- templates/lv2/data/manifest.ttl | 8 +++++++- templates/lv2/tibia-index.js | 8 +++++++- test/lv2.json | 2 +- test/plugin.h | 8 +++++--- test/product.json | 8 ++++++-- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/templates/lv2/data/manifest.ttl b/templates/lv2/data/manifest.ttl index 7d5670d..a0f51c9 100644 --- a/templates/lv2/data/manifest.ttl +++ b/templates/lv2/data/manifest.ttl @@ -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}} diff --git a/templates/lv2/tibia-index.js b/templates/lv2/tibia-index.js index 1d810e0..0aa3527 100644 --- a/templates/lv2/tibia-index.js +++ b/templates/lv2/tibia-index.js @@ -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); } diff --git a/test/lv2.json b/test/lv2.json index 994c838..25c438e 100644 --- a/test/lv2.json +++ b/test/lv2.json @@ -1,7 +1,7 @@ { "lv2": { "prefixes": { - "example": "https://www.example.com/" + "example": "http://www.example.com/" }, "uri": "@example:tibia_test", "project": "@example:project", diff --git a/test/plugin.h b/test/plugin.h index 7253db1..80a425e 100644 --- a/test/plugin.h +++ b/test/plugin.h @@ -1,3 +1,5 @@ +#include + 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]; } diff --git a/test/product.json b/test/product.json index bba7f18..31bf5ae 100644 --- a/test/product.json +++ b/test/product.json @@ -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 } ] }