Cmp.hpp (1869B)
1 #pragma once 2 3 #include "bogaudio.hpp" 4 5 extern Model* modelCmp; 6 7 namespace bogaudio { 8 9 struct Cmp : BGModule { 10 enum ParamsIds { 11 A_PARAM, 12 B_PARAM, 13 WINDOW_PARAM, 14 LAG_PARAM, 15 OUTPUT_PARAM, 16 NUM_PARAMS 17 }; 18 19 enum InputsIds { 20 A_INPUT, 21 B_INPUT, 22 WINDOW_INPUT, 23 LAG_INPUT, 24 NUM_INPUTS 25 }; 26 27 enum OutputsIds { 28 GREATER_OUTPUT, 29 LESS_OUTPUT, 30 EQUAL_OUTPUT, 31 NOT_EQUAL_OUTPUT, 32 NUM_OUTPUTS 33 }; 34 35 enum State { 36 LOW, 37 HIGH, 38 LAG_LOW, 39 LAG_HIGH 40 }; 41 42 State _thresholdState[maxChannels] {}; 43 int _thresholdLag[maxChannels] {}; 44 State _windowState[maxChannels] {}; 45 int _windowLag[maxChannels] {}; 46 float _highValue = 10.0f; 47 float _lowValue = 0.0f; 48 int _lagInSamples[maxChannels] {}; 49 50 Cmp() { 51 config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS); 52 configParam(A_PARAM, -1.0f, 1.0f, 0.0f, "A", " V", 0.0f, 10.0f); 53 configParam(B_PARAM, -1.0f, 1.0f, 0.0f, "B", " V", 0.0f, 10.0f); 54 configParam(WINDOW_PARAM, 0.0f, 1.0f, 0.5f, "Window", " V", 0.0f, 10.0f); 55 configParam<ScaledSquaringParamQuantity<1>>(LAG_PARAM, 0.0f, 1.0f, 0.1f, "Lag", " s"); 56 configSwitch(OUTPUT_PARAM, 0.0f, 1.0f, 0.0f, "Output", {"+10V", "+/-5V"}); 57 paramQuantities[OUTPUT_PARAM]->snapEnabled = true; 58 59 configInput(A_INPUT, "Signal A"); 60 configInput(B_INPUT, "Signal B"); 61 configInput(WINDOW_INPUT, "Window CV"); 62 configInput(LAG_INPUT, "Lag CV"); 63 64 configOutput(GREATER_OUTPUT, "Greater than"); 65 configOutput(LESS_OUTPUT, "Less than"); 66 configOutput(EQUAL_OUTPUT, "Equal"); 67 configOutput(NOT_EQUAL_OUTPUT, "Not equal"); 68 } 69 70 void reset() override; 71 bool active() override; 72 int channels() override; 73 void modulate() override; 74 void modulateChannel(int c) override; 75 void processChannel(const ProcessArgs& args, int c) override; 76 void stepChannel( 77 int c, 78 bool high, 79 State& state, 80 int& channelLag, 81 Output& highOutput, 82 Output& lowOutput 83 ); 84 }; 85 86 } // namespace bogaudio