%sw1_2

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

Inlets

bool32 trig

int32 i1

Outlets

int32 o

int32 a

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_i1 : 0;
outlet_a = ((val < param_prob)) ? inlet_i1 : 0;

Privacy

© 2024 Zrna Research