MCPcopy Create free account
hub / github.com/VCVRack/Befaco / getRandomizedValue

Method getRandomizedValue

src/Iroi.cpp:477–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475 }
476
477 float getRandomizedValue(ParamId paramId, float amount) {
478 const float value = params[paramId].getValue();
479
480 float r1 = rack::random::uniform();
481 float r2 = rack::random::uniform();
482
483 float sign = (r2 < 0.5f) ? 1.f : -1.f;
484 if (sign < 0.f && value <= 0.f) {
485 sign = 1.f;
486 } else if (sign > 0.f && value >= 1.f) {
487 sign = -1.f;
488 }
489
490 float next = value + r1 * amount * sign;
491 next = clamp(next, 0.f, 1.f);
492 return next;
493 }
494
495 void setRandomTarget(ParamId paramId, float amount, bool immediate) {
496 float next = getRandomizedValue(paramId, amount);

Callers

nothing calls this directly

Calls 1

getValueMethod · 0.80

Tested by

no test coverage detected