Browse Source

Add ParamQuantity::getScaledValue().

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
b9d91b85af
2 changed files with 10 additions and 0 deletions
  1. +1
    -0
      include/engine/ParamQuantity.hpp
  2. +9
    -0
      src/engine/ParamQuantity.cpp

+ 1
- 0
include/engine/ParamQuantity.hpp View File

@@ -66,6 +66,7 @@ struct ParamQuantity : Quantity {
void setSmoothValue(float value);
float getSmoothValue();
void setSmoothScaledValue(float scaledValue);
float getSmoothScaledValue();

void setValue(float value) override;
float getValue() override;


+ 9
- 0
src/engine/ParamQuantity.cpp View File

@@ -38,6 +38,15 @@ void ParamQuantity::setSmoothScaledValue(float scaledValue) {
setSmoothValue(math::rescale(scaledValue, 0.f, 1.f, getMinValue(), getMaxValue()));
}

float ParamQuantity::getScaledValue() {
if (!isBounded())
return getSmoothValue();
else if (getMinValue() == getMaxValue())
return 0.f;
else
return math::rescale(getSmoothValue(), getMinValue(), getMaxValue(), 0.f, 1.f);
}

void ParamQuantity::setValue(float value) {
if (!module)
return;


Loading…
Cancel
Save