frac32buffer x coordinate input
frac32buffer y coordinate input
frac32 mod input for the a parameter
frac32 mod input for the b parameter
frac32 mod input for the b parameter
frac32buffer z output
frac32.s.map a coefficient, see formula
frac32.s.map b coefficient, see formula
frac32.s.map c coefficient, see formula
bool32.tgl saturate input to normal range
combo function
int32_t map(int32_t x, int32_t y, int32_t a, int32_t b, int32_t c) {
int32_t z = 0;
#if (attr_function == 0) // linerar
z = ___SMMLA(a << 3, x << 2, ___SMMLA(b << 3, y << 2, c));
#elif (attr_function == 1) // quadratic
z = ___SMMLA(___SMMUL(a << 3, x << 2) << 2, x << 3,
___SMMLA(___SMMUL(b << 3, y << 2) << 2, y << 3,
___SMMUL(___SMMUL(c << 3, x << 2) << 2, y << 3)));
#elif (attr_function == 2) // cubic1
int32_t x3 = ___SMMUL(x << 2, ___SMMUL(x << 2, x << 3) << 3);
int32_t y3 = ___SMMUL(y << 2, ___SMMUL(y << 2, y << 3) << 3);
z = ___SMMLA(a << 3, x3 << 2, ___SMMLA(b << 3, y3 << 2, c));
#elif (attr_function == 3) // cubic2
int32_t x3 = ___SMMUL(x << 2, ___SMMUL(y << 2, y << 3) << 3);
int32_t y3 = ___SMMUL(y << 2, ___SMMUL(x << 2, x << 3) << 3);
z = ___SMMLA(a << 3, x3 << 2, ___SMMLA(b << 3, y3 << 2, c));
#elif (attr_function == 4) // sine1
SINE2TINTERP(___SMMUL(a << 3, x << 2) + ___SMMUL(b << 3, y << 2) + c << 5, z);
z = z >> 4;
#elif (attr_function == 5) // sine2
SINE2TINTERP(___SMMUL(a << 3, ___SMMUL(x << 3, x << 2) << 2) +
___SMMUL(b << 3, ___SMMUL(y << 3, y << 2) << 2) +
___SMMUL(c << 3, ___SMMUL(x << 3, y << 2) << 2),
z);
z = z >> 4;
#elif (attr_function == 6) // sine3
int32_t x3 = ___SMMUL(x << 2, ___SMMUL(x << 2, x << 3) << 3);
int32_t y3 = ___SMMUL(y << 2, ___SMMUL(y << 2, y << 3) << 3);
SINE2TINTERP(___SMMLA(a << 3, x3 << 2, ___SMMLA(b << 3, y3 << 2, c)) << 5, z);
z = z >> 4;
#elif (attr_function == 7) // sine4
int32_t x3 = ___SMMUL(x << 2, ___SMMUL(y << 2, y << 3) << 3);
int32_t y3 = ___SMMUL(y << 2, ___SMMUL(x << 2, x << 3) << 3);
SINE2TINTERP(___SMMLA(a << 3, x3 << 2, ___SMMLA(b << 3, y3 << 2, c)) << 5, z);
z = z >> 4;
#elif (attr_function == 8) // sine5
SINE2TINTERP(___SMMLA(c << 3,
___SMMUL(y << 2, ___SMMUL(x << 2, x << 3) << 3) << 2,
___SMMLA(b << 3, ___SMMUL(y << 2, y << 3) << 2,
___SMMUL(a << 3, x << 2)))
<< 5,
z);
z = z >> 4;
#elif (attr_function == 9) // complex1
float num = ___SMMUL(a << 2, ___SMMUL(x << 2, x << 3) << 3) +
___SMMUL(b << 2, ___SMMUL(y << 2, y << 3) << 3);
float den = ___SMMLA(x << 2, y << 3, (c << 2));
SINE2TINTERP((int32_t)(134217728.0f * num / den) << 5, z);
z = z >> 4;
#elif (attr_function == 10) // feedback1
SINE2TINTERP(___SMMUL(a << 3, x << 2) + ___SMMUL(b << 3, y << 2) +
___SMMUL(c << 3, out_old << 2)
<< 5,
z);
z = z >> 4;
out_old = z;
#elif (attr_function == 11) // feedback2
SINE2TINTERP(___SMMUL(a << 3, ___SMMUL(x << 3, x << 2) << 2) +
___SMMUL(b << 3, ___SMMUL(y << 3, y << 2) << 2) +
___SMMUL(c << 3, out_old << 2)
<< 5,
z);
z = z >> 4;
out_old = z;
#endif
return z;
}
int32_t a = 0;
int32_t b = 0;
int32_t c = 0;
int32_t out_old = 0;
int32_t increment_a = param_a + inlet_a - a >> 4;
int32_t increment_b = param_b + inlet_b - b >> 4;
int32_t increment_c = param_c + inlet_c - c >> 4;
for (int i = 0; i < BUFSIZE; i++) {
int32_t inX = __SSAT(inlet_x[i], 28);
int32_t inY = __SSAT(inlet_y[i], 28);
outlet_z[i] =
map(param_sat ? inX : inlet_x[i], param_sat ? inY : inlet_y[i], a, b, c);
a += increment_a;
b += increment_b;
c += increment_c;
}