%sw2_1i

probabiltiy switch 2-1i
Author: Philoop
License:
Github: phi/prob/%sw2_1i.axo

Inlets

int32 i1

int32 i2

bool32 trig

Outlets

int32 o

Parameters

frac32.s.map prob

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

outlet_o = val >= param_prob ? inlet_i2 : inlet_i1;

Privacy

© 2024 Zrna Research