| 45 | } |
| 46 | |
| 47 | void process(const ProcessArgs& args) override { |
| 48 | int channels1 = inputs[IN1_INPUT].getChannels(); |
| 49 | int channels2 = inputs[IN2_INPUT].getChannels(); |
| 50 | int channels3 = inputs[IN3_INPUT].getChannels(); |
| 51 | int channels4 = inputs[IN4_INPUT].getChannels(); |
| 52 | |
| 53 | int out_channels = 1; |
| 54 | out_channels = std::max(out_channels, channels1); |
| 55 | out_channels = std::max(out_channels, channels2); |
| 56 | out_channels = std::max(out_channels, channels3); |
| 57 | out_channels = std::max(out_channels, channels4); |
| 58 | |
| 59 | float_4 out[4] = {}; |
| 60 | |
| 61 | if (inputs[IN1_INPUT].isConnected()) { |
| 62 | for (int c = 0; c < channels1; c += 4) |
| 63 | out[c / 4] += inputs[IN1_INPUT].getVoltageSimd<float_4>(c) * params[CH1_PARAM].getValue(); |
| 64 | } |
| 65 | |
| 66 | if (inputs[IN2_INPUT].isConnected()) { |
| 67 | for (int c = 0; c < channels2; c += 4) |
| 68 | out[c / 4] += inputs[IN2_INPUT].getVoltageSimd<float_4>(c) * params[CH2_PARAM].getValue(); |
| 69 | } |
| 70 | |
| 71 | if (inputs[IN3_INPUT].isConnected()) { |
| 72 | for (int c = 0; c < channels3; c += 4) |
| 73 | out[c / 4] += inputs[IN3_INPUT].getVoltageSimd<float_4>(c) * params[CH3_PARAM].getValue(); |
| 74 | } |
| 75 | |
| 76 | if (inputs[IN4_INPUT].isConnected()) { |
| 77 | for (int c = 0; c < channels4; c += 4) |
| 78 | out[c / 4] += inputs[IN4_INPUT].getVoltageSimd<float_4>(c) * params[CH4_PARAM].getValue(); |
| 79 | } |
| 80 | |
| 81 | outputs[OUT1_OUTPUT].setChannels(out_channels); |
| 82 | outputs[OUT2_OUTPUT].setChannels(out_channels); |
| 83 | |
| 84 | for (int c = 0; c < out_channels; c += 4) { |
| 85 | outputs[OUT1_OUTPUT].setVoltageSimd(out[c / 4], c); |
| 86 | out[c / 4] *= -1.f; |
| 87 | outputs[OUT2_OUTPUT].setVoltageSimd(out[c / 4], c); |
| 88 | } |
| 89 | |
| 90 | if (out_channels == 1) { |
| 91 | float light = outputs[OUT1_OUTPUT].getVoltage(); |
| 92 | lights[OUT_POS_LIGHT].setSmoothBrightness(light / 5.f, args.sampleTime); |
| 93 | lights[OUT_NEG_LIGHT].setSmoothBrightness(-light / 5.f, args.sampleTime); |
| 94 | } |
| 95 | else { |
| 96 | float light = 0.0f; |
| 97 | for (int c = 0; c < out_channels; c++) { |
| 98 | float tmp = outputs[OUT1_OUTPUT].getVoltage(c); |
| 99 | light += tmp * tmp; |
| 100 | } |
| 101 | light = std::sqrt(light); |
| 102 | lights[OUT_POS_LIGHT].setBrightness(0.0f); |
| 103 | lights[OUT_NEG_LIGHT].setBrightness(0.0f); |
| 104 | lights[OUT_BLUE_LIGHT].setSmoothBrightness(light / 5.f, args.sampleTime); |
nothing calls this directly
no test coverage detected