BogaudioModules

BogaudioModules for VCV Rack
Log | Files | Refs | README | LICENSE

LLPG.hpp (1571B)


      1 #pragma once
      2 
      3 #include "lpg_common.hpp"
      4 #include "dsp/filters/multimode.hpp"
      5 
      6 extern Model* modelLLPG;
      7 
      8 namespace bogaudio {
      9 
     10 struct LLPG : BGModule {
     11 	enum ParamsIds {
     12 		RESPONSE_PARAM,
     13 		SHAPE_PARAM,
     14 		LPF_PARAM,
     15 		VCA_PARAM,
     16 		NUM_PARAMS
     17 	};
     18 
     19 	enum InputsIds {
     20 		GATE_INPUT,
     21 		IN_INPUT,
     22 		NUM_INPUTS
     23 	};
     24 
     25 	enum OutputsIds {
     26 		OUT_OUTPUT,
     27 		NUM_OUTPUTS
     28 	};
     29 
     30 	static constexpr float maxFilterCutoff = 20000.0f;
     31 
     32 	struct Engine {
     33 		Trigger trigger;
     34 		float gateSeconds = 0.0f;
     35 		float gateElapsedSeconds = 0.0f;
     36 		RiseFallShapedSlewLimiter slew;
     37 		MultimodeFilter4 lpf;
     38 		MultimodeFilter4 finalHP;
     39 		Amplifier vca;
     40 
     41 		void reset();
     42 		void setSampleRate(float sr);
     43 	};
     44 
     45 	Engine* _engines[maxChannels] {};
     46 	float _sampleRate = 0.0f;
     47 	float _sampleTime = 0.0f;
     48 
     49 	LLPG() {
     50 		config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS);
     51 		configParam(RESPONSE_PARAM, 0.0f, 1.0f, 0.5f, "Response", "%", 0.0f, 100.0f);
     52 		configParam(SHAPE_PARAM, -1.0f, 1.0f, -0.25f, "Shape");
     53 		configParam<ScaledSquaringParamQuantity<(int)maxFilterCutoff>>(LPF_PARAM, 0.0f, 1.0f, 0.0f, "LPF cutoff", " HZ");
     54 		configParam(VCA_PARAM, 0.0f, 1.0f, 0.0f, "VCA level", "%", 0.0f, 100.0f);
     55 
     56 		configInput(GATE_INPUT, "Gate");
     57 		configInput(IN_INPUT, "Signal");
     58 
     59 		configOutput(OUT_OUTPUT, "Signal");
     60 	}
     61 
     62 	void reset() override;
     63 	void sampleRateChange() override;
     64 	bool active() override;
     65 	int channels() override;
     66 	void addChannel(int c) override;
     67 	void removeChannel(int c) override;
     68 	void modulateChannel(int c) override;
     69 	void processChannel(const ProcessArgs& args, int c) override;
     70 };
     71 
     72 } // namespace bogaudio