|
|
@@ -1,6 +1,7 @@ |
|
|
|
#pragma once |
|
|
|
#include "ui/Quantity.hpp" |
|
|
|
#include "engine/Module.hpp" |
|
|
|
#include "engine/Param.hpp" |
|
|
|
|
|
|
|
|
|
|
|
namespace rack { |
|
|
@@ -16,70 +17,19 @@ struct ParamQuantity : Quantity { |
|
|
|
bool snap = false; |
|
|
|
float snapValue = 0.f; |
|
|
|
|
|
|
|
Param *getParam() { |
|
|
|
assert(module); |
|
|
|
return &module->params[paramId]; |
|
|
|
} |
|
|
|
|
|
|
|
void commitSnap() { |
|
|
|
// TODO |
|
|
|
} |
|
|
|
|
|
|
|
void setValue(float value) override { |
|
|
|
// TODO Smooth |
|
|
|
// TODO Snap |
|
|
|
getParam()->value = value; |
|
|
|
} |
|
|
|
|
|
|
|
float getValue() override { |
|
|
|
return getParam()->value; |
|
|
|
} |
|
|
|
|
|
|
|
float getMinValue() override { |
|
|
|
return getParam()->minValue; |
|
|
|
} |
|
|
|
|
|
|
|
float getMaxValue() override { |
|
|
|
return getParam()->maxValue; |
|
|
|
} |
|
|
|
|
|
|
|
float getDefaultValue() override { |
|
|
|
return getParam()->defaultValue; |
|
|
|
} |
|
|
|
|
|
|
|
float getDisplayValue() override { |
|
|
|
if (getParam()->displayBase == 0.f) { |
|
|
|
// Linear |
|
|
|
return getParam()->value * getParam()->displayMultiplier; |
|
|
|
} |
|
|
|
else { |
|
|
|
// Exponential |
|
|
|
return std::pow(getParam()->displayBase, getParam()->value) * getParam()->displayMultiplier; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void setDisplayValue(float displayValue) override { |
|
|
|
if (getParam()->displayBase == 0.f) { |
|
|
|
// Linear |
|
|
|
getParam()->value = displayValue / getParam()->displayMultiplier; |
|
|
|
} |
|
|
|
else { |
|
|
|
// Exponential |
|
|
|
getParam()->value = std::log(displayValue / getParam()->displayMultiplier) / std::log(getParam()->displayBase); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int getDisplayPrecision() override { |
|
|
|
return getParam()->displayPrecision; |
|
|
|
} |
|
|
|
|
|
|
|
std::string getLabel() override { |
|
|
|
return getParam()->label; |
|
|
|
} |
|
|
|
|
|
|
|
std::string getUnit() override { |
|
|
|
return getParam()->unit; |
|
|
|
} |
|
|
|
Param *getParam(); |
|
|
|
void commitSnap(); |
|
|
|
|
|
|
|
void setValue(float value) override; |
|
|
|
float getValue() override; |
|
|
|
float getMinValue() override; |
|
|
|
float getMaxValue() override; |
|
|
|
float getDefaultValue() override; |
|
|
|
float getDisplayValue() override; |
|
|
|
void setDisplayValue(float displayValue) override ; |
|
|
|
int getDisplayPrecision() override; |
|
|
|
std::string getLabel() override; |
|
|
|
std::string getUnit() override; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|