frac32.bipolar pitch
frac32buffer frequency
frac32buffer expFM
frac32buffer phase
frac32buffer sync
int32 waveform
frac32 mixSine
frac32 mix1
frac32 mix2
frac32 mix3
frac32buffer.bipolar sine wave
int32 divide1
int32 divide2
int32 divide3
frac32.s.map.pitch pitch
frac32.s.map.pitch LP
int32 octSine
int32 waveform
int32 step1
int32 quant1
int32 step2
int32 quant2
int32 step3
int32 quant3
frac32.u.map mixSine
frac32.u.map mix1
frac32.u.map mix2
frac32.u.map mix3
objref table
uint32_t Phase;
int32_t mix[4];
int32_t ccomp;
int32_t read1;
int32_t read2;
int32_t P[6];
int i;
int Strig;
int32_t wave;
int32_t smooth;
int32_t mixSine;
int32_t F;
int32_t tableOsc(int32_t inst, int32_t Phs, int32_t preset1a, int32_t preset1b,
int32_t Mix, int32_t preset2) {
read1 = attr_table.array[(((Phs)&1023) + ((preset1a + preset2) << 10)) &
attr_table.LENGTHMASK];
read2 = attr_table.array[(((Phs)&1023) + ((preset1b + preset2) << 10)) &
attr_table.LENGTHMASK];
ccomp = (1 << 27) - Mix;
mix[inst] = ___SMMUL(ccomp << 3, read1 << 2) + ___SMMUL(Mix << 3, read2 << 2);
};
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);
}
uint64_t MIX1;
uint64_t MIX2;
uint64_t MIX3;
int32_t MX(int32_t T) {
T = T > 0 ? T : -T;
T = T & ((1 << 28) - 1);
F = T > (1 << 27) ? (1 << 28) - T : T;
}
Phase = 0;
int16_t Preset = (param_waveform + inlet_waveform) & 1023;
int32_t f;
MTOF(param_LP, f)
MIX1 = param_mix1 + inlet_mix1;
MIX2 = param_mix2 + inlet_mix2;
MIX3 = param_mix3 + inlet_mix3;
MX(MIX1);
MIX1 = F;
MX(MIX2);
MIX2 = F;
MX(MIX3);
MIX3 = F;
P[0] = (MIX1 * param_quant1) >> 27;
MIX1 = (MIX1 - (P[0] << 27) / param_quant1) * param_quant1;
P[0] = P[0] * param_step1;
P[1] = P[0] + param_step1;
P[2] = (MIX2 * param_quant2) >> 27;
MIX2 = (MIX2 - (P[2] << 27) / param_quant2) * param_quant2;
P[2] = P[2] * param_step2;
P[3] = P[2] + param_step2;
P[4] = (MIX3 * param_quant3) >> 27;
MIX3 = (MIX3 - (P[4] << 27) / param_quant3) * param_quant3;
P[4] = P[4] * param_step3;
P[5] = P[4] + param_step3;
outlet_divide1 = param_quant1;
outlet_divide2 = param_quant2;
outlet_divide3 = param_quant3;
int32_t freq;
MTOFEXTENDED(param_pitch + inlet_pitch + inlet_expFM, freq);
int32_t Freq = freq + ___SMMUL(inlet_linFM << 3, freq << 3);
if ((inlet_sync > 0) && !Strig) {
Phase = 0;
Strig = 1;
} else if (inlet_sync < 1) {
Strig = 0;
}
mixSine = mixSine + (((param_mixSine + inlet_mixSine) - mixSine) >> 8);
Phase += Freq;
int32_t r;
int32_t p2 = Phase + inlet_phase;
SINE2TINTERP((p2) << param_octSine, r)
int32_t phase = p2 >> 22;
tableOsc(0, phase, P[0], P[1], MIX1, P[2] + P[4] + Preset);
tableOsc(1, phase, P[0], P[1], MIX1, P[3] + P[4] + Preset);
tableOsc(2, phase, P[0], P[1], MIX1, P[2] + P[5] + Preset);
tableOsc(3, phase, P[0], P[1], MIX1, P[3] + P[5] + Preset);
tablemix(0, mix[0], mix[1], MIX2);
tablemix(1, mix[2], mix[3], MIX2);
tablemix(0, mix[0], mix[1], MIX3);
wave = (___SMMUL(mixSine << 3, mix[0] << 2) + ___SMMUL(r, (1 << 27) - mixSine))
<< 1;
smooth = __SMMLA((wave - smooth) << 1, f, smooth);
outlet_wave = smooth;