computerscare-vcv-modules

computerscare modules for VCV Rack
Log | Files | Refs

commit ff852a76435d67afb8a8ea9a0dcce1a451c91c66
parent 256ab5caaeee336d3935d397cf562518223a3e0f
Author: Adam M <aemalone@gmail.com>
Date:   Sun,  3 Jan 2021 14:25:25 -0600

custom paramquantity to show zero_offset

Diffstat:
Msrc/ComputerscareBlankExpander.cpp | 51+++++++++++++++++++++++++++++++++++++--------------
1 file changed, 37 insertions(+), 14 deletions(-)

diff --git a/src/ComputerscareBlankExpander.cpp b/src/ComputerscareBlankExpander.cpp @@ -1,9 +1,24 @@ #include "Computerscare.hpp" +struct ComputerscareBlankExpander; + + struct FrameOffsetParam : ParamQuantity { + ComputerscareBlankExpander* module; + int numFrames = -1; + void setNumFrames(int num) { numFrames = num; } + std::string getDisplayValueString() override { + //return &module->params[paramId]; + float val = getValue(); + return string::f("%i", 1+((int) floor(val * numFrames )) % numFrames/*module->getFrameOffset()*/ ); + //return "Frame " +((std:: string)val);//+ ((int) floor(val * module->numFrames * 0.999)) % module->numFrames; + } + }; + struct ComputerscareBlankExpander : Module { float rightMessages[2][8] = {}; bool isConnected = false; float lastFrame = -1; + int numFrames = 1; enum ParamIds { CLOCK_MODE, @@ -38,13 +53,16 @@ struct ComputerscareBlankExpander : Module { std::vector<std::string> clockModeDescriptions; + FrameOffsetParam* frameOffsetQuantity; ComputerscareBlankExpander() { 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"); + configParam<FrameOffsetParam>(ZERO_OFFSET, 0.f, 0.999f, 0.f, "EOC / Reset Frame #"); + + frameOffsetQuantity = dynamic_cast<FrameOffsetParam*>(paramQuantities[ZERO_OFFSET]); clockModeDescriptions.push_back("Sync"); clockModeDescriptions.push_back("Scan"); @@ -53,7 +71,6 @@ struct ComputerscareBlankExpander : Module { rightExpander.producerMessage = rightMessages[0]; rightExpander.consumerMessage = rightMessages[1]; } - void process(const ProcessArgs &args) override { if (rightExpander.module && rightExpander.module->model == modelComputerscareBlank) { // Get consumer message @@ -64,7 +81,13 @@ struct ComputerscareBlankExpander : Module { float currentFrame = messageFromMother[0]; - int numFrames = messageFromMother[1]; + int newNumFrames = messageFromMother[1]; + + if(newNumFrames != numFrames) { + numFrames = newNumFrames; + frameOffsetQuantity->setNumFrames(numFrames); + } + float currentSyncTime = syncTimer.process(args.sampleTime); if (eocMessageReadTrigger.process(currentFrame == 0 ? 10.f : 0.f)) { @@ -76,13 +99,13 @@ struct ComputerscareBlankExpander : Module { messageToSendToMother[0] = params[CLOCK_MODE].getValue(); - + messageToSendToMother[1] = inputs[SYNC_INPUT].isConnected(); messageToSendToMother[2] = inputs[SYNC_INPUT].getVoltage(); messageToSendToMother[3] = inputs[RESET_INPUT].isConnected(); messageToSendToMother[4] = inputs[RESET_INPUT].getVoltage(); - + messageToSendToMother[5] = inputs[SPEED_INPUT].isConnected(); messageToSendToMother[6] = inputs[SPEED_INPUT].getVoltage(); @@ -124,20 +147,20 @@ struct ComputerscareBlankExpanderWidget : ModuleWidget { float outStartY = 250; - addParam(createParam<ClockModeButton>(Vec(0.5, inStartY+dY/2), module, ComputerscareBlankExpander::CLOCK_MODE)); + addParam(createParam<ClockModeButton>(Vec(0.5, inStartY + dY / 2), module, ComputerscareBlankExpander::CLOCK_MODE)); - addInput(createInput<InPort>(Vec(2, inStartY+dY), module, ComputerscareBlankExpander::SYNC_INPUT)); - - addParam(createParam<ComputerscareResetButton>(Vec(0, inStartY+2*dY), module, ComputerscareBlankExpander::MANUAL_RESET_BUTTON)); + addInput(createInput<InPort>(Vec(2, inStartY + dY), module, ComputerscareBlankExpander::SYNC_INPUT)); - addInput(createInput<InPort>(Vec(2, inStartY + 3*dY), module, ComputerscareBlankExpander::RESET_INPUT)); + addParam(createParam<ComputerscareResetButton>(Vec(0, inStartY + 2 * dY), module, ComputerscareBlankExpander::MANUAL_RESET_BUTTON)); + + 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), 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)); + + + 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() {