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

Method process

src/STMix.cpp:44–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 }
43
44 void process(const ProcessArgs& args) override {
45 float_4 out_left[4] = {};
46 float_4 out_right[4] = {};
47
48 int numActivePolyphonyEngines = 1;
49 for (int i = 0; i < numMixerChannels + 1; ++i) {
50 const int stereoPolyChannels = std::max(inputs[LEFT_INPUT + i].getChannels(),
51 inputs[RIGHT_INPUT + i].getChannels());
52 numActivePolyphonyEngines = std::max(numActivePolyphonyEngines, stereoPolyChannels);
53 }
54
55 for (int i = 0; i < numMixerChannels + 1; ++i) {
56
57 const float gain = (i < numMixerChannels) ? exponentialBipolar80Pade_5_4(params[GAIN_PARAM + i].getValue()) : 1.f;
58
59 for (int c = 0; c < numActivePolyphonyEngines; c += 4) {
60 const float_4 in_left = inputs[LEFT_INPUT + i].getNormalVoltageSimd<float_4>(0.f, c);
61 const float_4 in_right = inputs[RIGHT_INPUT + i].getNormalVoltageSimd<float_4>(in_left, c);
62
63 out_left[c / 4] += in_left * gain;
64 out_right[c / 4] += in_right * gain;
65 }
66 }
67
68 outputs[LEFT_OUTPUT].setChannels(numActivePolyphonyEngines);
69 outputs[RIGHT_OUTPUT].setChannels(numActivePolyphonyEngines);
70
71 for (int c = 0; c < numActivePolyphonyEngines; c += 4) {
72 outputs[LEFT_OUTPUT].setVoltageSimd(out_left[c / 4], c);
73 outputs[RIGHT_OUTPUT].setVoltageSimd(out_right[c / 4], c);
74 }
75
76 if (numActivePolyphonyEngines == 1) {
77 lights[LEFT_LED + 0].setSmoothBrightness(outputs[LEFT_OUTPUT].getVoltage() / 5.f, args.sampleTime);
78 lights[RIGHT_LED + 0].setSmoothBrightness(outputs[RIGHT_OUTPUT].getVoltage() / 5.f, args.sampleTime);
79 lights[LEFT_LED + 1].setBrightness(0.f);
80 lights[RIGHT_LED + 1].setBrightness(0.f);
81 lights[LEFT_LED + 2].setBrightness(0.f);
82 lights[RIGHT_LED + 2].setBrightness(0.f);
83 }
84 else {
85 lights[LEFT_LED + 0].setBrightness(0.f);
86 lights[RIGHT_LED + 0].setBrightness(0.f);
87 lights[LEFT_LED + 1].setBrightness(0.f);
88 lights[RIGHT_LED + 1].setBrightness(0.f);
89
90 float b_left = 0.f;
91 float b_right = 0.f;
92 for (int c = 0; c < numActivePolyphonyEngines; c++) {
93 b_left += std::pow(out_left[c / 4][c % 4], 2);
94 b_right += std::pow(out_right[c / 4][c % 4], 2);
95 }
96 b_left = std::sqrt(b_left) / 5.f;
97 b_right = std::sqrt(b_right) / 5.f;
98 lights[LEFT_LED + 2].setSmoothBrightness(b_left, args.sampleTime);
99 lights[RIGHT_LED + 2].setSmoothBrightness(b_right, args.sampleTime);
100 }
101 }

Callers

nothing calls this directly

Calls 3

getChannelsMethod · 0.80
getValueMethod · 0.80

Tested by

no test coverage detected