DP2Pulsaw

Low CPU Anti Aliased Sawtooth Pulse (Second order differentiated polynomial).
Author: Smashed Transistors
License: LGPL
Github: tiar/osc/DP2Pulsaw.axo

Inlets

frac32.bipolar pitch

Outlets

frac32buffer.bipolar selfPM wave

Parameters

frac32.s.map.pitch pitch

Declaration
float p, dp, _dp2, y0, y1, y2;
const float r = 1 / 7.0f;
const float a = -1.0f / (6 * r);
const float b = 0.5f * (1 - 0.5f * r);
const float c = (r / 6 - 0.25f) * r;
const float d = -0.25f * r;
const float e = (r / 6 + 0.25f) * r;
const float f = -r * r / 6;
float I2(float p) {
  if (p < r)
    return p * (c + p * (b + p * a));
  else
    return f + p * (e + p * d);
}
Init
p = y0 = y1 = y2 = 0.0f;
Control Rate
int32_t idp;
MTOFEXTENDED(param_pitch + inlet_pitch, idp);
dp = idp * (0.25f / (1 << 30));
_dp2 = (1 << 27) / (dp * dp);
// change of dp => update state variables y1 y2
p -= dp;
p += (p < 0);
y2 = I2(p);
p += dp;
p -= (p > 1);
y1 = I2(p);
Audio Rate
p += dp;
p -= (p > 1);
y0 = I2(p);
outlet_wave = (int32_t)((y0 + y2 - 2 * y1) * _dp2);
y2 = y1;
y1 = y0;

Privacy

© 2024 Zrna Research