From 7bf5d69c1ba550f81fc555f7b8dc07e70c1c6121 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 21 Jun 2022 12:45:47 +0100 Subject: [PATCH] Support mod:volts as LV2 unit Signed-off-by: falkTX --- source/backend/plugin/CarlaPluginLV2.cpp | 3 +++ source/includes/lv2_rdf.hpp | 2 ++ source/utils/CarlaLv2Utils.hpp | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/source/backend/plugin/CarlaPluginLV2.cpp b/source/backend/plugin/CarlaPluginLV2.cpp index 8217491b9..43de41e71 100644 --- a/source/backend/plugin/CarlaPluginLV2.cpp +++ b/source/backend/plugin/CarlaPluginLV2.cpp @@ -1271,6 +1271,9 @@ public: case LV2_PORT_UNIT_SEMITONE: std::strncpy(strBuf, "semi", STR_MAX); return true; + case LV2_PORT_UNIT_VOLTS: + std::strncpy(strBuf, "v", STR_MAX); + return true; } } } diff --git a/source/includes/lv2_rdf.hpp b/source/includes/lv2_rdf.hpp index 5abe39f92..1450350b0 100644 --- a/source/includes/lv2_rdf.hpp +++ b/source/includes/lv2_rdf.hpp @@ -96,6 +96,7 @@ typedef uint32_t LV2_Property; #define LV2_PORT_UNIT_PC 22 #define LV2_PORT_UNIT_S 23 #define LV2_PORT_UNIT_SEMITONE 24 +#define LV2_PORT_UNIT_VOLTS 25 #define LV2_IS_PORT_UNIT_BAR(x) ((x) == LV2_PORT_UNIT_BAR) #define LV2_IS_PORT_UNIT_BEAT(x) ((x) == LV2_PORT_UNIT_BEAT) @@ -121,6 +122,7 @@ typedef uint32_t LV2_Property; #define LV2_IS_PORT_UNIT_PC(x) ((x) == LV2_PORT_UNIT_PC) #define LV2_IS_PORT_UNIT_S(x) ((x) == LV2_PORT_UNIT_S) #define LV2_IS_PORT_UNIT_SEMITONE(x) ((x) == LV2_PORT_UNIT_SEMITONE) +#define LV2_IS_PORT_UNIT_VOLTS(x) ((x) == LV2_PORT_UNIT_VOLTS) // Port Types #define LV2_PORT_INPUT 0x001 diff --git a/source/utils/CarlaLv2Utils.hpp b/source/utils/CarlaLv2Utils.hpp index fe6dac311..e3246c8df 100644 --- a/source/utils/CarlaLv2Utils.hpp +++ b/source/utils/CarlaLv2Utils.hpp @@ -2291,6 +2291,8 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool loadPresets) rdfPort->Unit.Unit = LV2_PORT_UNIT_S; else if (std::strcmp(unitUnit, LV2_UNITS__semitone12TET) == 0) rdfPort->Unit.Unit = LV2_PORT_UNIT_SEMITONE; + else if (std::strcmp(unitUnit, "http://moddevices.com/ns/mod#volts") == 0) + rdfPort->Unit.Unit = LV2_PORT_UNIT_VOLTS; else carla_stderr("lv2_rdf_new(\"%s\") - got unknown unit '%s'", uri, unitUnit); } @@ -2603,6 +2605,8 @@ const LV2_RDF_Descriptor* lv2_rdf_new(const LV2_URI uri, const bool loadPresets) rdfParam.Unit.Unit = LV2_PORT_UNIT_S; else if (std::strcmp(unitUnit, LV2_UNITS__semitone12TET) == 0) rdfParam.Unit.Unit = LV2_PORT_UNIT_SEMITONE; + else if (std::strcmp(unitUnit, "http://moddevices.com/ns/mod#volts") == 0) + rdfParam.Unit.Unit = LV2_PORT_UNIT_VOLTS; else carla_stderr("lv2_rdf_new(\"%s\") - got unknown unit '%s'", uri, unitUnit); }