BogaudioModules

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

commit e3acf345bb2685b311574b77973bea2ef2d8a587
parent 7e460b770b33a66076a1cb69b06ec2680f280ea3
Author: Matt Demanett <matt@demanett.net>
Date:   Sat, 18 Nov 2017 17:18:39 -0500

Revise Offset module: replace ATTEN knob with SCALE (can multiply by more than 1).

Diffstat:
MREADME.md | 2+-
Mres/Offset-src.svg | 0
Mres/Offset.svg | 0
Mres/www/modules.png | 0
Msrc/BogaudioModules.cpp | 4++--
Msrc/Offset.cpp | 23+++++++++++++----------
6 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md @@ -51,7 +51,7 @@ DADSRH+ is a DADSRH, with the addition of CV inputs for each knob, and gate outp #### OFFSET -A 3-HP CV offset and attenuverter. The OFFSET and ATTEN knobs have CV inputs. +A 3-HP CV offset and scaler. The OFFSET and SCALE knobs have CV inputs. With an input signal, output is `(input + offset) * scale`. With no input connected, the output is constant in the value of `offset * scale`. #### S&H diff --git a/res/Offset-src.svg b/res/Offset-src.svg Binary files differ. diff --git a/res/Offset.svg b/res/Offset.svg Binary files differ. diff --git a/res/www/modules.png b/res/www/modules.png Binary files differ. diff --git a/src/BogaudioModules.cpp b/src/BogaudioModules.cpp @@ -12,6 +12,6 @@ void init(rack::Plugin *p) { p->addModel(createModel<ShaperPlusWidget>("Bogaudio", "Bogaudio-ShaperPlus", "Shaper+", ENVELOPE_GENERATOR_TAG, AMPLIFIER_TAG)); p->addModel(createModel<DADSRHWidget>("Bogaudio", "Bogaudio-DADSRH", "DADSR(H)", ENVELOPE_GENERATOR_TAG)); p->addModel(createModel<DADSRHPlusWidget>("Bogaudio", "Bogaudio-DADSRHPlus", "DADSR(H)+", ENVELOPE_GENERATOR_TAG)); - p->addModel(createModel<OffsetWidget>("Bogaudio", "Bogaudio-Offset", "Offset/Attenuverter", ATTENUATOR_TAG)); - p->addModel(createModel<SampleHoldWidget>("Bogaudio", "Bogaudio-SampleHold", "Sample & Hold", SAMPLE_AND_HOLD_TAG, DUAL_TAG)); + p->addModel(createModel<OffsetWidget>("Bogaudio", "Bogaudio-Offset", "Offset", ATTENUATOR_TAG)); + p->addModel(createModel<SampleHoldWidget>("Bogaudio", "Bogaudio-SampleHold", "S&H", SAMPLE_AND_HOLD_TAG, DUAL_TAG)); } diff --git a/src/Offset.cpp b/src/Offset.cpp @@ -4,13 +4,13 @@ struct Offset : Module { enum ParamIds { OFFSET_PARAM, - ATTEN_PARAM, + SCALE_PARAM, NUM_PARAMS }; enum InputIds { OFFSET_INPUT, - ATTEN_INPUT, + SCALE_INPUT, IN_INPUT, NUM_INPUTS }; @@ -29,12 +29,14 @@ struct Offset : Module { void Offset::step() { float offset = knobValue(params[OFFSET_PARAM], inputs[OFFSET_INPUT]); - float atten = knobValue(params[ATTEN_PARAM], inputs[ATTEN_INPUT]); + float scale = knobValue(params[SCALE_PARAM], inputs[SCALE_INPUT]); + scale = scale < 0.0 ? -pow(scale, 2.0) : pow(scale, 2.0); + scale *= 10.0; if (inputs[IN_INPUT].active) { - outputs[OUT_OUTPUT].value = clampf(inputs[IN_INPUT].value + 10.0 * offset, -10.0, 10.0) * atten; + outputs[OUT_OUTPUT].value = clampf((inputs[IN_INPUT].value + 10.0 * offset) * scale, -10.0, 10.0); } else { - outputs[OUT_OUTPUT].value = 10.0 * offset * atten; + outputs[OUT_OUTPUT].value = clampf(10.0 * offset * scale, -10.0, 10.0); } } @@ -62,22 +64,23 @@ OffsetWidget::OffsetWidget() { addChild(createScrew<ScrewSilver>(Vec(0, 0))); addChild(createScrew<ScrewSilver>(Vec(box.size.x - 15, 365))); + float knobNudge = 0.4; // generated by svg_widgets.rb - auto offsetParamPosition = Vec(7.5, 39.5); - auto attenParamPosition = Vec(7.5, 151.5); + auto offsetParamPosition = Vec(7.5 + knobNudge, 39.5 + knobNudge); + auto scaleParamPosition = Vec(7.5 + knobNudge, 151.5 + knobNudge); auto offsetInputPosition = Vec(10.5, 81.0); - auto attenInputPosition = Vec(10.5, 193.0); + auto scaleInputPosition = Vec(10.5, 193.0); auto inInputPosition = Vec(10.5, 243.0); auto outOutputPosition = Vec(10.5, 281.0); // end generated by svg_widgets.rb addParam(createParam<Knob29>(offsetParamPosition, module, Offset::OFFSET_PARAM, -1.0, 1.0, 0.0)); - addParam(createParam<Knob29>(attenParamPosition, module, Offset::ATTEN_PARAM, -1.0, 1.0, 0.0)); + addParam(createParam<Knob29>(scaleParamPosition, module, Offset::SCALE_PARAM, -1.0, 1.0, 0.316)); addInput(createInput<PJ301MPort>(offsetInputPosition, module, Offset::OFFSET_INPUT)); - addInput(createInput<PJ301MPort>(attenInputPosition, module, Offset::ATTEN_INPUT)); + addInput(createInput<PJ301MPort>(scaleInputPosition, module, Offset::SCALE_INPUT)); addInput(createInput<PJ301MPort>(inInputPosition, module, Offset::IN_INPUT)); addOutput(createOutput<PJ301MPort>(outOutputPosition, module, Offset::OUT_OUTPUT));