From a0fd7cbfc5ce6d35968d7d172b75f10c77cdccfa Mon Sep 17 00:00:00 2001 From: Christopher Arndt Date: Tue, 13 Aug 2019 18:46:27 +0200 Subject: [PATCH] [VST] Round integer param values after de-normalizing (fixes #171) (#172) * [VST] Round integer param values after de-normalizing (fixes #171) Signed-off-by: Christopher Arndt * Also use unnormalized value for boolean params Signed-off-by: Christopher Arndt --- distrho/src/DistrhoPluginVST.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/distrho/src/DistrhoPluginVST.cpp b/distrho/src/DistrhoPluginVST.cpp index c77b7af4..91446be8 100644 --- a/distrho/src/DistrhoPluginVST.cpp +++ b/distrho/src/DistrhoPluginVST.cpp @@ -575,7 +575,7 @@ public: else { d_lastUiSampleRate = fPlugin.getSampleRate(); - + // TODO const float scaleFactor = 1.0f; @@ -598,7 +598,7 @@ public: } # endif d_lastUiSampleRate = fPlugin.getSampleRate(); - + // TODO const float scaleFactor = 1.0f; @@ -925,18 +925,20 @@ public: const uint32_t hints(fPlugin.getParameterHints(index)); const ParameterRanges& ranges(fPlugin.getParameterRanges(index)); + value = ranges.getUnnormalizedValue(value); + if (hints & kParameterIsBoolean) { const float midRange = ranges.min + (ranges.max - ranges.min) / 2.0f; - value = value > midRange ? ranges.max : ranges.min; } - else if (hints & kParameterIsInteger) + + if (hints & kParameterIsInteger) { value = std::round(value); } - const float realValue(ranges.getUnnormalizedValue(value)); + const float realValue(value); fPlugin.setParameterValue(index, realValue); #if DISTRHO_PLUGIN_HAS_UI @@ -1306,7 +1308,7 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t case effGetParameterProperties: if (ptr != nullptr && index < static_cast(plugin.getParameterCount())) { - if (VstParameterProperties* const properties = (VstParameterProperties*)ptr) + if (VstParameterProperties* const properties = (VstParameterProperties*)ptr) { memset(properties, 0, sizeof(VstParameterProperties));