From aa20320f9a64ddcdf8d00e59fd8d06e35fec51ce Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 24 May 2021 09:58:48 +0100 Subject: [PATCH] Fix integer rounding for exported lv2 enumerations Closes #270 Fixes #258 Signed-off-by: falkTX --- distrho/src/DistrhoPluginLV2export.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/distrho/src/DistrhoPluginLV2export.cpp b/distrho/src/DistrhoPluginLV2export.cpp index c074109b..5645ab0f 100644 --- a/distrho/src/DistrhoPluginLV2export.cpp +++ b/distrho/src/DistrhoPluginLV2export.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2020 Filipe Coelho + * Copyright (C) 2012-2021 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -608,11 +608,13 @@ void lv2_generate_ttl(const char* const basename) pluginString += " rdfs:label \"\"\"" + enumValue.label + "\"\"\" ;\n"; - if (plugin.getParameterHints(i) & kParameterIsInteger) { - const int roundedValue = (int)(enumValue.value + 0.5f); + if (plugin.getParameterHints(i) & kParameterIsInteger) + { + const int roundedValue = (int)(enumValue.value + enumValue.value < 0.0f ? -0.5f : 0.5f); pluginString += " rdf:value " + String(roundedValue) + " ;\n"; } - else { + else + { pluginString += " rdf:value " + String(enumValue.value) + " ;\n"; }