2to2

Mode 1: Divides the incoming signal (inlet-in) up in portions (inlet-mod) and adds these to A and B outputs one by one (A>B>A>B>A>B>etc). Summed, these will give back the original signal. Mode 2: panning inlet-in using inled-mod Mode 3: mid(A)/side(B) signal Mode 4: max(A)/min(B) signal
Author: Remco van der Most
License: BSD
Github: sss/math/2to2.axo

Inlets

frac32 in

frac32 mod

frac32 switch

Outlets

frac32 A

frac32 B

Parameters

bool32.tgl switch

frac32.u.map mod

int32.hradio mode

Declaration
int32_t v27 = 1 << 27;
int32_t A;
int32_t B;

int32_t DIV(int32_t in, int32_t quant) {
  quant = (quant < 0 ? -quant : quant) + 2;
  int32_t hq = quant >> 1;
  int32_t dest = (in / quant);
  dest += in < 0 ? -1 : 0;
  int32_t left = in - dest * quant;
  A = (left > hq ? hq : left) + dest * hq;
  B = (left < hq ? 0 : left - hq) + dest * hq;
};

int32_t PAN(int32_t in, int32_t pan) {
  int32_t PN = __SSAT(pan, 28) + v27 << 2;
  B = ___SMMUL(in << 2, PN);
  A = in - B;
};

int32_t SD(int32_t in, int32_t S) {
  A = in + S >> 1;
  B = in - S >> 1;
}
int32_t MM(int32_t in, int32_t S) {
  A = in > S ? in : S;
  B = in > S ? S : in;
}
Control Rate
int32_t mod = mod + inlet_mod;
switch (param_mode) {
case 0:
  DIV(inlet_in, mod);
  break;
case 1:
  PAN(inlet_in, mod);
  break;
case 2:
  SD(inlet_in, mod);
  break;
case 3:
  MM(inlet_in, mod);
  break;
}
if ((param_switch > 0) || (inlet_switch > 0)) {
  outlet_A = B;
  outlet_B = A;
} else {
  outlet_A = A;
  outlet_B = B;
}

Privacy

© 2024 Zrna Research