bool32.risingfalling start/stop recording
bool32.rising record next event
int32 note 0 - 127
int32 velocity 0 -127
int32 length of recording in k-ticks
int32 last event index
uint32_t recarray[512];
uint32_t tc;
uint16_t tcc;
uint16_t count;
bool rec;
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[LENGTH];
uint32_t bitmask = 0b11111111111111110000000000000000;
uint32_t bitmask2 = 0b00000000000000001111111111111111;
uint16_t target;
if (inlet_rec && !rec) {
rec = 1;
tc = 0;
count = 0;
}
if (rec) {
tc++;
tcc = tc >> 1;
if (inlet_trigger) {
recarray[count] = ((tcc << 16) + ((inlet_note + 1) + (inlet_velo << 8)));
count += 1;
}
}
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) / tcc) * 512) >> 16;
while (array[target] > 0)
target++;
array[target] = recarray[ii] & bitmask2;
}
}
outlet_index = count;