int32 hold
int32 mode
frac32 trig
frac32 Vdec
frac32 Pdec
frac32 Ndec
frac32 pitch
frac32 Pamt
frac32 FM
frac32 E2C
frac32 sineLvl
frac32 noiseLvl
frac32 cut
frac32 reso
frac32 gain
frac32 LP
frac32 seed
frac32buffer out
frac32 Penv
frac32 Venv
frac32.s.map FM
frac32.s.map seed
frac32.s.map E2C
frac32.u.map sineLvl
frac32.u.map noiseLvl
frac32.u.map gain
frac32.u.map.filterq reso
int32.hradio mode
int32 hold
frac32.u.map.kdecaytime Vdec
frac32.u.map.kdecaytime Pdec
frac32.u.map.kdecaytime Ndec
frac32.s.map.pitch pitch
frac32.s.map.pitch Pamt
frac32.s.map.pitch cut
frac32.s.map.pitch LP
uint32_t phase;
int32_t sine;
int32_t v27 = 1 << 27;
uint32_t Penv;
uint32_t Venv;
uint32_t Nenv;
int gtrig;
int Gtrig;
int32_t noise;
int32_t val;
int32_t hp;
int32_t count;
int32_t low;
int32_t band;
int32_t mix;
int i;
int32_t wave;
int32_t PV;
int32_t PP;
int32_t PN;
uint32_t seeds[16];
low = 0;
band = 0;
seeds[8] = 0x21c32332; // + GenerateRandomNumber();
seeds[9] = 0xfbc57f7a; // + GenerateRandomNumber();
seeds[10] = 0x7dd1ef4a; // + GenerateRandomNumber();
seeds[11] = 0xe4ec34ad; // + GenerateRandomNumber();
seeds[12] = 0x72007b2f; // + GenerateRandomNumber();
seeds[13] = 0x3d1e9783; // + GenerateRandomNumber();
seeds[14] = 0xa4a8f892; // + GenerateRandomNumber();
seeds[15] = 0xc82c5e28; // + GenerateRandomNumber();
seeds[0] = seeds[8];
seeds[1] = seeds[9];
seeds[2] = seeds[10];
seeds[3] = seeds[11];
seeds[4] = seeds[12];
seeds[5] = seeds[13];
seeds[6] = seeds[14];
seeds[7] = seeds[15];
uint32_t F1;
MTOF(-param_Pdec - inlet_Pdec, F1)
uint32_t F2;
MTOF(-param_Vdec - inlet_Vdec << 1, F2)
F2 = F2 >> 1;
uint32_t F3;
MTOF(-(param_Ndec - inlet_Ndec << 1) + (1 << 26), F3)
int32_t Seed = param_seed + inlet_seed;
if (count >= param_hold) {
Penv = ___SMMLA(-Penv, F1 << 1, Penv);
Venv = ___SMMLA(-Venv, F2 << 1, Venv);
Nenv = ___SMMLA(-Nenv, F3 << 1, Nenv);
}
if ((inlet_trig > 0) && !gtrig) {
seeds[0] = seeds[8] + Seed;
seeds[1] = seeds[9] + Seed;
seeds[2] = seeds[10] + Seed;
seeds[3] = seeds[11] + Seed;
seeds[4] = seeds[12] + Seed;
seeds[5] = seeds[13] + Seed;
seeds[6] = seeds[14] + Seed;
seeds[7] = seeds[15] + Seed;
gtrig = 1;
Penv = (1 << 27);
Venv = inlet_trig;
Nenv = (1 << 27);
count = 0;
phase = 0;
} else if (inlet_trig == 0) {
gtrig = 0;
}
int hold = param_hold + inlet_hold;
count += 1;
count = count > hold ? hold : count;
int32_t PENV = Penv;
PENV = ___SMMUL(PENV << 3, PENV << 2);
int32_t VENV = Venv;
VENV = ___SMMUL(VENV << 3, VENV << 2);
VENV += ___SMMUL(__USAT(param_gain + inlet_gain, 27) << 2, VENV << 3) * 3;
int32_t NENV = ___SMMUL(Nenv << 3, Nenv << 2);
NENV = ___SMMUL(NENV << 3, NENV << 2);
NENV = ___SMMUL(NENV << 3, (__USAT(param_noiseLvl + inlet_noiseLvl, 27)) << 2);
int32_t freq;
MTOFEXTENDED(
param_pitch + inlet_pitch +
___SMMUL(__SSAT(param_Pamt + inlet_Pamt - param_pitch - inlet_pitch, 28)
<< 3,
PENV << 2),
freq)
freq = freq;
int32_t damp = (0x80 << 24) - (__USAT(param_reso + inlet_reso, 27) << 4);
damp = ___SMMUL(damp, damp);
int32_t alpha;
int32_t fraq;
MTOFEXTENDED(__SSAT(param_cut + inlet_cut +
___SMMUL(__SSAT(param_E2C + inlet_E2C, 28) << 3,
NENV << 2),
28),
alpha);
SINE2TINTERP(alpha, fraq);
int32_t sineLvl = __USAT(param_sineLvl + inlet_sineLvl, 27);
int32_t cut;
cut = param_LP + ___SMMUL(__SSAT(param_E2C + inlet_E2C, 28) << 3, VENV << 2);
// preset=(param_wave+inlet_waveform);
// preset=preset-preset/attr_table.Waveforms*attr_table.Waveforms;
// preset=preset<<attr_table.LENGTHPOW;
outlet_Penv = PENV;
outlet_Venv = __USAT(VENV, 27);
int32_t Noise = (1 << 28) - (__SSAT(param_cut + inlet_cut, 28) + (1 << 27));
int32_t FM = ___SMMUL(freq << 1, param_FM + inlet_FM << 3);
int32_t Vstp = (VENV - PV) >> 4;
int32_t Pstp = (PENV - PP) >> 4;
int32_t Nstp = (NENV - PN) >> 4;
int32_t IV = PV;
int32_t IP = PP;
int32_t IN = PN;
PV = VENV;
PP = PENV;
PN = NENV;
IV += Vstp;
IP += Pstp;
IN += Nstp;
int i;
int32_t n = 0;
for (i = 0; i < 8; i++) {
seeds[i] = (seeds[i] * 196314165) + 907633515;
n += ((int32_t)(seeds[i])) >> 7;
}
noise = n;
int32_t notch = (noise) - (___SMMUL(damp, band) << 1);
low = low + (___SMMUL(fraq, band) << 1);
int32_t high = notch - low;
band = (___SMMUL(fraq, high) << 1) + band;
int32_t out;
switch ((param_mode + inlet_mode) & 3) {
case 0:
out = low;
break;
case 1:
out = high;
break;
case 2:
out = band;
break;
case 3:
out = notch;
break;
}
noise = out << 4;
int32_t tmp = val;
int32_t over = v27 - (tmp > 0 ? tmp : -tmp);
if (param_FM < 0) {
tmp = tmp > 0 ? over : -tmp;
} else {
tmp = tmp > 0 ? -tmp : tmp;
}
hp += tmp - hp >> 9;
phase += freq + ___SMMUL(NENV, out >> 2) + (___SMMUL(FM, tmp - hp) << 8);
SINE2TINTERP(phase, sine)
wave =
__SSAT(___SMMUL(
___SMMUL(sine, sineLvl) +
__SSAT((___SMMUL((noise >> 2) +
(___SMMUL(noise, Noise << 3) << 3),
IN << 2)),
28)
<< 2,
IV << 1)
<< 2,
28)
<< 1;
int32_t Cut;
MTOF(cut - ((wave > 0 ? wave : -wave) << 2), Cut)
val = ___SMMLA((wave - val) << 1, Cut, val);
outlet_out = val;