Browse Source

Misc fixing

gh-pages
falkTX 9 years ago
parent
commit
9df2f7f1a3
4 changed files with 59 additions and 10 deletions
  1. +50
    -8
      distrho/DistrhoPlugin.hpp
  2. +2
    -0
      distrho/DistrhoUI.hpp
  3. +5
    -0
      distrho/DistrhoUtils.hpp
  4. +2
    -2
      distrho/extra/d_string.hpp

+ 50
- 8
distrho/DistrhoPlugin.hpp View File

@@ -69,34 +69,74 @@ struct ParameterRanges {
max = 1.0f;
}

/*!
* Fix default value within range.
*/
void fixDefault() noexcept
{
fixValue(def);
}

/*!
* Fix a value within range.
*/
void fixValue(float& value) const noexcept
{
if (value < min)
if (value <= min)
value = min;
else if (value > max)
value = max;
}

/*!
* Get a fixed value within range.
*/
float getFixedValue(const float& value) const noexcept
{
if (value < min)
if (value <= min)
return min;
else if (value > max)
if (value >= max)
return max;
return value;
}

/*!
* Get a value normalized to 0.0<->1.0.
*/
float getNormalizedValue(const float& value) const noexcept
{
const float newValue((value - min) / (max - min));
const float normValue((value - min) / (max - min));

if (newValue <= 0.0f)
if (normValue <= 0.0f)
return 0.0f;
if (newValue >= 1.0f)
if (normValue >= 1.0f)
return 1.0f;
return newValue;
return normValue;
}

/*!
* Get a value normalized to 0.0<->1.0, fixed within range.
*/
float getFixedAndNormalizedValue(const float& value) const noexcept
{
if (value <= min)
return 0.0f;
if (value >= max)
return 1.0f;

const float normValue((value - min) / (max - min));

if (normValue <= 0.0f)
return 0.0f;
if (normValue >= 1.0f)
return 1.0f;

return normValue;
}

/*!
* Get a proper value previously normalized to 0.0<->1.0.
*/
float getUnnormalizedValue(const float& value) const noexcept
{
return value * (max - min) + min;
@@ -113,7 +153,7 @@ struct Parameter {
d_string unit;
ParameterRanges ranges;

Parameter()
Parameter() noexcept
: hints(0x0) {}

void clear() noexcept
@@ -261,6 +301,8 @@ private:
struct PrivateData;
PrivateData* const pData;
friend class PluginExporter;

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Plugin)
};

// -----------------------------------------------------------------------


+ 2
- 0
distrho/DistrhoUI.hpp View File

@@ -87,6 +87,8 @@ private:
struct PrivateData;
PrivateData* const pData;
friend class UIExporter;

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Plugin)
};

// -----------------------------------------------------------------------


+ 5
- 0
distrho/DistrhoUtils.hpp View File

@@ -163,6 +163,11 @@ void d_msleep(const uint msecs)
} DISTRHO_SAFE_EXCEPTION("carla_msleep");
}

// -----------------------------------------------------------------------
// we always need this class

#include "extra/d_string.hpp"

// -----------------------------------------------------------------------

#endif // DISTRHO_UTILS_HPP_INCLUDED

+ 2
- 2
distrho/extra/d_string.hpp View File

@@ -17,7 +17,7 @@
#ifndef DISTRHO_STRING_HPP_INCLUDED
#define DISTRHO_STRING_HPP_INCLUDED

#include "../DistrhoUtils.hpp"
#include "d_leakdetector.hpp"

// -----------------------------------------------------------------------
// d_string class
@@ -709,7 +709,7 @@ private:
}
}

//DISTRHO_LEAK_DETECTOR(d_string)
DISTRHO_LEAK_DETECTOR(d_string)
DISTRHO_PREVENT_HEAP_ALLOCATION
};



Loading…
Cancel
Save