BogaudioModules

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

commit 4a0abea6687e20a3036e434262ade3fd664dff08
parent 0c98b220d78cc83aa40c49df5927629aa7eb9331
Author: Matt Demanett <matt@demanett.net>
Date:   Thu,  5 Jul 2018 00:22:42 -0400

UMIX: unity mixer.

Diffstat:
Ares-src/UMix-src.svg | 111+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ares/UMix.svg | 0
Asrc/UMix.cpp | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/UMix.hpp | 46++++++++++++++++++++++++++++++++++++++++++++++
Msrc/bogaudio.cpp | 4++++
5 files changed, 239 insertions(+), 0 deletions(-)

diff --git a/res-src/UMix-src.svg b/res-src/UMix-src.svg @@ -0,0 +1,111 @@ +<svg + version="1.1" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + width="45" + height="380" + viewBox="0 0 45 380" +> + <style> + text { + fill: #333; + font-family: 'Roboto', sans-serif; + font-weight: bold; + } + text.title { + font-family: 'Comfortaa', sans-serif; + font-weight: normal; + } + text.brand { + font-family: 'Audiowide', sans-serif; + font-weight: bold; + } + </style> + + <defs> + <symbol id="knob-small" viewBox="0 0 45px 45px"> + <g transform="translate(22.5 22.5)"> + <polyline points="-3,0 3,0" stroke-width="1" stroke="#00f" /> + <polyline points="0,-3 0,3" stroke-width="1" stroke="#00f" /> + <circle cx="0" cy="0" r="7.5" stroke-width="1" stroke="#00f" fill="none" /> + </g> + </symbol> + + <symbol id="knobguide-maxtick" viewBox="0 0 40px 40px"> + <g transform="translate(20 20)"> + <g transform="rotate(60) translate(10 0)"> + <polyline points="0,0 4,0" stroke-width="1" stroke="#333" /> + </g> + <path d="M 0 -12.5 A 12.5 12.5 0 0 1 12.5 0" stroke="#333" stroke-width="0.5" stroke-linecap="round" fill="none" transform="rotate(0)" /> + <path d="M 0 -12.5 A 12.5 12.5 0 0 1 12.5 0" stroke="#333" stroke-width="0.5" stroke-linecap="round" fill="none" transform="rotate(43)" /> + <path d="M 0 -12.5 A 12.5 12.5 0 0 0 -12.5 0" stroke="#333" stroke-width="0.5" stroke-linecap="round" fill="none" transform="rotate(0)" /> + <path d="M 0 -12.5 A 12.5 12.5 0 0 0 -12.5 0" stroke="#333" stroke-width="0.5" stroke-linecap="round" fill="none" transform="rotate(-43)" /> + </g> + </symbol> + + <symbol id="switch" viewBox="0 0 14px 24px"> + <rect width="14px" height="24px" stroke-width="1" stroke="#000" fill="#ddd" /> + <rect width="14px" height="12px" stroke-width="0" fill="#000" /> + </symbol> + + <symbol id="input" viewBox="0 0 24px 24px"> + <g transform="translate(12 12)"> + <circle cx="0" cy="0" r="5" stroke-width="1" stroke="#0f0" fill="#0f0" /> + <circle cx="0" cy="0" r="10.5" stroke-width="3" stroke="#0f0" fill="none" /> + </g> + </symbol> + + <symbol id="output" viewBox="0 0 24px 24px"> + <g transform="translate(12 12)"> + <circle cx="0" cy="0" r="5" stroke-width="1" stroke="#f00" fill="#f00" /> + <circle cx="0" cy="0" r="10.5" stroke-width="3" stroke="#f00" fill="none" /> + </g> + </symbol> + </defs> + + <rect width="100%" height="100%" fill="#ddd" /> + <polyline points="1,1 44,1 44,379 1,379 1,1" stroke="#e4e4e4" stroke-width="0.5" fill="none" /> + <polyline points="0.5,0.5 44.5,0.5 44.5,379.5 0.5,379.5 0.5,0.5" stroke="#ebebeb" stroke-width="0.8" fill="none" /> + <polyline points="0,0 45,0 45,380 0,380 0,0" stroke="#f2f2f2" stroke-width="1" fill="none" /> + + <g transform="rotate(-90) translate(-376 13)"> + <text class="title" font-size="7pt" letter-spacing="2.5px">UMIX</text> + <g transform="translate(0 12)"> + <text class="brand" font-size="7pt" letter-spacing="2px">BGA</text> + <rect width="3.0" height="3" fill="#ddd" transform="translate(11.5 -5)" /> + </g> + </g> + + <!-- <polyline points="22.5,0 22.5,380" stroke-width="0.5" stroke="#0f0" /> --> + + <g transform="translate(0 18)"> + <g transform="translate(5.5 0)"> + <rect width="34" height="10" fill="#fafafa" transform="translate(0 172)" /> + <rect width="34" height="182" rx="5" fill="#fafafa" /> + <use id="IN1_INPUT" xlink:href="#input" transform="translate(5 5)" /> + <use id="IN2_INPUT" xlink:href="#input" transform="translate(5 35)" /> + <use id="IN3_INPUT" xlink:href="#input" transform="translate(5 65)" /> + <use id="IN4_INPUT" xlink:href="#input" transform="translate(5 95)" /> + <use id="IN5_INPUT" xlink:href="#input" transform="translate(5 125)" /> + <use id="IN6_INPUT" xlink:href="#input" transform="translate(5 155)" /> + </g> + <g transform="translate(5.5 185)"> + <rect width="34" height="10" fill="#bbb" transform="translate(0 -3)" /> + <rect width="34" height="36" rx="5" fill="#bbb" /> + <use id="OUT_OUTPUT" xlink:href="#output" transform="translate(5 0)" /> + <text font-size="5pt" letter-spacing="2px" transform="translate(8.5 32)">OUT</text> + </g> + </g> + + <g transform="translate(15.5 254)"> + <text font-size="5pt" letter-spacing="2px" transform="translate(-2 -1)">SUM</text> + <use id="MODE_PARAM" xlink:href="#switch" transform="translate(0 2)" /> + <text font-size="5pt" letter-spacing="2px" transform="translate(-1 34)">AVG</text> + </g> + + <g transform="translate(0 305)"> + <text font-size="6pt" letter-spacing="2px" transform="translate(7 0)">LEVEL</text> + <use id="LEVEL_PARAM" xlink:href="#knob-small" transform="translate(0 -5)" /> + <use xlink:href="#knobguide-maxtick" transform="translate(2.2 -2.5)" /> + </g> +</svg> diff --git a/res/UMix.svg b/res/UMix.svg Binary files differ. diff --git a/src/UMix.cpp b/src/UMix.cpp @@ -0,0 +1,78 @@ + +#include "UMix.hpp" + +void UMix::step() { + if (!outputs[OUT_OUTPUT].active) { + return; + } + if (params[MODE_PARAM].value > 0.5f) { + float out = 0.0f; + for (int i = 0; i < 6; ++i) { + out += inputs[IN1_INPUT + i].value; + } + outputs[OUT_OUTPUT].value = _saturator.next(params[LEVEL_PARAM].value * out); + } + else { + float out = 0.0f; + int active = 0; + for (int i = 0; i < 6; ++i) { + if (inputs[IN1_INPUT + i].active) { + out += inputs[IN1_INPUT + i].value; + ++active; + } + } + if (active > 0) { + out /= (float)active; + outputs[OUT_OUTPUT].value = _saturator.next(params[LEVEL_PARAM].value * out); + } + else { + outputs[OUT_OUTPUT].value = 0.0f; + } + } +} + +struct UMixWidget : ModuleWidget { + static constexpr int hp = 3; + + UMixWidget(UMix* module) : ModuleWidget(module) { + box.size = Vec(RACK_GRID_WIDTH * hp, RACK_GRID_HEIGHT); + + { + SVGPanel *panel = new SVGPanel(); + panel->box.size = box.size; + panel->setBackground(SVG::load(assetPlugin(plugin, "res/UMix.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + + // generated by svg_widgets.rb + auto modeParamPosition = Vec(15.0, 255.5); + auto levelParamPosition = Vec(14.5, 314.5); + + auto in1InputPosition = Vec(10.5, 23.0); + auto in2InputPosition = Vec(10.5, 53.0); + auto in3InputPosition = Vec(10.5, 83.0); + auto in4InputPosition = Vec(10.5, 113.0); + auto in5InputPosition = Vec(10.5, 143.0); + auto in6InputPosition = Vec(10.5, 173.0); + + auto outOutputPosition = Vec(10.5, 203.0); + // end generated by svg_widgets.rb + + addParam(ParamWidget::create<SliderSwitch2State14>(modeParamPosition, module, UMix::MODE_PARAM, 0.0, 1.0, 1.0)); + addParam(ParamWidget::create<Knob16>(levelParamPosition, module, UMix::LEVEL_PARAM, 0.0, 1.0, 1.0)); + + addInput(Port::create<Port24>(in1InputPosition, Port::INPUT, module, UMix::IN1_INPUT)); + addInput(Port::create<Port24>(in2InputPosition, Port::INPUT, module, UMix::IN2_INPUT)); + addInput(Port::create<Port24>(in3InputPosition, Port::INPUT, module, UMix::IN3_INPUT)); + addInput(Port::create<Port24>(in4InputPosition, Port::INPUT, module, UMix::IN4_INPUT)); + addInput(Port::create<Port24>(in5InputPosition, Port::INPUT, module, UMix::IN5_INPUT)); + addInput(Port::create<Port24>(in6InputPosition, Port::INPUT, module, UMix::IN6_INPUT)); + + addOutput(Port::create<Port24>(outOutputPosition, Port::OUTPUT, module, UMix::OUT_OUTPUT)); + } +}; + +Model* modelUMix = createModel<UMix, UMixWidget>("Bogaudio-UMix", "UMix", "unity mixer", MIXER_TAG); diff --git a/src/UMix.hpp b/src/UMix.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include "bogaudio.hpp" +#include "dsp/signal.hpp" + +using namespace bogaudio::dsp; + +extern Model* modelUMix; + +namespace bogaudio { + +struct UMix : Module { + enum ParamsIds { + MODE_PARAM, + LEVEL_PARAM, + NUM_PARAMS + }; + + enum InputsIds { + IN1_INPUT, + IN2_INPUT, + IN3_INPUT, + IN4_INPUT, + IN5_INPUT, + IN6_INPUT, + NUM_INPUTS + }; + + enum OutputsIds { + OUT_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + NUM_LIGHTS + }; + + Saturator _saturator; + + UMix() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { + } + + void step() override; +}; + +} // namespace bogaudio diff --git a/src/bogaudio.cpp b/src/bogaudio.cpp @@ -31,6 +31,7 @@ #include "Stack.hpp" #include "Sums.hpp" #include "Switch.hpp" +#include "UMix.hpp" #include "VCA.hpp" #include "VCAmp.hpp" #include "VCM.hpp" @@ -73,6 +74,9 @@ void init(rack::Plugin *p) { p->addModel(modelMix4); p->addModel(modelMix8); p->addModel(modelVCM); +#ifdef EXPERIMENTAL + p->addModel(modelUMix); +#endif p->addModel(modelPan); p->addModel(modelXFade); p->addModel(modelVCA);