bool32 trig
frac32.bipolar pitch modulation
frac32.positive start position in table
frac32buffer wave
frac32.u.map position
frac32.u.map s
bool32.tgl envon
frac32.s.map a
frac32.s.map d
frac32.s.map r
frac32.s.map.pitch pitch
objref t
// Table/Play //
int pstart;
int pstop;
uint64_t pos;
int32_t TABLE;
// ADSR //
int32_t prev;
int32_t step;
int8_t stage;
int ntrig;
int32_t val;
int32_t Loopval;
// Table/Play //
pos = 0;
pstart = 0;
pstop = 1;
// ADSR //
stage = 0;
ntrig = 0;
val = 0;
// Table/Play //
if ((inlet_trig > 0) && !pstart) {
pstart = 1;
pstop = 0;
uint32_t asat = __USAT(inlet_pos + param_position, 27);
pos = ((uint64_t)(asat >> (27 - attr_t.LENGTHPOW))) << 32;
} else if (!(inlet_trig > 0)) {
pstart = 0;
}
if ((0) && !pstop) {
pstop = 1;
pstart = 0;
}
uint32_t f0;
MTOFEXTENDED(inlet_pitch + 0xFEC747D4 + param_pitch, f0);
// ADSR //
// vca
step = (Loopval - prev) >> 4;
int32_t i = prev;
prev = Loopval;
// env
if ((inlet_trig > 0) && !ntrig) {
stage = 1;
ntrig = 1;
}
if (!(inlet_trig > 0) && ntrig) {
stage = 0;
ntrig = 0;
}
if (stage == 0) {
int32_t r1;
int32_t r2;
MTOF(-param_r, r1);
r1 = 0x7FFFFFFF - (r1 >> 2);
val = ___SMMUL(val, r1) << 1;
} else if (stage == 1) {
int32_t a;
MTOF(-param_a, a);
a = a >> 2;
val = val + a;
if (val < 0) {
val = 0x7FFFFFFF;
stage = 2;
}
} else if (stage == 2) {
int32_t s = __USAT(param_s, 27);
int32_t d;
MTOF(-param_d, d);
d = 0x7FFFFFFF - (d >> 2);
val = (s << 4) + (___SMMUL(val - (s << 4), d) << 1);
}
Loopval = val >> 4;
if (!pstop) {
if ((pos >> 32) < attr_t.LENGTH) {
uint32_t r = ___SMMUL(attr_t.array[pos >> 32] << attr_t.GAIN,
INT32_MAX - (((uint32_t)pos) >> 1));
r = ___SMMLA(attr_t.array[(pos >> 32) + 1] << attr_t.GAIN,
(((uint32_t)pos) >> 1), r);
TABLE = r;
pos += ((uint64_t)f0) << 8;
} else
TABLE = 0;
} else
TABLE = 0;
// ADSR //
if (param_envon) {
outlet_out = ___SMMUL(TABLE, i) << 5;
i += step;
} else {
outlet_out = TABLE;
}