bool32 gate
bool32 jump
int32 Ssample
int32 Lsample
int32 loopmode
int32 Esample
int32 samplelength
frac32 Spitch
frac32 Sstart
frac32 Send
frac32 SLpitch
frac32 Lpitch
frac32 Lstart
frac32 Lend
frac32 LEpitch
frac32 Epitch
frac32 Estart
frac32 Eend
frac32 size
frac32buffer fm
frac32buffer table[a]
frac32 position
int32 stage
int32 Ssample
int32 Lsample
int32 Esample
frac32.s.map Spitch
frac32.s.map SLpitch
frac32.s.map Lpitch
frac32.s.map LEpitch
frac32.s.map Epitch
frac32.u.map Sstart
frac32.u.map Send
frac32.u.map Lstart
frac32.u.map Lend
frac32.u.map Estart
frac32.u.map Eend
int32.hradio loopmode
objref table
uint32_t count;
int gtrig;
int ntrig;
int play;
int stage;
int jtrig;
uint32_t caunt;
uint32_t LENGTHPOW = (inlet_samplelength);
uint32_t LENGTH = (1 << inlet_samplelength);
uint32_t LENGTHMASK = ((1 << inlet_samplelength) - 1);
caunt += 1;
int32_t sample[6];
sample[0] = ((param_Esample + inlet_Esample) & 127) << LENGTHPOW;
sample[1] = ((param_Ssample + inlet_Ssample) & 127) << LENGTHPOW;
sample[2] = ((param_Lsample + inlet_Lsample) & 127) << LENGTHPOW;
sample[3] = ((param_Lsample + inlet_Lsample) & 127) << LENGTHPOW;
sample[4] = ((param_Ssample + inlet_Ssample) & 127) << LENGTHPOW;
sample[5] = ((param_Esample + inlet_Esample) & 127) << LENGTHPOW;
int loopmode = (param_loopmode + inlet_loopmode) & 3;
int32_t freq[6];
MTOFEXTENDED(param_Spitch + inlet_Spitch - (1 << 64), freq[1])
freq[1] = freq[1] >> 8 + LENGTHPOW - 15;
MTOFEXTENDED(param_Lpitch + inlet_Lpitch - (1 << 64), freq[2])
freq[2] = freq[2] >> 8 + LENGTHPOW - 15;
MTOFEXTENDED(param_Epitch + inlet_Epitch - (1 << 64), freq[0])
freq[0] = freq[0] >> 8 + LENGTHPOW - 15;
MTOFEXTENDED(param_SLpitch + inlet_SLpitch - (1 << 64), freq[4])
freq[4] = freq[4] >> 8 + LENGTHPOW - 15;
MTOFEXTENDED(param_LEpitch + inlet_LEpitch - (1 << 64), freq[5])
freq[5] = freq[5] >> 8 + LENGTHPOW - 15;
uint32_t Sstart = __USAT(param_Sstart + inlet_Sstart, 27);
Sstart = (___SMMUL((1 << 30), Sstart << 4) << 3);
uint32_t Send = __USAT(param_Send + inlet_Send, 27);
Send = (___SMMUL((1 << 30) - (1 << 20), Send << 4) << 3) + (1 << 19);
freq[1] = Send > Sstart ? freq[1] : -freq[1];
uint32_t Lstart = __USAT(param_Lstart + inlet_Lstart, 27);
Lstart = (___SMMUL((1 << 30) - (1 << 20), Lstart << 4) << 3) + (1 << 19);
uint32_t Lend = __USAT(param_Lend + inlet_Lend, 27);
Lend = (___SMMUL((1 << 30) - (1 << 20), Lend << 4) << 3) + (1 << 19);
freq[2] = Lend > Lstart ? freq[2] : -freq[2];
freq[3] = -freq[2];
uint32_t Estart = __USAT(param_Estart + inlet_Estart, 27);
Estart = (___SMMUL((1 << 30) - (1 << 20), Estart << 4) << 3) + (1 << 19);
uint32_t Eend = __USAT(param_Eend + inlet_Eend, 27);
Eend = (___SMMUL((1 << 30) - (1 << 20), Eend << 4) << 3) + (1 << 19);
freq[0] = Eend > Estart ? freq[0] : -freq[0];
int Shigh = Send > Sstart ? 0 : 1;
int Lhigh = Lend > Lstart ? 0 : 1;
int Ehigh = Eend > Estart ? 0 : 1;
outlet_position = count >> 5;
outlet_stage = stage;
if ((inlet_jump > 0) && !jtrig) {
jtrig = 1;
int32_t position = caunt;
caunt = 0;
count += ___SMMUL((freq[stage] * (position << 6)), inlet_size << 2);
} else if (inlet_jump == 0) {
jtrig = 0;
}
if ((inlet_gate > 0) && !gtrig) {
play = 1;
gtrig = 1;
count = Sstart;
stage = 1;
ntrig = 0;
} else if (inlet_gate == 0) {
gtrig = 0;
}
if ((inlet_gate == 0) && !ntrig) {
ntrig = 1;
stage = 5;
}
if (play > 0) {
uint32_t asat = __USAT(count >> 5, 27);
int index = asat >> (27 - LENGTHPOW);
int32_t y1 = attr_table.array[(index & LENGTHMASK) + sample[stage]]
<< attr_table.GAIN;
int32_t y2 = attr_table.array[((index + 1) & LENGTHMASK) + sample[stage]]
<< attr_table.GAIN;
int frac = (asat - (index << (27 - LENGTHPOW))) << (LENGTHPOW + 3);
int32_t rr;
rr = ___SMMUL(y1, (1 << 30) - frac);
rr = ___SMMLA(y2, frac, rr);
outlet_o = rr << 2;
if (stage < 4) {
count += freq[stage] + ___SMMUL(freq[stage] << 5, inlet_fm << 3);
}
}
if (stage == 1) {
if (Shigh == 0) {
if (((count >> 1) + (freq[1] >> 1)) > (Send >> 1)) {
if (loopmode == 0) {
stage = 5;
}
if (loopmode > 0) {
stage = 4;
}
}
}
if (Shigh == 1) {
if (((count >> 1) + (freq[1] >> 1)) < (Send >> 1)) {
if (loopmode == 0) {
stage = 5;
}
if (loopmode > 0) {
stage = 4;
}
}
}
}
if (stage == 4) {
if ((loopmode == 1) || (loopmode == 3)) {
if (count > Lstart) {
count -= freq[4] + ___SMMUL(freq[4] << 5, inlet_fm << 3);
if (count < Lstart) {
stage = 2;
}
}
if (count < Lstart) {
count += freq[4] + ___SMMUL(freq[4] << 5, inlet_fm << 3);
if (count > Lstart) {
stage = 2;
}
}
}
if (loopmode == 2) {
if (count > Lend) {
count -= freq[4] + ___SMMUL(freq[4] << 5, inlet_fm << 3);
if (count < Lend) {
stage = 3;
}
}
if (count < Lend) {
count += freq[4] + ___SMMUL(freq[4] << 5, inlet_fm << 3);
if (count > Lend) {
stage = 3;
}
}
}
}
if (stage == 5) {
if (count > Estart) {
count -= freq[5] + ___SMMUL(freq[5] << 5, inlet_fm << 3);
if (count < Estart) {
stage = 0;
}
}
if (count < Estart) {
count += freq[5] + ___SMMUL(freq[5] << 5, inlet_fm << 3);
if (count > Estart) {
stage = 0;
}
}
}
if (loopmode == 1) {
if (stage == 2) {
if (Lhigh == 0) {
if (((count >> 1) + (freq[2] >> 1)) > (Lend >> 1)) {
count = Lstart;
}
}
if (Lhigh == 1) {
if (((count >> 1) + (freq[2] >> 1)) < (Lend >> 1)) {
count = Lstart;
}
}
}
}
if (loopmode == 2) {
if (stage == 3) {
if (Lhigh == 1) {
if (((count >> 1) + (freq[3] >> 1)) > (Lstart >> 1)) {
count = Lend;
}
}
if (Lhigh == 0) {
if (((count >> 1) + (freq[3] >> 1)) < (Lstart >> 1)) {
count = Lend;
}
}
}
}
if (loopmode == 3) {
if (stage == 2) {
if (Lhigh == 0) {
if (((count >> 1) + (freq[2] >> 1)) > (Lend >> 1)) {
stage = 3;
}
}
if (Lhigh == 1) {
if (((count >> 1) + (freq[2] >> 1)) < (Lend >> 1)) {
stage = 3;
}
}
}
if (stage == 3) {
if (Lhigh == 1) {
if (((count >> 1) + (freq[3] >> 1)) > (Lstart >> 1)) {
stage = 2;
}
}
if (Lhigh == 0) {
if (((count >> 1) + (freq[3] >> 1)) < (Lstart >> 1)) {
stage = 2;
}
}
}
}
if (stage == 0) {
if (Ehigh == 0) {
if (((count >> 1) + (freq[0] >> 1)) > (Eend >> 1)) {
play = 0;
}
}
if (Ehigh == 1) {
if (((count >> 1) + (freq[0] >> 1)) < (Eend >> 1)) {
play = 0;
}
}
}
if (play == 0) {
outlet_o = 0;
}