Modulo

unipolar modulo function Example: param_factor = 2 in modulo integ 0 -> 0 0 31 -> 62 0 32 -> 0 1 63 -> 62 1
Author: Smashed Transistors
License: LGPL
Github: tiar/kfunc/Modulo.axo

Inlets

frac32.positive in

frac32.bipolar factor

Outlets

frac32.positive modulo

int32.positive integer

Parameters

bool32.tgl mirror

frac32.u.map factor

Declaration
int32_t factor;
Control Rate
factor = __USAT(param_factor + inlet_factor, 27);
if (!param_mirror) {
  //                      q21         q27
  int32_t val = ___SMMUL(factor, inlet_in); // q16
  outlet_modulo = (val & ((1 << 16) - 1)) << 11;
  outlet_integer = val >> 16;
} else {
  //                       q21             q27
  int32_t val = ___SMMUL(factor, (1 << 27) - inlet_in); // q16
  outlet_modulo = (1 << 27) - ((val & ((1 << 16) - 1)) << 11);
  outlet_integer = val >> 16;
}

Privacy

© 2024 Zrna Research