BogaudioModules

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

VCO.hpp (1737B)


      1 #pragma once
      2 
      3 #include "bogaudio.hpp"
      4 #include "vco_base.hpp"
      5 
      6 extern Model* modelVCO;
      7 
      8 namespace bogaudio {
      9 
     10 struct VCO : VCOBase {
     11 	enum ParamsIds {
     12 		FREQUENCY_PARAM,
     13 		FINE_PARAM,
     14 		SLOW_PARAM,
     15 		PW_PARAM,
     16 		FM_PARAM,
     17 		FM_TYPE_PARAM,
     18 		LINEAR_PARAM,
     19 		NUM_PARAMS
     20 	};
     21 
     22 	enum InputsIds {
     23 		PITCH_INPUT,
     24 		SYNC_INPUT,
     25 		PW_INPUT,
     26 		FM_INPUT,
     27 		NUM_INPUTS
     28 	};
     29 
     30 	enum OutputsIds {
     31 		SQUARE_OUTPUT,
     32 		SAW_OUTPUT,
     33 		TRIANGLE_OUTPUT,
     34 		SINE_OUTPUT,
     35 		NUM_OUTPUTS
     36 	};
     37 
     38 	VCO()
     39 	: VCOBase(
     40 		FREQUENCY_PARAM,
     41 		FINE_PARAM,
     42 		PITCH_INPUT,
     43 		SYNC_INPUT,
     44 		FM_INPUT
     45 	)
     46 	{
     47 		config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS);
     48 		configParam<VCOFrequencyParamQuantity>(FREQUENCY_PARAM, -3.0f, 6.0f, 0.0f, "Frequency", " Hz");
     49 		configParam(FINE_PARAM, -1.0f, 1.0f, 0.0f, "Fine tune", " cents", 0.0f, 100.0f);
     50 		configButton(SLOW_PARAM, "Slow mode");
     51 		configParam(PW_PARAM, -1.0f, 1.0f, 0.0f, "Pulse width", "%", 0.0f, 100.0f*0.5f*(1.0f - 2.0f * SquareOscillator::minPulseWidth), 50.0f);
     52 		configParam(FM_PARAM, 0.0f, 1.0f, 0.0f, "FM depth", "%", 0.0f, 100.0f);
     53 		configSwitch(FM_TYPE_PARAM, 0.0f, 1.0f, 1.0f, "FM mode", {"Linear FM", "Exponential FM"});
     54 		configButton(LINEAR_PARAM, "Linear frequency");
     55 
     56 		configInput(PITCH_INPUT, "Pitch (1V/octave)");
     57 		configInput(SYNC_INPUT, "Sync");
     58 		configInput(PW_INPUT, "Pulse width CV");
     59 		configInput(FM_INPUT, "Frequency modulation");
     60 
     61 		configOutput(SQUARE_OUTPUT, "Square signal");
     62 		configOutput(SAW_OUTPUT, "Saw signal");
     63 		configOutput(TRIANGLE_OUTPUT, "Triangle signal");
     64 		configOutput(SINE_OUTPUT, "Sine signal");
     65 	}
     66 
     67 	bool active() override;
     68 	void modulate() override;
     69 	void modulateChannel(int c) override;
     70 	void processChannel(const ProcessArgs& args, int c) override;
     71 };
     72 
     73 } // namespace bogaudio