| 207 | } |
| 208 | |
| 209 | void process(const ProcessArgs& args) override { |
| 210 | |
| 211 | const bool pingReceived = pingTrigger.process(inputs[PING_INPUT].getVoltage()); |
| 212 | pingableClock.process(pingReceived, args.sampleTime); |
| 213 | |
| 214 | if (ledUpdate.process()) { |
| 215 | updateLEDRing(args); |
| 216 | } |
| 217 | |
| 218 | const float quantityCV = params[QUANTITY_CV_PARAM].getValue() * clamp(inputs[QUANTITY_INPUT].getVoltage(), -5.0, +10.f) / 5.f; |
| 219 | const int quantity = clamp((int)(params[QUANTITY_PARAM].getValue() + std::round(16 * quantityCV)), 1, MAX_REPETITIONS); |
| 220 | |
| 221 | const bool loop = params[CYCLE_PARAM].getValue(); |
| 222 | |
| 223 | const float divMultCV = 4.0 * inputs[TIME_INPUT].getVoltage() / 10.f; |
| 224 | const int divMult = -clamp((int)(divMultCV + params[TIME_PARAM].getValue()), -4, +4); |
| 225 | |
| 226 | const float distributionCV = inputs[DISTRIBUTION_INPUT].getVoltage() / 10.f; |
| 227 | const float distribution = clamp(distributionCV + params[DISTRIBUTION_PARAM].getValue(), -1.f, +1.f); |
| 228 | |
| 229 | const bool triggerInputTriggered = triggTrigger.process(inputs[TRIGGER_INPUT].getVoltage()); |
| 230 | const bool triggerButtonTriggered = buttonTrigger.process(params[TRIGGER_PARAM].getValue()); |
| 231 | const bool startBurst = triggerInputTriggered || triggerButtonTriggered; |
| 232 | |
| 233 | if (startBurst) { |
| 234 | const float prob = clamp(params[PROBABILITY_PARAM].getValue() + inputs[PROBABILITY_INPUT].getVoltage() / 10.f, 0.f, 1.f); |
| 235 | const bool inhibitBurst = rack::random::uniform() < prob; |
| 236 | |
| 237 | // remember to do at current tempo |
| 238 | burstEngine.trigger(quantity, divMult, pingableClock.tempo, distribution, inhibitBurst, includeOriginalTrigger); |
| 239 | } |
| 240 | |
| 241 | float burstOut, eocOut; |
| 242 | bool eoc; |
| 243 | std::tie(burstOut, eocOut, eoc) = burstEngine.process(args.sampleTime); |
| 244 | |
| 245 | // if the burst has finished, we can also re-trigger |
| 246 | if (eoc && loop) { |
| 247 | const float prob = clamp(params[PROBABILITY_PARAM].getValue() + inputs[PROBABILITY_INPUT].getVoltage() / 10.f, 0.f, 1.f); |
| 248 | const bool inhibitBurst = rack::random::uniform() < prob; |
| 249 | |
| 250 | // remember to do at current tempo |
| 251 | burstEngine.trigger(quantity, divMult, pingableClock.tempo, distribution, inhibitBurst, includeOriginalTrigger); |
| 252 | } |
| 253 | |
| 254 | const bool tempoOutHigh = pingableClock.isTempoOutHigh(); |
| 255 | outputs[TEMPO_OUTPUT].setVoltage(10.f * tempoOutHigh); |
| 256 | lights[TEMPO_LIGHT].setBrightnessSmooth(tempoOutHigh, args.sampleTime); |
| 257 | |
| 258 | outputs[OUT_OUTPUT].setVoltage(10.f * burstOut); |
| 259 | lights[OUT_LIGHT].setBrightnessSmooth(burstOut, args.sampleTime); |
| 260 | |
| 261 | outputs[EOC_OUTPUT].setVoltage(10.f * eocOut); |
| 262 | lights[EOC_LIGHT].setBrightnessSmooth(eocOut, args.sampleTime); |
| 263 | } |
| 264 | |
| 265 | void updateLEDRing(const ProcessArgs& args) { |
| 266 | int activeLed; |
no test coverage detected