frac32 trgCl
frac32 trgOp
frac32 negDec
frac32buffer.bipolar white noise
frac32 hp
frac32.s.map tfm
frac32.u.map chance
frac32.u.map.kdecaytime decCl
frac32.u.map.kdecaytime decOp
frac32.s.map.pitch pitch
frac32.s.map.pitch tune
bool trg;
int32_t phase;
int32_t Phase;
int32_t hp;
int32_t lp;
int32_t en;
int32_t freq;
int32_t vol;
int32_t tune;
int32_t chance;
int32_t Vdec;
trg = 0;
int32_t pitch;
MTOFEXTENDED(param_pitch, pitch)
int trig = inlet_trgCl || inlet_trgOp;
if ((trig > 0) && !trg) {
trg = 1;
en = (1 << 27);
if (inlet_trgCl) {
MTOF(-param_decCl + ___SMMUL(inlet_negDec << 2, param_decCl << 2), Vdec)
vol = tune = inlet_trgCl;
chance = __SSAT(param_chance - (inlet_trgCl >> 2), 28);
chance = ___SMMUL(chance << 3, chance << 2);
}
if (inlet_trgOp) {
MTOF(-param_decOp + ___SMMUL(inlet_negDec << 2, param_decOp << 2), Vdec)
vol = tune = inlet_trgOp;
chance = __SSAT(param_chance - (inlet_trgOp >> 2), 28);
chance = ___SMMUL(chance << 3, chance << 2);
}
} else if (trig == 0) {
trg = 0;
}
en -= ___SMMUL(en, Vdec);
int32_t En;
// En=(1<<27)-en;
// En=(1<<27)-___SMMUL(En<<3,En<<2);
En = en;
En = ___SMMUL(En << 3, En << 2);
En = ___SMMUL(En << 3, En << 2);
En = ___SMMUL(En << 3, En << 2);
outlet_hp = En;
En = ___SMMUL(En << 3, vol << 2);
MTOF(param_tune + tune + ___SMMUL(param_tfm << 3, En << 2), freq)
Phase += pitch;
int32_t sine;
sine = Phase > 0 ? (1 << 30) : -(1 << 30);
int i;
for (i = 0; i < 3; i++) {
if ((int32_t)(GenerateRandomNumber() >> 4) < chance) {
phase = phase > 0 ? -(1 << 28) : (1 << 28);
}
lp = ___SMMLA((phase - lp) << 1, freq, lp);
hp = ___SMMLA((lp - hp) << 1, freq, hp);
}
int32_t o = lp - hp;
o = ___SMMUL(sine, o);
o = o > En ? En : o;
o = o < -En ? -En : o;
outlet_digital = o;