%sw2_1f

probabiltiy switch 2-1f
Author: Philoop
License: GPL
Github: phi/prob/%sw2_1f.axo

Inlets

bool32 trig

frac32.bipolar i1

frac32.bipolar i2

Outlets

frac32.bipolar 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