frac32.bipolar pitch
frac32 fmw
frac32 rate
frac32buffer frequency
frac32buffer phase
bool32 rst
frac32buffer.bipolar sine wave
frac32.u.map phase
int32 Scnt
frac32.s.map.kpitch rate
frac32.s.map.pitch pitch
frac32.s.map.pitch hp
frac32.s.map.pitch lp
bool32.tgl dir
frac32.s.map FM
frac32.s.map feed
uint32_t Phase;
int32_t val1;
int32_t val2;
int32_t feed;
int32_t cnt;
uint32_t pv;
int dir;
int trig;
int32_t offset;
uint32_t LFO;
int rst;
Phase = 0;
dir = 1;
int32_t freq;
MTOFEXTENDED(param_pitch + inlet_pitch, freq);
if (param_dir > 0) {
freq = freq * param_Scnt;
}
int32_t F;
MTOF(param_hp, F)
int32_t G;
MTOF(param_lp + inlet_pitch, G)
int32_t rate = param_rate;
rate = rate > 0 ? rate : -rate;
rate = ___SMMUL(param_rate << 3, rate << 2);
int32_t FM = ___SMMUL(freq, param_FM + inlet_fmw << 3) << 2;
int32_t RT;
MTOFEXTENDED(param_rate + inlet_rate, RT)
LFO += RT >> 8;
if ((inlet_rst > 0) && !rst) {
rst = 1;
LFO = 0;
} else if (inlet_rst <= 0) {
rst = 0;
}
int32_t Z = (freq + inlet_freq + (___SMMUL(val2 << 2, FM << 3) << 4)) * dir;
Phase += Z;
if (Z > 0) {
if (pv > Phase) {
cnt += 1;
cnt = cnt > param_Scnt ? 0 : cnt;
if (cnt == 0) {
offset = LFO << 4;
if (param_dir == 1) {
dir = dir > 0 ? -1 : 1;
}
}
}
}
if (Z < 0) {
if (pv < Phase) {
cnt += 1;
cnt = cnt > param_Scnt ? 0 : cnt;
if (cnt == 0) {
offset = LFO << 4;
if (param_dir == 1) {
dir = dir > 0 ? -1 : 1;
}
}
}
}
else if (feed < 0) {
trig = 0;
}
int32_t r;
int32_t p2 = Phase + (inlet_phase << 4);
SINE2TINTERP(p2 + offset, r)
int32_t t;
SINE2TINTERP(p2 + (param_phase << 5), t)
r = r >> 6;
r += ___SMMUL(t >> 1, feed);
val1 = ___SMMLA((r - val1) << 1, F, val1);
val2 = ___SMMLA((r - val1 - val2) << 1, G, val2);
outlet_wave = val2;
feed = __SSAT(___SMMUL(val2, param_feed << 4) << 3, 29);
pv = Phase;