| 131 | } |
| 132 | |
| 133 | void process(const ProcessArgs& args) override { |
| 134 | int channels = std::max(inputs[NOTE_INPUT].getChannels(), 1); |
| 135 | |
| 136 | // Get input |
| 137 | if (!inputBuffer.full()) { |
| 138 | dsp::Frame<16 * 2> inputFrame = {}; |
| 139 | for (int c = 0; c < channels; c++) { |
| 140 | inputFrame.samples[c * 2 + 0] = inputs[BLOW_INPUT].getPolyVoltage(c) / 5.0; |
| 141 | inputFrame.samples[c * 2 + 1] = inputs[STRIKE_INPUT].getPolyVoltage(c) / 5.0; |
| 142 | } |
| 143 | inputBuffer.push(inputFrame); |
| 144 | } |
| 145 | |
| 146 | // Generate output if output buffer is empty |
| 147 | if (outputBuffer.empty()) { |
| 148 | // blow[channel][bufferIndex] |
| 149 | float blow[16][16] = {}; |
| 150 | float strike[16][16] = {}; |
| 151 | |
| 152 | // Convert input buffer |
| 153 | { |
| 154 | inputSrc.setRates(args.sampleRate, 32000); |
| 155 | inputSrc.setChannels(channels * 2); |
| 156 | int inLen = inputBuffer.size(); |
| 157 | int outLen = 16; |
| 158 | dsp::Frame<16 * 2> inputFrames[outLen]; |
| 159 | inputSrc.process(inputBuffer.startData(), &inLen, inputFrames, &outLen); |
| 160 | inputBuffer.startIncr(inLen); |
| 161 | |
| 162 | for (int c = 0; c < channels; c++) { |
| 163 | for (int i = 0; i < outLen; i++) { |
| 164 | blow[c][i] = inputFrames[i].samples[c * 2 + 0]; |
| 165 | strike[c][i] = inputFrames[i].samples[c * 2 + 1]; |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | // Process channels |
| 171 | // main[channel][bufferIndex] |
| 172 | float main[16][16]; |
| 173 | float aux[16][16]; |
| 174 | float gateLight = 0.f; |
| 175 | float exciterLight = 0.f; |
| 176 | float resonatorLight = 0.f; |
| 177 | |
| 178 | for (int c = 0; c < channels; c++) { |
| 179 | // Set patch from parameters |
| 180 | elements::Patch* p = parts[c]->mutable_patch(); |
| 181 | p->exciter_envelope_shape = params[CONTOUR_PARAM].getValue(); |
| 182 | p->exciter_bow_level = params[BOW_PARAM].getValue(); |
| 183 | p->exciter_blow_level = params[BLOW_PARAM].getValue(); |
| 184 | p->exciter_strike_level = params[STRIKE_PARAM].getValue(); |
| 185 | |
| 186 | #define BIND(_p, _m, _i) clamp(params[_p].getValue() + 3.3f * dsp::quadraticBipolar(params[_m].getValue()) * inputs[_i].getPolyVoltage(c) / 5.f, 0.f, 0.9995f) |
| 187 | |
| 188 | p->exciter_bow_timbre = BIND(BOW_TIMBRE_PARAM, BOW_TIMBRE_MOD_PARAM, BOW_TIMBRE_MOD_INPUT); |
| 189 | p->exciter_blow_meta = BIND(FLOW_PARAM, FLOW_MOD_PARAM, FLOW_MOD_INPUT); |
| 190 | p->exciter_blow_timbre = BIND(BLOW_TIMBRE_PARAM, BLOW_TIMBRE_MOD_PARAM, BLOW_TIMBRE_MOD_INPUT); |