computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit 256ab5caaeee336d3935d397cf562518223a3e0f
parent 27016937392282cc0574ce6da4c2ed210ee15d3e
Author: Adam M <aemalone@gmail.com>
Date:   Sun,  3 Jan 2021 11:22:04 -0600

Zero offset input for blank

Diffstat:
Msrc/ComputerscareBlank.cpp | 26+++++++++++++++++---------
Msrc/ComputerscareBlankExpander.cpp | 12++++++++++--
Msrc/ComputerscareRolyPouter.cpp | 22----------------------
Msrc/MenuParams.hpp | 6------
4 files changed, 27 insertions(+), 39 deletions(-)

diff --git a/src/ComputerscareBlank.cpp b/src/ComputerscareBlank.cpp @@ -31,6 +31,7 @@ struct ComputerscareBlank : ComputerscareMenuParamModule { float yOffset = 0.f; int imageFitEnum = 0; int currentFrame = 0; + int mappedFrame = 0; int numFrames = 0; int sampleCounter = 0; float frameDelay = .5; @@ -62,6 +63,8 @@ struct ComputerscareBlank : ComputerscareMenuParamModule { float speedFactor = 1.f; + float zeroOffset = 0.f; + std::vector<std::string> animationModeDescriptions; std::vector<std::string> endBehaviorDescriptions; @@ -78,6 +81,7 @@ struct ComputerscareBlank : ComputerscareMenuParamModule { CONSTANT_FRAME_DELAY, ANIMATION_MODE, END_BEHAVIOR, + ZERO_OFFSET, NUM_PARAMS }; enum InputIds { @@ -97,6 +101,7 @@ struct ComputerscareBlank : ComputerscareMenuParamModule { configParam(ANIMATION_ENABLED, 0.f, 1.f, 1.f, "Animation Enabled"); configParam(CONSTANT_FRAME_DELAY, 0.f, 1.f, 0.f, "Constant Frame Delay"); configMenuParam(END_BEHAVIOR, 0.f, 5.f, 0.f, "Animation End Behavior", 2); + configParam(ZERO_OFFSET, -1.f, 1.f, 0.f, "Frame Zero Offset"); animationModeDescriptions.push_back("Forward"); animationModeDescriptions.push_back("Reverse"); @@ -137,6 +142,8 @@ struct ComputerscareBlank : ComputerscareMenuParamModule { resetConnected = messageFromExpander[3]; speedConnected = messageFromExpander[5]; + zeroOffset = messageFromExpander[7]; + if (clockConnected) { bool clockTriggered = clockTrigger.process(messageFromExpander[2]); if (clockMode == 0) { @@ -170,6 +177,7 @@ struct ComputerscareBlank : ComputerscareMenuParamModule { } messageToSendToExpander[0] = float (currentFrame); + messageToSendToExpander[1] = float (numFrames); // Flip messages at the end of the timestep leftExpander.module->rightExpander.messageFlipRequested = true; } @@ -360,7 +368,7 @@ struct ComputerscareBlank : ComputerscareMenuParamModule { } void setCurrentFrameDelayFromTable() { if (ready) { - setFrameDelay(frameDelays[currentFrame]); + setFrameDelay(frameDelays[mappedFrame]); } } void nextFrame() { @@ -374,6 +382,7 @@ struct ComputerscareBlank : ComputerscareMenuParamModule { if (numFrames) { sampleCounter = 0; currentFrame = frameNum; + mappedFrame = (currentFrame + ((int)floor(zeroOffset * numFrames))+numFrames) % numFrames; currentFrame += numFrames; currentFrame %= numFrames; setCurrentFrameDelayFromTable(); @@ -504,9 +513,9 @@ struct ssmi : MenuItem //ComputerscareRolyPouter *pouter; int mySetVal = 1; ParamQuantity *myParamQuantity; - ssmi(int i,ParamQuantity* pq) + ssmi(int i, ParamQuantity* pq) { - mySetVal=i; + mySetVal = i; myParamQuantity = pq; } @@ -527,7 +536,7 @@ struct Strongbipper : MenuItem { Menu *createChildMenu() override { Menu *menu = new Menu; for (unsigned int i = 0; i < options.size(); i++) { - ssmi *menuItem = new ssmi(i,param); + ssmi *menuItem = new ssmi(i, param); menuItem->text = options[i]; //menuItem->pouter = pouter; menu->addChild(menuItem); @@ -535,7 +544,7 @@ struct Strongbipper : MenuItem { return menu; } void step() override { - rightText = "("+options[param->getValue()]+") "+RIGHT_ARROW; + rightText = "(" + options[param->getValue()] + ") " + RIGHT_ARROW; MenuItem::step(); } }; @@ -659,9 +668,8 @@ struct PNGDisplay : TransparentWidget { } void step() override { if (blankModule && blankModule->loadedJSON) { - if (blankModule->currentFrame != currentFrame) { - currentFrame = blankModule->currentFrame; - //blankModule->setFrameDelay(gifBuddy.getSecondsDelay(currentFrame)); + if (blankModule->mappedFrame != currentFrame) { + currentFrame = blankModule->mappedFrame; } } @@ -778,7 +786,7 @@ struct ComputerscareBlankWidget : MenuParamModuleWidget { menu->addChild(modeMenu); - + Strongbipper *endMenu = new Strongbipper(); endMenu->text = "Animation End Behavior"; diff --git a/src/ComputerscareBlankExpander.cpp b/src/ComputerscareBlankExpander.cpp @@ -8,6 +8,7 @@ struct ComputerscareBlankExpander : Module { enum ParamIds { CLOCK_MODE, MANUAL_RESET_BUTTON, + ZERO_OFFSET, NUM_PARAMS }; enum InputIds { @@ -43,6 +44,7 @@ struct ComputerscareBlankExpander : Module { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); configParam(CLOCK_MODE, 0.f, 2.f, 0.f, "Clock Mode"); configParam(MANUAL_RESET_BUTTON, 0.f, 1.f, 0.f, "Manual Reset"); + configParam(ZERO_OFFSET,-1.f,1.f,0.f,"Frame Zero Offset"); clockModeDescriptions.push_back("Sync"); clockModeDescriptions.push_back("Scan"); @@ -62,6 +64,7 @@ struct ComputerscareBlankExpander : Module { float currentFrame = messageFromMother[0]; + int numFrames = messageFromMother[1]; float currentSyncTime = syncTimer.process(args.sampleTime); if (eocMessageReadTrigger.process(currentFrame == 0 ? 10.f : 0.f)) { @@ -83,6 +86,8 @@ struct ComputerscareBlankExpander : Module { messageToSendToMother[5] = inputs[SPEED_INPUT].isConnected(); messageToSendToMother[6] = inputs[SPEED_INPUT].getVoltage(); + messageToSendToMother[7] = params[ZERO_OFFSET].getValue(); + outputs[EOC_OUTPUT].setVoltage(eocPulse.process(args.sampleTime) ? 10.f : 0.f); outputs[EACH_FRAME_OUTPUT].setVoltage(eachFramePulse.process(args.sampleTime) ? 10.f : 0.f); @@ -128,8 +133,11 @@ struct ComputerscareBlankExpanderWidget : ModuleWidget { addInput(createInput<InPort>(Vec(2, inStartY + 3*dY), module, ComputerscareBlankExpander::RESET_INPUT)); addInput(createInput<InPort>(Vec(2, inStartY + 4 * dY), module, ComputerscareBlankExpander::SPEED_INPUT)); - addOutput(createOutput<PointingUpPentagonPort>(Vec(2, outStartY + dY), module, ComputerscareBlankExpander::EACH_FRAME_OUTPUT)); - addOutput(createOutput<PointingUpPentagonPort>(Vec(2, outStartY), module, ComputerscareBlankExpander::EOC_OUTPUT)); + addOutput(createOutput<PointingUpPentagonPort>(Vec(2, outStartY), module, ComputerscareBlankExpander::EACH_FRAME_OUTPUT)); + + + addParam(createParam<SmallKnob>(Vec(4, outStartY+dY), module, ComputerscareBlankExpander::ZERO_OFFSET)); + addOutput(createOutput<PointingUpPentagonPort>(Vec(2, outStartY + dY*1.5), module, ComputerscareBlankExpander::EOC_OUTPUT)); } void step() { diff --git a/src/ComputerscareRolyPouter.cpp b/src/ComputerscareRolyPouter.cpp @@ -282,28 +282,6 @@ struct OneToOneItem: MenuItem { MenuItem::step(); } }; -/*struct LaundryChannelsItem : MenuItem { - ComputerscareLaundrySoup *module; - int row; - Menu *createChildMenu() override { - Menu *menu = new Menu; - for (int channels = -1; channels <= 16; channels++) { - LaundryChannelItem *item = new LaundryChannelItem; - item->row = row; - if (channels < 0) - item->text = "Automatic"; - else - item->text = string::f("%d", channels); - if (row > -1) { - item->rightText = CHECKMARK(module->channelCountEnum[row] == channels); - } - item->module = module; - item->channels = channels; - menu->addChild(item); - } - return menu; - } -};*/ struct SetAllItem : MenuItem { ComputerscareRolyPouter *pouter; diff --git a/src/MenuParams.hpp b/src/MenuParams.hpp @@ -63,12 +63,6 @@ struct MenuParam : MenuEntry { } else if (type == 1) { speedParam = new MediumDotSnapKnob(); - /* - //addChild(construct<SubMenuAndKnob>); - submenu = new SubMenuAndKnob(); - submenu->text = "select menu param control label"; - submenu->rightText = RIGHT_ARROW;*/ - } else if (type == 2) { speedParam = new SmoothKnob();