| 37 | } |
| 38 | |
| 39 | void process(const ProcessArgs& args) override { |
| 40 | |
| 41 | float_4 in[4] = {}; |
| 42 | float_4 riseCV[4] = {}; |
| 43 | float_4 fallCV[4] = {}; |
| 44 | |
| 45 | // this is the number of active polyphony engines, defined by the input |
| 46 | int numPolyphonyEngines = inputs[IN_INPUT].getChannels(); |
| 47 | |
| 48 | // minimum and maximum slopes in volts per second |
| 49 | const float slewMin = 0.1; |
| 50 | const float slewMax = 10000.f; |
| 51 | // Amount of extra slew per voltage difference |
| 52 | const float shapeScale = 1 / 10.f; |
| 53 | |
| 54 | const float_4 param_rise = params[RISE_PARAM].getValue() * 10.f; |
| 55 | const float_4 param_fall = params[FALL_PARAM].getValue() * 10.f; |
| 56 | |
| 57 | outputs[OUT_OUTPUT].setChannels(numPolyphonyEngines); |
| 58 | |
| 59 | for (int c = 0; c < numPolyphonyEngines; c += 4) { |
| 60 | in[c / 4] = inputs[IN_INPUT].getVoltageSimd<float_4>(c); |
| 61 | |
| 62 | if (inputs[RISE_INPUT].isConnected()) { |
| 63 | riseCV[c / 4] = inputs[RISE_INPUT].getPolyVoltageSimd<float_4>(c); |
| 64 | } |
| 65 | if (inputs[FALL_INPUT].isConnected()) { |
| 66 | fallCV[c / 4] = inputs[FALL_INPUT].getPolyVoltageSimd<float_4>(c); |
| 67 | } |
| 68 | |
| 69 | riseCV[c / 4] += param_rise; |
| 70 | fallCV[c / 4] += param_fall; |
| 71 | |
| 72 | float_4 delta = in[c / 4] - out[c / 4]; |
| 73 | float_4 delta_gt_0 = delta > 0.f; |
| 74 | float_4 delta_lt_0 = delta < 0.f; |
| 75 | |
| 76 | float_4 rateCV = {}; |
| 77 | rateCV = ifelse(delta_gt_0, riseCV[c / 4], 0.f); |
| 78 | rateCV = ifelse(delta_lt_0, fallCV[c / 4], rateCV) * 0.1f; |
| 79 | |
| 80 | float_4 pm_one = simd::sgn(delta); |
| 81 | float_4 slew = slewMax * simd::pow(slewMin / slewMax, rateCV); |
| 82 | |
| 83 | const float shape = params[SHAPE_PARAM].getValue(); |
| 84 | out[c / 4] += slew * simd::crossfade(pm_one, shapeScale * delta, shape) * args.sampleTime; |
| 85 | out[c / 4] = ifelse(delta_gt_0 & (out[c / 4] > in[c / 4]), in[c / 4], out[c / 4]); |
| 86 | out[c / 4] = ifelse(delta_lt_0 & (out[c / 4] < in[c / 4]), in[c / 4], out[c / 4]); |
| 87 | |
| 88 | outputs[OUT_OUTPUT].setVoltageSimd(out[c / 4], c); |
| 89 | } |
| 90 | } |
| 91 | }; |
| 92 | |
| 93 |
nothing calls this directly
no test coverage detected