BogaudioModules

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

Vish.hpp (2089B)


      1 #pragma once
      2 
      3 #include "lpg_common.hpp"
      4 
      5 extern Model* modelVish;
      6 
      7 namespace bogaudio {
      8 
      9 struct Vish : LPGEnvBaseModule {
     10 	enum ParamsIds {
     11 		RISE_PARAM,
     12 		RISE_SHAPE_PARAM,
     13 		FALL_PARAM,
     14 		FALL_SHAPE_PARAM,
     15 		MINIMUM_GATE_PARAM,
     16 		GATE_TO_TRIGGER_PARAM,
     17 		TIMES_10X_PARAM,
     18 		NUM_PARAMS
     19 	};
     20 
     21 	enum InputsIds {
     22 		RISE_INPUT,
     23 		MINIMUM_GATE_INPUT,
     24 		FALL_INPUT,
     25 		SHAPE_INPUT,
     26 		GATE_INPUT,
     27 		NUM_INPUTS
     28 	};
     29 
     30 	enum OutputsIds {
     31 		OUT_OUTPUT,
     32 		NUM_OUTPUTS
     33 	};
     34 
     35 	struct Engine {
     36 		Trigger trigger;
     37 		rack::dsp::PulseGenerator gatePulseGen;
     38 		float gateSeconds = 0.0f;
     39 		float gateElapsedSeconds = 0.0f;
     40 		RiseFallShapedSlewLimiter slew;
     41 
     42 		void reset();
     43 	};
     44 
     45 	Engine* _engines[maxChannels] {};
     46 	float _sampleRate = 0.0f;
     47 	float _sampleTime = 0.0f;
     48 
     49 	Vish()
     50 	: LPGEnvBaseModule(GATE_TO_TRIGGER_PARAM, TIMES_10X_PARAM)
     51 	{
     52 		config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS);
     53 		configParam<TimeParamQuantity<300>>(RISE_PARAM, 0.0f, 1.0f, 0.57735f, "Rise time", " ms");
     54 		configParam(RISE_SHAPE_PARAM, -1.0f, 1.0f, 0.0f, "Rise shape");
     55 		configParam<TimeParamQuantity<1>>(FALL_PARAM, 0.0f, 1.0f, 0.5477226f, "Fall time", " s");
     56 		configParam(FALL_SHAPE_PARAM, -1.0f, 1.0f, 0.0f, "Fall shape");
     57 		configParam<TimeParamQuantity<1>>(MINIMUM_GATE_PARAM, 0.0f, 1.0f, SQUARE_ROOT_ONE_TENTH, "Minimum gate", " s");
     58 		configSwitch(GATE_TO_TRIGGER_PARAM, 0.0f, 1.0f, 1.0f, "Gate to trigger mode", {"Disabled (input pass-through)", "Enabled"});
     59 		configSwitch(TIMES_10X_PARAM, 0.0f, 1.0f, 0.0f, "Timings 10X mode", {"Disabled (normal)", "Enabled"});
     60 
     61 		configInput(RISE_INPUT, "Rise CV");
     62 		configInput(MINIMUM_GATE_INPUT, "Minimum gate CV");
     63 		configInput(FALL_INPUT, "Fall CV");
     64 		configInput(SHAPE_INPUT, "Shape CV");
     65 		configInput(GATE_INPUT, "Gate");
     66 
     67 		configOutput(OUT_OUTPUT, "Envelope");
     68 	}
     69 
     70 	void reset() override;
     71 	void sampleRateChange() override;
     72 	bool active() override;
     73 	int channels() override;
     74 	void addChannel(int c) override;
     75 	void removeChannel(int c) override;
     76 	void modulateChannel(int c) override;
     77 	void processChannel(const ProcessArgs& args, int c) override;
     78 };
     79 
     80 } // namespace bogaudio