bool32.rising trigger an editing action
bool32.rising defragment the sample data
bool32.rising clear all data
bool32.risingfalling copy the selected slot
bool32.risingfalling move the selected slot
bool32.risingfalling delete the selected slot
bool32 pitchUp
bool32 pitchDown
int32.positive slot to work on
bool32.pulse pulse on delete
objref wave
objref params
combo blocksize
bool ctrig;
bool dtrig;
bool cpytrig;
bool cpytemptrig;
bool del;
bool clrtrig;
bool move;
bool mtrig;
uint8_t mslot;
uint8_t srcslot;
bool copytrig;
uint32_t sstart;
uint32_t send;
uint32_t slength;
uint32_t slottemp[4];
int32_t paramtemp[1 << attr_blocksize];
static const uint16_t LENGTH = 1024;
uint32_t *array;
bool REC;
uint8_t RECSLOT;
void delete_slot(uint8_t target) __attribute__((noinline)) {
if (array[(target << 2) + 2]) {
sstart = array[target << 2];
send = array[(target << 2) + 1];
int i;
for (i = 0; i < 4; i++)
array[(target << 2) + i] = 0;
for (i = 0; i < (1 << attr_blocksize); i++)
attr_params.array[(target << attr_blocksize) + i] = 0;
bool check = 1;
for (i = 0; i < 127; i++)
if (array[(i << 2) + 1] == send)
check = 0;
if (check) {
array[array[1023] + 512] = sstart;
array[array[1023] + 767] = send;
array[1023]++;
}
}
}
static uint32_t _array[attr_poly][1024] __attribute__((section(".sdram")));
array = &_array[parent->polyIndex][0];
{
int i;
for (i = 0; i < 1024; i++)
array[i] = 0;
}
mslot = inlet_slot % 126;
outlet_delete = 0;
// delete
if (inlet_delete && inlet_trig && !dtrig) {
delete_slot(mslot);
dtrig = 1;
outlet_delete = 1;
}
// compact
if (inlet_defrag && !ctrig) {
ctrig = 1;
int i;
for (i = 0; i < array[1023]; i++) {
send = array[i + 767];
sstart = array[i + 512];
slength = (send - sstart);
int shift_index;
for (shift_index = 0; shift_index < 512; shift_index += 4)
if (array[shift_index] >= send) {
array[shift_index] -= slength;
array[shift_index + 1] -= slength;
}
int move_samples;
for (move_samples = send; move_samples < (array[1022]); move_samples++)
attr_wave.array[move_samples - slength] = attr_wave.array[move_samples];
int shift_chunks;
for (shift_chunks = 0; shift_chunks < array[1023]; shift_chunks++)
if (array[shift_chunks + 512] >= send) {
array[shift_chunks + 512] -= slength;
array[shift_chunks + 767] -= slength;
}
array[1022] -= slength;
}
array[1023] = 0;
}
if (!inlet_defrag)
ctrig = 0;
// paste
if (inlet_trig && cpytemptrig && !cpytrig && (inlet_copy || move)) {
cpytrig = 1;
delete_slot(mslot);
int i;
for (i = 0; i < 4; i++)
array[(mslot << 2) + i] = slottemp[i];
if (inlet_copy && inlet_pitchUp)
paramtemp[8] += (((1 << attr_params.GAIN) / 3) + 1);
if (inlet_copy && inlet_pitchDown)
paramtemp[8] -= (((1 << attr_params.GAIN) / 3) + 1);
for (i = 0; i < (1 << attr_blocksize); i++)
attr_params.array[(mslot << attr_blocksize) + i] = paramtemp[i];
if (move) {
delete_slot(srcslot);
outlet_delete = 1;
move = 0;
}
}
// copy
if (inlet_trig && !cpytemptrig && (inlet_copy || move)) {
cpytemptrig = 1;
srcslot = mslot;
int i;
for (i = 0; i < 4; i++)
slottemp[i] = array[(mslot << 2) + i];
for (i = 0; i < (1 << attr_blocksize); i++)
paramtemp[i] = attr_params.array[(mslot << attr_blocksize) + i];
}
// move
if (inlet_move && !mtrig) {
mtrig = 1;
move = 1;
}
// clear
if (inlet_clear && !clrtrig) {
clrtrig = 1;
int i;
for (i = 0; i < 1024; i++)
array[i] = 0;
for (i = 0; i < ((1 << attr_blocksize) << 7); i++)
attr_params.array[i] = 0;
}
if (!inlet_copy && !inlet_move)
cpytemptrig = 0;
if (!inlet_move) {
mtrig = 0;
move = 0;
}
if (!inlet_trig) {
cpytrig = 0;
dtrig = 0;
}
if (!inlet_clear)
clrtrig = 0;