multiPM

(First order differentiated polynomial).
Author: Smashed Transistors
License: LGPL
Github: tiar/osc/multiPM.axo

Inlets

frac32.bipolar pitch

frac32buffer.bipolar mod

Outlets

frac32buffer.bipolar saw

frac32buffer.bipolar sqr

frac32buffer.bipolar tri

frac32buffer.bipolar sin

Parameters

frac32.u.map mod

frac32.s.map.pitch pitch

Declaration
float p, dp;
float x0 = 0, x1;
float y0Saw, y1Saw;
float y0Sqr, y1Sqr;
float y0Tri, y1Tri;
float y0Sin, y1Sin;
Init
p = 32;
x0 = 0;
y0Saw = 0;
y0Sqr = 0;
y0Tri = 0;
y0Sin = 0;
Control Rate
int32_t idp;
MTOFEXTENDED(param_pitch + inlet_pitch, idp);
dp = idp * (0.25f / (1 << 30));
Audio Rate
p += dp;
if (p > 33) {
  p -= 1;
  x0 -= 1;
}
x1 = x0;
y1Saw = y0Saw;
y1Sqr = y0Sqr;
y1Tri = y0Tri;
y1Sin = y0Sin;
float pm = p + arm::q_to_float(___SMMUL(inlet_mod, param_mod), 27 - 6);
x0 = pm;
pm -= (int32_t)pm;
float saw = pm * 2 - 1;
y0Saw = saw * saw;
float sqr = saw > 0 ? 1.0f : -1.0f;
y0Sqr = 2 * fabsf(saw) - 1;        // tri
y0Tri = y0Sqr * y0Sqr * sqr - sqr; // sine
float xs = pm <= 0.5f ? pm : 1.0f - pm;
y0Sin = xs * xs * (4 - (16 / 3.0f) * xs);
float x1_x0 = x1 - x0;
if (fabsf(x1_x0) > 0.0001f) {
  float _x1_x0 = 1.0f / x1_x0;
  outlet_saw = arm::float_to_q((y1Saw - y0Saw) * _x1_x0, 27 - 2);
  outlet_sqr = arm::float_to_q((y1Sqr - y0Sqr) * _x1_x0, 27 - 2);
  outlet_tri = arm::float_to_q((y1Tri - y0Tri) * _x1_x0, 27 - 3);
  outlet_sin = arm::float_to_q((y1Sin - y0Sin) * _x1_x0, 27);
} else {
  outlet_saw = arm::float_to_q(saw, 27);
  outlet_sqr = arm::float_to_q(sqr, 27);
  outlet_tri = arm::float_to_q(y0Sqr, 27);
  outlet_sin = arm::float_to_q(y0Tri, 27);
}

Privacy

© 2024 Zrna Research