PEQ14XF.cpp (4321B)
1 2 #include "PEQ14XF.hpp" 3 4 void PEQ14XF::addChannel(int c) { 5 _engines[c] = new Engine(); 6 } 7 8 void PEQ14XF::removeChannel(int c) { 9 delete _engines[c]; 10 _engines[c] = NULL; 11 } 12 13 void PEQ14XF::modulateChannel(int c) { 14 Engine& e = *_engines[c]; 15 16 float sr = APP->engine->getSampleRate(); 17 float response = sensitivity(params[DAMP_PARAM], &inputs[DAMP_INPUT], c); 18 if (e.response != response) { 19 e.response = response; 20 for (int i = 0; i < 14; ++i) { 21 e.efs[i].setParams(sr, e.response); 22 } 23 } 24 25 e.gain.setLevel(gain(params[GAIN_PARAM], &inputs[GAIN_INPUT], c)); 26 } 27 28 void PEQ14XF::processAll(const ProcessArgs& args) { 29 for (int i = 0; i < 14; ++i) { 30 outputs[EF1_OUTPUT + i].setChannels(_channels); 31 } 32 33 _baseMessage = NULL; 34 if (baseConnected()) { 35 _baseMessage = fromBase(); 36 } 37 38 if (expanderConnected()) { 39 if (_baseMessage) { 40 // *toExpander() = *_baseMessage; 41 _baseMessage->copyTo(toExpander()); 42 } 43 else { 44 toExpander()->reset(); 45 } 46 } 47 } 48 49 void PEQ14XF::processChannel(const ProcessArgs& args, int c) { 50 if (_baseMessage && _baseMessage->valid) { 51 Engine& e = *_engines[c]; 52 for (int i = 0; i < 14; ++i) { 53 if (outputs[EF1_OUTPUT + i].isConnected()) { 54 float out = e.efs[i].next(_baseMessage->outs[c][i]); 55 out = scaleEF(out, _baseMessage->frequencies[c][i], _baseMessage->bandwidths[c]); 56 out = e.gain.next(out); 57 out = _saturator.next(out); 58 outputs[EF1_OUTPUT + i].setVoltage(out, c); 59 } 60 } 61 } 62 else { 63 for (int i = 0; i < 14; ++i) { 64 outputs[EF1_OUTPUT + i].setVoltage(0.0f, c); 65 } 66 } 67 } 68 69 struct PEQ14XFWidget : BGModuleWidget { 70 static constexpr int hp = 5; 71 72 PEQ14XFWidget(PEQ14XF* module) { 73 setModule(module); 74 box.size = Vec(RACK_GRID_WIDTH * hp, RACK_GRID_HEIGHT); 75 setPanel(box.size, "PEQ14XF"); 76 createScrews(); 77 78 // generated by svg_widgets.rb 79 auto dampParamPosition = Vec(12.0, 30.0); 80 auto gainParamPosition = Vec(47.0, 29.5); 81 82 auto dampInputPosition = Vec(8.0, 63.0); 83 auto gainInputPosition = Vec(43.0, 62.5); 84 85 auto ef1OutputPosition = Vec(10.5, 111.0); 86 auto ef2OutputPosition = Vec(10.5, 146.0); 87 auto ef3OutputPosition = Vec(10.5, 181.0); 88 auto ef4OutputPosition = Vec(10.5, 216.0); 89 auto ef5OutputPosition = Vec(10.5, 251.0); 90 auto ef6OutputPosition = Vec(10.5, 286.0); 91 auto ef7OutputPosition = Vec(10.5, 321.0); 92 auto ef8OutputPosition = Vec(41.5, 111.0); 93 auto ef9OutputPosition = Vec(41.5, 146.0); 94 auto ef10OutputPosition = Vec(41.5, 181.0); 95 auto ef11OutputPosition = Vec(41.5, 216.0); 96 auto ef12OutputPosition = Vec(41.5, 251.0); 97 auto ef13OutputPosition = Vec(41.5, 286.0); 98 auto ef14OutputPosition = Vec(41.5, 321.0); 99 // end generated by svg_widgets.rb 100 101 addParam(createParam<Knob16>(dampParamPosition, module, PEQ14XF::DAMP_PARAM)); 102 addParam(createParam<Knob16>(gainParamPosition, module, PEQ14XF::GAIN_PARAM)); 103 104 addInput(createInput<Port24>(dampInputPosition, module, PEQ14XF::DAMP_INPUT)); 105 addInput(createInput<Port24>(gainInputPosition, module, PEQ14XF::GAIN_INPUT)); 106 107 addOutput(createOutput<Port24>(ef1OutputPosition, module, PEQ14XF::EF1_OUTPUT)); 108 addOutput(createOutput<Port24>(ef2OutputPosition, module, PEQ14XF::EF2_OUTPUT)); 109 addOutput(createOutput<Port24>(ef3OutputPosition, module, PEQ14XF::EF3_OUTPUT)); 110 addOutput(createOutput<Port24>(ef4OutputPosition, module, PEQ14XF::EF4_OUTPUT)); 111 addOutput(createOutput<Port24>(ef5OutputPosition, module, PEQ14XF::EF5_OUTPUT)); 112 addOutput(createOutput<Port24>(ef6OutputPosition, module, PEQ14XF::EF6_OUTPUT)); 113 addOutput(createOutput<Port24>(ef7OutputPosition, module, PEQ14XF::EF7_OUTPUT)); 114 addOutput(createOutput<Port24>(ef8OutputPosition, module, PEQ14XF::EF8_OUTPUT)); 115 addOutput(createOutput<Port24>(ef9OutputPosition, module, PEQ14XF::EF9_OUTPUT)); 116 addOutput(createOutput<Port24>(ef10OutputPosition, module, PEQ14XF::EF10_OUTPUT)); 117 addOutput(createOutput<Port24>(ef11OutputPosition, module, PEQ14XF::EF11_OUTPUT)); 118 addOutput(createOutput<Port24>(ef12OutputPosition, module, PEQ14XF::EF12_OUTPUT)); 119 addOutput(createOutput<Port24>(ef13OutputPosition, module, PEQ14XF::EF13_OUTPUT)); 120 addOutput(createOutput<Port24>(ef14OutputPosition, module, PEQ14XF::EF14_OUTPUT)); 121 } 122 }; 123 124 Model* modelPEQ14XF = createModel<PEQ14XF, PEQ14XFWidget>("Bogaudio-PEQ14XF", "PEQ14XF", "PEQ14 envelope followers expander", "Filter", "Expander", "Polyphonic");