Shaper.hpp (2160B)
1 #pragma once 2 3 #include "bogaudio.hpp" 4 #include "trigger_on_load.hpp" 5 #include "shaper_core.hpp" 6 7 extern Model* modelShaper; 8 9 namespace bogaudio { 10 11 struct Shaper : TriggerOnLoadModule { 12 enum ParamsIds { 13 ATTACK_PARAM, 14 ON_PARAM, 15 DECAY_PARAM, 16 OFF_PARAM, 17 ENV_PARAM, 18 SIGNAL_PARAM, 19 TRIGGER_PARAM, 20 SPEED_PARAM, 21 LOOP_PARAM, 22 NUM_PARAMS 23 }; 24 25 enum InputsIds { 26 SIGNAL_INPUT, 27 TRIGGER_INPUT, 28 NUM_INPUTS 29 }; 30 31 enum OutputsIds { 32 SIGNAL_OUTPUT, 33 ENV_OUTPUT, 34 INV_OUTPUT, 35 TRIGGER_OUTPUT, 36 NUM_OUTPUTS 37 }; 38 39 enum LightsIds { 40 ATTACK_LIGHT, 41 ON_LIGHT, 42 DECAY_LIGHT, 43 OFF_LIGHT, 44 NUM_LIGHTS 45 }; 46 47 ShaperCore* _core[maxChannels] {}; 48 float _attackLights[maxChannels] {}; 49 float _onLights[maxChannels] {}; 50 float _decayLights[maxChannels] {}; 51 float _offLights[maxChannels] {}; 52 53 Shaper() { 54 config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); 55 configParam<EnvelopeSegmentParamQuantity>(ATTACK_PARAM, 0.0f, 1.0f, 0.14142f, "Attack", " s"); 56 configParam<EnvelopeSegmentParamQuantity>(ON_PARAM, 0.0f, 1.0f, SQUARE_ROOT_ONE_TENTH, "On", " s"); 57 configParam<EnvelopeSegmentParamQuantity>(DECAY_PARAM, 0.0f, 1.0f, SQUARE_ROOT_ONE_TENTH, "Decay", " s"); 58 configParam<EnvelopeSegmentParamQuantity>(OFF_PARAM, 0.0f, 1.0f, 0.07071f, "Off", " s"); 59 configParam(ENV_PARAM, 0.0f, 1.0f, 1.0f, "Env", "%", 0.0f, 100.0f); 60 configParam(SIGNAL_PARAM, 0.0f, 1.0f, 0.1f, "Signal", "x", 10.0f); 61 configButton(TRIGGER_PARAM, "Trigger"); 62 configSwitch(SPEED_PARAM, 0.0f, 1.0f, 1.0f, "Speed", {"Slow", "Normal"}); 63 configSwitch(LOOP_PARAM, 0.0f, 1.0f, 1.0f, "Loop", {"Loop", "Stop"}); 64 65 configInput(SIGNAL_INPUT, "Signal"); 66 configInput(TRIGGER_INPUT, "Trigger"); 67 68 configOutput(SIGNAL_OUTPUT, "Signal"); 69 configOutput(ENV_OUTPUT, "Envelope"); 70 configOutput(INV_OUTPUT, "Inverted envelope"); 71 configOutput(TRIGGER_OUTPUT, "Trigger"); 72 } 73 74 void reset() override; 75 int channels() override; 76 void addChannel(int c) override; 77 void removeChannel(int c) override; 78 void processChannel(const ProcessArgs& args, int c) override; 79 void postProcess(const ProcessArgs& args) override; 80 81 bool shouldTriggerOnNextLoad() override; 82 }; 83 84 } // namespace bogaudio