frac32 additional data,for example timepoint of the recording start
frac32buffer audio in
int32.positive select a slot to record into (0 - 127)
int32.positive playback mode the currently recording slot will be set to
bool32.risingfalling arm the recorder
bool32.rising a pulse will start a recording a sample in the selected slot if 'arm' is 1 and the selected slot doesn't already contain a sample
bool32.rising clear the recorders data
int32.positive slot currently recording to
frac32.positive remaining recording-time
bool32.pulse issues a pulse when a new slot is recorded
bool32 recording status
bool32 rec status && fade status
bool32 '1' if a slot already contains a sample
frac32.s.map.kdecaytime.exp attack
frac32.s.map.kdecaytime.exp release
objref table to record to
bool rec;
bool recstate;
bool fadetrig;
bool rtrig;
uint32_t fadepos;
uint32_t recstart;
uint32_t recend;
uint32_t rec_max;
uint8_t shift;
int32_t env;
uint8_t mslot;
uint8_t preslot;
uint8_t recslot;
static const uint16_t LENGTH = 512;
uint32_t array[512];
bool full;
bool rectrig;
rec_max = attr_wave.LENGTH;
shift = (27 - attr_wave.LENGTHPOW);
{
int i;
for (i = 0; i < 512; i++)
array[i] = 0;
}
outlet_recstart = 0;
mslot = (inlet_slot % 126);
full = array[(mslot << 2) + 2];
if (inlet_arm) {
if (!full && (inlet_rec && !rectrig)) {
rectrig = 1;
recslot = mslot;
if (rec)
array[(preslot << 2) + 1] = array[511];
rec = 1;
recstate = 1;
outlet_recstart = 1;
fadetrig = 0;
recstart = array[511];
array[recslot << 2] = array[511];
array[(recslot << 2) + 2] = (inlet_playmode) ? inlet_playmode : 1;
array[(recslot << 2) + 3] = __SSAT(inlet_Aux, 28);
preslot = recslot;
}
}
if (!inlet_rec)
rectrig = 0;
if (!inlet_arm && rec) {
rec = 0;
array[(recslot << 2) + 1] = array[511];
}
// fades
if (rec) {
env = (1 << 27) - (___SMMUL((1 << 27) - env, param_attack) << 1);
} else {
env = ___SMMUL(env, param_release) << 1;
if (!fadetrig) {
fadetrig = 1;
recend = array[511];
fadepos = recstart;
}
}
recstate = env;
// clear
if (inlet_clear && !rtrig) {
rtrig = 1;
int i;
for (i = 0; i < 512; i++)
array[i] = 0;
}
if (!inlet_clear)
rtrig = 0;
outlet_slotFull = full;
outlet_remain = (rec_max - array[511]) << shift;
outlet_recstate = rec;
outlet_fadestate = recstate;
outlet_recslot = recslot;
// record
if (recstate) {
if (rec) {
attr_wave.array[array[511]] =
__SSAT((___SMMUL((inlet_wave), env) << 5), 28) >> attr_wave.GAIN;
if (array[511] < rec_max)
array[511]++;
else
array[511] = recstart;
} else {
attr_wave.array[fadepos] = (__SSAT((___SMMUL((inlet_wave), env) << 5), 28) +
(attr_wave.array[fadepos] << attr_wave.GAIN)) >>
attr_wave.GAIN;
fadepos++;
if (fadepos >= recend)
fadepos = recstart;
}
}