computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit 67aa2a094cb9a88057267333f9a5d7c643cc9d51
parent b62d2f86da86342637bb968ed74d7ffe2fd4745a
Author: Adam M <aemalone@gmail.com>
Date:   Sun, 12 Apr 2020 09:33:33 -0500

Boly puttons disableable buttons, better poly handling, momentary mode

Diffstat:
Mplugin.json | 2+-
Mres/computerscare-medium-knob-disabled.svg | 4++--
Ares/computerscare-medium-knob-dot-indicator-disabled.svg | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/ComputerscareBolyPuttons.cpp | 121+++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/ComputerscareKnolyPobs.cpp | 9---------
5 files changed, 137 insertions(+), 73 deletions(-)

diff --git a/plugin.json b/plugin.json @@ -46,7 +46,7 @@ {"slug":"computerscare-i-love-cookies", "name":"I Love Cookies", "description":"Text-based CV and signal sequencer", - "tags":["Sequencer","Utility","Random"] + "tags":["Sequencer","Utility","Random","Polyphonic"] }, {"slug":"computerscare-roly-pouter", diff --git a/res/computerscare-medium-knob-disabled.svg b/res/computerscare-medium-knob-disabled.svg @@ -41,7 +41,7 @@ id="namedview1287" showgrid="false" inkscape:zoom="15.733333" - inkscape:cx="11.595259" + inkscape:cx="0.15458079" inkscape:cy="14.442801" inkscape:window-x="0" inkscape:window-y="0" @@ -65,7 +65,7 @@ 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" + 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:#6b7a77;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 14.237539,34.504377 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 13.86087,44.294338 13.873915,43.70924 16.2374,43.918996 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" diff --git a/res/computerscare-medium-knob-dot-indicator-disabled.svg b/res/computerscare-medium-knob-dot-indicator-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 28 28" + version="1.1" + sodipodi:docname="computerscare-medium-knob-dot-indicator-disabled.svg" + inkscape:version="0.92.2 5c3e80d, 2017-08-06" + width="28" + height="28"> + <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="7.5228158" + inkscape:cy="16.744952" + 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,-32)"> + <path + style="fill:#aab8ba;stroke:#000000;stroke-width:0.40182629;stroke-opacity:1;fill-opacity:1" + d="M 25.62578,46.000183 C 26.374585,54.886007 20.596733,58.72213 13.967114,58.111561 7.8708847,57.550115 -0.06927658,50.275098 1.9123265,44.034327 4.8258211,34.858699 5.0683776,37.665788 7.8677328,36.080009 10.080145,34.82672 10.946556,34.276664 13.967114,34.001984 c 3.68123,-0.334759 7.366697,-0.291907 10.540264,2.584521 1.741799,1.578715 0.910119,6.942056 1.118402,9.413678 z" + id="Big_Button_Circle" + inkscape:connector-curvature="0" + sodipodi:nodetypes="sssssss" /> + <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:#6b7a77;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.37795276;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;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 16.862146,36.050648 c 0.117928,-0.66458 0.143572,-1.22448 -0.101176,-1.753193 0.307778,-0.299636 0.726646,-0.503303 0.602995,-0.886243 -0.274556,-0.256096 -0.848253,-0.275434 -1.252334,-0.22093 -0.552513,0.09233 -1.178468,0.03274 -1.689073,0.149938 -2.516396,0.08453 -1.133525,0.778224 -1.263805,1.416518 0.04674,0.589114 -0.213607,1.270542 -0.111272,1.865607 1.164475,1.134156 2.759399,0.548985 3.814665,-0.571697 z" + id="Button_Pointer" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccccccc" /> + </g> +</svg> diff --git a/src/ComputerscareBolyPuttons.cpp b/src/ComputerscareBolyPuttons.cpp @@ -16,7 +16,8 @@ struct ComputerscareBolyPuttons : ComputerscarePolyModule { ComputerscareSVGPanel* panelRef; enum ParamIds { TOGGLE, - POLY_CHANNELS=TOGGLE+numToggles, + POLY_CHANNELS = TOGGLE + numToggles, + MOMENTARY_MODE, NUM_PARAMS }; @@ -92,31 +93,34 @@ struct ComputerscareBolyPuttons : ComputerscarePolyModule { } json_t *dataToJson() override { - json_t *rootJ = json_object(); + json_t *rootJ = json_object(); json_object_set_new(rootJ, "outputRange", json_integer(outputRangeEnum)); json_object_set_new(rootJ, "radioMode", json_boolean(radioMode)); json_object_set_new(rootJ, "momentaryMode", json_boolean(momentary)); return rootJ; - } + } void onRandomize() override { - if (radioMode) { - int rIndex = floor(random::uniform() * 16); - switchOffAllButtonsButOne(rIndex); - params[TOGGLE + rIndex].setValue(1.f); - } - else { - for (int i = 0; i < numToggles; i++) { - params[TOGGLE + i].setValue(random::uniform() < 0.5 ? 0.f : 1.f); + if (momentary) { + } else { + if (radioMode) { + int rIndex = floor(random::uniform() * 16); + switchOffAllButtonsButOne(rIndex); + params[TOGGLE + rIndex].setValue(1.f); + } + else { + for (int i = 0; i < numToggles; i++) { + params[TOGGLE + i].setValue(random::uniform() < 0.5 ? 0.f : 1.f); + } } } } void checkPoly() override { - int aChannels=inputs[A_INPUT].getChannels(); - int bChannels=inputs[B_INPUT].getChannels(); + int aChannels = inputs[A_INPUT].getChannels(); + int bChannels = inputs[B_INPUT].getChannels(); int knobSetting = params[POLY_CHANNELS].getValue(); - if(knobSetting ==0) { - polyChannels = (aChannels==0 && bChannels ==0) ? 16 : std::max(aChannels,bChannels); + if (knobSetting == 0) { + polyChannels = (aChannels == 0 && bChannels == 0) ? 16 : std::max(aChannels, bChannels); } else { polyChannels = knobSetting; @@ -126,65 +130,41 @@ struct ComputerscareBolyPuttons : ComputerscarePolyModule { void process(const ProcessArgs &args) override { ComputerscarePolyModule::checkCounter(); - float min = outputRanges[outputRangeEnum][0]; - float max = outputRanges[outputRangeEnum][1]; + float rangeMin = outputRanges[outputRangeEnum][0]; + float rangeMax = outputRanges[outputRangeEnum][1]; int numAChannels = inputs[A_INPUT].getChannels(); int numBChannels = inputs[B_INPUT].getChannels(); - - //if (outputs[SCALED_OUTPUT + i].isConnected() || outputs[QUANTIZED_OUTPUT + i].isConnected()) { - // numInputChannels = inputs[CHANNEL_INPUT + i].getChannels(); - if (momentary) { - for (int i = 0; i < numToggles; i++) { - if (momentaryTriggers[i].process(params[TOGGLE + i].getValue())) { - pulseGen[i].trigger(); - if (inputs[A_INPUT].isConnected()) { - min = inputs[A_INPUT].getVoltage(i % numAChannels); - } - - if (inputs[B_INPUT].isConnected()) { - max = inputs[B_INPUT].getVoltage(i % numBChannels); - } - - float spread = max - min; - outputs[POLY_OUTPUT].setVoltage(pulseGen[i].process(APP->engine->getSampleTime())*spread + min, i); - } + float min; + float max; + float spread; - } + if (radioMode && !momentary) { + checkForParamChanges(); } - //toggle mode - else { - if (radioMode) { - checkForParamChanges(); - } - for (int i = 0; i < numToggles; i++) { - if (inputs[A_INPUT].isConnected()) { - min = inputs[A_INPUT].getVoltage(i % numAChannels); - } - - if (inputs[B_INPUT].isConnected()) { - max = inputs[B_INPUT].getVoltage(i % numBChannels); - } - - float spread = max - min; - outputs[POLY_OUTPUT].setVoltage(params[TOGGLE + i].getValue()*spread + min, i); - } + for(int i = 0; i < polyChannels; i++) { + min = i< numAChannels ? inputs[A_INPUT].getVoltage(i) : rangeMin; + max = i< numBChannels ? inputs[B_INPUT].getVoltage(i) : rangeMax; + spread = max-min; + outputs[POLY_OUTPUT].setVoltage(params[TOGGLE + i].getValue()*spread + min, i); } } }; struct DisableableParamWidget : SmallIsoButton { - ComputerscarePolyModule *module; + ComputerscareBolyPuttons *module; int channel; + DisableableParamWidget() { SmallIsoButton(); } void step() override { if (module) { disabled = channel > module->polyChannels - 1; + momentary = module->momentary; } SmallIsoButton::step(); } @@ -204,7 +184,7 @@ struct ComputerscareBolyPuttonsWidget : ModuleWidget { } - channelWidget = new PolyOutputChannelsWidget(Vec(22,23),module,ComputerscareBolyPuttons::POLY_CHANNELS); + channelWidget = new PolyOutputChannelsWidget(Vec(22, 23), module, ComputerscareBolyPuttons::POLY_CHANNELS); addChild(channelWidget); float xx; @@ -214,7 +194,7 @@ struct ComputerscareBolyPuttonsWidget : ModuleWidget { for (int i = 0; i < numToggles; i++) { xx = 5.2f + 27.3 * (i - i % 8) / 8; yy = 92 + 33.5 * (i % 8) + 14.3 * (i - i % 8) / 8; - dx = 4 - (i-i%8)*0.9; + dx = 4 - (i - i % 8) * 0.9; dy = 19; addLabeledButton(std::to_string(i + 1), xx, yy, module, i, dx, dy); } @@ -229,8 +209,8 @@ struct ComputerscareBolyPuttonsWidget : ModuleWidget { DisableableParamWidget* button = createParam<DisableableParamWidget>(Vec(x, y), module, ComputerscareBolyPuttons::TOGGLE + index); - button->module=module; - button->channel=index; + button->module = module; + button->channel = index; addParam(button); @@ -245,12 +225,11 @@ struct ComputerscareBolyPuttonsWidget : ModuleWidget { addChild(smallLetterDisplay); } - + void fromJson(json_t *rootJ) override { ModuleWidget::fromJson(rootJ); bolyPuttons->legacyJSON(rootJ); - } void appendContextMenu(Menu *menu) override; @@ -283,6 +262,20 @@ struct RadioModeMenuItem: MenuItem { MenuItem::step(); } }; +struct MomentaryModeMenuItem: MenuItem { + ComputerscareBolyPuttons *bolyPuttons; + MomentaryModeMenuItem() { + + } + void onAction(const event::Action &e) override { + bolyPuttons->momentary = !bolyPuttons->momentary; + } + void step() override { + rightText = bolyPuttons->momentary ? "✔" : ""; + MenuItem::step(); + } +}; + void ComputerscareBolyPuttonsWidget::appendContextMenu(Menu *menu) { @@ -291,12 +284,18 @@ void ComputerscareBolyPuttonsWidget::appendContextMenu(Menu *menu) menu->addChild(construct<MenuLabel>(&MenuLabel::text, "")); menu->addChild(construct<MenuLabel>(&MenuLabel::text, "How The Buttons Work")); RadioModeMenuItem *radioMode = new RadioModeMenuItem(); - radioMode->text = "Exclusive Mode (behaves like radio buttons)"; + radioMode->text = "Exclusive Mode (like radio buttons: only can be pressed at a time)"; radioMode->bolyPuttons = bolyPuttons; menu->addChild(radioMode); menu->addChild(construct<MenuLabel>(&MenuLabel::text, "")); + MomentaryModeMenuItem *momentaryMode = new MomentaryModeMenuItem(); + momentaryMode->text = "Momentary (gate output while button is held)"; + momentaryMode->bolyPuttons = bolyPuttons; + menu->addChild(momentaryMode); + + menu->addChild(construct<MenuLabel>(&MenuLabel::text, "")); menu->addChild(construct<MenuLabel>(&MenuLabel::text, "Off / On Values (A ... B)")); menu->addChild(construct<OutputRangeItem>(&MenuItem::text, " 0v ... +10v", &OutputRangeItem::bolyPuttons, bolyPuttons, &OutputRangeItem::outputRangeEnum, 0)); diff --git a/src/ComputerscareKnolyPobs.cpp b/src/ComputerscareKnolyPobs.cpp @@ -88,22 +88,13 @@ struct ComputerscareKnolyPobsWidget : ModuleWidget { ComputerscareSVGPanel *panel = new ComputerscareSVGPanel(); panel->box.size = box.size; panel->setBackground(APP->window->loadSvg(asset::plugin(pluginInstance, "res/ComputerscareKnolyPobsPanel.svg"))); - - //module->panelRef = panel; addChild(panel); } - - - - //addParam(createParam<TinyChannelsSnapKnob>(Vec(8, 26), module, ComputerscareKnolyPobs::POLY_CHANNELS)); - channelWidget = new PolyOutputChannelsWidget(Vec(1,23),module,ComputerscareKnolyPobs::POLY_CHANNELS); addChild(channelWidget); - - float xx; float yy; for (int i = 0; i < numKnobs; i++) {