frac32.positive offset inside the table
frac32.positive length of the area to index,or loop end
frac32.positive start position inside 'range' on 'reset'
frac32.positive start of the loop
frac32.bipolar sample increment,+ 64 normal speed forward, - 64 backward
bool32.risingfalling toggle playback
bool32.rising reset to 'startpoint'
int32 loop count since reset
int32 lenght of the loop in samples
frac32buffer audio out
objref table
float32_t index;
uint32_t r;
uint32_t pos;
uint32_t out;
int shift;
int range;
int reset;
int loopstart;
int count;
bool add;
index = 0;
r = 1;
// 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;
}
range = (inlet_range >> shift);
reset = ((___SMMUL(inlet_range, inlet_startpoint) << 5) >> shift);
loopstart = ((___SMMUL(inlet_range, inlet_loopstart) << 5) >> shift);
{
if (inlet_reset && r) {
index = reset;
r = 0;
count = 0;
} else {
if (!inlet_reset)
r = 1;
index += (inlet_speed * (float)(1.0f / (1 << 27)));
pos = (index + loopstart);
out = ((pos << shift) + inlet_offset);
add = range;
// set a range
if (inlet_speed > 0) {
if (pos >= (range)) {
index = 0;
count += add;
}
} else {
if (pos <= loopstart) {
index = (range - loopstart);
count += add;
}
}
}
if (inlet_play)
outlet_count = count;
else
outlet_count = 0;
outlet_smps = (range - loopstart);
}
// player
uint32_t asat = __USAT(out, 27);
int indexp = asat >> (27 - attr_table.LENGTHPOW);
int32_t y1 = attr_table.array[indexp] << attr_table.GAIN;
int32_t y2 = attr_table.array[(indexp + 1) & attr_table.LENGTHMASK]
<< attr_table.GAIN;
int frac = (asat - (indexp << (27 - attr_table.LENGTHPOW)))
<< (attr_table.LENGTHPOW + 3);
int32_t rr;
rr = ___SMMUL(y1, (1 << 30) - frac);
rr = ___SMMLA(y2, frac, rr);
outlet_out = ((rr << 2) * inlet_play);