Ssquare

description
Author: Remco van der Most
License: BSD
Github: sss/dist/Ssquare.axo

Inlets

frac32 exp

frac32 mod

frac32buffer.positive in

Outlets

frac32buffer out

Parameters

frac32.s.map exp

frac32.s.map mod

frac32.s.map lvl

int32 stack

Declaration
int i;
int32_t expo[32];
int dir;
int32_t pEXP;
int32_t sEXP;
int32_t pMOD;
int32_t sMOD;
Control Rate
int32_t EXP = param_exp + inlet_exp;
int32_t MOD = param_mod + inlet_mod;

sEXP = (EXP - pEXP) >> 4;
int32_t S1 = pEXP;
pEXP = EXP;

sMOD = (MOD - pMOD) >> 4;
int32_t S2 = pMOD;
pMOD = MOD;
Audio Rate
S1 += sEXP;
S2 += sMOD;

int32_t IN = __SSAT(inlet_in, 28);
int32_t inexpo = __SSAT(S1 + ___SMMUL((IN - (1 << 26)) << 3, S2 << 3), 28);
dir = inexpo > 0 ? 1 : -1;
inexpo = inexpo > 0 ? inexpo : -inexpo;
int32_t inv = (1 << 27) - inexpo;

int dar;
dar = inlet_in > 0 ? 1 : -1;
int32_t pos = IN;
pos = pos > 0 ? pos : -pos;
if (dir > 0) {
  expo[0] = ___SMMUL(pos << 3, (inv + ___SMMUL(inexpo << 3, pos << 2)) << 2);
}
if (dir < 0) {
  expo[0] =
      ___SMMUL(((1 << 27) - pos) << 3,
               (inv + ___SMMUL(inexpo << 3, ((1 << 27) - pos) << 2)) << 2);
}
for (i = 1; i <= param_stack; i++)
  expo[i] = ___SMMUL(expo[i - 1] << 3,
                     (inv + ___SMMUL(inexpo << 3, expo[i - 1] << 2)) << 2);
if (dir > 0) {
  outlet_out = ___SMMUL((expo[param_stack] * dar) << 3, param_lvl << 2);
}
if (dir < 0) {
  outlet_out =
      ___SMMUL((((1 << 27) - expo[param_stack]) * dar) << 3, param_lvl << 2);
}

Privacy

© 2024 Zrna Research