6coseg

Author: Smashed Transistors
License: LGPL
Github: tiar/osc/6coseg.axo

Inlets

frac32.bipolar pitch

Outlets

frac32buffer.bipolar wave

Parameters

frac32.s.map.pitch pitch

frac32.u.map.ratio R0

frac32.u.map.ratio R1

frac32.u.map.ratio R2

frac32.s.map l0

frac32.s.map l1

frac32.s.map l2

frac32.s.map l3

frac32.s.map l4

frac32.s.map l5

Declaration
const int N = 3;
int cpt;
// Saw
float p, dp;
float R[3], _R[3], _1_R[3];
float l[7];
Init
p = 0.0f;
cpt = 0;
Control Rate
int32_t idp;
MTOFEXTENDED(param_pitch + inlet_pitch, idp);
dp = idp * ((3 * 0.25f) / (1 << 30));

if (N * dp > 0.5f) {
  R[0] = R[1] = R[2] = 0.5f;
  _1_R[0] = _1_R[1] = _1_R[2] = _R[0] = _R[1] = _R[2] = 2.0f;
} else {
  R[0] = (param_R0) * (1.0f / (1 << 27));
  R[1] = (param_R1) * (1.0f / (1 << 27));
  R[2] = (param_R2) * (1.0f / (1 << 27));
  for (int i = 0; i < 3; i++) {
    if (R[i] < N * dp)
      R[i] = N * dp;
    else if (R[i] > 1 - N * dp)
      R[i] = 1 - N * dp;
    _R[i] = 1.0f / R[i];
    _1_R[i] = 1.0f / (1 - R[i]);
  }
}
l[0] = (float)param_l0;
l[1] = (float)param_l1;
l[2] = (float)param_l2;
l[3] = (float)param_l3;
l[4] = (float)param_l4;
l[5] = (float)param_l5;
l[6] = (float)param_l0; // for modulo
Audio Rate
p += dp;
if (p >= 1) {
  p -= 1;
  cpt++;
  if (cpt >= 3)
    cpt = 0;
}
float pr;
int i;
if (p < R[cpt]) {
  pr = p * _R[cpt];
  i = cpt << 1;
} else {
  pr = (p - R[cpt]) * _1_R[cpt];
  i = (cpt << 1) + 1;
}

float a = pr * pr * (3 - 2 * pr);
outlet_wave = (int32_t)((l[i] + a * (l[i + 1] - l[i])));

Privacy

© 2024 Zrna Research