frac32buffer wave input
frac32 phase
bool32 reset
frac32buffer out
int32 stack
int32 smooth
frac32.u.map depth
frac32.u.map spread
frac32.s.map.kpitch rate
frac32.s.map.kpitch mod
frac32.s.map FMW
frac32.s.map drift
frac32.s.map phase
frac32.s.map phsSprd
frac32.s.map feed
bool32.mom reset
combo size
static const uint32_t LENGTHPOW = (attr_size);
static const uint32_t LENGTH = (1 << attr_size);
static const uint32_t LENGTHMASK = ((1 << attr_size) - 1);
int32_t *array;
uint32_t writepos;
uint32_t phase[32];
int i;
int32_t freq;
int64_t sine[32];
int32_t sum;
int32_t val[32];
int rtrig;
int32_t mod;
int32_t FMphase;
int32_t FMsine;
static int32_t _array[attr_poly][1 << attr_size]
__attribute__((section(".sdram")));
array = &_array[parent->polyIndex][0];
int i;
writepos = 0;
for (i = 0; i < LENGTH; i++)
array[i] = 0;
MTOFEXTENDED(param_mod, mod)
FMphase += mod >> 7;
SINE2TINTERP(FMphase, FMsine)
MTOFEXTENDED(param_rate, freq)
if (((param_reset + inlet_reset) > 0) && !rtrig) {
for (i = 0; i < param_stack; i++) {
phase[i] = 0;
}
rtrig = 1;
} else if (param_reset + inlet_reset < 1) {
rtrig = 0;
}
for (i = 0; i < param_stack; i++) {
phase[i] += ((freq + ___SMMUL(i * freq << 2, param_drift << 3) +
___SMMUL(param_FMW, FMsine)) >>
7);
SINE2TINTERP(
phase[i] +
((i * param_phsSprd / param_stack + param_phase + inlet_phase) << 4),
sine[i])
sine[i] = ((___SMMUL((sine[i] >> 1) + (1 << 30), param_depth << 4) << 1) +
(___SMMUL(((1 << 27) - param_depth), (i * param_spread)) << 4));
}
writepos = (writepos + 1) & LENGTHMASK;
array[writepos] = inlet_in + ___SMMUL(param_feed << 4, sum << 4) / param_stack;
sum = 0;
for (i = 0; i < param_stack; i++) {
val[i] = val[i] + ((sine[i] - val[i]) >> param_smooth);
sum += array[(writepos - ((val[i]) >> 32 - LENGTHPOW) & LENGTHMASK)] >> 2;
}
outlet_out = sum + inlet_in >> 2;