sinsaw

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

Inlets

frac32.positive brill

frac32.bipolar pitch

Outlets

frac32buffer.bipolar wave

Parameters

frac32.s.map.pitch pitch

frac32.u.map brill

Declaration
const int N = 2;
// Saw
float p, dp;
float slope, _slope_1;
Init
p = 0.0f;
Control Rate
int32_t idp;
MTOFEXTENDED(param_pitch + inlet_pitch, idp);
dp = idp * (0.25f / (1 << 30));

float coef = 1.0f + 15 - (param_brill + inlet_brill) * (15.0f / (1 << 27));
if (coef < 1)
  coef = 1;
slope = (N * dp * coef > 0.5f) ? 2.0f : 1.0f / (1.0f - N * dp * coef);
_slope_1 = 1.0f / (slope - 1.0f);
Audio Rate
p += dp;
p -= (p > 1);
float x = p * slope;
if (x > 1) { // ]1, slope] -> ]1, 0]
  x = (slope - x) * _slope_1;
}
x = 2 * x - 1;
x = 0.5f * x * (3 - x * x);
outlet_wave = (int32_t)(x * (1 << 27));

Privacy

© 2024 Zrna Research