frac32buffer sync
frac32 pitch
frac32 mix1
frac32 mix2
frac32 sinemix
int32 step
frac32buffer out
int32 divide1
int32 divide2
int32 waveform
int32 quant1
int32 start1
int32 step1
int32 quant2
int32 start2
int32 step2
frac32.u.map mix1
frac32.u.map mix2
frac32.s.map.pitch pitch
frac32.s.map FMW
frac32.s.map sinemix
objref table
int32_t i;
int strig;
uint32_t phase;
int trig;
int32_t MIX1a;
int32_t MIX1b;
int32_t MIX2a;
int32_t MIX2b;
int32_t smooth1;
int32_t smooth2;
uint32_t W[4];
uint32_t w[4];
int32_t F;
int32_t mix[2];
int32_t MX(int32_t T) {
T = T > 0 ? T : -T;
T = T & ((1 << 28) - 1);
F = T > (1 << 27) ? (1 << 28) - T : T;
}
int32_t tablemix(int32_t inst, int32_t WaveA, int32_t WaveB, int32_t Mix) {
mix[inst] = ___SMMUL(((1 << 27) - Mix) << 3, WaveA << 2) +
___SMMUL(Mix << 3, WaveB << 2);
}
int32_t M1step;
int32_t M1prv;
int32_t M2step;
int32_t M2prv;
int32_t val;
int32_t prev;
prev = 0;
int32_t freq;
MTOFEXTENDED(param_pitch + inlet_pitch, freq)
int32_t FMW = ___SMMUL(freq << 5, param_FMW << 3);
int32_t MiX1 = param_mix1 + inlet_mix1;
MX(MiX1);
MiX1 = F;
int32_t MiX2 = param_mix2 + inlet_mix2;
MX(MiX2);
MiX2 = F;
smooth1 += (MiX1 - smooth1) >> 4;
MiX1 = smooth1;
smooth2 += (MiX2 - smooth2) >> 4;
MiX2 = smooth2;
M1step = (MiX1 - M1prv) >> 4;
int32_t MIX1b = M1prv;
M1prv = MiX1;
M2step = (MiX2 - M2prv) >> 4;
int32_t MIX2b = M2prv;
M2prv = MiX2;
outlet_divide1 = param_quant1;
outlet_divide2 = param_quant2;
int32_t step1 = inlet_step + param_step1;
int32_t step2 = inlet_step + param_step2;
int32_t SiNe = __USAT(inlet_sinemix + param_sinemix, 27);
int32_t step = SiNe - prev >> 4;
int32_t SINE = prev;
prev = SiNe;
float32_t ratio = (float32_t)(attr_table.maxLvl) / 64;
SINE += step;
if ((inlet_sync > 0) && !strig) {
strig = 1;
phase = 0;
} else if (inlet_sync < 0) {
strig = 0;
}
MIX1b += M1step;
MIX1a = MIX1b;
MIX2b += M2step;
MIX2a = MIX2b;
W[0] = ((MIX1a >> 4) * param_quant1) >> 23;
MIX1a = (MIX1a - (W[0] << 27) / param_quant1) * param_quant1;
// W[0]+=param_start1;
W[0] = W[0] * step1 + param_start1 + param_waveform;
W[1] = W[0] + step1;
W[2] = ((MIX2a >> 4) * param_quant2) >> 23;
MIX2a = (MIX2a - (W[2] << 27) / param_quant2) * param_quant2;
// W[2]+=param_start2;
W[2] = W[2] * step2 + param_start2 + param_waveform;
W[3] = W[2] + step2;
for (i = 0; i < 4; i++) {
W[i] = (W[i] - (W[i] / attr_table.Waveforms) * attr_table.Waveforms);
W[i] = W[i] < 0 ? W[i] + attr_table.Waveforms : W[i];
}
w[0] = W[0] + W[2];
w[1] = W[1] + W[2];
w[2] = W[0] + W[3];
w[3] = W[1] + W[3];
for (i = 0; i < 4; i++) {
w[i] = (w[i] - (w[i] / attr_table.Waveforms) * attr_table.Waveforms);
w[i] = w[i] < 0 ? w[i] + attr_table.Waveforms : w[i];
w[i] = w[i] * attr_table.LENGTH;
}
phase += freq + ___SMMUL(FMW << 3, mix[0] - val << 2);
uint32_t p1 = (phase >> 32 - attr_table.LENGTHPOW);
uint32_t Mit = ((phase << attr_table.LENGTHPOW) >> 2) & 0x3FFFFFFF;
int32_t out1;
int32_t out2;
int32_t out3;
int32_t out4;
out1 = ___SMMUL(attr_table.array[p1 + w[0]] << 2, (1 << 30) - Mit);
out1 += ___SMMUL(
attr_table.array[((p1 + 1) & attr_table.LENGTHMASK) + w[0]] << 2, Mit);
out2 = ___SMMUL(attr_table.array[p1 + w[1]] << 2, (1 << 30) - Mit);
out2 += ___SMMUL(
attr_table.array[((p1 + 1) & attr_table.LENGTHMASK) + w[1]] << 2, Mit);
out3 = ___SMMUL(attr_table.array[p1 + w[2]] << 2, (1 << 30) - Mit);
out3 += ___SMMUL(
attr_table.array[((p1 + 1) & attr_table.LENGTHMASK) + w[2]] << 2, Mit);
out4 = ___SMMUL(attr_table.array[p1 + w[3]] << 2, (1 << 30) - Mit);
out4 += ___SMMUL(
attr_table.array[((p1 + 1) & attr_table.LENGTHMASK) + w[3]] << 2, Mit);
// out2=attr_table.array[p1+w[1]];
// out3=attr_table.array[p1+w[2]];
// out4=attr_table.array[p1+w[3]];
tablemix(0, out1, out2, MIX1a);
tablemix(1, out3, out4, MIX1a);
tablemix(0, mix[0], mix[1], MIX2a);
int32_t sine;
SINE2TINTERP(phase, sine)
mix[0] =
___SMMUL(mix[0] << 3, SINE << 2) + ___SMMUL(sine * ratio, (1 << 27) - SINE);
val += (mix[0] - val) >> 9;
outlet_out = mix[0] - val;