| 64 | kout[] op kin1[], kin2[] |
| 65 | */ |
| 66 | template <MYFLT (*bop)(MYFLT, MYFLT)> struct ArrayOp2 : csnd::Plugin<1, 2> { |
| 67 | |
| 68 | int process(csnd::myfltvec &out, csnd::myfltvec &in1, csnd::myfltvec &in2) { |
| 69 | std::transform(in1.begin(), in1.end(), in2.begin(), out.begin(), |
| 70 | [](MYFLT f1, MYFLT f2) { return bop(f1, f2); }); |
| 71 | return OK; |
| 72 | } |
| 73 | |
| 74 | int init() { |
| 75 | csnd::myfltvec &out = outargs.myfltvec_data(0); |
| 76 | csnd::myfltvec &in1 = inargs.myfltvec_data(0); |
| 77 | csnd::myfltvec &in2 = inargs.myfltvec_data(1); |
| 78 | if (UNLIKELY(in2.len() < in1.len())) |
| 79 | return csound->init_error(Str_noop("second input array is too short\n")); |
| 80 | out.init(csound, in1.len()); |
| 81 | if (!is_perf()) process(out, in1, in2); |
| 82 | return OK; |
| 83 | } |
| 84 | int kperf() { |
| 85 | return process(outargs.myfltvec_data(0), inargs.myfltvec_data(0), |
| 86 | inargs.myfltvec_data(1)); |
| 87 | } |
| 88 | }; |
| 89 | |
| 90 | /** k-rate binary operator with array and scalar |
| 91 | kout[] op kin1[], kin2 |
nothing calls this directly
no outgoing calls
no test coverage detected