commit 9df2f7f1a3b295bacf5a75f0c6cbc27845fe1a22
parent 90a3485ca0e8f459af3002743f9f2ecd03c6a6cb
Author: falkTX <falktx@gmail.com>
Date: Fri, 25 Apr 2014 19:36:41 +0100
Misc fixing
Diffstat:
4 files changed, 59 insertions(+), 10 deletions(-)
diff --git a/distrho/DistrhoPlugin.hpp b/distrho/DistrhoPlugin.hpp
@@ -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)
};
// -----------------------------------------------------------------------
diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp
@@ -87,6 +87,8 @@ private:
struct PrivateData;
PrivateData* const pData;
friend class UIExporter;
+
+ DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Plugin)
};
// -----------------------------------------------------------------------
diff --git a/distrho/DistrhoUtils.hpp b/distrho/DistrhoUtils.hpp
@@ -164,5 +164,10 @@ void d_msleep(const uint msecs)
}
// -----------------------------------------------------------------------
+// we always need this class
+
+#include "extra/d_string.hpp"
+
+// -----------------------------------------------------------------------
#endif // DISTRHO_UTILS_HPP_INCLUDED
diff --git a/distrho/extra/d_string.hpp b/distrho/extra/d_string.hpp
@@ -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
};