BogaudioModules

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

PEQ6XF.cpp (2790B)


      1 
      2 #include "PEQ6XF.hpp"
      3 
      4 void PEQ6XF::addChannel(int c) {
      5 	_engines[c] = new Engine();
      6 }
      7 
      8 void PEQ6XF::removeChannel(int c) {
      9 	delete _engines[c];
     10 	_engines[c] = NULL;
     11 }
     12 
     13 void PEQ6XF::modulate() {
     14 	float sr = APP->engine->getSampleRate();
     15 	float response = sensitivity(params[DAMP_PARAM], NULL, 0);
     16 	if (_response != response) {
     17 		_response = response;
     18 		for (int c = 0; c < _channels; ++c) {
     19 			for (int i = 0; i < 6; ++i) {
     20 				_engines[c]->efs[i].setParams(sr, _response);
     21 			}
     22 		}
     23 	}
     24 
     25 	_gain.setLevel(gain(params[GAIN_PARAM], NULL, 0));
     26 }
     27 
     28 void PEQ6XF::processAll(const ProcessArgs& args) {
     29 	for (int i = 0; i < 6; ++i) {
     30 		outputs[EF1_OUTPUT + i].setChannels(_channels);
     31 	}
     32 
     33 	_baseMessage = NULL;
     34 	if (baseConnected()) {
     35 		_baseMessage = fromBase();
     36 	}
     37 }
     38 
     39 void PEQ6XF::processChannel(const ProcessArgs& args, int c) {
     40 	if (_baseMessage) {
     41 		Engine& e = *_engines[c];
     42 		for (int i = 0; i < 6; ++i) {
     43 			if (outputs[EF1_OUTPUT + i].isConnected()) {
     44 				float out = e.efs[i].next(_baseMessage->outs[c][i]);
     45 				out = scaleEF(out, _baseMessage->frequencies[c][i], _baseMessage->bandwidths[c]);
     46 				out = _gain.next(out);
     47 				out = _saturator.next(out);
     48 				outputs[EF1_OUTPUT + i].setVoltage(out, c);
     49 			}
     50 		}
     51 	}
     52 	else {
     53 		for (int i = 0; i < 6; ++i) {
     54 			outputs[EF1_OUTPUT + i].setVoltage(0.0f, c);
     55 		}
     56 	}
     57 }
     58 
     59 struct PEQ6XFWidget : BGModuleWidget {
     60 	static constexpr int hp = 3;
     61 
     62 	PEQ6XFWidget(PEQ6XF* module) {
     63 		setModule(module);
     64 		box.size = Vec(RACK_GRID_WIDTH * hp, RACK_GRID_HEIGHT);
     65 		setPanel(box.size, "PEQ6XF");
     66 		createScrews();
     67 
     68 		// generated by svg_widgets.rb
     69 		auto dampParamPosition = Vec(14.5, 32.0);
     70 		auto gainParamPosition = Vec(14.5, 71.0);
     71 
     72 		auto ef1OutputPosition = Vec(10.5, 107.0);
     73 		auto ef2OutputPosition = Vec(10.5, 142.0);
     74 		auto ef3OutputPosition = Vec(10.5, 177.0);
     75 		auto ef4OutputPosition = Vec(10.5, 212.0);
     76 		auto ef5OutputPosition = Vec(10.5, 247.0);
     77 		auto ef6OutputPosition = Vec(10.5, 282.0);
     78 		// end generated by svg_widgets.rb
     79 
     80 		addParam(createParam<Knob16>(dampParamPosition, module, PEQ6XF::DAMP_PARAM));
     81 		addParam(createParam<Knob16>(gainParamPosition, module, PEQ6XF::GAIN_PARAM));
     82 
     83 		addOutput(createOutput<Port24>(ef1OutputPosition, module, PEQ6XF::EF1_OUTPUT));
     84 		addOutput(createOutput<Port24>(ef2OutputPosition, module, PEQ6XF::EF2_OUTPUT));
     85 		addOutput(createOutput<Port24>(ef3OutputPosition, module, PEQ6XF::EF3_OUTPUT));
     86 		addOutput(createOutput<Port24>(ef4OutputPosition, module, PEQ6XF::EF4_OUTPUT));
     87 		addOutput(createOutput<Port24>(ef5OutputPosition, module, PEQ6XF::EF5_OUTPUT));
     88 		addOutput(createOutput<Port24>(ef6OutputPosition, module, PEQ6XF::EF6_OUTPUT));
     89 	}
     90 };
     91 
     92 Model* modelPEQ6XF = createModel<PEQ6XF, PEQ6XFWidget>("Bogaudio-PEQ6XF", "PEQ6XF", "PEQ6 envelope followers expander", "Filter", "Expander", "Polyphonic");