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

Method process

src/Bandit.cpp:142–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140
141
142 void process(const ProcessArgs& args) override {
143
144 const int maxPolyphony = std::max({1, inputs[ALL_INPUT].getChannels(), inputs[LOW_INPUT].getChannels(),
145 inputs[LOW_MID_INPUT].getChannels(), inputs[HIGH_MID_INPUT].getChannels(),
146 inputs[HIGH_INPUT].getChannels()});
147
148 const bool allReturnsActiveAndMonophonic = inputs[LOW_RETURN_INPUT].isMonophonic() && inputs[LOW_MID_RETURN_INPUT].isMonophonic() &&
149 inputs[HIGH_MID_RETURN_INPUT].isMonophonic() && inputs[HIGH_RETURN_INPUT].isMonophonic();
150
151 float_4 mixOutput[4] = {};
152 for (int c = 0; c < maxPolyphony; c += 4) {
153
154 const float_4 inLow = inputs[LOW_INPUT].getPolyVoltageSimd<float_4>(c);
155 const float_4 inLowMid = inputs[LOW_MID_INPUT].getPolyVoltageSimd<float_4>(c);
156 const float_4 inHighMid = inputs[HIGH_MID_INPUT].getPolyVoltageSimd<float_4>(c);
157 const float_4 inHigh = inputs[HIGH_INPUT].getPolyVoltageSimd<float_4>(c);
158 const float_4 inAll = inputs[ALL_INPUT].getPolyVoltageSimd<float_4>(c);
159
160 const float_4 lowGain = params[LOW_GAIN_PARAM].getValue() * clamp(inputs[LOW_CV_INPUT].getNormalPolyVoltageSimd<float_4>(10.f, c) / 10.f, 0.f, 1.f);
161 const float_4 outLow = 0.7 * 2 * filterLow[c / 4][1].process(filterLow[c / 4][0].process((inLow + inAll) * lowGain));
162 outputs[LOW_OUTPUT].setVoltageSimd<float_4>(outLow, c);
163
164 const float_4 lowMidGain = params[LOW_MID_GAIN_PARAM].getValue() * clamp(inputs[LOW_MID_CV_INPUT].getNormalPolyVoltageSimd<float_4>(10.f, c) / 10.f, 0.f, 1.f);
165 const float_4 outLowMid = 2 * filterLowMid[c / 4][1].process(filterLowMid[c / 4][0].process((inLowMid + inAll) * lowMidGain));
166 outputs[LOW_MID_OUTPUT].setVoltageSimd<float_4>(outLowMid, c);
167
168 const float_4 highMidGain = params[HIGH_MID_GAIN_PARAM].getValue() * clamp(inputs[HIGH_MID_CV_INPUT].getNormalPolyVoltageSimd<float_4>(10.f, c) / 10.f, 0.f, 1.f);
169 const float_4 outHighMid = 2 * filterHighMid[c / 4][1].process(filterHighMid[c / 4][0].process((inHighMid + inAll) * highMidGain));
170 outputs[HIGH_MID_OUTPUT].setVoltageSimd<float_4>(outHighMid, c);
171
172 const float_4 highGain = params[HIGH_GAIN_PARAM].getValue() * clamp(inputs[HIGH_CV_INPUT].getNormalPolyVoltageSimd<float_4>(10.f, c) / 10.f, 0.f, 1.f);
173 const float_4 outHigh = 0.7 * 2 * filterHigh[c / 4][1].process(filterHigh[c / 4][0].process((inHigh + inAll) * highGain));
174 outputs[HIGH_OUTPUT].setVoltageSimd<float_4>(outHigh, c);
175
176 // the fx return input is normalled to the fx send output
177 mixOutput[c / 4] = inputs[LOW_RETURN_INPUT].getNormalPolyVoltageSimd<float_4>(outLow * !outputs[LOW_OUTPUT].isConnected(), c);
178 mixOutput[c / 4] += inputs[LOW_MID_RETURN_INPUT].getNormalPolyVoltageSimd<float_4>(outLowMid * !outputs[LOW_MID_OUTPUT].isConnected(), c);
179 mixOutput[c / 4] += inputs[HIGH_MID_RETURN_INPUT].getNormalPolyVoltageSimd<float_4>(outHighMid * !outputs[HIGH_MID_OUTPUT].isConnected(), c);
180 mixOutput[c / 4] += inputs[HIGH_RETURN_INPUT].getNormalPolyVoltageSimd<float_4>(outHigh * !outputs[HIGH_OUTPUT].isConnected(), c);
181 mixOutput[c / 4] = mixOutput[c / 4] * clamp(inputs[ALL_CV_INPUT].getNormalPolyVoltageSimd<float_4>(10.f, c) / 10.f, 0.f, 1.f);
182
183 if (applySaturation) {
184 mixOutput[c / 4] = Saturator<float_4>::process(mixOutput[c / 4] / 10.f) * 10.f;
185 }
186
187 outputs[MIX_OUTPUT].setVoltageSimd<float_4>(mixOutput[c / 4], c);
188 }
189
190 outputs[LOW_OUTPUT].setChannels(maxPolyphony);
191 outputs[LOW_MID_OUTPUT].setChannels(maxPolyphony);
192 outputs[HIGH_MID_OUTPUT].setChannels(maxPolyphony);
193 outputs[HIGH_OUTPUT].setChannels(maxPolyphony);
194
195 if (allReturnsActiveAndMonophonic) {
196 // special case: if all return paths are connected and monophonic, then output mix should be monophonic
197 outputs[MIX_OUTPUT].setChannels(1);
198 }
199 else {

Callers

nothing calls this directly

Calls 2

getChannelsMethod · 0.80
getValueMethod · 0.80

Tested by

no test coverage detected