diff --git a/source/backend/CarlaBackend.h b/source/backend/CarlaBackend.h index 9d7baba08..de0c65394 100644 --- a/source/backend/CarlaBackend.h +++ b/source/backend/CarlaBackend.h @@ -20,6 +20,8 @@ #include "CarlaDefines.h" +#include + #ifdef CARLA_PROPER_CPP11_SUPPORT # include #else @@ -1384,6 +1386,19 @@ typedef struct { return value * (max - min) + min; } + + /*! + * Get a logarithmic value previously normalized to 0.0<->1.0. + */ + float getUnnormalizedLogValue(const float& value) const noexcept + { + if (value <= 0.0f) + return min; + if (value >= 1.0f) + return max; + + return min * std::pow(max/min, value); + } #endif /* __cplusplus */ } ParameterRanges; diff --git a/source/backend/plugin/CarlaPluginDSSI.cpp b/source/backend/plugin/CarlaPluginDSSI.cpp index 01d535674..441f9f47f 100644 --- a/source/backend/plugin/CarlaPluginDSSI.cpp +++ b/source/backend/plugin/CarlaPluginDSSI.cpp @@ -1533,7 +1533,10 @@ public: } else { - value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); + if (pData->param.data[k].hints & PARAMETER_IS_LOGARITHMIC) + value = pData->param.ranges[k].getUnnormalizedLogValue(ctrlEvent.value); + else + value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); if (pData->param.data[k].hints & PARAMETER_IS_INTEGER) value = std::rint(value); diff --git a/source/backend/plugin/CarlaPluginFluidSynth.cpp b/source/backend/plugin/CarlaPluginFluidSynth.cpp index 0da797b3c..227186f05 100644 --- a/source/backend/plugin/CarlaPluginFluidSynth.cpp +++ b/source/backend/plugin/CarlaPluginFluidSynth.cpp @@ -1192,7 +1192,10 @@ public: } else { - value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); + if (pData->param.data[k].hints & PARAMETER_IS_LOGARITHMIC) + value = pData->param.ranges[k].getUnnormalizedLogValue(ctrlEvent.value); + else + value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); if (pData->param.data[k].hints & PARAMETER_IS_INTEGER) value = std::rint(value); diff --git a/source/backend/plugin/CarlaPluginJuce.cpp b/source/backend/plugin/CarlaPluginJuce.cpp index ec2bc5b8f..dee95368e 100644 --- a/source/backend/plugin/CarlaPluginJuce.cpp +++ b/source/backend/plugin/CarlaPluginJuce.cpp @@ -824,7 +824,10 @@ public: } else { - value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); + if (pData->param.data[k].hints & PARAMETER_IS_LOGARITHMIC) + value = pData->param.ranges[k].getUnnormalizedLogValue(ctrlEvent.value); + else + value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); if (pData->param.data[k].hints & PARAMETER_IS_INTEGER) value = std::rint(value); diff --git a/source/backend/plugin/CarlaPluginLADSPA.cpp b/source/backend/plugin/CarlaPluginLADSPA.cpp index ade264bcb..e2407ec94 100644 --- a/source/backend/plugin/CarlaPluginLADSPA.cpp +++ b/source/backend/plugin/CarlaPluginLADSPA.cpp @@ -1026,7 +1026,10 @@ public: } else { - value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); + if (pData->param.data[k].hints & PARAMETER_IS_LOGARITHMIC) + value = pData->param.ranges[k].getUnnormalizedLogValue(ctrlEvent.value); + else + value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); if (pData->param.data[k].hints & PARAMETER_IS_INTEGER) value = std::rint(value); diff --git a/source/backend/plugin/CarlaPluginLV2.cpp b/source/backend/plugin/CarlaPluginLV2.cpp index ac8741654..405573af6 100644 --- a/source/backend/plugin/CarlaPluginLV2.cpp +++ b/source/backend/plugin/CarlaPluginLV2.cpp @@ -3168,7 +3168,10 @@ public: } else { - value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); + if (pData->param.data[k].hints & PARAMETER_IS_LOGARITHMIC) + value = pData->param.ranges[k].getUnnormalizedLogValue(ctrlEvent.value); + else + value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); if (pData->param.data[k].hints & PARAMETER_IS_INTEGER) value = std::rint(value); diff --git a/source/backend/plugin/CarlaPluginNative.cpp b/source/backend/plugin/CarlaPluginNative.cpp index 01e5cde84..18c7b7ad2 100644 --- a/source/backend/plugin/CarlaPluginNative.cpp +++ b/source/backend/plugin/CarlaPluginNative.cpp @@ -1560,7 +1560,10 @@ public: } else { - value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); + if (pData->param.data[k].hints & PARAMETER_IS_LOGARITHMIC) + value = pData->param.ranges[k].getUnnormalizedLogValue(ctrlEvent.value); + else + value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); if (pData->param.data[k].hints & PARAMETER_IS_INTEGER) value = std::rint(value); diff --git a/source/backend/plugin/CarlaPluginVST2.cpp b/source/backend/plugin/CarlaPluginVST2.cpp index ce9cdd682..6ac905b3d 100644 --- a/source/backend/plugin/CarlaPluginVST2.cpp +++ b/source/backend/plugin/CarlaPluginVST2.cpp @@ -1279,7 +1279,10 @@ public: } else { - value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); + if (pData->param.data[k].hints & PARAMETER_IS_LOGARITHMIC) + value = pData->param.ranges[k].getUnnormalizedLogValue(ctrlEvent.value); + else + value = pData->param.ranges[k].getUnnormalizedValue(ctrlEvent.value); if (pData->param.data[k].hints & PARAMETER_IS_INTEGER) value = std::rint(value);