BogaudioModules

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

VCM.hpp (2013B)


      1 #pragma once
      2 
      3 #include "bogaudio.hpp"
      4 #include "disable_output_limit.hpp"
      5 #include "dsp/signal.hpp"
      6 
      7 using namespace bogaudio::dsp;
      8 
      9 extern Model* modelVCM;
     10 
     11 namespace bogaudio {
     12 
     13 struct VCM : DisableOutputLimitModule {
     14 	enum ParamsIds {
     15 		LEVEL1_PARAM,
     16 		LEVEL2_PARAM,
     17 		LEVEL3_PARAM,
     18 		LEVEL4_PARAM,
     19 		MIX_PARAM,
     20 		LINEAR_PARAM,
     21 		NUM_PARAMS
     22 	};
     23 
     24 	enum InputsIds {
     25 		IN1_INPUT,
     26 		CV1_INPUT,
     27 		IN2_INPUT,
     28 		CV2_INPUT,
     29 		IN3_INPUT,
     30 		CV3_INPUT,
     31 		IN4_INPUT,
     32 		CV4_INPUT,
     33 		MIX_CV_INPUT,
     34 		NUM_INPUTS
     35 	};
     36 
     37 	enum OutputsIds {
     38 		MIX_OUTPUT,
     39 		NUM_OUTPUTS
     40 	};
     41 
     42 	Amplifier _amplifier1[maxChannels];
     43 	Amplifier _amplifier2[maxChannels];
     44 	Amplifier _amplifier3[maxChannels];
     45 	Amplifier _amplifier4[maxChannels];
     46 
     47 	struct LevelParamQuantity : AmplifierParamQuantity {
     48 		bool isLinear() override;
     49 	};
     50 
     51 	VCM() {
     52 		config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS);
     53 		configParam<LevelParamQuantity>(LEVEL1_PARAM, 0.0f, 1.0f, 0.8f, "Level 1");
     54 		configParam<LevelParamQuantity>(LEVEL2_PARAM, 0.0f, 1.0f, 0.8f, "Level 2");
     55 		configParam<LevelParamQuantity>(LEVEL3_PARAM, 0.0f, 1.0f, 0.8f, "Level 3");
     56 		configParam<LevelParamQuantity>(LEVEL4_PARAM, 0.0f, 1.0f, 0.8f, "Level 4");
     57 		configParam<LevelParamQuantity>(MIX_PARAM, 0.0f, 1.0f, 0.8f, "Mix level");
     58 		configParam(LINEAR_PARAM, 0.0f, 1.0f, 0.0f, "Linear");
     59 
     60 		configInput(IN1_INPUT, "Signal 1");
     61 		configInput(CV1_INPUT, "Level 1 CV");
     62 		configInput(IN2_INPUT, "Signal 2");
     63 		configInput(CV2_INPUT, "Level 2 CV");
     64 		configInput(IN3_INPUT, "Signal 3");
     65 		configInput(CV3_INPUT, "Level 3 CV");
     66 		configInput(IN4_INPUT, "Signal 4");
     67 		configInput(CV4_INPUT, "Level 4 CV");
     68 		configInput(MIX_CV_INPUT, "Mix level CV");
     69 
     70 		configOutput(MIX_OUTPUT, "Signal");
     71 	}
     72 
     73 	inline bool isLinear() { return params[LINEAR_PARAM].getValue() > 0.5f; }
     74 	bool active() override;
     75 	int channels() override;
     76 	void processChannel(const ProcessArgs& args, int c) override;
     77 	float channelStep(int c, Input& input, Param& knob, Input& cv, Amplifier& amplifier, bool linear);
     78 };
     79 
     80 } // namespace bogaudio