Clpr.hpp (1871B)
1 #pragma once 2 3 #include "bogaudio.hpp" 4 #include "dsp/signal.hpp" 5 6 using namespace bogaudio::dsp; 7 8 extern Model* modelClpr; 9 10 namespace bogaudio { 11 12 struct Clpr : BGModule { 13 enum ParamsIds { 14 THRESHOLD_PARAM, 15 OUTPUT_GAIN_PARAM, 16 KNEE_PARAM, 17 NUM_PARAMS 18 }; 19 20 enum InputsIds { 21 LEFT_INPUT, 22 RIGHT_INPUT, 23 THRESHOLD_INPUT, 24 OUTPUT_GAIN_INPUT, 25 NUM_INPUTS 26 }; 27 28 enum OutputsIds { 29 LEFT_OUTPUT, 30 RIGHT_OUTPUT, 31 NUM_OUTPUTS 32 }; 33 34 struct Engine { 35 float thresholdDb = 0.0f; 36 float outGain = -1.0f; 37 float outLevel = 0.0f; 38 39 Compressor compressor; 40 Amplifier amplifier; 41 Saturator saturator; 42 }; 43 44 Engine* _engines[maxChannels] {}; 45 bool _softKnee = true; 46 float _thresholdRange = 1.0f; 47 48 struct ThresholdParamQuantity : ParamQuantity { 49 float getDisplayValue() override; 50 void setDisplayValue(float v) override; 51 }; 52 53 Clpr() { 54 config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS); 55 configParam<ThresholdParamQuantity>(THRESHOLD_PARAM, 0.0f, 1.0f, 0.8f, "Threshold", " dB"); 56 configParam(OUTPUT_GAIN_PARAM, 0.0f, 1.0f, 0.0f, "Output gain", " dB", 0.0f, 24.0f); 57 configSwitch(KNEE_PARAM, 0.0f, 1.0f, 1.0f, "Knee", {"Hard", "Soft"}); 58 configBypass(LEFT_INPUT, LEFT_OUTPUT); 59 configBypass(RIGHT_INPUT, RIGHT_OUTPUT); 60 61 configInput(LEFT_INPUT, "Left signal"); 62 configInput(RIGHT_INPUT, "Right signal"); 63 configInput(THRESHOLD_INPUT, "Threshold CV"); 64 configInput(OUTPUT_GAIN_INPUT, "Output gain CV"); 65 66 configOutput(LEFT_OUTPUT, "Left signal"); 67 configOutput(RIGHT_OUTPUT, "Right signal"); 68 } 69 70 json_t* saveToJson(json_t* root) override; 71 void loadFromJson(json_t* root) override; 72 bool active() override; 73 int channels() override; 74 void addChannel(int c) override; 75 void removeChannel(int c) override; 76 void modulate() override; 77 void modulateChannel(int c) override; 78 void processChannel(const ProcessArgs& args, int c) override; 79 }; 80 81 } // namespace bogaudio