diff --git a/compile.mk b/compile.mk index d3063d41..879d66e6 100644 --- a/compile.mk +++ b/compile.mk @@ -11,7 +11,7 @@ FLAGS += -MMD -MP # Debugger symbols. These are removed with `strip`. FLAGS += -g # Optimization -FLAGS += -O3 -march=nocona +FLAGS += -O3 -march=nocona -funsafe-math-optimizations # Warnings FLAGS += -Wall -Wextra -Wno-unused-parameter diff --git a/include/math.hpp b/include/math.hpp index db4b5099..a4713570 100644 --- a/include/math.hpp +++ b/include/math.hpp @@ -109,6 +109,7 @@ inline float sgn(float x) { } /** Converts -0.f to 0.f. Leaves all other values unchanged. */ +__attribute__((optimize("signed-zeros"))) inline float normalizeZero(float x) { return x + 0.f; } diff --git a/include/rack0.hpp b/include/rack0.hpp index 0fc7ce83..b71ec1ad 100644 --- a/include/rack0.hpp +++ b/include/rack0.hpp @@ -22,11 +22,11 @@ DEPRECATED inline int min(int a, int b) {return std::min(a, b);} DEPRECATED inline int max(int a, int b) {return std::max(a, b);} DEPRECATED inline int eucmod(int a, int base) {return eucMod(a, base);} DEPRECATED inline bool ispow2(int n) {return isPow2(n);} -DEPRECATED inline int clamp2(int x, int a, int b) {return clampBetween(x, a, b);} +DEPRECATED inline int clamp2(int x, int a, int b) {return clampSafe(x, a, b);} DEPRECATED inline float min(float a, float b) {return std::min(a, b);} DEPRECATED inline float max(float a, float b) {return std::max(a, b);} DEPRECATED inline float eucmod(float a, float base) {return eucMod(a, base);} -DEPRECATED inline float clamp2(float x, float a, float b) {return clampBetween(x, a, b);} +DEPRECATED inline float clamp2(float x, float a, float b) {return clampSafe(x, a, b);} DEPRECATED inline int mini(int a, int b) {return std::min(a, b);} DEPRECATED inline int maxi(int a, int b) {return std::max(a, b);} @@ -40,12 +40,12 @@ DEPRECATED inline float sgnf(float x) {return sgn(x);} DEPRECATED inline float eucmodf(float a, float base) {return eucMod(a, base);} DEPRECATED inline bool nearf(float a, float b, float epsilon = 1.0e-6f) {return math::isNear(a, b, epsilon);} DEPRECATED inline float clampf(float x, float min, float max) {return math::clamp(x, min, max);} -DEPRECATED inline float clamp2f(float x, float min, float max) {return clampBetween(x, min, max);} +DEPRECATED inline float clamp2f(float x, float min, float max) {return clampSafe(x, min, max);} DEPRECATED inline float chopf(float x, float eps) {return chop(x, eps);} DEPRECATED inline float rescalef(float x, float a, float b, float yMin, float yMax) {return math::rescale(x, a, b, yMin, yMax);} DEPRECATED inline float crossf(float a, float b, float frac) {return crossfade(a, b, frac);} DEPRECATED inline float interpf(const float *p, float x) {return interpolateLinear(p, x);} -DEPRECATED inline void cmultf(float *cr, float *ci, float ar, float ai, float br, float bi) {return cmult(cr, ci, ar, ai, br, bi);} +DEPRECATED inline void cmultf(float *cr, float *ci, float ar, float ai, float br, float bi) {return complexMult(cr, ci, ar, ai, br, bi);} //////////////////// // random diff --git a/src/app/ParamQuantity.cpp b/src/app/ParamQuantity.cpp index 9caa6d3d..21ebcc1e 100644 --- a/src/app/ParamQuantity.cpp +++ b/src/app/ParamQuantity.cpp @@ -60,7 +60,7 @@ float ParamQuantity::getDisplayValue() { return Quantity::getDisplayValue(); if (getParam()->displayBase == 0.f) { // Linear - return getValue() * getParam()->displayMultiplier; + return getSmoothValue() * getParam()->displayMultiplier; } else if (getParam()->displayBase == 1.f) { // Fixed (special case of exponential) @@ -68,7 +68,7 @@ float ParamQuantity::getDisplayValue() { } else { // Exponential - return std::pow(getParam()->displayBase, getValue()) * getParam()->displayMultiplier; + return std::pow(getParam()->displayBase, getSmoothValue()) * getParam()->displayMultiplier; } } @@ -92,13 +92,7 @@ void ParamQuantity::setDisplayValue(float displayValue) { int ParamQuantity::getDisplayPrecision() { if (!module) return Quantity::getDisplayPrecision(); - float displayValue = getDisplayValue(); - if (displayValue == 0.f) - return 0; - if (std::round(displayValue) == displayValue) - return 0; - float log = std::log10(std::abs(getDisplayValue())); - return (int) std::ceil(math::clamp(-log + 3.f, 0.f, 6.f)); + return 5; } std::string ParamQuantity::getDisplayValueString() { diff --git a/src/ui/Quantity.cpp b/src/ui/Quantity.cpp index f2302f5d..dbdab9b2 100644 --- a/src/ui/Quantity.cpp +++ b/src/ui/Quantity.cpp @@ -6,7 +6,7 @@ namespace rack { std::string Quantity::getDisplayValueString() { - return string::f("%.*f", getDisplayPrecision(), math::normalizeZero(getDisplayValue())); + return string::f("%.*g", getDisplayPrecision(), math::normalizeZero(getDisplayValue())); } void Quantity::setDisplayValueString(std::string s) {