rotationMix

crossfade between four inputs 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: Remco van der Most
License: BSD
Github: sss/mix/rotationMix.axo

Inlets

frac32buffer input

frac32buffer input

frac32buffer i3

frac32buffer i4

frac32.positive control

frac32 distance

Outlets

frac32buffer output

Declaration
int32_t prev1;
int32_t step1;
int32_t prev2;
int32_t step2;
int32_t prev3;
int32_t step3;
int32_t prev4;
int32_t step4;
int32_t SQRT(int32_t in) {
  int32_t ai = in > 0 ? in : -in;
  float aif = ai;
  aif *= (1 << 27);
  aif = _VSQRTF(aif);
  return (int)aif;
}
Control Rate
int32_t X;
int32_t Y;
int32_t phase = inlet_distance > 0 ? (1 << 26) : 0;
SINE2TINTERP((inlet_angle + phase - (1 << 25)) << 5, X)
SINE2TINTERP((inlet_angle + phase) << 5, Y)
// X=X>>5;

// Y=Y>>5;

int32_t distance = inlet_distance;
distance = distance > 0 ? distance : -distance;
X = __SSAT(___SMMUL(distance << 3, X), 27);
Y = __SSAT(___SMMUL(distance << 3, Y), 27);
int32_t x = -X + (1 << 26);
int32_t y = -Y + (1 << 26);

X = X + (1 << 26);

Y = Y + (1 << 26);

// X=X+(1<<26);
// Y=Y+(1<<26);
// x=SQRT(x)<<2;
// y=SQRT(y)<<2;
// X=SQRT(X)<<2;
// Y=SQRT(Y)<<2;
x = x << 2;
y = y << 2;
X = X << 2;
Y = Y << 2;
step1 = (X - prev1) >> 4;
int32_t i1 = prev1;
prev1 = X;
step2 = (Y - prev2) >> 4;
int32_t i2 = prev2;
prev2 = Y;
step3 = (x - prev3) >> 4;
int32_t i3 = prev3;
prev3 = x;
step4 = (y - prev4) >> 4;
int32_t i4 = prev4;
prev4 = y;
Audio Rate
i1 += step1;
i2 += step2;
i3 += step3;
i4 += step4;
// int32_t cX = ((1<<27)-i1);
// int32_t cY = ((1<<27)-i2);

int32_t a1 = ___SMMUL(inlet_i2 << 3, i1);
a1 += ___SMMUL(inlet_i1 << 3, i3);

int32_t a2 = ___SMMUL(inlet_i4 << 3, i1);
a2 += ___SMMUL(inlet_i3 << 3, i3);

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

outlet_o = a3;

Privacy

© 2024 Zrna Research