frac32.bipolar pitch
frac32 pwm
frac32 mod
frac32 start
frac32 sync
int32 rateM
int32 rateD
int32 preset1
int32 preset2
frac32buffer.bipolar sine wave
frac32.s.map.pitch pitch
int32 harm2nd
int32 rateM
int32 rateD
int32 preset1
int32 preset2
frac32.u.map pwm
frac32.u.map mod
frac32.u.map start
bool32.tgl link
objref table
uint32_t phase;
int i;
uint32_t LFO;
int32_t rate;
float32_t A;
float32_t B;
uint32_t PM;
uint32_t Pm;
int32_t prev1;
int32_t prev2;
int32_t prev3;
float32_t prev4;
float32_t prev5;
int32_t step1;
int32_t step2;
int32_t step3;
float32_t step4;
float32_t step5;
int strig;
uint32_t count;
uint32_t timer;
phase = 0;
int32_t freq;
MTOFEXTENDED(param_pitch + inlet_pitch, freq)
PM = param_pwm + inlet_pwm;
PM = PM > 0 ? PM : -PM;
PM = PM & ((1 << 28) - 1);
PM = PM > (1 << 27) ? (2 << 27) - PM : PM;
PM = __USAT(PM + 1, 27) << 4;
A = ((float32_t)(1 << 31)) / ((float32_t)(PM << 1));
B = ((float32_t)(1 << 31)) / ((float32_t)(((1 << 31) - PM) << 1));
PM = PM << 1;
int32_t mod1 = param_mod + inlet_mod;
mod1 = mod1 > 0 ? mod1 : -mod1;
mod1 = mod1 & ((1 << 28) - 1);
mod1 = mod1 > (1 << 27) ? (2 << 27) - mod1 : mod1;
mod1 = mod1 << 4;
int32_t mod2;
mod2 = mod1 * 3;
int32_t Start = param_start + inlet_start;
Start = Start > 0 ? Start : -Start;
Start = Start & ((1 << 28) - 1);
Start = Start > (1 << 27) ? (2 << 27) - Start : Start;
step1 = ((((int32_t)(PM)) + (1 << 31)) - prev1) >> 4;
int32_t i1 = prev1;
prev1 = ((int32_t)(PM)) + (1 << 31);
step2 = (mod1 - prev2) >> 4;
int32_t i2 = prev2;
prev2 = mod1;
step3 = (Start - prev3) >> 4;
int32_t i3 = prev3;
prev3 = Start;
step4 = (A - prev4) / (float32_t)16;
float32_t i4 = prev4;
prev4 = A;
step5 = (B - prev5) / (float32_t)16;
float32_t i5 = prev5;
prev5 = B;
int rateM = param_rateM + inlet_rateM;
int rateD = param_rateD + inlet_rateD;
int preset1 = param_preset1 + inlet_preset1;
int preset2 = param_preset2 + inlet_preset2 + preset1 * param_link;
preset2 = preset2 - (preset2 / attr_table.presets) * attr_table.presets;
preset2 = preset2 < 0 ? preset2 + attr_table.presets : preset2;
preset2 = preset2 * attr_table.LENGTH;
preset1 = preset1 - (preset1 / attr_table.presets) * attr_table.presets;
preset1 = preset1 < 0 ? preset1 + attr_table.presets : preset1;
preset1 = preset1 * attr_table.LENGTH;
if ((inlet_sync > 0) && !strig) {
timer = ((1 << 31) / count) << 1;
count = 0;
strig = 1;
} else if (inlet_sync <= 0) {
strig = 0;
}
count += 1;
uint32_t Phase;
phase += freq;
LFO += timer * rateM / rateD;
uint32_t PHase = phase;
if (phase < (1 << 31)) {
PHase = ___SMMUL(phase, i3 << 4) << 2;
} else {
PHase = (___SMMUL(phase, ((1 << 27) - i3) << 4) << 2);
}
if (PHase < Pm) {
Phase = (1 << 31) + ((int32_t)(PHase * i4)) + i2;
}
if (PHase >= Pm) {
Phase = ((uint32_t)((PHase - Pm) * i5 - (1 << 31))) + i2 + (1 << 31);
}
outlet_wave =
attr_table
.array[((Phase >> 32 - attr_table.LENGTHPOW) & attr_table.LENGTHMASK) +
preset1];
outlet_wave +=
attr_table
.array[((((Phase * param_harm2nd) + LFO) >> 32 - attr_table.LENGTHPOW) &
attr_table.LENGTHMASK) +
preset2] /
(1 + (param_harm2nd - 1) / 2);
i1 += step1;
i2 += step2;
i3 += step3;
i4 += step4;
i5 += step5;
Pm = (uint32_t)(i1) + (1 << 31);