//============================================================================================================ //! //! \file Keys-G1.cpp //! //! \brief Keys-G1 is a six input times six voice note monitoring module. //! //============================================================================================================ #include "Gratrix.hpp" namespace rack_plugin_Gratrix { //============================================================================================================ //! \brief The module. struct GtxModule_Keys_G1 : Module { enum ParamIds { NUM_PARAMS }; enum InputIds { GATE_1R_INPUT, // N+1 GATE_1G_INPUT, // N+1 GATE_1B_INPUT, // N+1 GATE_2R_INPUT, // N+1 GATE_2G_INPUT, // N+1 GATE_2B_INPUT, // N+1 VOCT_1R_INPUT, // N VOCT_1G_INPUT, // N VOCT_1B_INPUT, // N VOCT_2R_INPUT, // N VOCT_2G_INPUT, // N VOCT_2B_INPUT, // N NUM_INPUTS, }; enum OutputIds { NUM_OUTPUTS }; enum LightIds { KEY_LIGHT_1 = 0, KEY_LIGHT_2 = KEY_LIGHT_1 + 6 * 12 * 3, NUM_LIGHTS = KEY_LIGHT_2 + 6 * 12 * 3 }; static constexpr std::size_t imap(std::size_t port, std::size_t bank) { return port + bank * NUM_INPUTS; } static void decode(float *lights, int offset, const Input &in_gate, const Input &in_voct) { bool enable = ((in_gate.active && in_gate.value >= 1.0f) || !in_gate.active) && in_voct.active; if (enable) { int note = static_cast(std::floor(in_voct.value * 12.0f + 0.5f)) + 3*12; if (note >= 0 && note < 6*12) { lights[note * 3 + offset] = 1.0f; } } } GtxModule_Keys_G1() : Module(NUM_PARAMS, ((GTX__N+1) * NUM_INPUTS/2) + (GTX__N * NUM_INPUTS/2), NUM_OUTPUTS, NUM_LIGHTS) {} void step() override { float leds[NUM_LIGHTS] = {}; for (std::size_t i=0; i(Vec(15, 0))); addChild(Widget::create(Vec(box.size.x-30, 0))); addChild(Widget::create(Vec(15, 365))); addChild(Widget::create(Vec(box.size.x-30, 365))); for (std::size_t i=0; i(Vec(px(0, i), py(1, i)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::GATE_1R_INPUT, i))); addInput(createInputGTX(Vec(px(1, i), py(1, i)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::GATE_1G_INPUT, i))); addInput(createInputGTX(Vec(px(2, i), py(1, i)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::GATE_1B_INPUT, i))); addInput(createInputGTX(Vec(px(3, i), py(1, i)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::GATE_2R_INPUT, i))); addInput(createInputGTX(Vec(px(4, i), py(1, i)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::GATE_2G_INPUT, i))); addInput(createInputGTX(Vec(px(5, i), py(1, i)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::GATE_2B_INPUT, i))); addInput(createInputGTX(Vec(px(0, i), py(2, i)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::VOCT_1R_INPUT, i))); addInput(createInputGTX(Vec(px(1, i), py(2, i)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::VOCT_1G_INPUT, i))); addInput(createInputGTX(Vec(px(2, i), py(2, i)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::VOCT_1B_INPUT, i))); addInput(createInputGTX(Vec(px(3, i), py(2, i)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::VOCT_2R_INPUT, i))); addInput(createInputGTX(Vec(px(4, i), py(2, i)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::VOCT_2G_INPUT, i))); addInput(createInputGTX(Vec(px(5, i), py(2, i)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::VOCT_2B_INPUT, i))); } addInput(createInputGTX(Vec(gx(0), gy(1)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::GATE_1R_INPUT, GTX__N))); addInput(createInputGTX(Vec(gx(1), gy(1)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::GATE_1G_INPUT, GTX__N))); addInput(createInputGTX(Vec(gx(2), gy(1)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::GATE_1B_INPUT, GTX__N))); addInput(createInputGTX(Vec(gx(3), gy(1)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::GATE_2R_INPUT, GTX__N))); addInput(createInputGTX(Vec(gx(4), gy(1)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::GATE_2G_INPUT, GTX__N))); addInput(createInputGTX(Vec(gx(5), gy(1)), module, GtxModule_Keys_G1::imap(GtxModule_Keys_G1::GATE_2B_INPUT, GTX__N))); for (std::size_t i=0; i<6; ++i) { addChild(ModuleLightWidget::create>(l_s(gx(i) - 30, fy(0+0.08) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_2 + 3 * (i * 12 + 0))); // C addChild(ModuleLightWidget::create>(l_s(gx(i) - 25, fy(0+0.08) - 5), module, GtxModule_Keys_G1::KEY_LIGHT_2 + 3 * (i * 12 + 1))); // C# addChild(ModuleLightWidget::create>(l_s(gx(i) - 20, fy(0+0.08) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_2 + 3 * (i * 12 + 2))); // D addChild(ModuleLightWidget::create>(l_s(gx(i) - 15, fy(0+0.08) - 5), module, GtxModule_Keys_G1::KEY_LIGHT_2 + 3 * (i * 12 + 3))); // Eb addChild(ModuleLightWidget::create>(l_s(gx(i) - 10, fy(0+0.08) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_2 + 3 * (i * 12 + 4))); // E addChild(ModuleLightWidget::create>(l_s(gx(i) , fy(0+0.08) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_2 + 3 * (i * 12 + 5))); // F addChild(ModuleLightWidget::create>(l_s(gx(i) + 5, fy(0+0.08) - 5), module, GtxModule_Keys_G1::KEY_LIGHT_2 + 3 * (i * 12 + 6))); // Fs addChild(ModuleLightWidget::create>(l_s(gx(i) + 10, fy(0+0.08) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_2 + 3 * (i * 12 + 7))); // G addChild(ModuleLightWidget::create>(l_s(gx(i) + 15, fy(0+0.08) - 5), module, GtxModule_Keys_G1::KEY_LIGHT_2 + 3 * (i * 12 + 8))); // Ab addChild(ModuleLightWidget::create>(l_s(gx(i) + 20, fy(0+0.08) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_2 + 3 * (i * 12 + 9))); // A addChild(ModuleLightWidget::create>(l_s(gx(i) + 25, fy(0+0.08) - 5), module, GtxModule_Keys_G1::KEY_LIGHT_2 + 3 * (i * 12 + 10))); // Bb addChild(ModuleLightWidget::create>(l_s(gx(i) + 30, fy(0+0.08) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_2 + 3 * (i * 12 + 11))); // B } for (std::size_t i=0; i<6; ++i) { addChild(ModuleLightWidget::create>(l_s(gx(i) - 30, fy(0-0.28) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_1 + 3 * (i * 12 + 0))); // C addChild(ModuleLightWidget::create>(l_s(gx(i) - 25, fy(0-0.28) - 5), module, GtxModule_Keys_G1::KEY_LIGHT_1 + 3 * (i * 12 + 1))); // C# addChild(ModuleLightWidget::create>(l_s(gx(i) - 20, fy(0-0.28) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_1 + 3 * (i * 12 + 2))); // D addChild(ModuleLightWidget::create>(l_s(gx(i) - 15, fy(0-0.28) - 5), module, GtxModule_Keys_G1::KEY_LIGHT_1 + 3 * (i * 12 + 3))); // Eb addChild(ModuleLightWidget::create>(l_s(gx(i) - 10, fy(0-0.28) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_1 + 3 * (i * 12 + 4))); // E addChild(ModuleLightWidget::create>(l_s(gx(i) , fy(0-0.28) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_1 + 3 * (i * 12 + 5))); // F addChild(ModuleLightWidget::create>(l_s(gx(i) + 5, fy(0-0.28) - 5), module, GtxModule_Keys_G1::KEY_LIGHT_1 + 3 * (i * 12 + 6))); // Fs addChild(ModuleLightWidget::create>(l_s(gx(i) + 10, fy(0-0.28) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_1 + 3 * (i * 12 + 7))); // G addChild(ModuleLightWidget::create>(l_s(gx(i) + 15, fy(0-0.28) - 5), module, GtxModule_Keys_G1::KEY_LIGHT_1 + 3 * (i * 12 + 8))); // Ab addChild(ModuleLightWidget::create>(l_s(gx(i) + 20, fy(0-0.28) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_1 + 3 * (i * 12 + 9))); // A addChild(ModuleLightWidget::create>(l_s(gx(i) + 25, fy(0-0.28) - 5), module, GtxModule_Keys_G1::KEY_LIGHT_1 + 3 * (i * 12 + 10))); // Bb addChild(ModuleLightWidget::create>(l_s(gx(i) + 30, fy(0-0.28) + 5), module, GtxModule_Keys_G1::KEY_LIGHT_1 + 3 * (i * 12 + 11))); // B } } }; } // namespace rack_plugin_Gratrix using namespace rack_plugin_Gratrix; RACK_PLUGIN_MODEL_INIT(Gratrix, Keys_G1) { Model *model = Model::create("Gratrix", "Keys-G1", "Keys-G1", VISUAL_TAG); return model; }