ShaperPlus.hpp (2767B)
1 #pragma once 2 3 #include "bogaudio.hpp" 4 #include "trigger_on_load.hpp" 5 #include "shaper_core.hpp" 6 7 extern Model* modelShaperPlus; 8 9 namespace bogaudio { 10 11 struct ShaperPlus : 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 ATTACK_INPUT, 29 ON_INPUT, 30 DECAY_INPUT, 31 OFF_INPUT, 32 ENV_INPUT, 33 SIGNALCV_INPUT, 34 NUM_INPUTS 35 }; 36 37 enum OutputsIds { 38 SIGNAL_OUTPUT, 39 ENV_OUTPUT, 40 INV_OUTPUT, 41 TRIGGER_OUTPUT, 42 ATTACK_OUTPUT, 43 ON_OUTPUT, 44 DECAY_OUTPUT, 45 OFF_OUTPUT, 46 NUM_OUTPUTS 47 }; 48 49 enum LightsIds { 50 ATTACK_LIGHT, 51 ON_LIGHT, 52 DECAY_LIGHT, 53 OFF_LIGHT, 54 NUM_LIGHTS 55 }; 56 57 ShaperCore* _core[maxChannels] {}; 58 float _attackLights[maxChannels] {}; 59 float _onLights[maxChannels] {}; 60 float _decayLights[maxChannels] {}; 61 float _offLights[maxChannels] {}; 62 63 ShaperPlus() { 64 config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); 65 configParam<EnvelopeSegmentParamQuantity>(ATTACK_PARAM, 0.0f, 1.0f, 0.14142f, "Attack", " s"); 66 configParam<EnvelopeSegmentParamQuantity>(ON_PARAM, 0.0f, 1.0f, SQUARE_ROOT_ONE_TENTH, "On", " s"); 67 configParam<EnvelopeSegmentParamQuantity>(DECAY_PARAM, 0.0f, 1.0f, SQUARE_ROOT_ONE_TENTH, "Decay", " s"); 68 configParam<EnvelopeSegmentParamQuantity>(OFF_PARAM, 0.0f, 1.0f, 0.07071f, "Off", " s"); 69 configParam(ENV_PARAM, 0.0f, 1.0f, 1.0f, "Env", "%", 0.0f, 100.0f); 70 configParam(SIGNAL_PARAM, 0.0f, 1.0f, 0.1f, "Signal", "x", 10.0f); 71 configButton(TRIGGER_PARAM, "Trigger"); 72 configSwitch(SPEED_PARAM, 0.0f, 1.0f, 1.0f, "Speed", {"Slow", "Normal"}); 73 configSwitch(LOOP_PARAM, 0.0f, 1.0f, 1.0f, "Loop", {"Loop", "Stop"}); 74 75 configInput(SIGNAL_INPUT, "Signal"); 76 configInput(TRIGGER_INPUT, "Trigger"); 77 configInput(ATTACK_INPUT, "Attack CV"); 78 configInput(ON_INPUT, "On CV"); 79 configInput(DECAY_INPUT, "Decay CV"); 80 configInput(OFF_INPUT, "Off CV"); 81 configInput(ENV_INPUT, "Envelope level CV"); 82 configInput(SIGNALCV_INPUT, "Output signal level CV"); 83 84 configOutput(SIGNAL_OUTPUT, "Signal"); 85 configOutput(ENV_OUTPUT, "Envelope"); 86 configOutput(INV_OUTPUT, "Inverted envelope"); 87 configOutput(TRIGGER_OUTPUT, "Trigger"); 88 configOutput(ATTACK_OUTPUT, "Attack stage gate"); 89 configOutput(ON_OUTPUT, "On stage gate"); 90 configOutput(DECAY_OUTPUT, "Decay stage gate"); 91 configOutput(OFF_OUTPUT, "Off stage gate"); 92 } 93 94 void reset() override; 95 int channels() override; 96 void addChannel(int c) override; 97 void removeChannel(int c) override; 98 void processChannel(const ProcessArgs& args, int c) override; 99 void postProcess(const ProcessArgs& args) override; 100 101 bool shouldTriggerOnNextLoad() override; 102 }; 103 104 } // namespace bogaudio