bool32 HSon
frac32 Tsync
frac32 expFMW
frac32 freq
frac32 intFMW
frac32 extFMW
int32 M
int32 D
int32 O
int32 FMS
int32 waveA
int32 waveB
int32 mix
frac32 out
frac32.s.map expFMW
frac32.s.map FMW
frac32.s.map extFMW
frac32.s.map pw
int32.hradio sub
frac32.s.map.kpitch LP
bool32.tgl Hsync
int32 M
int32 D
int32 O
int32 FMS
int32 waveA
int32 waveB
int32 mix
bool32 sine1
bool32 halfsine2
bool32 doublesine3
bool32 triangle4
bool32 saw5
bool32 doublesaw6
bool32 doubleshark7
bool32 doublefin8
bool32 square9
bool32 pulse10
bool32 sub11
bool32 mixOut12
bool32 filtered13
uint32_t phase;
uint32_t Phase;
int32_t wave[13];
int select[13];
int i;
int32_t FM;
int32_t HP;
int32_t LP;
int32_t mix;
int htrig;
int32_t fmw1;
int32_t fmw2;
int32_t intFMW;
int32_t INTFMW;
int ttrig;
uint32_t count;
uint32_t timer;
float32_t rate;
Phase = 0;
int M = inlet_M + param_M;
int D = inlet_D + param_D;
D = D < 1 ? 1 : D;
int O = inlet_O + param_O;
rate = ((float32_t)(timer)) / ((float32_t)(48000));
rate = (((1 << 31) / 1500) / rate);
uint32_t freq;
if (O >= 0) {
freq = ((int32_t)(rate * M / D)) << O;
}
if (O < 0) {
freq = ((int32_t)(rate * M / D)) >> -O;
}
// MTOFEXTENDED(param_pitch +
// inlet_pitch+___SMMUL(param_expFMW,inlet_expFMW),freq);
freq = (freq >> (1 + param_sub));
int waveA = __USAT(param_waveA + inlet_waveA, 8);
int waveB = __USAT(param_waveB + inlet_waveB, 8);
int MIX = __USAT(param_mix + inlet_mix, 8);
int FmS = __USAT(param_FMS + inlet_FMS, 8);
waveA = waveA - (waveA / 11) * 11;
waveB = waveB - (waveB / 11) * 11;
MIX = MIX - (MIX / 13) * 13;
FmS = FmS - (FmS / 13) * 13;
waveA = waveA > 0 ? waveA : -waveA;
waveB = waveB > 0 ? waveB : -waveB;
MIX = MIX > 0 ? MIX : -MIX;
FmS = FmS > 0 ? FmS : -FmS;
for (i = 0; i < 13; i++) {
select[i] =
((waveA == i) + (waveB == i) + (MIX == i) + (FmS == i)) > 0 ? 1 : 0;
}
int32_t lp;
MTOF(param_LP, lp);
fmw1 = ___SMMUL(param_extFMW << 3, inlet_extFMW << 2);
INTFMW = param_FMW + inlet_intFMW;
disp_sine1 = select[0];
disp_halfsine2 = select[1];
disp_doublesine3 = select[2];
disp_triangle4 = select[3];
disp_saw5 = select[4];
disp_doublesaw6 = select[5];
disp_doubleshark7 = select[6];
disp_doublefin8 = select[7];
disp_square9 = select[8];
disp_pulse10 = select[9];
disp_sub11 = select[10];
disp_mixOut12 = select[11];
disp_filtered13 = select[12];
if (param_Hsync + inlet_HSon > 0) {
if ((inlet_freq > 0) && !htrig) {
htrig = 1;
phase = 0;
} else if (inlet_freq < 0) {
htrig = 0;
}
}
// fmw2=fmw2+(((fmw1)-fmw2)>>6);
// intFMW=intFMW+(((INTFMW)-intFMW)>>6);
// int32_t Fm;
// Fm=___SMMUL(fmw2<<4,inlet_freq<<3)+___SMMUL(intFMW<<4,(wave[FmS])<<3);
// FM=FM+((Fm-FM)>>9);
// phase += freq+___SMMUL(freq<<3,(FM-Fm)<<2);
phase += freq;
if (select[10] > 0) {
int32_t sub = (phase + (1 << 29));
sub = sub > 0 ? (1 << 26) : -(1 << 26);
wave[10] = sub;
}
Phase = phase << (1 + param_sub);
int32_t Sphase = Phase + (1 << 30);
int32_t doublesaw;
doublesaw = Phase << 1;
if (select[0] > 0) {
int32_t sine;
SINE2TINTERP(Phase, sine)
sine = sine >> 5;
wave[0] = sine;
}
if (select[1] > 0) {
int32_t sine;
SINE2TINTERP((Sphase) >> 1, sine)
sine = sine >> 5;
wave[1] = sine;
}
if (select[2] > 0) {
int32_t sine;
SINE2TINTERP(Phase << 1, sine)
sine = sine >> 5;
wave[2] = sine;
}
if (select[9] > 0) {
int32_t pulse;
pulse = Sphase > (param_pw << 4) ? (1 << 26) : -(1 << 26);
wave[9] = pulse;
}
if (select[8] > 0) {
int32_t square;
square = Sphase > 0 ? (1 << 26) : -(1 << 26);
wave[8] = square;
}
if (select[4] > 0) {
int32_t saw = (Sphase + (1 << 31)) >> 5;
wave[4] = saw;
}
if (select[6] > 0) {
int32_t doublesharks =
(doublesaw > 0 ? (1 << 31) - doublesaw : doublesaw) >> 5;
wave[6] = doublesharks;
}
if (select[7] > 0) {
int32_t doublefin = (doublesaw > 0 ? doublesaw : (1 << 31) - doublesaw) >> 5;
wave[7] = doublefin;
}
if (select[5] > 0) {
doublesaw = doublesaw >> 5;
wave[5] = doublesaw;
}
if (select[3] > 0) {
int32_t tri;
tri = Sphase > 0 ? Sphase : -Sphase;
tri = (tri - (1 << 30)) >> 4;
wave[3] = tri;
}
mix = ___SMMUL(wave[waveA] << 3, (wave[MIX] + (1 << 26)) << 2) +
___SMMUL(wave[waveB] << 3, ((1 << 27) - (wave[MIX] + (1 << 26))) << 2);
wave[11] = mix;
LP = ___SMMLA((mix - LP) << 1, lp, LP);
wave[12] = LP;
outlet_out = LP;
if ((inlet_Tsync > 0) && (!(ttrig))) {
ttrig = 1;
timer = count;
count = 0;
} else if (!(inlet_Tsync > 0)) {
ttrig = 0;
}
count += 1;