%i sw

probabiltiy random i
Author: Philoop
License: GPL
Github: phi/prob/% i.sw.axo

Inlets

bool32 trig

int32 reso

Outlets

int32 o

Parameters

int32 value

frac32.s.map prob

bool32.tgl on

Displays

int32.label v

Declaration
int32_t val;
int32_t val1;
int ntrig;
int rtrig;
Init
val = (int32_t)(GenerateRandomNumber()) >> 4;
val1 = (int32_t)(GenerateRandomNumber()) >> 4;
ntrig = 0;
rtrig = 0;
Control Rate
if ((inlet_trig > 0) && !ntrig) {
  val = (int32_t)(GenerateRandomNumber()) >> 4;
  ntrig = 1;
} else if (!(inlet_trig > 0))
  ntrig = 0;

if (((param_prob > val) && (inlet_trig) > 0) && !rtrig) {
  if (param_value)
    val1 = (int32_t)(GenerateRandomNumber() % (param_value));
  else
    val1 = 0;
  rtrig = 1;
} else if (!(inlet_trig > 0))
  rtrig = 0;
outlet_o = (param_on) ? (val1 + inlet_reso) : (inlet_reso);
disp_v = outlet_o;

Privacy

© 2024 Zrna Research