computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit 31875379286c4c00a793527586676caa5675898d
parent b45154c69b6cce7fe9831293c42e0dd81379f8f6
Author: Adam M <aemalone@gmail.com>
Date:   Sun, 27 Dec 2020 11:14:24 -0600

Select algorithm goly penerator

Diffstat:
Mres/ComputerscareGolyPeneratorPanel.svg | 12++++++------
Msrc/Computerscare.hpp | 6++++++
Msrc/ComputerscareBlank.cpp | 144+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
Msrc/ComputerscareGolyPenerator.cpp | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Msrc/MenuParams.hpp | 131+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Msrc/golyFunctions.cpp | 10+++++-----
6 files changed, 342 insertions(+), 59 deletions(-)

diff --git a/res/ComputerscareGolyPeneratorPanel.svg b/res/ComputerscareGolyPeneratorPanel.svg @@ -25,10 +25,10 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="11.313709" - inkscape:cx="34.04832" - inkscape:cy="278.57564" + inkscape:cx="30.33601" + inkscape:cy="360.7768" inkscape:document-units="mm" - inkscape:current-layer="text1023" + inkscape:current-layer="g1669" showgrid="false" units="px" inkscape:snap-bbox="true" @@ -235,7 +235,7 @@ </g> <g id="g9547" - transform="matrix(0.23127322,-0.07546583,0.02054862,0.22663881,-1.1606061,289.06733)"> + transform="matrix(0.23127322,-0.07546583,0.02054862,0.22663881,-2.7040876,289.7923)"> <g style="display:inline" inkscape:label="Layer 1" @@ -370,8 +370,8 @@ inkscape:connector-curvature="0" /> </g> <path - style="fill:#fcfcfc;fill-opacity:1;stroke:#464646;stroke-width:0.296;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers" - d="m 0.84393651,279.05851 14.57839849,0.0321 -0.300846,0.96549 -0.42519,9.06913 -13.85235483,-0.0321 z" + style="fill:#fcfcfc;fill-opacity:1;stroke:#464646;stroke-width:0.327203;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers" + d="m 0.8595379,279.07411 14.5471951,0.0393 -0.300202,1.1823 -0.424279,11.10574 -13.82270645,-0.0393 z" id="rect1127" inkscape:connector-curvature="0" sodipodi:nodetypes="cccccc" /> diff --git a/src/Computerscare.hpp b/src/Computerscare.hpp @@ -379,6 +379,12 @@ struct ScrambleKnob : RoundKnob { setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-scramble-knob.svg"))); } }; +struct ScrambleSnapKnob : RoundKnob { + ScrambleSnapKnob() { + snap=true; + setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-scramble-knob.svg"))); + } +}; struct SmallSnapKnob : RoundBlackSnapKnob { //bool visible = true; diff --git a/src/ComputerscareBlank.cpp b/src/ComputerscareBlank.cpp @@ -6,15 +6,18 @@ #include <fstream> #include <sstream> #include <thread> +#include <dirent.h> struct ComputerscareBlank; -struct ComputerscareBlank : Module { +struct ComputerscareBlank : ComputerscareMenuParamModule { bool loading = true; bool loadedJSON = false; std::string path; + std::string parentDirectory; std::vector<std::string> paths; + std::vector<std::string> catalog; float width = 120; float height = 380; int rotation = 0; @@ -32,12 +35,16 @@ struct ComputerscareBlank : Module { int speed = 100000; int imageStatus = 0; + std::vector<std::string> animationModeDescriptions; + std::vector<std::string> endBehaviorDescriptions; + ComputerscareSVGPanel* panelRef; enum ParamIds { ANIMATION_SPEED, ANIMATION_ENABLED, CONSTANT_FRAME_DELAY, ANIMATION_MODE, + END_BEHAVIOR, NUM_PARAMS }; enum InputIds { @@ -55,10 +62,27 @@ struct ComputerscareBlank : Module { ComputerscareBlank() { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); - configParam(ANIMATION_SPEED, -10.f, 10.f, 1.0, "Animation Speed"); + configMenuParam(ANIMATION_SPEED, 0.05f, 20.f, 1.0, "Animation Speed", 2,"x"); configParam(ANIMATION_ENABLED, 0.f, 1.f, 1.f, "Animation Enabled"); configParam(CONSTANT_FRAME_DELAY, 0.f, 1.f, 0.f, "Constant Frame Delay"); - configParam(ANIMATION_MODE, 0.f, 3.f, 0.f, "Animation Mode"); + configMenuParam(END_BEHAVIOR, 0.f, 5.f, 0.f, "Animation End Behavior", 2); + + animationModeDescriptions.push_back("Forward"); + animationModeDescriptions.push_back("Reverse"); + animationModeDescriptions.push_back("Ping Pong"); + animationModeDescriptions.push_back("Random Shuffled"); + animationModeDescriptions.push_back("Full Random"); + + endBehaviorDescriptions.push_back("Repeat"); + endBehaviorDescriptions.push_back("Stop"); + endBehaviorDescriptions.push_back("Select Random"); + endBehaviorDescriptions.push_back("Load Next"); + endBehaviorDescriptions.push_back("Load Previous"); + + + configMenuParam(ANIMATION_MODE, 0.f, "Animation Mode",animationModeDescriptions); + + paths.push_back("empty"); } void process(const ProcessArgs &args) override { @@ -70,14 +94,7 @@ struct ComputerscareBlank : Module { if (params[ANIMATION_ENABLED].getValue()) { if (numFrames > 1) { - if(params[ANIMATION_SPEED].getValue() >=0 ) { - currentFrame++; - } - else { - currentFrame--; - } - currentFrame+=numFrames; - currentFrame %= numFrames; + tickAnimation(); } } } @@ -94,17 +111,49 @@ struct ComputerscareBlank : Module { if (!pathC) { return; } + parentDirectory = dir; std::string path = pathC; std::free(pathC); setPath(path); } + void getContainingDirectory(int index = 0) { + + std::string dir = rack::string::directory(paths[index]); + + struct dirent* dirp = NULL; + DIR* rep = NULL; + + rep = opendir(dir.c_str()); + + int i = 0; + catalog.clear(); + //fichier.clear(); + while ((dirp = readdir(rep)) != NULL) { + std::string name = dirp->d_name; + + std::size_t found = name.find(".gif", name.length() - 5); + if (found != std::string::npos) { + catalog.push_back(name); + //DEBUG("we got gif:%s",name.c_str()); + } + } + } + void loadRandomGif(int index = 0) { + std::string dir = rack::string::directory(paths[index]); + getContainingDirectory(); + int randomIndex = floor(random::uniform() * catalog.size()); + + setPath(dir + "/" + catalog[randomIndex]); + } + void setPath(std::string path, int index = 0) { //if (paths.size() <= index) { //paths.push_back(path); //} //else { + numFrames = 0; paths[index] = path; //} printf("setted %s\n", path.c_str()); @@ -126,10 +175,10 @@ struct ComputerscareBlank : Module { } else { if (params[CONSTANT_FRAME_DELAY].getValue()) { - frameDelay = .04/speedKnob; + frameDelay = .04 / speedKnob; } else { - frameDelay = base/speedKnob; + frameDelay = base / speedKnob; } } } @@ -137,6 +186,20 @@ struct ComputerscareBlank : Module { //return numFrames > 0 ? paths[currentFrame] : ""; return paths[0]; } + void tickAnimation() { + if (params[ANIMATION_SPEED].getValue() >= 0 ) { + nextFrame(); + } + else { + prevFrame(); + } + if(currentFrame == 0) { + int eb = params[END_BEHAVIOR].getValue(); + if(eb == 3 ) { + loadRandomGif(); + } + } + } void nextFrame() { currentFrame++; currentFrame %= numFrames; @@ -247,6 +310,32 @@ struct InvertYMenuItem: MenuItem { MenuItem::step(); } }; +struct KeyboardControlChildMenu : MenuItem { + ComputerscareBlank *blank; + + Menu *createChildMenu() override { + Menu *menu = new Menu; + menu->addChild(construct<MenuLabel>(&MenuLabel::text, "A,S,D,F: Translate image position")); + menu->addChild(construct<MenuLabel>(&MenuLabel::text, "Z,X: Zoom in/out")); + menu->addChild(construct<MenuLabel>(&MenuLabel::text, "J,L: Previous / next frame")); + menu->addChild(construct<MenuLabel>(&MenuLabel::text, "K: Go to first frame")); + + menu->addChild(construct<MenuLabel>(&MenuLabel::text, "I: Go to random frame")); + + menu->addChild(construct<MenuLabel>(&MenuLabel::text, "O: Load random image from same directory")); + + menu->addChild(construct<MenuLabel>(&MenuLabel::text, "P: Toggle animation on/off")); + + + InvertYMenuItem *invertYMenuItem = new InvertYMenuItem(); + invertYMenuItem->text = "Invert Y-Axis"; + invertYMenuItem->blank = blank; + menu->addChild(invertYMenuItem); + + return menu; + } + +}; struct PNGDisplay : TransparentWidget { ComputerscareBlank *blankModule; @@ -341,7 +430,7 @@ struct PNGDisplay : TransparentWidget { } }; -struct ComputerscareBlankWidget : ModuleWidget { +struct ComputerscareBlankWidget : MenuParamModuleWidget { ComputerscareBlankWidget(ComputerscareBlank *blankModule) { setModule(blankModule); @@ -391,9 +480,13 @@ struct ComputerscareBlankWidget : ModuleWidget { menu->addChild(new MenuEntry); - menu->addChild(construct<MenuLabel>(&MenuLabel::text, "Keyboard Controls:")); - menu->addChild(construct<MenuLabel>(&MenuLabel::text, "A,S,D,F: Translate image position")); - menu->addChild(construct<MenuLabel>(&MenuLabel::text, "Z,X: Zoom in/out")); + //menu->addChild(construct<MenuLabel>(&MenuLabel::text, "Keyboard Controls:")); + + KeyboardControlChildMenu *kbMenu = new KeyboardControlChildMenu(); + kbMenu->text = "Keyboard Controls"; + kbMenu->rightText = RIGHT_ARROW; + kbMenu->blank = blank; + menu->addChild(kbMenu); menu->addChild(construct<MenuLabel>(&MenuLabel::text, "")); @@ -414,11 +507,6 @@ struct ComputerscareBlankWidget : ModuleWidget { menu->addChild(construct<MenuLabel>(&MenuLabel::text, "")); - InvertYMenuItem *invertYMenuItem = new InvertYMenuItem(); - invertYMenuItem->text = "Invert Y-Axis"; - invertYMenuItem->blank = blank; - menu->addChild(invertYMenuItem); - /*SmoothKnob* speedParam = new SmoothKnob(); speedParam->paramQuantity = blankModule->paramQuantities[ComputerscareBlank::ANIMATION_SPEED]; @@ -432,18 +520,21 @@ struct ComputerscareBlankWidget : ModuleWidget { //menu->addChild(construct<MenuLabel>(&MenuLabel::text, "Animation Speed")); menu->addChild(LabeledKnob);*/ - MenuParam* animEnabled = new MenuParam(blankModule->paramQuantities[ComputerscareBlank::ANIMATION_ENABLED],0); + MenuParam* animEnabled = new MenuParam(blankModule->paramQuantities[ComputerscareBlank::ANIMATION_ENABLED], 0); menu->addChild(animEnabled); MenuParam* speedParam = new MenuParam(blankModule->paramQuantities[ComputerscareBlank::ANIMATION_SPEED], 2); menu->addChild(speedParam); - MenuParam* mp = new MenuParam(blankModule->paramQuantities[ComputerscareBlank::CONSTANT_FRAME_DELAY], 2); + MenuParam* mp = new MenuParam(blankModule->paramQuantities[ComputerscareBlank::CONSTANT_FRAME_DELAY], 0); menu->addChild(mp); MenuParam* am = new MenuParam(blankModule->paramQuantities[ComputerscareBlank::ANIMATION_MODE], 1); menu->addChild(am); + MenuParam* eb = new MenuParam(blankModule->paramQuantities[ComputerscareBlank::END_BEHAVIOR], 1); + menu->addChild(eb); + @@ -554,7 +645,10 @@ struct ComputerscareBlankWidget : ModuleWidget { blankModule->toggleAnimationEnabled(); e.consume(this); } break; - + case GLFW_KEY_O: { + blankModule->loadRandomGif(); + e.consume(this); + } break; } } ModuleWidget::onHoverKey(e); diff --git a/src/ComputerscareGolyPenerator.cpp b/src/ComputerscareGolyPenerator.cpp @@ -18,6 +18,8 @@ struct ComputerscareGolyPenerator : ComputerscarePolyModule { ComputerscareSVGPanel* panelRef; Goly goly; float currentValues[16] = {0.f}; + std::vector<std::string> availableAlgorithms; + enum ParamIds { ALGORITHM, IN_OFFSET, @@ -44,7 +46,7 @@ struct ComputerscareGolyPenerator : ComputerscarePolyModule { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); - configParam(ALGORITHM , 1.f, 5.f, 1.f, "Algorithm"); + configParam(ALGORITHM , 0.f, 4.f, 0.f, "Algorithm"); configParam(IN_OFFSET, -1.f, 1.f, 0.f, "Channel Center"); configParam(IN_SCALE, -2.f, 2.f, 1.f, "Channel Spread"); @@ -53,6 +55,13 @@ struct ComputerscareGolyPenerator : ComputerscarePolyModule { configParam(OUT_OFFSET, -10.f, 10.f, 0.f, "Output Offset"); configParam<AutoParamQuantity>(POLY_CHANNELS, 1.f, 16.f, 16.f, "Poly Channels"); + availableAlgorithms.push_back("Linear"); + availableAlgorithms.push_back("Sigmoid"); + availableAlgorithms.push_back("Hump"); + availableAlgorithms.push_back("Sinusoid"); + availableAlgorithms.push_back("Pseudo-Random"); + + goly = Goly(); } @@ -60,6 +69,9 @@ struct ComputerscareGolyPenerator : ComputerscarePolyModule { std::vector<float> golyParams = {params[IN_OFFSET].getValue(), params[IN_SCALE].getValue(), params[OUT_SCALE].getValue(), params[OUT_OFFSET].getValue()}; goly.invoke((int) std::floor(params[ALGORITHM].getValue()), golyParams, params[POLY_CHANNELS].getValue()); } + void setAlgorithm(int algoVal) { + params[ALGORITHM].setValue(algoVal); + } void checkPoly() override { int knobSetting = params[POLY_CHANNELS].getValue(); polyChannels = knobSetting == 0 ? 16 : knobSetting; @@ -82,6 +94,60 @@ struct ComputerscareGolyPenerator : ComputerscarePolyModule { } }; +struct setAlgoItem : MenuItem +{ + ComputerscareGolyPenerator *penerator; + int mySetVal; + setAlgoItem(int setVal) + { + mySetVal = setVal; + } + + void onAction(const event::Action &e) override + { + penerator->setAlgorithm(mySetVal); + } + void step() override { + rightText = CHECKMARK(penerator->params[ComputerscareGolyPenerator::ALGORITHM].getValue() == mySetVal); + MenuItem::step(); + } +}; + +/*struct SetAllItem : MenuItem { + ComputerscareRolyPouter *pouter; + + Menu *createChildMenu() override { + Menu *menu = new Menu; + for (int i = 1; i < 17; i++) { + ssmi *menuItem = new ssmi(i); + menuItem->text = "Set all to ch. " + std::to_string(i); + menuItem->pouter = pouter; + menu->addChild(menuItem); + } + return menu; + } + +};*/ +struct AlgorithmChildMenu : MenuItem { + ComputerscareGolyPenerator *penerator; + + Menu *createChildMenu() override { + Menu *menu = new Menu; + menu->addChild(construct<MenuLabel>(&MenuLabel::text, "Farties")); + + for (unsigned int i = 0; i < penerator->availableAlgorithms.size(); i++) { + setAlgoItem *menuItem = new setAlgoItem(i); + //ParamSettingItem *menuItem = new ParamSettingItem(i,ComputerscareGolyPenerator::ALGORITHM); + + menuItem->text = penerator->availableAlgorithms[i]; + menuItem->penerator = penerator; + menu->addChild(menuItem); + } + + return menu; + } + +}; struct PeneratorDisplay : TransparentWidget { ComputerscareGolyPenerator *module; @@ -105,17 +171,17 @@ struct PeneratorDisplay : TransparentWidget { DrawHelper draw = DrawHelper(args.vg); Points pts = Points(); - nvgTranslate(args.vg, box.size.x / 2, box.size.y/2+5); - pts.linear(ch, Vec(0, -box.size.y/2), Vec(0, 150)); + nvgTranslate(args.vg, box.size.x / 2, box.size.y / 2 + 5); + pts.linear(ch, Vec(0, -box.size.y / 2), Vec(0, 150)); std::vector<Vec> polyVals; std::vector<NVGcolor> colors; std::vector<Vec> thicknesses; for (int i = 0; i < 16; i++) { - polyVals.push_back(Vec(valsToDraw[i] * 2,0.f)); - colors.push_back(draw.sincolor(0,{1,1,0})); + polyVals.push_back(Vec(valsToDraw[i] * 2, 0.f)); + colors.push_back(draw.sincolor(0, {1, 1, 0})); - thicknesses.push_back(Vec(160/(1+ch), 0)); + thicknesses.push_back(Vec(160 / (1 + ch), 0)); } draw.drawLines(pts.get(), polyVals, colors, thicknesses); } @@ -141,7 +207,7 @@ struct ComputerscareGolyPeneratorWidget : ModuleWidget { float xx; float yy; - addLabeledKnob<SmoothKnob>("Algo", 5, 30, module, ComputerscareGolyPenerator::ALGORITHM, 0, 0, true); + addLabeledKnob<ScrambleSnapKnob>("Algo", 4, 336, module, ComputerscareGolyPenerator::ALGORITHM, 0, 0, true); addLabeledKnob<SmoothKnob>("center", 28, 80, module, ComputerscareGolyPenerator::IN_OFFSET, 0, 0); addLabeledKnob<SmallKnob>("spread", 5, 86, module, ComputerscareGolyPenerator::IN_SCALE, 0, 0); addLabeledKnob<SmallKnob>("scale", 33, 290, module, ComputerscareGolyPenerator::OUT_SCALE, 0, 0); @@ -149,12 +215,24 @@ struct ComputerscareGolyPeneratorWidget : ModuleWidget { //addLabeledKnob("ch out",5,90,module,ComputerscareGolyPenerator::POLY_CHANNELS,-2,0); - channelWidget = new PolyOutputChannelsWidget(Vec(0, 312), module, ComputerscareGolyPenerator::POLY_CHANNELS); + channelWidget = new PolyOutputChannelsWidget(Vec(8, 312), module, ComputerscareGolyPenerator::POLY_CHANNELS); addChild(channelWidget); - addOutput(createOutput<PointingUpPentagonPort>(Vec(28, 318), module, ComputerscareGolyPenerator::POLY_OUTPUT)); + addOutput(createOutput<PointingUpPentagonPort>(Vec(28, 328), module, ComputerscareGolyPenerator::POLY_OUTPUT)); } + void appendContextMenu(Menu* menu) override { + ComputerscareGolyPenerator* penerator = dynamic_cast<ComputerscareGolyPenerator*>(this->module); + + menu->addChild(new MenuEntry); + + + AlgorithmChildMenu *algoMenu = new AlgorithmChildMenu(); + algoMenu->text = "Algorithm"; + algoMenu->rightText = RIGHT_ARROW; + algoMenu->penerator = penerator; + menu->addChild(algoMenu); + } template <typename BASE> @@ -167,7 +245,7 @@ struct ComputerscareGolyPeneratorWidget : ModuleWidget { smallLetterDisplay->textAlign = 1; if (snap) { - addParam(createParam<MediumDotSnapKnob>(Vec(x, y), module, paramIndex)); + addParam(createParam<BASE>(Vec(x, y), module, paramIndex)); } else { addParam(createParam<BASE>(Vec(x, y), module, paramIndex)); diff --git a/src/MenuParams.hpp b/src/MenuParams.hpp @@ -20,37 +20,142 @@ a few options: */ +struct ParamAndType { + ParamQuantity* param; + int type; + ParamAndType(ParamQuantity* p, int t) { + param = p; + type = t; + } +}; struct MenuParam : MenuEntry { ParamWidget* speedParam; - MenuLabel* johnLabel; + MenuLabel* displayString; + float controlRightMargin = 10; - MenuParam(ParamQuantity* pq,int type) { - if(type==0) { + MenuParam(ParamQuantity* param, int type) { + if (type == 0) { speedParam = new SmallIsoButton(); - // DisableableParamWidget* button = createParam<DisableableParamWidget>(Vec(x, y), module, ComputerscareBolyPuttons::TOGGLE + index); - } - if(type==1) { + else if (type == 1) { speedParam = new MediumDotSnapKnob(); } - - if(type==2) { + else if (type == 2) { speedParam = new SmoothKnob(); } + speedParam->paramQuantity = param; + speedParam->box.pos = Vec(controlRightMargin, 0); + box.size.y = 28; + johnLabel = construct<MenuLabel>(&MenuLabel::text, param->getLabel()); + johnLabel->box.pos = Vec(speedParam->box.size.x + controlRightMargin * 2, 0); + addChild(speedParam); + addChild(johnLabel); + } - speedParam->paramQuantity = pq; - johnLabel = construct<MenuLabel>(&MenuLabel::text, pq->getLabel()); - johnLabel->box.pos = Vec(speedParam->box.size.x+20, 0); +}; + +/* + 0: boolean + -button + -menu checkbox + -gate or toggle input + + -keyboard toggle w/ schmitt trigger + + 1: discrete + -snap knob + -dropdown menu + -forward/back buttons + -cv input + -forward/back input + + -keyboard forward/back + + 2: continuous + -smooth knob + -slider + -cv input + +*/ + - addChild(speedParam); - addChild(johnLabel); +struct MultiselectParamQuantity; +struct ComputerscareMenuParamModule : Module { + std::vector<ParamAndType*> paramList; + std::map<int,ParamAndType*> pidMap; + ParamQuantity* pq; + void configMenuParam(int paramId, float minValue, float maxValue, float defaultValue, std::string label = "", int controlType = 2, std::string unit = "", float displayBase = 0.f, float displayMultiplier = 1.f, float displayOffset = 0.f) { + + configParam(paramId, minValue, maxValue, defaultValue, label, unit, displayBase, displayMultiplier); + pq = paramQuantities[paramId]; + ParamAndType* pt = new ParamAndType(pq, controlType); + paramList.push_back(pt); + } + void configMenuParam(int paramId, float defaultValue,std::string label= "",std::vector<std::string> options = {}) { + int size = (int) options.size(); + configParam<MultiselectParamQuantity>(paramId,0,size-1,defaultValue,label); + pq = paramQuantities[paramId]; + ParamAndType* pt = new ParamAndType(pq, 2); + paramList.push_back(pt); + pidMap.insert({paramId,pt}); + } + std::vector<ParamAndType*> getParamList() { + return paramList; + } + std::string getOptionValue(int paramId,int index) { + //std::vector<std::string> *options = pidMap.find(paramId); + //return pidMap.find(paramId).at(index); + return "charles"; + } +}; +struct MultiselectParamQuantity : ParamQuantity { + ComputerscareMenuParamModule* module; + std::string getDisplayValueString() override { + int index = Quantity::getValue(); + return module->getOptionValue(paramId,index); + } +}; +struct MenuParamModuleWidget : ModuleWidget { + MenuParamModuleWidget() { + + DEBUG("Im inside MenuParamModuleWidget dontcha know"); + } + /*std::vector<ParamAndType> *myListOParams; + MenuParamModuleWidget(std::vector<ParamAndType> *paramList) { + myListOParams = paramList; + } + void initMyStuff(widget::OpaqueWidget* parent) { + for (unsigned int i = 0; i < myListOParams.size(); i++) { + MenuParam* speedParam = new MenuParam(*myListOParams[i]); + parent->addChild(speedParam); + } + }*/ +}; +struct ParamSettingItem : MenuItem { + int myVal; + Param* myParam; + ParamSettingItem(int val,Param *param) { + myVal=val; + myParam=param; + } + void onAction(const event::Action &e) override { + myParam->setValue(myVal); + } + void step() override { + rightText = CHECKMARK(myParam->getValue() == myVal); + MenuItem::step(); } }; + + + + + diff --git a/src/golyFunctions.cpp b/src/golyFunctions.cpp @@ -21,7 +21,7 @@ void Goly::invoke(int algorithm, std::vector<float> gp, int num = 16) { float trigFactor = 2*M_PI / num; switch (algorithm) { - case 1: // code to be executed if n = 1; + case 0: // code to be executed if n = 1; //linear //ip / proportion //defaults:[A,B,C,D]=[0,1,1,0] @@ -33,7 +33,7 @@ void Goly::invoke(int algorithm, std::vector<float> gp, int num = 16) { currentValues[i] = gp[2] * ((ip - gp[0]) * gp[1]) + gp[3]; } break; - case 2: + case 1: //sigmoid for (int i = 0; i < num; i++) { float ip = (float)i / num; @@ -41,7 +41,7 @@ void Goly::invoke(int algorithm, std::vector<float> gp, int num = 16) { currentValues[i] = gp[2] / (1 + exp(-d * exp(-4 * gp[1]+6))) + gp[3]; } break; - case 3: + case 2: //hump for (int i = 0; i < num; i++) { float ip = (float)i / num; @@ -49,7 +49,7 @@ void Goly::invoke(int algorithm, std::vector<float> gp, int num = 16) { currentValues[i] = gp[2] * exp(-d*d*exp(-5*gp[1]+7)) + gp[3]; } break; - case 4: + case 3: //sine wave for (int i = 0; i < num; i++) { float ip = (float)i / num; @@ -57,7 +57,7 @@ void Goly::invoke(int algorithm, std::vector<float> gp, int num = 16) { currentValues[i] = gp[2] * (1+sinf(d*exp(-2*gp[1]+2)))/2 + gp[3]; } break; - case 5: + case 4: //pseudo random for(int i = 0; i < num; i++) { float ip = (float) i / num;