frac32buffer wave input
bool32 when high, records input into the table at next start position
bool32 when high, clears buffer and start positions
None
bool32.tgl autoclear
objref this should refer to a 16bit table allocator (sdram)
objref this should refer to a 32bit table allocator
uint32_t writepos;
bool rec;
bool clear;
int i;
bool clr;
writepos = 0;
if (((inlet_clear || clr > 0) && !clear) ||
((param_autoclear > 0) && (attr_starts.array[0] == 63))) {
clear = 1;
for (i = 0; i < attr_samples.LENGTH; i++) {
attr_samples.array[i] = 0;
}
for (i = 0; i < attr_starts.LENGTH; i++) {
attr_starts.array[i] = 0;
}
clr = 0;
} else if (inlet_clear || clr < 1) {
clear = 0;
}
if ((inlet_rec > 0) && (writepos < attr_samples.LENGTH) &&
(attr_starts.array[0] < 63)) {
if (!rec) {
rec = 1;
}
writepos = (writepos + 1);
if (writepos > attr_samples.LENGTHMASK) {
clr = 1;
}
writepos = writepos & attr_samples.LENGTHMASK;
attr_samples.array[writepos] = __SSAT(inlet_in >> 14, 16);
} else if ((inlet_rec < 1) && (rec == 1)) {
rec = 0;
attr_starts.array[0] += 1;
attr_starts.array[attr_starts.array[0]] = writepos;
}