From d3f1a4c469e4d112b89c3f054fff160b7e9b50a7 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 21 Aug 2018 20:51:49 +0200 Subject: [PATCH] Add enumeration to one of nekobi's knobs --- dpf/distrho/src/DistrhoPluginVST.cpp | 15 ++++++++++++++- plugins/Nekobi/DistrhoPluginNekobi.cpp | 10 ++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/dpf/distrho/src/DistrhoPluginVST.cpp b/dpf/distrho/src/DistrhoPluginVST.cpp index 2f389ed..a4543da 100644 --- a/dpf/distrho/src/DistrhoPluginVST.cpp +++ b/dpf/distrho/src/DistrhoPluginVST.cpp @@ -906,9 +906,22 @@ public: return ranges.getNormalizedValue(fPlugin.getParameterValue(index)); } - void vst_setParameter(const int32_t index, const float value) + void vst_setParameter(const int32_t index, float value) { + const uint32_t hints(fPlugin.getParameterHints(index)); const ParameterRanges& ranges(fPlugin.getParameterRanges(index)); + + 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) + { + value = std::round(value); + } + const float realValue(ranges.getUnnormalizedValue(value)); fPlugin.setParameterValue(index, realValue); diff --git a/plugins/Nekobi/DistrhoPluginNekobi.cpp b/plugins/Nekobi/DistrhoPluginNekobi.cpp index 15839d0..d41f97e 100644 --- a/plugins/Nekobi/DistrhoPluginNekobi.cpp +++ b/plugins/Nekobi/DistrhoPluginNekobi.cpp @@ -170,6 +170,16 @@ void DistrhoPluginNekobi::initParameter(uint32_t index, Parameter& parameter) parameter.ranges.def = 0.0f; parameter.ranges.min = 0.0f; parameter.ranges.max = 1.0f; + parameter.enumValues.count = 2; + parameter.enumValues.restrictedMode = true; + { + ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[2]; + enumValues[0].value = 0.0f; + enumValues[0].label = "Square"; + enumValues[1].value = 1.0f; + enumValues[1].label = "Triangle"; + parameter.enumValues.values = enumValues; + } break; case paramTuning: parameter.hints = kParameterIsAutomable; // was 0.5 <-> 2.0, log