commit 2cc5686dfb5a205c572ad04c7b214cd9bc07b0d5
parent ae27d9100edc4a5b235cad3163074a14057183a8
Author: Matt Demanett <matt@demanett.net>
Date: Sun, 7 Jan 2018 01:38:07 -0500
Work-in-progress VCA.
Diffstat:
5 files changed, 218 insertions(+), 0 deletions(-)
diff --git a/res-src/VCA-src.svg b/res-src/VCA-src.svg
@@ -0,0 +1,131 @@
+<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" viewBox="0 0 45px 45px">
+ <g transform="translate(22.5 22.5)">
+ <polyline points="-5,0 5,0" stroke-width="1" stroke="#00f" />
+ <polyline points="0,-5 0,5" stroke-width="1" stroke="#00f" />
+ <circle cx="0" cy="0" r="14" stroke-width="1" stroke="#00f" fill="none" />
+ </g>
+ </symbol>
+
+ <symbol id="knobguide" viewBox="0 0 45px 45px">
+ <g transform="translate(22.5 22.5)">
+ <g transform="rotate(-240) translate(17 0)">
+ <!-- <polyline points="0,0 3,0" stroke-width="0.3" stroke="#333" /> -->
+ <text font-size="6.5pt" transform="translate(4 0) rotate(240) translate(-2.5 3)">0</text>
+ </g>
+ <g transform="rotate(-210) translate(17 0)">
+ <polyline points="0,0 3,0" stroke-width="0.3" stroke="#333" />
+ </g>
+ <g transform="rotate(-180) translate(17 0)">
+ <polyline points="0,0 3,0" stroke-width="0.3" stroke="#333" />
+ </g>
+ <g transform="rotate(-150) translate(17 0)">
+ <polyline points="0,0 3,0" stroke-width="0.3" stroke="#333" />
+ </g>
+ <g transform="rotate(-120) translate(17 0)">
+ <polyline points="0,0 3,0" stroke-width="0.3" stroke="#333" />
+ </g>
+ <g transform="rotate(-90) translate(17 0)">
+ <polyline points="0,0 3,0" stroke-width="0.3" stroke="#333" />
+ </g>
+ <g transform="rotate(-60) translate(17 0)">
+ <polyline points="0,0 3,0" stroke-width="0.3" stroke="#333" />
+ </g>
+ <g transform="rotate(-30) translate(17 0)">
+ <polyline points="0,0 3,0" stroke-width="0.3" stroke="#333" />
+ </g>
+ <g transform="rotate(0) translate(17 0)">
+ <polyline points="0,0 3,0" stroke-width="0.3" stroke="#333" />
+ </g>
+ <g transform="rotate(30) translate(17 0)">
+ <polyline points="0,0 3,0" stroke-width="0.3" stroke="#333" />
+ </g>
+ <g transform="rotate(60) translate(17 0)">
+ <!-- <polyline points="0,0 3,0" stroke-width="0.3" stroke="#333" /> -->
+ <text font-size="6.5pt" transform="translate(4 0) rotate(-60) translate(-5 3)">10</text>
+ </g>
+ </g>
+ </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" />
+
+ <!-- <polyline points="22.5,0 22.5,380" stroke-width="0.5" stroke="#0f0" /> -->
+ <!-- <rect width="45" height="10" fill="#0f0" transform="translate(0 68)" /> -->
+ <!-- <rect width="45" height="10" fill="#0f0" transform="translate(0 127)" /> -->
+ <!-- <rect width="45" height="10" fill="#0f0" transform="translate(0 177)" /> -->
+
+ <g transform="rotate(-90) translate(-376 13)">
+ <text class="title" font-size="7pt" letter-spacing="2.5px">VCA</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>
+
+ <g transform="translate(0 25)">
+ <text font-size="6pt" letter-spacing="2px" transform="translate(7 0)">LEVEL</text>
+ <use id="LEVEL_PARAM" xlink:href="#knob" transform="translate(0 1)" />
+ <use xlink:href="#knobguide" transform="translate(0 1)" />
+ </g>
+
+ <g transform="translate(0 180)">
+ <g transform="translate(5.5 0)">
+ <rect width="34" height="10" fill="#fafafa" transform="translate(0 98)" />
+ <rect width="34" height="105" rx="5" fill="#fafafa" />
+ <use id="EXP_INPUT" xlink:href="#input" transform="translate(5 3)" />
+ <text font-size="5pt" letter-spacing="2px" transform="translate(9 35)">EXP</text>
+ <use id="LIN_INPUT" xlink:href="#input" transform="translate(5 38)" />
+ <text font-size="5pt" letter-spacing="2px" transform="translate(10 70)">LIN</text>
+ <use id="IN_INPUT" xlink:href="#input" transform="translate(5 73)" />
+ <text font-size="5pt" letter-spacing="2px" transform="translate(12.5 105)">IN</text>
+ </g>
+ <g transform="translate(5.5 111)">
+ <rect width="34" height="10" fill="#bbb" transform="translate(0 -3)" />
+ <rect width="34" height="35" 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>
+</svg>
diff --git a/res/VCA.svg b/res/VCA.svg
Binary files differ.
diff --git a/src/BogaudioModules.cpp b/src/BogaudioModules.cpp
@@ -25,4 +25,7 @@ void init(rack::Plugin *p) {
p->addModel(createModel<ReftoneWidget>("Bogaudio", "Bogaudio-Reftone", "Reftone", UTILITY_TAG));
p->addModel(createModel<SampleHoldWidget>("Bogaudio", "Bogaudio-SampleHold", "S&H", SAMPLE_AND_HOLD_TAG, DUAL_TAG, UTILITY_TAG));
p->addModel(createModel<SwitchWidget>("Bogaudio", "Bogaudio-Switch", "Switch", UTILITY_TAG));
+#ifdef EXPERIMENTAL
+ p->addModel(createModel<VCAWidget>("Bogaudio", "Bogaudio-VCA", "VCA", UTILITY_TAG, AMPLIFIER_TAG));
+#endif
}
diff --git a/src/BogaudioModules.hpp b/src/BogaudioModules.hpp
@@ -65,4 +65,8 @@ struct SwitchWidget : ModuleWidget {
SwitchWidget();
};
+struct VCAWidget : ModuleWidget {
+ VCAWidget();
+};
+
} // namespae bogaudio
diff --git a/src/VCA.cpp b/src/VCA.cpp
@@ -0,0 +1,80 @@
+
+#include "BogaudioModules.hpp"
+
+struct VCA : Module {
+ enum ParamsIds {
+ LEVEL_PARAM,
+ NUM_PARAMS
+ };
+
+ enum InputsIds {
+ EXP_INPUT,
+ LIN_INPUT,
+ IN_INPUT,
+ NUM_INPUTS
+ };
+
+ enum OutputsIds {
+ OUT_OUTPUT,
+ NUM_OUTPUTS
+ };
+
+ enum LightsIds {
+ NUM_LIGHTS
+ };
+
+ VCA() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {}
+
+ virtual void step() override;
+};
+
+void VCA::step() {
+ if (inputs[IN_INPUT].active && outputs[OUT_OUTPUT].active) {
+ float level = clampf(params[LEVEL_PARAM].value, 0.0, 1.0);
+ if (inputs[EXP_INPUT].active) {
+ level *= powf(clampf(inputs[EXP_INPUT].value, 0.0, 10.0) / 10.0, 1.5);
+ }
+ else if (inputs[LIN_INPUT].active) {
+ level *= clampf(inputs[LIN_INPUT].value, 0.0, 10.0) / 10.0;
+ }
+ outputs[OUT_OUTPUT].value = level * inputs[IN_INPUT].value;
+ }
+ else {
+ outputs[OUT_OUTPUT].value = 0.0;
+ }
+}
+
+
+VCAWidget::VCAWidget() {
+ VCA *module = new VCA();
+ setModule(module);
+ box.size = Vec(RACK_GRID_WIDTH * 3, RACK_GRID_HEIGHT);
+
+ {
+ SVGPanel *panel = new SVGPanel();
+ panel->box.size = box.size;
+ panel->setBackground(SVG::load(assetPlugin(plugin, "res/VCA.svg")));
+ addChild(panel);
+ }
+
+ addChild(createScrew<ScrewSilver>(Vec(0, 0)));
+ addChild(createScrew<ScrewSilver>(Vec(box.size.x - 15, 365)));
+
+ // generated by svg_widgets.rb
+ auto levelParamPosition = Vec(8.0, 34.0);
+
+ auto expInputPosition = Vec(10.5, 183.0);
+ auto linInputPosition = Vec(10.5, 218.0);
+ auto inInputPosition = Vec(10.5, 253.0);
+
+ auto outOutputPosition = Vec(10.5, 291.0);
+ // end generated by svg_widgets.rb
+
+ addParam(createParam<Knob29>(levelParamPosition, module, VCA::LEVEL_PARAM, 0.0, 1.0, 0.5));
+
+ addInput(createInput<Port24>(expInputPosition, module, VCA::EXP_INPUT));
+ addInput(createInput<Port24>(linInputPosition, module, VCA::LIN_INPUT));
+ addInput(createInput<Port24>(inInputPosition, module, VCA::IN_INPUT));
+
+ addOutput(createOutput<Port24>(outOutputPosition, module, VCA::OUT_OUTPUT));
+}