computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit 91b9f1c7f1fa5ad3ee483de3c10f9a556af9e8cf
parent ec43a8f99d7c53cf68ec3665427cab0e795beeaa
Author: Adam M <aemalone@gmail.com>
Date:   Thu,  2 Apr 2020 18:01:03 -0500

knoly pobs channel selector

Diffstat:
Ares/computerscare-medium-knob-disabled.svg | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/Computerscare.hpp | 8++++++++
Msrc/ComputerscareKnolyPobs.cpp | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
3 files changed, 150 insertions(+), 22 deletions(-)

diff --git a/res/computerscare-medium-knob-disabled.svg b/res/computerscare-medium-knob-disabled.svg @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="Layer_1" + data-name="Layer 1" + viewBox="0 0 25 25" + version="1.1" + sodipodi:docname="computerscare-medium-knob-disabled.svg" + inkscape:version="0.92.2 5c3e80d, 2017-08-06" + width="25" + height="25"> + <metadata + id="metadata1289"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>01 Big Knob</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1398" + inkscape:window-height="834" + id="namedview1287" + showgrid="false" + inkscape:zoom="15.733333" + inkscape:cx="11.595259" + inkscape:cy="14.442801" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="Big_Knob" /> + <defs + id="defs1279"> + <style + id="style1277">.cls-1{fill:#245559;}.cls-2{fill:none;stroke:#24c9a6;stroke-miterlimit:10;stroke-width:3px;}</style> + </defs> + <title + id="title1281">01 Big Knob</title> + <g + id="Big_Knob" + data-name="Big Knob" + transform="translate(0,-35)"> + <path + style="fill:#aab8ba;stroke:#000000;stroke-width:0.40182629;stroke-opacity:1;fill-opacity:1" + d="M 24.481712,47.462047 C 25.230517,56.347871 19.452665,60.183994 12.823046,59.573425 6.7268169,59.011979 -0.88018101,53.855561 0.76825872,47.518636 2.9825816,39.006345 7.9149746,34.966172 12.823046,35.463848 c 3.677562,0.372903 5.413953,1.519566 9.012194,3.842931 2.236175,1.443886 2.438189,5.683646 2.646472,8.155268 z" + id="Big_Button_Circle" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ssssss" /> + <path + style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#586e69;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.25012431;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="m 12.648556,35.966241 c -0.805644,0.558027 -0.691444,3.009458 -0.691444,3.009458 l -0.407053,0.80561 -0.465831,0.818822 -0.03646,1.006865 0.740245,0.763454 -0.378082,0.879472 -0.51384,2.783426 c 1.375796,-0.277146 1.388841,-0.862244 3.752326,-0.652488 l -0.824782,-1.602788 -0.426925,-1.313821 -0.03457,-1.287464 0.272428,-0.557398 0.03944,-0.694762 -0.230216,-4.138167 c -0.655513,-0.05738 -0.744387,-0.07207 -0.749803,0.01842 -0.0038,0.06 0,0 -0.04534,0.161355 0,0 -0.06874,0.05423 -0.08683,0.03536 -0.01817,-0.01885 0.08676,-0.03536 0.08676,-0.03536 z" + id="Button_Pointer" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccccccccccccccscacc" /> + </g> +</svg> diff --git a/src/Computerscare.hpp b/src/Computerscare.hpp @@ -289,12 +289,20 @@ struct MediumDotSnapKnob : RoundBlackSnapKnob { setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-medium-knob-dot-indicator.svg"))); } }; +struct TinyChannelsSnapKnob: RoundBlackSnapKnob { + TinyChannelsSnapKnob() { + setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-scramble-knob.svg"))); + } + void randomize() override {return;} +}; struct SmoothKnob : RoundKnob { SmoothKnob() { setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-medium-knob-effed.svg"))); } + }; + struct SmallKnob : RoundKnob { SmallKnob() { setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-small-knob-effed.svg"))); diff --git a/src/ComputerscareKnolyPobs.cpp b/src/ComputerscareKnolyPobs.cpp @@ -4,16 +4,16 @@ struct ComputerscareKnolyPobs; const int numKnobs = 16; -const int numToggles = 16; -const int numOutputs = 16; - struct ComputerscareKnolyPobs : Module { - int counter = 0; + int counterPeriod = 64; + int counter = counterPeriod + 1; + int polyChannels = 16; + ComputerscareSVGPanel* panelRef; enum ParamIds { KNOB, - TOGGLES = KNOB + numKnobs, - NUM_PARAMS = TOGGLES + numToggles + POLY_CHANNELS = KNOB + numKnobs, + NUM_PARAMS }; enum InputIds { @@ -22,7 +22,7 @@ struct ComputerscareKnolyPobs : Module { }; enum OutputIds { POLY_OUTPUT, - NUM_OUTPUTS = POLY_OUTPUT + numOutputs + NUM_OUTPUTS }; enum LightIds { NUM_LIGHTS @@ -34,25 +34,63 @@ struct ComputerscareKnolyPobs : Module { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); for (int i = 0; i < numKnobs; i++) { - configParam(KNOB + i, 0.0f, 10.0f, 0.0f); - configParam(KNOB + i, 0.f, 10.f, 0.f, "Channel " + std::to_string(i + 1) + " Voltage", " Volts"); + configParam(KNOB + i, 0.f, 10.f, 0.f, "Channel " + std::to_string(i + 1)); } - + configParam(POLY_CHANNELS, 1.f, 16.f, 16.f, "Poly Channels"); } void process(const ProcessArgs &args) override { counter++; - if (counter > 5012) { + if (counter > 64) { + checkPoly(); //printf("%f \n",random::uniform()); counter = 0; //rect4032 //south facing high wall } - outputs[POLY_OUTPUT].setChannels(16); - for (int i = 0; i < numKnobs; i++) { + + for (int i = 0; i < polyChannels; i++) { outputs[POLY_OUTPUT].setVoltage(params[KNOB + i].getValue(), i); } } + void checkPoly() { + float candidate= params[POLY_CHANNELS].getValue(); + if(polyChannels != candidate) { + polyChannels = candidate; + outputs[POLY_OUTPUT].setChannels(polyChannels); + redraw(); + } + + + } + void redraw() { + for (int i = 0; i < polyChannels; i++) { + //params[KNOB+i].setValue(random::uniform()); + } + } + +}; + +struct DisableableSmoothKnob : RoundKnob { + std::shared_ptr<Svg> enabledSvg = APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-medium-knob-effed.svg")); + std::shared_ptr<Svg> disabledSvg = APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-medium-knob-disabled.svg")); + + int channel = 0; + ComputerscareKnolyPobs *module; + + DisableableSmoothKnob() { + //setSvg(enabledSvg); + } + void draw(const DrawArgs& args) override { + if (module) { + bool disabled = (channel > module->polyChannels - 1); + setSvg(disabled ? disabledSvg : enabledSvg); + dirtyValue=-10.f; + } + else { + } + RoundKnob::draw(args); + } }; struct ComputerscareKnolyPobsWidget : ModuleWidget { @@ -67,20 +105,18 @@ struct ComputerscareKnolyPobsWidget : ModuleWidget { panel->setBackground(APP->window->loadSvg(asset::plugin(pluginInstance, "res/ComputerscareKnolyPobsPanel.svg"))); //module->panelRef = panel; - addChild(panel); - } + + addParam(createParam<TinyChannelsSnapKnob>(Vec(6, 20), module, ComputerscareKnolyPobs::POLY_CHANNELS)); + float xx; float yy; for (int i = 0; i < numKnobs; i++) { - xx = 1.4f + 24.3 * (i-i % 8)/8; - yy = 64 + 37.5 * (i % 8) + 14.3 * (i - i % 8)/8; - addLabeledKnob(std::to_string(i + 1), xx, yy, module, i, (i-i%8)*1.2-2, 0); + xx = 1.4f + 24.3 * (i - i % 8) / 8; + yy = 64 + 37.5 * (i % 8) + 14.3 * (i - i % 8) / 8; + addLabeledKnob(std::to_string(i + 1), xx, yy, module, i, (i - i % 8) * 1.2 - 2, 0); } - - - addOutput(createOutput<PointingUpPentagonPort>(Vec(28, 24), module, ComputerscareKnolyPobs::POLY_OUTPUT)); } @@ -92,13 +128,23 @@ struct ComputerscareKnolyPobsWidget : ModuleWidget { smallLetterDisplay->value = label; smallLetterDisplay->textAlign = 1; - addParam(createParam<SmoothKnob>(Vec(x, y), module, ComputerscareKnolyPobs::KNOB + index)); + ParamWidget* pob = createParam<DisableableSmoothKnob>(Vec(x, y), module, ComputerscareKnolyPobs::KNOB + index); + + DisableableSmoothKnob* fader = dynamic_cast<DisableableSmoothKnob*>(pob); + + fader->module = module; + fader->channel = index; + + addParam(fader); + + smallLetterDisplay->box.pos = Vec(x + labelDx, y - 12 + labelDy); addChild(smallLetterDisplay); } + DisableableSmoothKnob* fader; SmallLetterDisplay* smallLetterDisplay; };