EPTRSaw

Low CPU Anti Aliased Sawtooth using second order EPTR algoroithm (one correction point).
Author: Smashed Transistors, Ricard Wanderlof
License: LGPL
Github: ricard/osc/EPTRSaw.axo

Inlets

frac32.bipolar pitch

Outlets

frac32buffer.bipolar sawtooth wave

Parameters

frac32.s.map.pitch pitch

Declaration
float p, dp, y;
// Sawtooth EPTR polynomial
float corr(float p, float dp) { return p - p / dp + 1 / dp - 1; }
Init
p = 0;
Control Rate
int32_t idp;
MTOFEXTENDED(param_pitch + inlet_pitch, idp);
dp = idp * (0.25f / (1 << 30));
Audio Rate
p += 2 * dp;
if (p > 1 - dp) {
  y = corr(p, dp);
  p -= 2; // wrap phase
} else {
  y = p;
}
outlet_saw = (int32_t)(y * (1 << 27));

Privacy

© 2024 Zrna Research