BogaudioModules

BogaudioModules for VCV Rack
Log | Files | Refs | README | LICENSE

commit fdbc9736a254ce0b9add170f5180b4bc54a94bb1
parent 31ad26eebd44bcb2d67ed6e0e645be0a65730da7
Author: Matt Demanett <matt@demanett.net>
Date:   Sat,  5 Oct 2019 23:00:26 -0400

OFFSET: fix param tooltips.

Diffstat:
Msrc/Offset.hpp | 4++--
Msrc/param_quantities.hpp | 20++++++++++++++------
2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/Offset.hpp b/src/Offset.hpp @@ -28,8 +28,8 @@ struct Offset : DisableOutputLimitModule { Offset() { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS); - configParam(OFFSET_PARAM, -1.0f, 1.0f, 0.0f, "Offset", " V", 0.0f, 5.0f); - configParam(SCALE_PARAM, -1.0f, 1.0f, 0.316f, "Scale", "%", 0.0f, 100.0f); + configParam(OFFSET_PARAM, -1.0f, 1.0f, 0.0f, "Offset", " V", 0.0f, 10.0f); + configParam<TenXSquaringParamQuantity>(SCALE_PARAM, -1.0f, 1.0f, 0.31623f, "Scale", "x"); } int channels() override; diff --git a/src/param_quantities.hpp b/src/param_quantities.hpp @@ -17,18 +17,26 @@ struct ScaledSquaringParamQuantity : ParamQuantity { return v; } - v *= v; - v *= (float)scale; - return v; + float vv = v * v; + vv *= (float)scale; + if (v < 0.0f) { + return -vv; + } + return vv; } void setDisplayValue(float displayValue) override { if (!module) { return; } - displayValue /= (float)scale; - displayValue = powf(displayValue, 0.5f); - setValue(displayValue); + float v = fabsf(displayValue) / (float)scale; + v = powf(v, 0.5f); + if (displayValue < 0.0f) { + setValue(-v); + } + else { + setValue(v); + } } };