1RngCount

single core range counter (divremc with internal level manipulation)
Author: Remco van der Most
License: BSD
Github: sss/patt/1RngCount.axo

Inlets

int32 nominator

int32 denominator

int32 AftRng

frac32 PreMul

frac32 PreJmp

frac32 PreChg

Outlets

int32 PreRng

int32 AftRng

Declaration
int32_t ptrig;
int32_t pval;
Init
ptrig = 0;
pval = 0;
Control Rate
int r;
int s;
int t;
int u;
int a;
int b;
int c;
int d;
int e;
int f;
int g;
int h;
int i;
int j;
int k;
int l;
int m;
int n;

if (inlet_Count >= 0)
  r = ((unsigned int)inlet_Count) / inlet_PreRng;
else
  r = -(((unsigned int)(inlet_PreRng - inlet_Count)) / inlet_PreRng);

a = inlet_Count - (r * inlet_PreRng);
c = inlet_AftRng << 2;
b = a * ___SMMUL((inlet_PreMul) << 3, c) + r * ___SMMUL(inlet_PreJmp << 3, c) +
    r * a * ___SMMUL(inlet_PreChg << 3, c);

if (b >= 0)
  s = ((unsigned int)b) / inlet_AftRng;
else
  s = -(((unsigned int)(inlet_AftRng - b)) / inlet_AftRng);

d = b - (s * inlet_AftRng);

outlet_PreRng = a;
outlet_AftRng = d;

Privacy

© 2024 Zrna Research