bool32.rising trigger
frac32buffer wave
combo sample
const static int max_length = 32 * 1024;
int16_t *sample;
uint32_t _pos = max_length;
int ntrig = 0;
static int16_t _sample[max_length] __attribute__((section(".sdram")));
sample = &_sample[0];
FIL FileObject;
FRESULT err;
UINT bytes_read;
const char fn[] = "/shared/808/attr_sample.raw";
err = f_open(&FileObject, fn, FA_READ | FA_OPEN_EXISTING);
if (err != FR_OK) {
LogTextMessage("Open failed: %s", fn);
// clear from file end to array end
int i;
for (i = 0; i < max_length; i++) {
sample[i] = 0;
}
return;
}
err = f_read(&FileObject, (char *)sample, sizeof(_sample), &bytes_read);
if (err != FR_OK) {
LogTextMessage("Read failed\n");
return;
}
err = f_close(&FileObject);
if (err != FR_OK) {
LogTextMessage("Close failed\n");
return;
}
int i = bytes_read / 2; // 16 bit per sample
// clear from file end to array end
for (; i < max_length; i++) {
sample[i] = 0;
}
if ((inlet_trig > 0) && !ntrig) {
_pos = 0;
ntrig = 1;
}
if (!(inlet_trig > 0))
ntrig = 0;
int32_t i;
if (_pos < max_length) {
for (i = 0; i < BUFSIZE; i++)
(outlet_out)[i] = (sample[_pos++]) << 12;
} else {
for (i = 0; i < BUFSIZE; i++)
(outlet_out)[i] = 0;
}