Browse Source

Make MIDI CC events apply in log scale if needed

This helps #387, but rule is defined by the plugin.
Later on the user must be able to choose the scale mode
(among other things)
tags/1.9.7
falkTX 8 years ago
parent
commit
5991c38360
8 changed files with 43 additions and 7 deletions
  1. +15
    -0
      source/backend/CarlaBackend.h
  2. +4
    -1
      source/backend/plugin/CarlaPluginDSSI.cpp
  3. +4
    -1
      source/backend/plugin/CarlaPluginFluidSynth.cpp
  4. +4
    -1
      source/backend/plugin/CarlaPluginJuce.cpp
  5. +4
    -1
      source/backend/plugin/CarlaPluginLADSPA.cpp
  6. +4
    -1
      source/backend/plugin/CarlaPluginLV2.cpp
  7. +4
    -1
      source/backend/plugin/CarlaPluginNative.cpp
  8. +4
    -1
      source/backend/plugin/CarlaPluginVST2.cpp

+ 15
- 0
source/backend/CarlaBackend.h View File

@@ -20,6 +20,8 @@

#include "CarlaDefines.h"

#include <cmath>

#ifdef CARLA_PROPER_CPP11_SUPPORT
# include <cstdint>
#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;


+ 4
- 1
source/backend/plugin/CarlaPluginDSSI.cpp View File

@@ -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);


+ 4
- 1
source/backend/plugin/CarlaPluginFluidSynth.cpp View File

@@ -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);


+ 4
- 1
source/backend/plugin/CarlaPluginJuce.cpp View File

@@ -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);


+ 4
- 1
source/backend/plugin/CarlaPluginLADSPA.cpp View File

@@ -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);


+ 4
- 1
source/backend/plugin/CarlaPluginLV2.cpp View File

@@ -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);


+ 4
- 1
source/backend/plugin/CarlaPluginNative.cpp View File

@@ -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);


+ 4
- 1
source/backend/plugin/CarlaPluginVST2.cpp View File

@@ -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);


Loading…
Cancel
Save