DP2Saw

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

Inlets

frac32.bipolar pitch

Outlets

frac32buffer.bipolar selfPM wave

Parameters

frac32.s.map.pitch pitch

Declaration
float p, dp, _dp2, y0, y1, y2;
float I2(float p) { return p * (1 / 6.0f + p * (-0.5f + p * (1 / 3.0f))); }
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