divremcGates

divide integer with constant, also outputs remainder (modulo). Gate int inputs set position for triggers (eg. when set to 3, each time rem goes by "3", sends a gate out)
Author: Remco van der Most
License: BSD
Github: sss/math/divremcGates.axo

Inlets

int32 nominator

int32 denominator

int32 G1

int32 G2

Outlets

int32 remainder of division by denominator

int32 a divided by denominator

bool32.pulse G1

bool32.pulse G2

Control Rate
outlet_G1 = 0;
outlet_G2 = 0;
int r;
if (inlet_a >= 0)
  r = ((unsigned int)inlet_a) / inlet_denominator;
else
  r = -(((unsigned int)(inlet_denominator - inlet_a)) / inlet_denominator);
outlet_div = r;
outlet_rem = inlet_a - (r * inlet_denominator);

if (outlet_rem == (inlet_G1)) {
  outlet_G1 = 1;
}
if (outlet_div == (inlet_G2)) {
  outlet_G2 = 1;
}

Privacy

© 2024 Zrna Research