BogaudioModules

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

Follow.hpp (1220B)


      1 #pragma once
      2 
      3 #include "bogaudio.hpp"
      4 #include "follower_base.hpp"
      5 #include "dsp/filters/equalizer.hpp"
      6 #include "dsp/filters/utility.hpp"
      7 
      8 using namespace bogaudio::dsp;
      9 
     10 extern Model* modelFollow;
     11 
     12 namespace bogaudio {
     13 
     14 struct Follow : FollowerBase {
     15 	enum ParamsIds {
     16 		RESPONSE_PARAM,
     17 		GAIN_PARAM,
     18 		NUM_PARAMS
     19 	};
     20 
     21 	enum InputsIds {
     22 		RESPONSE_INPUT,
     23 		GAIN_INPUT,
     24 		IN_INPUT,
     25 		NUM_INPUTS
     26 	};
     27 
     28 	enum OutputsIds {
     29 		OUT_OUTPUT,
     30 		NUM_OUTPUTS
     31 	};
     32 
     33 	struct Engine {
     34 		EnvelopeFollower follower;
     35 		Amplifier gain;
     36 	};
     37 
     38 	Engine* _engines[maxChannels] {};
     39 	Saturator _saturator;
     40 
     41 	Follow() {
     42 		config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS);
     43 		configParam(RESPONSE_PARAM, 0.0f, 1.0f, 0.3f, "Smoothing", "%", 0.0f, 100.0f);
     44 		configParam<EFGainParamQuantity>(GAIN_PARAM, -1.0f, 1.0f, 0.0f, "Gain", " dB");
     45 
     46 		configInput(RESPONSE_INPUT, "Response CV");
     47 		configInput(GAIN_INPUT, "Gain CV");
     48 		configInput(IN_INPUT, "Signal");
     49 
     50 		configOutput(OUT_OUTPUT, "Envelope");
     51 	}
     52 
     53 	bool active() override;
     54 	int channels() override;
     55 	void addChannel(int c) override;
     56 	void removeChannel(int c) override;
     57 	void modulateChannel(int c) override;
     58 	void processChannel(const ProcessArgs& args, int c) override;
     59 };
     60 
     61 } // namespace bogaudio