Browse Source

[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 <chris@chrisarndt.de>

* Also use unnormalized value for boolean params

Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
pull/175/head
Christopher Arndt Filipe Coelho <falktx@gmail.com> 5 years ago
parent
commit
a0fd7cbfc5
1 changed files with 8 additions and 6 deletions
  1. +8
    -6
      distrho/src/DistrhoPluginVST.cpp

+ 8
- 6
distrho/src/DistrhoPluginVST.cpp View File

@@ -575,7 +575,7 @@ public:
else else
{ {
d_lastUiSampleRate = fPlugin.getSampleRate(); d_lastUiSampleRate = fPlugin.getSampleRate();
// TODO // TODO
const float scaleFactor = 1.0f; const float scaleFactor = 1.0f;


@@ -598,7 +598,7 @@ public:
} }
# endif # endif
d_lastUiSampleRate = fPlugin.getSampleRate(); d_lastUiSampleRate = fPlugin.getSampleRate();
// TODO // TODO
const float scaleFactor = 1.0f; const float scaleFactor = 1.0f;


@@ -925,18 +925,20 @@ public:
const uint32_t hints(fPlugin.getParameterHints(index)); const uint32_t hints(fPlugin.getParameterHints(index));
const ParameterRanges& ranges(fPlugin.getParameterRanges(index)); const ParameterRanges& ranges(fPlugin.getParameterRanges(index));


value = ranges.getUnnormalizedValue(value);

if (hints & kParameterIsBoolean) if (hints & kParameterIsBoolean)
{ {
const float midRange = ranges.min + (ranges.max - ranges.min) / 2.0f; const float midRange = ranges.min + (ranges.max - ranges.min) / 2.0f;

value = value > midRange ? ranges.max : ranges.min; value = value > midRange ? ranges.max : ranges.min;
} }
else if (hints & kParameterIsInteger)

if (hints & kParameterIsInteger)
{ {
value = std::round(value); value = std::round(value);
} }


const float realValue(ranges.getUnnormalizedValue(value));
const float realValue(value);
fPlugin.setParameterValue(index, realValue); fPlugin.setParameterValue(index, realValue);


#if DISTRHO_PLUGIN_HAS_UI #if DISTRHO_PLUGIN_HAS_UI
@@ -1306,7 +1308,7 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
case effGetParameterProperties: case effGetParameterProperties:
if (ptr != nullptr && index < static_cast<int32_t>(plugin.getParameterCount())) if (ptr != nullptr && index < static_cast<int32_t>(plugin.getParameterCount()))
{ {
if (VstParameterProperties* const properties = (VstParameterProperties*)ptr)
if (VstParameterProperties* const properties = (VstParameterProperties*)ptr)
{ {
memset(properties, 0, sizeof(VstParameterProperties)); memset(properties, 0, sizeof(VstParameterProperties));




Loading…
Cancel
Save