bool32.risingfalling start/stop recording
bool32.risingfalling dub
int32.positive note
int32.positive velo
int32.positive index
int32 length of recording in k-ticks
uint32_t tc;
uint16_t count;
bool rec;
uint8_t pren;
uint8_t prev;
uint8_t velo;
bool trig;
static const uint16_t LENGTHPOW = 9;
static const uint16_t LENGTH = 1 << 9;
static const uint16_t LENGTHMASK = (1 << 9) - 1;
static const uint16_t BITS = 16;
static const uint16_t GAIN = 12;
uint16_t *array;
uint32_t *recarray;
uint32_t bitmask = 0b11111111111111110000000000000000;
uint32_t bitmask2 = 0b00000000000000001111111111111111;
uint16_t target;
uint8_t _note;
uint8_t _velo;
trig = 0;
pren = 0;
prev = 0;
static uint16_t _array[attr_poly][LENGTH] __attribute__((section(".sdram")));
array = &_array[parent->polyIndex][0];
static uint32_t _recarray[attr_poly][LENGTH] __attribute__((section(".sdram")));
recarray = &_recarray[parent->polyIndex][0];
{
int i;
for (i = 0; i < LENGTH; i++) {
array[i] = 0;
recarray[i] = 0;
}
}
if (inlet_rec && !rec) {
rec = 1;
tc = 0;
count = 0;
pren = 255;
}
if ((inlet_note != pren) || (inlet_velo != prev)) {
trig = 1;
pren = inlet_note;
prev = inlet_velo;
}
if (rec) {
tc++;
if (trig) {
recarray[count] = ((tc << 16) + ((inlet_note + 1) + (inlet_velo << 8)));
count++;
}
}
outlet_length = tc;
if (rec && (!inlet_rec)) {
rec = 0;
int i;
for (i = 0; i < 512; i++)
array[i] = 0;
int ii;
for (ii = 0; ii < count; ii++) {
target = (((recarray[ii] & bitmask) / tc) * 512) >> 16;
while (array[target] > 0)
target++;
array[target] = recarray[ii] & bitmask2;
}
}
if (inlet_dub) {
if (trig) {
target = inlet_index;
while (array[target])
target++;
array[target] = (inlet_note + 1) + (inlet_velo << 8);
}
}
trig = 0;