BogaudioModules

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

commit db902de0e6f6992dbb03674217a4a5039b172ace
parent c019b0bd32d92495508dd1f2c7bbcab4bb70a34a
Author: Matt Demanett <matt@demanett.net>
Date:   Wed, 19 Sep 2018 20:20:43 -0400

MUTE8: eight mutes with buttons and CV. #19

Diffstat:
Ares-src/Mute8-src.svg | 152+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ares/Mute8.svg | 0
Asrc/Mute8.cpp | 151++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/Mute8.hpp | 88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/bogaudio.cpp | 2++
5 files changed, 393 insertions(+), 0 deletions(-)

diff --git a/res-src/Mute8-src.svg b/res-src/Mute8-src.svg @@ -0,0 +1,152 @@ +<svg + version="1.1" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + width="150" + height="380" + viewBox="0 0 150 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="button" viewBox="0 0 20px 20px"> + <g transform="translate(10 10)"> + <circle cx="0" cy="0" r="8.8" stroke-width="1" stroke="#00f" fill="#f00" /> + </g> + </symbol> + + <symbol id="light" viewBox="0 0 6.4px 6.4px"> + <rect width="6.4" height="6.4" fill="#0f0" /> + </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 149,1 149,379 1,379 1,1" stroke="#e4e4e4" stroke-width="0.5" fill="none" /> + <polyline points="0.5,0.5 149.5,0.5 149.5,379.5 0.5,379.5 0.5,0.5" stroke="#ebebeb" stroke-width="0.8" fill="none" /> + <polyline points="0,0 150,0 150,380 0,380 0,0" stroke="#f2f2f2" stroke-width="1" fill="none" /> + + <!-- <rect width="40" height="20" fill="#0f0" transform="translate(0 0)" /> --> + <!-- <rect width="40" height="20" fill="#0f0" transform="translate(110 0)" /> --> + + <text class="title" x="36.5" y="19" font-size="12pt" letter-spacing="4px">MUTE8</text> + <g transform="translate(35.5 374)"> + <text class="brand" font-size="8pt" letter-spacing="2px">BOGAUDIO</text> + <rect width="3.0" height="3" fill="#ddd" transform="translate(24 -5)" /> + </g> + + <g transform="translate(8 32)"> + <rect width="30" height="328" rx="5" fill="#fafafa" /> + <g transform="translate(3 4)"> + <use id="INPUT1_INPUT" xlink:href="#input" transform="translate(0 0)" /> + <use id="INPUT2_INPUT" xlink:href="#input" transform="translate(0 40)" /> + <use id="INPUT3_INPUT" xlink:href="#input" transform="translate(0 80)" /> + <use id="INPUT4_INPUT" xlink:href="#input" transform="translate(0 120)" /> + + <use id="INPUT5_INPUT" xlink:href="#input" transform="translate(0 160)" /> + <use id="INPUT6_INPUT" xlink:href="#input" transform="translate(0 200)" /> + <use id="INPUT7_INPUT" xlink:href="#input" transform="translate(0 240)" /> + <use id="INPUT8_INPUT" xlink:href="#input" transform="translate(0 280)" /> + </g> + <text font-size="6pt" letter-spacing="2px" transform="translate(9.8 320)">IN</text> + </g> + + <g transform="translate(43 32)"> + <rect width="30" height="328" rx="5" fill="#fafafa" /> + <g transform="translate(3 4)"> + <use id="MUTE1_INPUT" xlink:href="#input" transform="translate(0 0)" /> + <use id="MUTE2_INPUT" xlink:href="#input" transform="translate(0 40)" /> + <use id="MUTE3_INPUT" xlink:href="#input" transform="translate(0 80)" /> + <use id="MUTE4_INPUT" xlink:href="#input" transform="translate(0 120)" /> + + <use id="MUTE5_INPUT" xlink:href="#input" transform="translate(0 160)" /> + <use id="MUTE6_INPUT" xlink:href="#input" transform="translate(0 200)" /> + <use id="MUTE7_INPUT" xlink:href="#input" transform="translate(0 240)" /> + <use id="MUTE8_INPUT" xlink:href="#input" transform="translate(0 280)" /> + </g> + <text font-size="6pt" letter-spacing="2px" transform="translate(8 320)">CV</text> + </g> + + <g transform="translate(77.5 32)"> + <!-- <rect width="30" height="328" rx="5" fill="#fafafa" /> --> + <g transform="translate(0 4)"> + <g transform="translate(0 2)"> + <use id="MUTE1_PARAM" xlink:href="#button" transform="translate(0 2)" /> + <use id="MUTE1_LIGHT" xlink:href="#light" transform="translate(23 8.8)" /> + </g> + <g transform="translate(0 42)"> + <use id="MUTE2_PARAM" xlink:href="#button" transform="translate(0 2)" /> + <use id="MUTE2_LIGHT" xlink:href="#light" transform="translate(23 8.8)" /> + </g> + <g transform="translate(0 82)"> + <use id="MUTE3_PARAM" xlink:href="#button" transform="translate(0 2)" /> + <use id="MUTE3_LIGHT" xlink:href="#light" transform="translate(23 8.8)" /> + </g> + <g transform="translate(0 122)"> + <use id="MUTE4_PARAM" xlink:href="#button" transform="translate(0 2)" /> + <use id="MUTE4_LIGHT" xlink:href="#light" transform="translate(23 8.8)" /> + </g> + + <g transform="translate(0 162)"> + <use id="MUTE5_PARAM" xlink:href="#button" transform="translate(0 2)" /> + <use id="MUTE5_LIGHT" xlink:href="#light" transform="translate(23 8.8)" /> + </g> + <g transform="translate(0 202)"> + <use id="MUTE6_PARAM" xlink:href="#button" transform="translate(0 2)" /> + <use id="MUTE6_LIGHT" xlink:href="#light" transform="translate(23 8.8)" /> + </g> + <g transform="translate(0 242)"> + <use id="MUTE7_PARAM" xlink:href="#button" transform="translate(0 2)" /> + <use id="MUTE7_LIGHT" xlink:href="#light" transform="translate(23 8.8)" /> + </g> + <g transform="translate(0 280)"> + <use id="MUTE8_PARAM" xlink:href="#button" transform="translate(0 2)" /> + <use id="MUTE8_LIGHT" xlink:href="#light" transform="translate(23 8.8)" /> + </g> + </g> + <text font-size="6pt" letter-spacing="2px" transform="translate(1 320)">MUTE</text> + </g> + + <g transform="translate(112 32)"> + <rect width="30" height="328" rx="5" fill="#bbb" /> + <g transform="translate(3 4)"> + <use id="OUTPUT1_OUTPUT" xlink:href="#output" transform="translate(0 0)" /> + <use id="OUTPUT2_OUTPUT" xlink:href="#output" transform="translate(0 40)" /> + <use id="OUTPUT3_OUTPUT" xlink:href="#output" transform="translate(0 80)" /> + <use id="OUTPUT4_OUTPUT" xlink:href="#output" transform="translate(0 120)" /> + + <use id="OUTPUT5_OUTPUT" xlink:href="#output" transform="translate(0 160)" /> + <use id="OUTPUT6_OUTPUT" xlink:href="#output" transform="translate(0 200)" /> + <use id="OUTPUT7_OUTPUT" xlink:href="#output" transform="translate(0 240)" /> + <use id="OUTPUT8_OUTPUT" xlink:href="#output" transform="translate(0 280)" /> + </g> + <text font-size="6pt" letter-spacing="2px" transform="translate(5 320)">OUT</text> + </g> +</svg> diff --git a/res/Mute8.svg b/res/Mute8.svg Binary files differ. diff --git a/src/Mute8.cpp b/src/Mute8.cpp @@ -0,0 +1,151 @@ + +#include "Mute8.hpp" +#include "mixer.hpp" + +const float Mute8::maxDecibels = 0.0f; +const float Mute8::minDecibels = Amplifier::minDecibels; +const float Mute8::slewTimeMS = 5.0f; + +void Mute8::onReset() { + for (int i = 0; i < 8; ++i) { + _triggers[i].reset(); + } +} + +void Mute8::onSampleRateChange() { + float sampleRate = engineGetSampleRate(); + for (int i = 0; i < 8; ++i) { + _slewLimiters[i].setParams(sampleRate, slewTimeMS, maxDecibels - minDecibels); + } +} + +void Mute8::step() { + for (int i = 0; i < 8; ++i) { + stepChannel(i); + } +} + +void Mute8::stepChannel(int i) { + _triggers[i].process(inputs[MUTE1_INPUT + i].value); + if (params[MUTE1_PARAM + i].value > 0.5f || _triggers[i].isHigh()) { + lights[MUTE1_LIGHT + i].value = 1.0f; + _amplifiers[i].setLevel(_slewLimiters[i].next(minDecibels)); + } + else { + lights[MUTE1_LIGHT + i].value = 0.0f; + _amplifiers[i].setLevel(_slewLimiters[i].next(maxDecibels)); + } + outputs[OUTPUT1_OUTPUT + i].value = _amplifiers[i].next(inputs[INPUT1_INPUT + i].active ? inputs[INPUT1_INPUT + i].value : 5.0f); +} + +struct Mute8Widget : ModuleWidget { + static constexpr int hp = 10; + + Mute8Widget(Mute8* 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/Mute8.svg"))); + addChild(panel); + } + + addChild(Widget::create<ScrewSilver>(Vec(0, 0))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 0))); + addChild(Widget::create<ScrewSilver>(Vec(0, 365))); + addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365))); + + // generated by svg_widgets.rb + auto mute1ParamPosition = Vec(78.2, 40.7); + auto mute2ParamPosition = Vec(78.2, 80.7); + auto mute3ParamPosition = Vec(78.2, 120.7); + auto mute4ParamPosition = Vec(78.2, 160.7); + auto mute5ParamPosition = Vec(78.2, 200.7); + auto mute6ParamPosition = Vec(78.2, 240.7); + auto mute7ParamPosition = Vec(78.2, 280.7); + auto mute8ParamPosition = Vec(78.2, 318.7); + + auto input1InputPosition = Vec(11.0, 36.0); + auto input2InputPosition = Vec(11.0, 76.0); + auto input3InputPosition = Vec(11.0, 116.0); + auto input4InputPosition = Vec(11.0, 156.0); + auto input5InputPosition = Vec(11.0, 196.0); + auto input6InputPosition = Vec(11.0, 236.0); + auto input7InputPosition = Vec(11.0, 276.0); + auto input8InputPosition = Vec(11.0, 316.0); + auto mute1InputPosition = Vec(46.0, 36.0); + auto mute2InputPosition = Vec(46.0, 76.0); + auto mute3InputPosition = Vec(46.0, 116.0); + auto mute4InputPosition = Vec(46.0, 156.0); + auto mute5InputPosition = Vec(46.0, 196.0); + auto mute6InputPosition = Vec(46.0, 236.0); + auto mute7InputPosition = Vec(46.0, 276.0); + auto mute8InputPosition = Vec(46.0, 316.0); + + auto output1OutputPosition = Vec(115.0, 36.0); + auto output2OutputPosition = Vec(115.0, 76.0); + auto output3OutputPosition = Vec(115.0, 116.0); + auto output4OutputPosition = Vec(115.0, 156.0); + auto output5OutputPosition = Vec(115.0, 196.0); + auto output6OutputPosition = Vec(115.0, 236.0); + auto output7OutputPosition = Vec(115.0, 276.0); + auto output8OutputPosition = Vec(115.0, 316.0); + + auto mute1LightPosition = Vec(100.5, 46.8); + auto mute2LightPosition = Vec(100.5, 86.8); + auto mute3LightPosition = Vec(100.5, 126.8); + auto mute4LightPosition = Vec(100.5, 166.8); + auto mute5LightPosition = Vec(100.5, 206.8); + auto mute6LightPosition = Vec(100.5, 246.8); + auto mute7LightPosition = Vec(100.5, 286.8); + auto mute8LightPosition = Vec(100.5, 324.8); + // end generated by svg_widgets.rb + + addParam(ParamWidget::create<MuteButton>(mute1ParamPosition, module, Mute8::MUTE1_PARAM, 0.0, 1.0, 0.0)); + addParam(ParamWidget::create<MuteButton>(mute2ParamPosition, module, Mute8::MUTE2_PARAM, 0.0, 1.0, 0.0)); + addParam(ParamWidget::create<MuteButton>(mute3ParamPosition, module, Mute8::MUTE3_PARAM, 0.0, 1.0, 0.0)); + addParam(ParamWidget::create<MuteButton>(mute4ParamPosition, module, Mute8::MUTE4_PARAM, 0.0, 1.0, 0.0)); + addParam(ParamWidget::create<MuteButton>(mute5ParamPosition, module, Mute8::MUTE5_PARAM, 0.0, 1.0, 0.0)); + addParam(ParamWidget::create<MuteButton>(mute6ParamPosition, module, Mute8::MUTE6_PARAM, 0.0, 1.0, 0.0)); + addParam(ParamWidget::create<MuteButton>(mute7ParamPosition, module, Mute8::MUTE7_PARAM, 0.0, 1.0, 0.0)); + addParam(ParamWidget::create<MuteButton>(mute8ParamPosition, module, Mute8::MUTE8_PARAM, 0.0, 1.0, 0.0)); + + addInput(Port::create<Port24>(input1InputPosition, Port::INPUT, module, Mute8::INPUT1_INPUT)); + addInput(Port::create<Port24>(input2InputPosition, Port::INPUT, module, Mute8::INPUT2_INPUT)); + addInput(Port::create<Port24>(input3InputPosition, Port::INPUT, module, Mute8::INPUT3_INPUT)); + addInput(Port::create<Port24>(input4InputPosition, Port::INPUT, module, Mute8::INPUT4_INPUT)); + addInput(Port::create<Port24>(input5InputPosition, Port::INPUT, module, Mute8::INPUT5_INPUT)); + addInput(Port::create<Port24>(input6InputPosition, Port::INPUT, module, Mute8::INPUT6_INPUT)); + addInput(Port::create<Port24>(input7InputPosition, Port::INPUT, module, Mute8::INPUT7_INPUT)); + addInput(Port::create<Port24>(input8InputPosition, Port::INPUT, module, Mute8::INPUT8_INPUT)); + addInput(Port::create<Port24>(mute1InputPosition, Port::INPUT, module, Mute8::MUTE1_INPUT)); + addInput(Port::create<Port24>(mute2InputPosition, Port::INPUT, module, Mute8::MUTE2_INPUT)); + addInput(Port::create<Port24>(mute3InputPosition, Port::INPUT, module, Mute8::MUTE3_INPUT)); + addInput(Port::create<Port24>(mute4InputPosition, Port::INPUT, module, Mute8::MUTE4_INPUT)); + addInput(Port::create<Port24>(mute5InputPosition, Port::INPUT, module, Mute8::MUTE5_INPUT)); + addInput(Port::create<Port24>(mute6InputPosition, Port::INPUT, module, Mute8::MUTE6_INPUT)); + addInput(Port::create<Port24>(mute7InputPosition, Port::INPUT, module, Mute8::MUTE7_INPUT)); + addInput(Port::create<Port24>(mute8InputPosition, Port::INPUT, module, Mute8::MUTE8_INPUT)); + + addOutput(Port::create<Port24>(output1OutputPosition, Port::OUTPUT, module, Mute8::OUTPUT1_OUTPUT)); + addOutput(Port::create<Port24>(output2OutputPosition, Port::OUTPUT, module, Mute8::OUTPUT2_OUTPUT)); + addOutput(Port::create<Port24>(output3OutputPosition, Port::OUTPUT, module, Mute8::OUTPUT3_OUTPUT)); + addOutput(Port::create<Port24>(output4OutputPosition, Port::OUTPUT, module, Mute8::OUTPUT4_OUTPUT)); + addOutput(Port::create<Port24>(output5OutputPosition, Port::OUTPUT, module, Mute8::OUTPUT5_OUTPUT)); + addOutput(Port::create<Port24>(output6OutputPosition, Port::OUTPUT, module, Mute8::OUTPUT6_OUTPUT)); + addOutput(Port::create<Port24>(output7OutputPosition, Port::OUTPUT, module, Mute8::OUTPUT7_OUTPUT)); + addOutput(Port::create<Port24>(output8OutputPosition, Port::OUTPUT, module, Mute8::OUTPUT8_OUTPUT)); + + addChild(ModuleLightWidget::create<SmallLight<GreenLight>>(mute1LightPosition, module, Mute8::MUTE1_LIGHT)); + addChild(ModuleLightWidget::create<SmallLight<GreenLight>>(mute2LightPosition, module, Mute8::MUTE2_LIGHT)); + addChild(ModuleLightWidget::create<SmallLight<GreenLight>>(mute3LightPosition, module, Mute8::MUTE3_LIGHT)); + addChild(ModuleLightWidget::create<SmallLight<GreenLight>>(mute4LightPosition, module, Mute8::MUTE4_LIGHT)); + addChild(ModuleLightWidget::create<SmallLight<GreenLight>>(mute5LightPosition, module, Mute8::MUTE5_LIGHT)); + addChild(ModuleLightWidget::create<SmallLight<GreenLight>>(mute6LightPosition, module, Mute8::MUTE6_LIGHT)); + addChild(ModuleLightWidget::create<SmallLight<GreenLight>>(mute7LightPosition, module, Mute8::MUTE7_LIGHT)); + addChild(ModuleLightWidget::create<SmallLight<GreenLight>>(mute8LightPosition, module, Mute8::MUTE8_LIGHT)); + } +}; + +Model* modelMute8 = createModel<Mute8, Mute8Widget>("Bogaudio-Mute8", "Mute8", "eight mutes with CV", UTILITY_TAG); diff --git a/src/Mute8.hpp b/src/Mute8.hpp @@ -0,0 +1,88 @@ +#pragma once + +#include "bogaudio.hpp" +#include "dsp/signal.hpp" + +using namespace bogaudio::dsp; + +extern Model* modelMute8; + +namespace bogaudio { + +struct Mute8 : Module { + enum ParamsIds { + MUTE1_PARAM, + MUTE2_PARAM, + MUTE3_PARAM, + MUTE4_PARAM, + MUTE5_PARAM, + MUTE6_PARAM, + MUTE7_PARAM, + MUTE8_PARAM, + NUM_PARAMS + }; + + enum InputsIds { + INPUT1_INPUT, + INPUT2_INPUT, + INPUT3_INPUT, + INPUT4_INPUT, + INPUT5_INPUT, + INPUT6_INPUT, + INPUT7_INPUT, + INPUT8_INPUT, + MUTE1_INPUT, + MUTE2_INPUT, + MUTE3_INPUT, + MUTE4_INPUT, + MUTE5_INPUT, + MUTE6_INPUT, + MUTE7_INPUT, + MUTE8_INPUT, + NUM_INPUTS + }; + + enum OutputsIds { + OUTPUT1_OUTPUT, + OUTPUT2_OUTPUT, + OUTPUT3_OUTPUT, + OUTPUT4_OUTPUT, + OUTPUT5_OUTPUT, + OUTPUT6_OUTPUT, + OUTPUT7_OUTPUT, + OUTPUT8_OUTPUT, + NUM_OUTPUTS + }; + + enum LightsIds { + MUTE1_LIGHT, + MUTE2_LIGHT, + MUTE3_LIGHT, + MUTE4_LIGHT, + MUTE5_LIGHT, + MUTE6_LIGHT, + MUTE7_LIGHT, + MUTE8_LIGHT, + NUM_LIGHTS + }; + + static const float maxDecibels; + static const float minDecibels; + static const float slewTimeMS; + + Amplifier _amplifiers[8]; + SlewLimiter _slewLimiters[8]; + SchmittTrigger _triggers[8]; + + Mute8() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { + onReset(); + onSampleRateChange(); + } + + void onReset() override; + void onSampleRateChange() override; + void step() override; + void stepChannel(int i); +}; + +} // namespace bogaudio diff --git a/src/bogaudio.cpp b/src/bogaudio.cpp @@ -25,6 +25,7 @@ #include "Mix4.hpp" #include "Mix8.hpp" #include "Mult.hpp" +#include "Mute8.hpp" #include "Noise.hpp" #include "Offset.hpp" #include "Pan.hpp" @@ -85,6 +86,7 @@ void init(rack::Plugin *p) { #ifdef EXPERIMENTAL p->addModel(modelUMix); p->addModel(modelMatrix88); + p->addModel(modelMute8); #endif p->addModel(modelPan); p->addModel(modelXFade);