MCPcopy Create free account
hub / github.com/VCVRack/Befaco / process

Method process

src/Mixer2.cpp:52–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 }
51
52 void process(const ProcessArgs& args) override {
53 const int numPolyphonyEngines = std::max({1, inputs[CH1_INPUT].getChannels(), inputs[CH2_INPUT].getChannels(), inputs[CH3_INPUT].getChannels(), inputs[CH4_INPUT].getChannels()});
54 const bool useMasterMix = !outputs[MIX_12_OUPUT].isConnected();
55
56 // used for LEDs
57 float_4 sum12 = 0.f, sum34 = 0.f;
58 for (int c = 0; c < numPolyphonyEngines; c += 4) {
59 float_4 out12 = 0.f;
60 float_4 out34 = 0.f;
61
62 if (inputs[CH1_INPUT].isConnected()) {
63 out12 += inputs[CH1_INPUT].getVoltageSimd<float_4>(c) * params[GAIN1_PARAM].getValue();
64 }
65
66 if (inputs[CH2_INPUT].isConnected()) {
67 out12 += inputs[CH2_INPUT].getVoltageSimd<float_4>(c) * params[GAIN2_PARAM].getValue();
68 }
69
70 if (inputs[CH3_INPUT].isConnected()) {
71 out34 += inputs[CH3_INPUT].getVoltageSimd<float_4>(c) * params[GAIN3_PARAM].getValue();
72 }
73
74 if (inputs[CH4_INPUT].isConnected()) {
75 out34 += inputs[CH4_INPUT].getVoltageSimd<float_4>(c) * params[GAIN4_PARAM].getValue();
76 }
77
78 const float_4 mix12 = useMasterMix ? float_4::zero() : out12;
79 const float_4 mix34 = useMasterMix ? out12 + out34 : out34;
80
81 if (applyClipping) {
82 outputs[MIX_12_OUPUT].setVoltageSimd(clip(mix12), c);
83 outputs[MIX_34_OUPUT].setVoltageSimd(clip(mix34), c);
84 }
85 else {
86 outputs[MIX_12_OUPUT].setVoltageSimd(mix12, c);
87 outputs[MIX_34_OUPUT].setVoltageSimd(mix34, c);
88 }
89
90 sum12 += simd::pow(out12, 2);
91 sum34 += simd::pow(out34, 2);
92 }
93
94 outputs[MIX_12_OUPUT].setChannels(numPolyphonyEngines);
95 outputs[MIX_34_OUPUT].setChannels(numPolyphonyEngines);
96
97 if (lightDivider.process()) {
98 const float deltaTime = args.sampleTime * lightDivider.getDivision();
99 if (numPolyphonyEngines == 1) {
100 lights[MIX12_LIGHT + 0].setBrightnessSmooth(std::abs(sum12[0]) / 5.f, deltaTime);
101 lights[MIX12_LIGHT + 1].setBrightness(0.f);
102 lights[MIX12_LIGHT + 2].setBrightness(0.f);
103 lights[MIX34_LIGHT + 0].setBrightnessSmooth(std::abs(sum34[0]) / 5.f, deltaTime);
104 lights[MIX34_LIGHT + 1].setBrightness(0.f);
105 lights[MIX34_LIGHT + 2].setBrightness(0.f);
106 }
107 else {
108 // TODO: better polyphonic lights?
109 lights[MIX12_LIGHT + 0].setBrightness(0.f);

Callers

nothing calls this directly

Calls 3

clipFunction · 0.85
getChannelsMethod · 0.80
getValueMethod · 0.80

Tested by

no test coverage detected