Browse Source

Add ParamQuantity::setSmoothScaledValue().

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
4f98870e88
2 changed files with 13 additions and 5 deletions
  1. +2
    -1
      include/engine/ParamQuantity.hpp
  2. +11
    -4
      src/engine/ParamQuantity.cpp

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

@@ -63,8 +63,9 @@ struct ParamQuantity : Quantity {

Param* getParam();
/** Request to the engine to smoothly set the value */
void setSmoothValue(float smoothValue);
void setSmoothValue(float value);
float getSmoothValue();
void setSmoothScaledValue(float scaledValue);

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


+ 11
- 4
src/engine/ParamQuantity.cpp View File

@@ -16,13 +16,13 @@ engine::Param* ParamQuantity::getParam() {
return &module->params[paramId];
}

void ParamQuantity::setSmoothValue(float smoothValue) {
void ParamQuantity::setSmoothValue(float value) {
if (!module)
return;
smoothValue = math::clampSafe(smoothValue, getMinValue(), getMaxValue());
value = math::clampSafe(value, getMinValue(), getMaxValue());
if (snapEnabled)
smoothValue = std::round(smoothValue);
APP->engine->setSmoothParam(module, paramId, smoothValue);
value = std::round(value);
APP->engine->setSmoothParam(module, paramId, value);
}

float ParamQuantity::getSmoothValue() {
@@ -31,6 +31,13 @@ float ParamQuantity::getSmoothValue() {
return APP->engine->getSmoothParam(module, paramId);
}

void ParamQuantity::setSmoothScaledValue(float scaledValue) {
if (!isBounded())
setSmoothValue(scaledValue);
else
setSmoothValue(math::rescale(scaledValue, 0.f, 1.f, getMinValue(), getMaxValue()));
}

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


Loading…
Cancel
Save