commit 141a707555a30eb8af9adaa8b990a15eceee7497
parent 165c0703111ae3e11d0254d4a88b3c3c9170ab2c
Author: Adam M <aemalone@gmail.com>
Date: Sat, 27 Oct 2018 01:36:38 -0500
make ilovecookies work
Diffstat:
3 files changed, 117 insertions(+), 11 deletions(-)
diff --git a/res/computerscare-medium-knob-effed.svg b/res/computerscare-medium-knob-effed.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 24 24"
+ version="1.1"
+ sodipodi:docname="computerscare-medium-knob-effed.svg"
+ inkscape:version="0.92.2 5c3e80d, 2017-08-06"
+ width="24"
+ height="24">
+ <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="22.250293"
+ inkscape:cx="10.260513"
+ 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,-36)">
+ <path
+ style="fill:#245559;stroke:#000000;stroke-width:0.3851625;stroke-opacity:1"
+ d="M 23.416981,47.848118 C 24.134733,56.365445 18.59649,60.042484 12.241802,59.457236 6.3983829,58.919073 -0.89315225,53.976492 0.68692657,47.90236 2.8094213,39.743075 7.5372676,35.870447 12.241802,36.347485 c 3.525053,0.357439 6.496545,2.763659 7.494736,5.154063 0.983156,2.354404 3.480798,3.977445 3.680443,6.34657 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:#24c9a6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.93513405px;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.524313,36.829044 c -0.503283,0.534885 -0.431943,2.884655 -0.431943,2.884655 l -0.0077,0.935591 -0.537576,0.621476 -0.02277,0.96511 0.46243,0.731793 -0.236187,0.843001 -0.320995,2.667997 c 0.859456,-0.265652 0.867606,-0.826487 2.34407,-0.62543 l -0.515241,-1.53632 -0.515162,-1.041486 0.226864,-1.451923 0.665221,-0.534283 -0.470396,-0.66595 -0.143814,-3.966556 c -0.409498,-0.055 -0.465018,-0.06908 -0.468402,0.01766 -0.0023,0.05751 0,0 -0.02833,0.154664 0,0 -0.04294,0.05198 -0.05424,0.0339 -0.01135,-0.01807 0.05419,-0.0339 0.05419,-0.0339 z"
+ id="Button_Pointer"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccccccccccscac" />
+ </g>
+</svg>
diff --git a/src/Computerscare.hpp b/src/Computerscare.hpp
@@ -75,9 +75,14 @@ struct InPort : SVGPort {
struct LrgKnob : RoundBlackSnapKnob {
LrgKnob() {
- setSVG(SVG::load(assetPlugin(plugin, "res/computerscare-big-knob-effed.svg")));
- //void randomize() override;
+ setSVG(SVG::load(assetPlugin(plugin, "res/computerscare-big-knob-effed.svg")));
box.size = Vec(32,32);
}
void randomize() override { return; }
};
+struct SmoothKnob : RoundBlackKnob {
+ SmoothKnob() {
+ setSVG(SVG::load(assetPlugin(plugin, "res/computerscare-medium-knob-effed.svg")));
+ box.size = Vec(20,20);
+ }
+};
diff --git a/src/ComputerscareILoveCookies.cpp b/src/ComputerscareILoveCookies.cpp
@@ -11,7 +11,9 @@
struct ComputerscareILoveCookies;
const int numFields = 3;
-const std::string b64lookup = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&$0";
+const int numKnobRows = 5;
+const int numKnobColumns = 5;
+const std::string knoblookup = "abcdefghijklmnopqrstuvwxy";
class MyTextFieldCookie : public LedDisplayTextField {
@@ -65,7 +67,8 @@ private:
struct ComputerscareILoveCookies : Module {
enum ParamIds {
- NUM_PARAMS
+ KNOB_PARAM,
+ NUM_PARAMS = KNOB_PARAM + numKnobRows * numKnobColumns
};
enum InputIds {
GLOBAL_CLOCK_INPUT,
@@ -132,7 +135,7 @@ ComputerscareILoveCookies() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LI
}
void randomizeAllFields() {
- std::string mainlookup ="111111111111111111122223333333344444444444444445556667778888888888888999";
+ std::string mainlookup =knoblookup;
std::string string = "";
std::string randchar = "";
int length = 0;
@@ -150,9 +153,16 @@ ComputerscareILoveCookies() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LI
}
- void parseFormula(std::string expr, int index) {
+ void parseFormula(std::string input, int index) {
std::vector<int> absoluteSequence;
- absoluteSequence = parseEntireString(expr,b64lookup);
+ int currentVal;
+ absoluteSequence.resize(0);
+
+ for(unsigned int i = 0; i < input.length(); i++) {
+ currentVal = knoblookup.find(input[i]);
+ absoluteSequence.push_back(currentVal);
+ }
+
numSteps[index] = absoluteSequence.size();
absoluteSequences[index] = absoluteSequence;
}
@@ -195,7 +205,8 @@ void onCreate () override
void ComputerscareILoveCookies::step() {
bool globalGateIn = globalClockTrigger.isHigh();
- bool activeStep = false;
+ bool activeStep = 0;
+ int activeKnob;
bool atFirstStep = false;
bool clocked = globalClockTrigger.process(inputs[GLOBAL_CLOCK_INPUT].value);
bool currentTriggerIsHigh;
@@ -226,15 +237,18 @@ void ComputerscareILoveCookies::step() {
resetOneOfThem(i);
}
- activeStep = absoluteSequences[i][this->absoluteStep[i]]==1;
+ activeKnob = absoluteSequences[i][this->absoluteStep[i]];
+ //printf("%i, %f",i,activeKnob);
+
atFirstStep = (this->absoluteStep[i] == 0);
}
if(inputs[CLOCK_INPUT + i].active) {
- outputs[TRG_OUTPUT + i].value = (currentTriggerIsHigh && activeStep) ? 10.0f : 0.0f;
+ outputs[TRG_OUTPUT + i].value = params[KNOB_PARAM + activeKnob].value;
+
outputs[FIRST_STEP_OUTPUT + i].value = (currentTriggerIsHigh && atFirstStep) ? 10.f : 0.0f;
}
else {
- outputs[TRG_OUTPUT + i].value = (globalGateIn && activeStep) ? 10.0f : 0.0f;
+ outputs[TRG_OUTPUT + i].value = params[KNOB_PARAM + activeKnob].value;
outputs[FIRST_STEP_OUTPUT + i].value = (globalGateIn && atFirstStep) ? 10.f : 0.0f;
}
}
@@ -283,9 +297,22 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget {
double verticalSpacing = 18.4;
int verticalStart = 82;
+
+ double knobXStart = 6;
+ double knobYStart = 8;
+ double knobRowWidth = 12;
+ double knobColumnHeight = 9;
ComputerscareILoveCookiesWidget(ComputerscareILoveCookies *module) : ModuleWidget(module) {
setPanel(SVG::load(assetPlugin(plugin, "res/ComputerscareILoveCookiesPanel.svg")));
+
+ for(int i = 0; i < numKnobRows; i++) {
+ for(int j = 0; j < numKnobColumns; j++) {
+ ParamWidget* knob = ParamWidget::create<SmoothKnob>(mm2px(Vec(knobXStart + j*knobRowWidth,knobYStart + i*knobColumnHeight)), module, ComputerscareILoveCookies::KNOB_PARAM +numKnobColumns*i + j, 0.0f, 10.0f, 0.0f);
+ addParam(knob);
+ }
+ }
+
//global clock input
addInput(Port::create<InPort>(mm2px(Vec(2 , 59)), Port::INPUT, module, ComputerscareILoveCookies::GLOBAL_CLOCK_INPUT));