Browse Source

Add unused PluginParameterData::getFinalValueWithMidiDelta()

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.2.0-RC1
falkTX 4 years ago
parent
commit
b4eac526e2
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 61 additions and 7 deletions
  1. +59
    -6
      source/backend/plugin/CarlaPluginInternal.cpp
  2. +2
    -1
      source/backend/plugin/CarlaPluginInternal.hpp

+ 59
- 6
source/backend/plugin/CarlaPluginInternal.cpp View File

@@ -1,6 +1,6 @@
/* /*
* Carla Plugin * Carla Plugin
* Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2020 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -20,6 +20,7 @@


#include "CarlaLibCounter.hpp" #include "CarlaLibCounter.hpp"
#include "CarlaMathUtils.hpp" #include "CarlaMathUtils.hpp"
#include "CarlaMIDI.h"


CARLA_BACKEND_START_NAMESPACE CARLA_BACKEND_START_NAMESPACE


@@ -311,9 +312,10 @@ static float _getUnnormalizedLogValue(const float min, const float max, const fl
return rmin * std::pow(max/rmin, value); return rmin * std::pow(max/rmin, value);
} }


float PluginParameterData::getFinalUnnormalizedValue(const uint32_t parameterId, float value) const noexcept
float PluginParameterData::getFinalUnnormalizedValue(const uint32_t parameterId,
const float normalizedValue) const noexcept
{ {
float min, max;
float min, max, value;


if (data[parameterId].mappedControlIndex != CONTROL_INDEX_CV if (data[parameterId].mappedControlIndex != CONTROL_INDEX_CV
&& (data[parameterId].hints & PARAMETER_MAPPED_RANGES_SET) != 0x0) && (data[parameterId].hints & PARAMETER_MAPPED_RANGES_SET) != 0x0)
@@ -329,14 +331,14 @@ float PluginParameterData::getFinalUnnormalizedValue(const uint32_t parameterId,


if (data[parameterId].hints & PARAMETER_IS_BOOLEAN) if (data[parameterId].hints & PARAMETER_IS_BOOLEAN)
{ {
value = (value < 0.5f) ? min : max;
value = (normalizedValue < 0.5f) ? min : max;
} }
else else
{ {
if (data[parameterId].hints & PARAMETER_IS_LOGARITHMIC) if (data[parameterId].hints & PARAMETER_IS_LOGARITHMIC)
value = _getUnnormalizedLogValue(min, max, value);
value = _getUnnormalizedLogValue(min, max, normalizedValue);
else else
value = _getUnnormalizedValue(min, max, value);
value = _getUnnormalizedValue(min, max, normalizedValue);


if (data[parameterId].hints & PARAMETER_IS_INTEGER) if (data[parameterId].hints & PARAMETER_IS_INTEGER)
value = std::rint(value); value = std::rint(value);
@@ -345,6 +347,57 @@ float PluginParameterData::getFinalUnnormalizedValue(const uint32_t parameterId,
return value; return value;
} }


float PluginParameterData::getFinalValueWithMidiDelta(const uint32_t parameterId,
float value, int8_t delta) const noexcept
{
if (delta < 0)
return value;
if (data[parameterId].mappedControlIndex <= 0 || data[parameterId].mappedControlIndex >= MAX_MIDI_CONTROL)
return value;

float min, max;

if ((data[parameterId].hints & PARAMETER_MAPPED_RANGES_SET) != 0x0)
{
min = data[parameterId].mappedMinimum;
max = data[parameterId].mappedMaximum;
}
else
{
min = ranges[parameterId].min;
max = ranges[parameterId].max;
}

if (data[parameterId].hints & PARAMETER_IS_BOOLEAN)
{
value = delta > 63 ? min : max;
}
else
{
if (data[parameterId].hints & PARAMETER_IS_INTEGER)
{
if (delta > 63)
value += delta - 128.0f;
else
value += delta;
}
else
{
if (delta > 63)
delta = delta - 128;

value += (max - min) * (static_cast<float>(delta) / 127.0f);
}

if (value < min)
value = min;
else if (value > max)
value = max;
}

return value;
}

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// PluginProgramData // PluginProgramData




+ 2
- 1
source/backend/plugin/CarlaPluginInternal.hpp View File

@@ -182,7 +182,8 @@ struct PluginParameterData {
void createNew(uint32_t newCount, bool withSpecial); void createNew(uint32_t newCount, bool withSpecial);
void clear() noexcept; void clear() noexcept;
float getFixedValue(uint32_t parameterId, float value) const noexcept; float getFixedValue(uint32_t parameterId, float value) const noexcept;
float getFinalUnnormalizedValue(uint32_t parameterId, float value) const noexcept;
float getFinalUnnormalizedValue(uint32_t parameterId, float normalizedValue) const noexcept;
float getFinalValueWithMidiDelta(uint32_t parameterId, float value, int8_t delta) const noexcept;


CARLA_DECLARE_NON_COPY_STRUCT(PluginParameterData) CARLA_DECLARE_NON_COPY_STRUCT(PluginParameterData)
}; };


Loading…
Cancel
Save