Lgsw.hpp (1771B)
1 #pragma once 2 3 #include "bogaudio.hpp" 4 #include "save_latch_to_patch.hpp" 5 6 extern Model* modelLgsw; 7 8 namespace bogaudio { 9 10 struct Lgsw : SaveLatchToPatchModule { 11 enum ParamsIds { 12 GATE_PARAM, 13 LATCH_PARAM, 14 LOGIC_MODE_PARAM, 15 NUM_PARAMS 16 }; 17 18 enum InputsIds { 19 GATE_A_INPUT, 20 GATE_B_INPUT, 21 LOGIC_MODE_INPUT, 22 HIGH_INPUT, 23 LOW_INPUT, 24 NUM_INPUTS 25 }; 26 27 enum OutputsIds { 28 OUT_OUTPUT, 29 NUM_OUTPUTS 30 }; 31 32 enum LightsIds { 33 LOGIC_OR_LIGHT, 34 LOGIC_AND_LIGHT, 35 LOGIC_XOR_LIGHT, 36 LOGIC_NOR_LIGHT, 37 LOGIC_NAND_LIGHT, 38 HIGH_LIGHT, 39 LOW_LIGHT, 40 NUM_LIGHTS 41 }; 42 43 enum Logic { 44 OR_LOGIC, 45 AND_LOGIC, 46 XOR_LOGIC, 47 NOR_LOGIC, 48 NAND_LOGIC 49 }; 50 51 Trigger _buttonTriggers[maxChannels]; 52 Trigger _aTriggers[maxChannels]; 53 Trigger _bTriggers[maxChannels]; 54 bool _lastLogicTrue[maxChannels] {}; 55 int _highLightSum = 0; 56 int _lowLightSum = 0; 57 Logic _logic = OR_LOGIC; 58 59 Lgsw() { 60 config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); 61 configButton(GATE_PARAM, "Gate"); 62 configSwitch(LATCH_PARAM, 0.0f, 1.0f, 0.0f, "Latch", {"Disabled", "Enabled"}); 63 configSwitch(LOGIC_MODE_PARAM, 0.0f, 4.0f, 0.0f, "Logic", {"OR", "AND", "XOR", "NOR", "NAND"}); 64 65 configInput(GATE_A_INPUT, "Gate A"); 66 configInput(GATE_B_INPUT, "Gate B"); 67 configInput(LOGIC_MODE_INPUT, "Logic CV"); 68 configInput(HIGH_INPUT, "High signal"); 69 configInput(LOW_INPUT, "Low signal"); 70 71 configOutput(OUT_OUTPUT, "Signal"); 72 } 73 74 void resetChannel(int c); 75 void reset() override; 76 int channels() override; 77 void channelsChanged(int before, int after) override; 78 void modulate() override; 79 void processAlways(const ProcessArgs& args) override; 80 void processChannel(const ProcessArgs& args, int _c) override; 81 void postProcessAlways(const ProcessArgs& args) override; 82 }; 83 84 } // namespace bogaudio