frac32 trigClosed
frac32 trigOpen
frac32 pitch
frac32 negDec
frac32buffer out
frac32 o1
frac32.u.map.kdecaytime hitC
frac32.u.map.kdecaytime hitO
frac32.u.map.kdecaytime tailC
frac32.u.map.kdecaytime tailO
frac32.s.map Pamt
frac32.s.map fA
frac32.s.map fB
frac32.u.map AmixB
frac32.u.map FM
frac32.s.map.pitch cut
frac32.u.map.filterq reso
uint32_t P[2];
int32_t R[2];
int32_t S[2];
int32_t V[2];
int32_t C[2];
int32_t N[2];
bool trig;
int32_t env;
int32_t Env;
int i;
int32_t low[2];
int32_t band[2];
int32_t freq[2];
int32_t Vdec;
int32_t Pdec;
env = env - ___SMMUL(Vdec, env);
Env = Env - ___SMMUL(Pdec, Env);
if (((inlet_trigOpen + inlet_trigClosed) > 0) && !trig) {
trig = 1;
if (inlet_trigOpen > 0) {
env = (__USAT(inlet_trigOpen, 27));
Env = (__USAT(inlet_trigOpen, 27));
MTOF(-(param_hitO << 1) + ___SMMUL(inlet_negDec << 2, param_hitO << 2) +
(1 << 27),
Pdec)
MTOF(-(param_tailO << 1) + ___SMMUL(inlet_negDec << 2, param_tailO << 2) +
(1 << 27),
Vdec)
}
if (inlet_trigClosed > 0) {
MTOF(-(__SSAT((param_hitC << 1) -
___SMMUL(inlet_negDec << 2, param_hitC << 2),
28)) +
(1 << 27),
Pdec)
MTOF(-(__SSAT((param_tailC << 1) -
___SMMUL(inlet_negDec << 2, param_tailC << 2),
28)) +
(1 << 27),
Vdec)
env = (__USAT(inlet_trigClosed, 27));
Env = (__USAT(inlet_trigClosed, 27));
}
} else if ((inlet_trigOpen + inlet_trigClosed) == 0) {
trig = 0;
}
int32_t Venv = env;
int32_t Penv = Env > (1 << 26) ? (1 << 27) : 0;
Venv = ___SMMUL(Venv << 3, Venv << 2);
outlet_o1 = Env;
Venv = Penv > Venv ? Penv : Venv >> 1;
// Venv=___SMMUL(Venv<<3,Venv<<2);
// Venv=___SMMUL(Venv<<3,Venv<<2);
// Venv=___SMMUL(Venv<<3,Venv<<2);
int32_t p1 = (param_fA + inlet_pitch >> 2) + (1 << 26);
int32_t p2 = (param_fB >> 2);
int32_t Pamt = (param_Pamt >> 2) + (1 << 26);
MTOFEXTENDED(p1 + (Penv > 0 ? Pamt - p1 : 0), R[0])
MTOFEXTENDED(p1 + p2 + (Penv > 0 ? Pamt - p1 - p2 : 0), R[1])
MTOF(p1 + param_cut + (Penv >> 1) - (1 << 32), C[0])
MTOF(p1 + p2 + param_cut + (Penv >> 1) - (1 << 32), C[1])
int32_t mix = __USAT(param_AmixB + Vdec, 27);
int32_t cmix = (1 << 27) - mix;
int32_t damp = (0x80 << 24) - (param_reso << 4);
damp = ___SMMUL(damp, damp);
int32_t alpha;
MTOFEXTENDED(__SSAT(p1 + param_cut + (Penv >> 1) - (1 << 32), 28), alpha);
SINE2TINTERP(alpha, freq[0]);
MTOFEXTENDED(__SSAT(p1 + p2 + param_cut + (Penv >> 1) - (1 << 32), 28), alpha);
SINE2TINTERP(alpha, freq[1]);
int32_t noise = (int32_t)(GenerateRandomNumber)();
if (noise > 0) {
N[0] += noise - (1 << 31);
} else {
N[1] += noise + (1 << 31);
}
for (i = 0; i < 2; i++) {
int32_t notch = N[i] - (___SMMUL(damp, band[i]) << 1);
low[i] = low[i] + (___SMMUL(freq[i], band[i]) << 1);
int32_t high = notch - low[i];
band[i] = (___SMMUL(freq[i], high) << 1) + band[i];
P[i] += R[i];
V[i] = ___SMMLA(((S[i] >> 4) - V[i]) << 1, C[i], V[i]);
S[i] = P[i] +
(___SMMUL(___SMMUL(___SMMUL(param_FM << 3, (1 << 27) - Venv << 2) << 1,
high << 2)
<< 4,
V[(i + 1) & 1] - S[i] << 2)
<< 3);
S[i] = S[i] > 0 ? (1 << 27) : (-1 << 27);
}
outlet_out =
___SMMUL(___SMMUL(cmix, S[0]) + ___SMMUL(mix << 3, S[1]) << 2, Venv << 3);