bool32.risingfalling record
frac32buffer audio in
frac32.positive length of recording in fraction of the table
int32 length in samples
objref table
bool rec;
int recpos;
int shift;
recpos = 0;
rec = 0;
// set 'shift factor' for storing the recording length/the sync output
if (attr_table.LENGTH == 2048) {
shift = 16;
}
if (attr_table.LENGTH == 4096) {
shift = 15;
}
if (attr_table.LENGTH == 8192) {
shift = 14;
}
if (attr_table.LENGTH == 16384) {
shift = 13;
}
if (attr_table.LENGTH == 32768) {
shift = 12;
}
if (attr_table.LENGTH == 65536) {
shift = 11;
}
if (attr_table.LENGTH == 131072) {
shift = 10;
}
if (attr_table.LENGTH == 262144) {
shift = 9;
}
if (attr_table.LENGTH == 524288) {
shift = 8;
}
if (attr_table.LENGTH == 1048576) {
shift = 7;
}
if (attr_table.LENGTH == 2097152) {
shift = 6;
}
if (attr_table.LENGTH == 4194304) {
shift = 5;
}
if ((inlet_rec) && !rec) {
rec = 1;
recpos = 0;
} else if (!(inlet_rec)) {
rec = 0;
outlet_range = (recpos << shift);
outlet_smps = recpos;
}
// record
if (rec) {
recpos++;
if (recpos >= attr_table.LENGTH)
recpos = 0;
attr_table.array[recpos] = __SSAT(inlet_wave, 28) >> attr_table.GAIN;
}