int32.positive slot
bool32.risingfalling loopRec
bool32.risingfalling sync
bool32.risingfalling sliceArm
bool32.risingfalling DISABLE
frac32.positive phase
bool32.rising sliceRec
int32 slot
bool32 arm
bool32.pulse rec
int32.positive playmode
objref smplr
spinner loopFlag
spinner sliceFlag
bool srec;
uint8_t slot;
bool rec;
bool lrec;
uint32_t start;
int32_t _ap;
int32_t phase;
bool full;
outlet_rec = 0;
full = attr_smplr.array[(inlet_slot << 5) + 2];
if (!inlet_DISABLE) {
if (inlet_loopRec && !lrec) {
lrec = 1;
start = inlet_phase;
outlet_playmode = attr_loopFlag;
if (full) {
slot = 255;
int i;
for (i = 0; i < 126; i++)
if (!attr_smplr.array[(i << 5) + 2]) {
slot = i;
break;
}
} else
slot = inlet_slot;
if (slot != 255) {
rec = 1;
outlet_rec = 1;
}
}
if (!inlet_loopRec && lrec) {
if (inlet_sync) {
phase = (inlet_phase - start) & ((1 << 27) - 1);
if ((phase - _ap) <= 0) {
lrec = 0;
rec = 0;
attr_smplr.RECPOS -= 16;
}
_ap = phase;
} else {
rec = 0;
lrec = 0;
}
}
if (!lrec) {
if ((inlet_sliceArm && !rec) && !full) {
srec = 1;
rec = 1;
}
if (srec) {
outlet_rec = inlet_sliceRec;
if (!full)
slot = inlet_slot;
outlet_playmode = attr_sliceFlag;
}
if (!inlet_sliceArm && srec) {
srec = 0;
rec = 0;
}
}
outlet_arm = rec;
outlet_slot = slot;
}