From 0e88599c2dcd1c731bea62c9da296121a9ec1b13 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 13 Aug 2023 17:09:16 -0400 Subject: [PATCH] Add SHADR module WIP. --- plugin.json | 6 + res/SHADR.svg | 728 +++++++++++++++++++++++++++++++++++++++++++++++++ src/SHADR.cpp | 84 ++++++ src/plugin.cpp | 1 + src/plugin.hpp | 1 + 5 files changed, 820 insertions(+) create mode 100644 res/SHADR.svg create mode 100644 src/SHADR.cpp diff --git a/plugin.json b/plugin.json index 00c1bba..b10e865 100644 --- a/plugin.json +++ b/plugin.json @@ -391,6 +391,12 @@ "tags": [ "Utility" ] + }, + { + "slug": "SHADR", + "name": "Sample & Hold Analog Shift Register", + "description": "", + "tags": [] } ] } \ No newline at end of file diff --git a/res/SHADR.svg b/res/SHADR.svg new file mode 100644 index 0000000..183661d --- /dev/null +++ b/res/SHADR.svg @@ -0,0 +1,728 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SHADR.cpp b/src/SHADR.cpp new file mode 100644 index 0000000..3968c0c --- /dev/null +++ b/src/SHADR.cpp @@ -0,0 +1,84 @@ +#include "plugin.hpp" + + +struct SHADR : Module { + enum ParamId { + RND_PARAM, + PUSH_PARAM, + CLEAR_PARAM, + PARAMS_LEN + }; + enum InputId { + ENUMS(IN_INPUTS, 8), + ENUMS(TRIG_INPUTS, 8), + INPUTS_LEN + }; + enum OutputId { + ENUMS(SH_OUTPUTS, 8), + OUTPUTS_LEN + }; + enum LightId { + LIGHTS_LEN + }; + + SHADR() { + config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN); + configParam(RND_PARAM, 0.f, 1.f, 0.f, ""); + configParam(PUSH_PARAM, 0.f, 1.f, 0.f, ""); + configParam(CLEAR_PARAM, 0.f, 1.f, 0.f, ""); + for (int i = 0; i < 8; i++) { + configInput(IN_INPUTS + i, string::f("Sample %d", i + 1)); + configInput(TRIG_INPUTS + i, string::f("Trigger %d", i + 1)); + configOutput(SH_OUTPUTS + i, string::f("Sample %d", i + 1)); + } + } + + void process(const ProcessArgs& args) override { + } +}; + + +struct SHADRWidget : ModuleWidget { + SHADRWidget(SHADR* module) { + setModule(module); + setPanel(createPanel(asset::plugin(pluginInstance, "res/SHADR.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))); + + addParam(createParamCentered(mm2px(Vec(6.96, 21.852)), module, SHADR::RND_PARAM)); + addParam(createParamCentered>(mm2px(Vec(17.788, 21.852)), module, SHADR::PUSH_PARAM)); + addParam(createParamCentered(mm2px(Vec(28.6, 21.852)), module, SHADR::CLEAR_PARAM)); + + addInput(createInputCentered(mm2px(Vec(6.96, 42.113)), module, SHADR::IN_INPUTS + 0)); + addInput(createInputCentered(mm2px(Vec(17.788, 42.055)), module, SHADR::TRIG_INPUTS + 0)); + addInput(createInputCentered(mm2px(Vec(6.96, 52.241)), module, SHADR::IN_INPUTS + 1)); + addInput(createInputCentered(mm2px(Vec(17.788, 52.241)), module, SHADR::TRIG_INPUTS + 1)); + addInput(createInputCentered(mm2px(Vec(6.96, 62.368)), module, SHADR::IN_INPUTS + 2)); + addInput(createInputCentered(mm2px(Vec(17.788, 62.368)), module, SHADR::TRIG_INPUTS + 2)); + addInput(createInputCentered(mm2px(Vec(6.96, 72.496)), module, SHADR::IN_INPUTS + 3)); + addInput(createInputCentered(mm2px(Vec(17.788, 72.496)), module, SHADR::TRIG_INPUTS + 3)); + addInput(createInputCentered(mm2px(Vec(6.96, 82.623)), module, SHADR::IN_INPUTS + 4)); + addInput(createInputCentered(mm2px(Vec(17.788, 82.623)), module, SHADR::TRIG_INPUTS + 4)); + addInput(createInputCentered(mm2px(Vec(6.96, 92.75)), module, SHADR::IN_INPUTS + 5)); + addInput(createInputCentered(mm2px(Vec(17.788, 92.75)), module, SHADR::TRIG_INPUTS + 5)); + addInput(createInputCentered(mm2px(Vec(6.96, 102.878)), module, SHADR::IN_INPUTS + 6)); + addInput(createInputCentered(mm2px(Vec(17.788, 102.878)), module, SHADR::TRIG_INPUTS + 6)); + addInput(createInputCentered(mm2px(Vec(6.96, 113.005)), module, SHADR::IN_INPUTS + 7)); + addInput(createInputCentered(mm2px(Vec(17.788, 113.005)), module, SHADR::TRIG_INPUTS + 7)); + + addOutput(createOutputCentered(mm2px(Vec(28.6, 42.113)), module, SHADR::SH_OUTPUTS + 0)); + addOutput(createOutputCentered(mm2px(Vec(28.6, 52.241)), module, SHADR::SH_OUTPUTS + 1)); + addOutput(createOutputCentered(mm2px(Vec(28.6, 62.368)), module, SHADR::SH_OUTPUTS + 2)); + addOutput(createOutputCentered(mm2px(Vec(28.6, 72.496)), module, SHADR::SH_OUTPUTS + 3)); + addOutput(createOutputCentered(mm2px(Vec(28.6, 82.623)), module, SHADR::SH_OUTPUTS + 4)); + addOutput(createOutputCentered(mm2px(Vec(28.6, 92.75)), module, SHADR::SH_OUTPUTS + 5)); + addOutput(createOutputCentered(mm2px(Vec(28.6, 102.878)), module, SHADR::SH_OUTPUTS + 6)); + addOutput(createOutputCentered(mm2px(Vec(28.6, 113.005)), module, SHADR::SH_OUTPUTS + 7)); + } +}; + + +Model* modelSHADR = createModel("SHADR"); \ No newline at end of file diff --git a/src/plugin.cpp b/src/plugin.cpp index 699ff83..312daee 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -44,4 +44,5 @@ void init(Plugin* p) { p->addModel(modelRescale); p->addModel(modelRandomValues); p->addModel(modelPush); + p->addModel(modelSHADR); } diff --git a/src/plugin.hpp b/src/plugin.hpp index d9e9c09..00a0fd5 100644 --- a/src/plugin.hpp +++ b/src/plugin.hpp @@ -44,6 +44,7 @@ extern Model* modelMult; extern Model* modelRescale; extern Model* modelRandomValues; extern Model* modelPush; +extern Model* modelSHADR; struct DigitalDisplay : Widget {