diff --git a/plugin.json b/plugin.json index ec39554..3ec29ca 100644 --- a/plugin.json +++ b/plugin.json @@ -347,6 +347,15 @@ "tags": [ "Polyphonic" ] + }, + { + "slug": "Mult", + "name": "Mult", + "description": "Copies a signal to 8 outputs", + "tags": [ + "Utility", + "Polyphonic" + ] } ] } \ No newline at end of file diff --git a/res/Mult.svg b/res/Mult.svg new file mode 100644 index 0000000..ffd6fa5 --- /dev/null +++ b/res/Mult.svg @@ -0,0 +1,213 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mult.cpp b/src/Mult.cpp new file mode 100644 index 0000000..544a164 --- /dev/null +++ b/src/Mult.cpp @@ -0,0 +1,63 @@ +#include "plugin.hpp" + + +struct Mult : Module { + enum ParamId { + PARAMS_LEN + }; + enum InputId { + MULT_INPUT, + INPUTS_LEN + }; + enum OutputId { + ENUMS(MULT_OUTPUTS, 8), + OUTPUTS_LEN + }; + enum LightId { + LIGHTS_LEN + }; + + Mult() { + config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN); + configInput(MULT_INPUT, "Mult"); + for (int i = 0; i < 8; i++) + configOutput(MULT_OUTPUTS + i, string::f("Mult %d", i + 1)); + } + + void process(const ProcessArgs& args) override { + int channels = std::max(1, inputs[MULT_INPUT].getChannels()); + + // Copy input to outputs + for (int i = 0; i < 8; i++) { + outputs[MULT_OUTPUTS + i].setChannels(channels); + outputs[MULT_OUTPUTS + i].writeVoltages(inputs[MULT_INPUT].getVoltages()); + } + } +}; + + +struct MultWidget : ModuleWidget { + MultWidget(Mult* module) { + setModule(module); + setPanel(createPanel(asset::plugin(pluginInstance, "res/Mult.svg"))); + + addChild(createWidget(Vec(RACK_GRID_WIDTH, 0))); + addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); + addChild(createWidget(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); + addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); + + addInput(createInputCentered(mm2px(Vec(7.62, 22.001)), module, Mult::MULT_INPUT)); + + addOutput(createOutputCentered(mm2px(Vec(7.62, 42.017)), module, Mult::MULT_OUTPUTS + 0)); + addOutput(createOutputCentered(mm2px(Vec(7.62, 52.155)), module, Mult::MULT_OUTPUTS + 1)); + addOutput(createOutputCentered(mm2px(Vec(7.62, 62.315)), module, Mult::MULT_OUTPUTS + 2)); + addOutput(createOutputCentered(mm2px(Vec(7.62, 72.475)), module, Mult::MULT_OUTPUTS + 3)); + addOutput(createOutputCentered(mm2px(Vec(7.62, 82.635)), module, Mult::MULT_OUTPUTS + 4)); + addOutput(createOutputCentered(mm2px(Vec(7.62, 92.795)), module, Mult::MULT_OUTPUTS + 5)); + addOutput(createOutputCentered(mm2px(Vec(7.62, 102.955)), module, Mult::MULT_OUTPUTS + 6)); + addOutput(createOutputCentered(mm2px(Vec(7.62, 113.115)), module, Mult::MULT_OUTPUTS + 7)); + } +}; + + +Model* modelMult = createModel("Mult"); \ No newline at end of file diff --git a/src/plugin.cpp b/src/plugin.cpp index f737025..bdf417e 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -40,4 +40,5 @@ void init(Plugin* p) { p->addModel(modelCompare); p->addModel(modelGates); p->addModel(modelProcess); + p->addModel(modelMult); } diff --git a/src/plugin.hpp b/src/plugin.hpp index ad57997..910e193 100644 --- a/src/plugin.hpp +++ b/src/plugin.hpp @@ -40,6 +40,7 @@ extern Model* modelLogic; extern Model* modelCompare; extern Model* modelGates; extern Model* modelProcess; +extern Model* modelMult; struct DigitalDisplay : Widget {