saw80

CS80ish sawtooth with its distinctive glitch
Author: Smashed Transistors
License: LGPL
Github: tiar/osc/saw80.axo

Inlets

frac32.bipolar pitch

frac32.bipolar HP

Outlets

frac32buffer.bipolar out

Parameters

frac32.s.map.pitch pitch

frac32.s.map HP

frac32.u.map pulse

Declaration
float x0, x1, x2, x3, x4, x5, x6, x7, acc;
float p, dp, _dp;
Init
x0 = x1 = x2 = x3 = x4 = x5 = x6 = x7 = acc = 0;
p = 0.5f;
dp = 0.5f;
_dp = 2.0f;
Control Rate
int32_t idp;

MTOFEXTENDED(param_pitch + inlet_pitch, idp);
dp = arm::q_to_float(idp, 32);
if (dp > 0.5f)
  dp = 0.5f;
// MTOFEXTENDED(-param_pitch - inlet_pitch, idp);
//_dp = 21200.387f * arm::q_to_float(idp,32);
_dp = 1.0f / dp;
int32_t f;
MTOFEXTENDED(param_HP + inlet_HP - (24 << 21), f);
float coefHP = 1 - arm::q_to_float(f, 32);

float pulse = arm::q_to_float(param_pulse, 27);
if (dp > 4000.0f / 48000.0f) {
  if (dp > 8000.0f / 48000.0f)
    pulse = 0;
  else
    pulse *= 1 - (dp - 4000.0f / 48000.0f) * (1 / (4000.0f / 48000.0f));
}
Audio Rate
p += dp;
if (p >= 1) {
  p -= 1;
  int a = ((int)(64 * p * _dp));
  if (a <= 31) {
    a *= 8;
    x7 += tiar_bli153_8_32[a];
    a++;
    x6 += tiar_bli153_8_32[a];
    a++;
    x5 += tiar_bli153_8_32[a];
    a++;
    x4 += tiar_bli153_8_32[a];
    a++;
    x3 += tiar_bli153_8_32[a];
    a++;
    x2 += tiar_bli153_8_32[a];
    a++;
    x1 += tiar_bli153_8_32[a];
    a++;
    x0 = tiar_bli153_8_32[a];
  } else {
    a = (64 - a) * 8 - 1;
    x7 += tiar_bli153_8_32[a];
    a--;
    x6 += tiar_bli153_8_32[a];
    a--;
    x5 += tiar_bli153_8_32[a];
    a--;
    x4 += tiar_bli153_8_32[a];
    a--;
    x3 += tiar_bli153_8_32[a];
    a--;
    x2 += tiar_bli153_8_32[a];
    a--;
    x1 += tiar_bli153_8_32[a];
    a--;
    x0 = tiar_bli153_8_32[a];
  }
} else {
  x0 = 0;
}
acc += dp - x7;
acc *= coefHP;
outlet_out = arm::float_to_q(acc - pulse * x7, 27);

x7 = x6;
x6 = x5;
x5 = x4;
x4 = x3;
x3 = x2;
x2 = x1;
x1 = x0;

Privacy

© 2024 Zrna Research