BogaudioModules

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

commit e791978fd4f9e5cc0cd7fd42d7ded315128d075e
parent 592aead62e76e1a3f87dae213007ddfb8c4a826d
Author: Matt Demanett <matt@demanett.net>
Date:   Sun, 14 Jul 2019 23:28:18 -0400

ADDR-SEQ: set default output range (back) to +/-10; fix output knob labels and right-click value set to reflected the selected range. #53

Diffstat:
Msrc/AddrSeq.cpp | 23+++++++++++++++++++++++
Msrc/AddrSeq.hpp | 23++++++++++++++---------
2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/src/AddrSeq.cpp b/src/AddrSeq.cpp @@ -71,6 +71,29 @@ void AddrSeq::process(const ProcessArgs& args) { outputs[OUT_OUTPUT].setVoltage(out); } +float AddrSeq::OutputParamQuantity::getDisplayValue() { + float v = getValue(); + if (!module) { + return v; + } + + AddrSeq* m = dynamic_cast<AddrSeq*>(module); + v += m->_rangeOffset; + v *= m->_rangeScale; + return v; +} + +void AddrSeq::OutputParamQuantity::setDisplayValue(float v) { + if (!module) { + return; + } + + AddrSeq* m = dynamic_cast<AddrSeq*>(module); + v /= m->_rangeScale; + v -= m->_rangeOffset; + setValue(v); +} + struct SelectOnClockMenuItem : MenuItem { AddrSeq* _module; diff --git a/src/AddrSeq.hpp b/src/AddrSeq.hpp @@ -56,21 +56,26 @@ struct AddrSeq : Module { bool _selectOnClock = false; int _select = 0; float _rangeOffset = 0.0f; - float _rangeScale = 5.0f; + float _rangeScale = 10.0f; + + struct OutputParamQuantity : ParamQuantity { + float getDisplayValue() override; + void setDisplayValue(float v) override; + }; AddrSeq() { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); configParam(STEPS_PARAM, 1.0f, 8.0f, 8.0f, "Steps"); configParam(DIRECTION_PARAM, 0.0f, 1.0f, 1.0f, "Direction"); configParam(SELECT_PARAM, 0.0f, 7.0f, 0.0f, "Select step"); - configParam(OUT1_PARAM, -1.0f, 1.0f, 0.0f, "Step 1", " V", 0.0f, 10.0f); - configParam(OUT2_PARAM, -1.0f, 1.0f, 0.0f, "Step 2", " V", 0.0f, 10.0f); - configParam(OUT3_PARAM, -1.0f, 1.0f, 0.0f, "Step 3", " V", 0.0f, 10.0f); - configParam(OUT4_PARAM, -1.0f, 1.0f, 0.0f, "Step 4", " V", 0.0f, 10.0f); - configParam(OUT5_PARAM, -1.0f, 1.0f, 0.0f, "Step 5", " V", 0.0f, 10.0f); - configParam(OUT6_PARAM, -1.0f, 1.0f, 0.0f, "Step 6", " V", 0.0f, 10.0f); - configParam(OUT7_PARAM, -1.0f, 1.0f, 0.0f, "Step 7", " V", 0.0f, 10.0f); - configParam(OUT8_PARAM, -1.0f, 1.0f, 0.0f, "Step 8", " V", 0.0f, 10.0f); + configParam<OutputParamQuantity>(OUT1_PARAM, -1.0f, 1.0f, 0.0f, "Step 1", " V"); + configParam<OutputParamQuantity>(OUT2_PARAM, -1.0f, 1.0f, 0.0f, "Step 2", " V"); + configParam<OutputParamQuantity>(OUT3_PARAM, -1.0f, 1.0f, 0.0f, "Step 3", " V"); + configParam<OutputParamQuantity>(OUT4_PARAM, -1.0f, 1.0f, 0.0f, "Step 4", " V"); + configParam<OutputParamQuantity>(OUT5_PARAM, -1.0f, 1.0f, 0.0f, "Step 5", " V"); + configParam<OutputParamQuantity>(OUT6_PARAM, -1.0f, 1.0f, 0.0f, "Step 6", " V"); + configParam<OutputParamQuantity>(OUT7_PARAM, -1.0f, 1.0f, 0.0f, "Step 7", " V"); + configParam<OutputParamQuantity>(OUT8_PARAM, -1.0f, 1.0f, 0.0f, "Step 8", " V"); onReset(); onSampleRateChange();