frac32.bipolar pitch
frac32.bipolar l0
frac32.bipolar l1
frac32.bipolar l2
frac32.bipolar l3
frac32.bipolar l4
frac32.bipolar l5
frac32.positive R0
frac32.positive R1
frac32.positive R2
frac32buffer.bipolar wave
frac32.s.map.pitch pitch
const int N = 3;
int cpt = 0;
// Saw
float p, dp;
float R[3], _R[3], _1_R[3];
float l[7];
p = 0.0f;
cpt = 0;
int32_t idp;
MTOFEXTENDED(param_pitch + inlet_pitch, idp);
dp = idp * ((3 * 0.25f) / (1 << 30));
if (N * dp > 0.5f) {
R[0] = R[1] = R[2] = 0.5f;
_1_R[0] = _1_R[1] = _1_R[2] = _R[0] = _R[1] = _R[2] = 2.0f;
} else {
R[0] = (inlet_R0) * (1.0f / (1 << 27));
R[1] = (inlet_R1) * (1.0f / (1 << 27));
R[2] = (inlet_R2) * (1.0f / (1 << 27));
for (int i = 0; i < 3; i++) {
if (R[i] < N * dp)
R[i] = N * dp;
else if (R[i] > 1 - N * dp)
R[i] = 1 - N * dp;
_R[i] = 1.0f / R[i];
_1_R[i] = 1.0f / (1 - R[i]);
}
}
l[0] = (float)inlet_l0;
l[1] = (float)inlet_l1;
l[2] = (float)inlet_l2;
l[3] = (float)inlet_l3;
l[4] = (float)inlet_l4;
l[5] = (float)inlet_l5;
l[6] = (float)inlet_l0; // for modulo
p += dp;
if (p >= 1) {
p -= 1;
cpt++;
if (cpt >= 3)
cpt = 0;
}
float pr;
int i;
if (p < R[cpt]) {
pr = p * _R[cpt];
i = cpt << 1;
} else {
pr = (p - R[cpt]) * _1_R[cpt];
i = (cpt << 1) + 1;
}
float a = pr * pr * (3 - 2 * pr);
outlet_wave = (int32_t)((l[i] + a * (l[i + 1] - l[i])));