spatialRotator

crossfade between four outputs using angle and distance controls. distance is limited to a 1:1 ratio, so high distance values turn the sine-rotation into a clipped triangle rotation, following the maximum mix-limits.
Author: Johannes Taelman
License: BSD
Github: sss/spat/spatialRotator.axo

Inlets

frac32buffer input

frac32.positive control

frac32 distance

Outlets

frac32buffer output

frac32buffer o2

frac32buffer o3

frac32buffer o4

Declaration
int32_t prev1;
int32_t step1;
int32_t prev2;
int32_t step2;
Control Rate
int32_t X;
int32_t Y;
int32_t phase = inlet_distance > 0 ? (1 << 26) : 0;
SINE2TINTERP((inlet_angle + phase) << 5, X)
SINE2TINTERP((inlet_angle + phase + (1 << 25)) << 5, Y)
X = X >> 5;
X = X + (1 << 26);
Y = Y >> 5;
Y = Y + (1 << 26);
int32_t distance = inlet_distance;
distance = distance > 0 ? distance : -distance;
X = ___SMMUL(distance << 3, X << 4);
Y = ___SMMUL(distance << 3, Y << 4);
X = __USAT(X, 27);
Y = __USAT(Y, 27);

step1 = (X - prev1) >> 4;
int32_t i1 = prev1;
prev1 = X;
step2 = (Y - prev2) >> 4;
int32_t i2 = prev2;
prev2 = Y;
Audio Rate
i1 += step1;
i2 += step2;
int32_t cX = ((1 << 27) - i1);
int32_t cY = ((1 << 27) - i2);

int32_t a1 = ___SMMUL(inlet_i1 << 3, i1 << 2);
int32_t a2 = ___SMMUL(inlet_i1 << 3, cX << 2);

int32_t a3 = ___SMMUL(a1 << 3, i2 << 2);
a3 += ___SMMUL(a2 << 3, cY << 2);

outlet_o1 = ___SMMUL(a1 << 3, i2 << 2);
outlet_o2 = ___SMMUL(a1 << 3, cY << 2);
outlet_o3 = ___SMMUL(a2 << 3, i2 << 2);
outlet_o4 = ___SMMUL(a2 << 3, cY << 2);

Privacy

© 2024 Zrna Research