bool32 trg
frac32 delaybase
None
int32 max
bool32.tgl bypass
bool32.tgl solo
combo size
// always keep these the same names, as these are the "general in/out names"
int32_t outL, outR;
int32_t IL, IR;
bool bypass, solo;
// I often use names like "v30" to save powers of 2, saves up some calculation
// time.
uint32_t v30 = (uint32_t)1 << 30;
uint32_t v26 = (uint32_t)1 << 26;
uint32_t v27 = (uint32_t)1 << 27;
// this is the code for the effect
// Don't change the inL/inR, IL/IR outL/outR names!
static const uint32_t LENGTHPOW = (attr_size);
static const uint32_t LENGTH = (1 << attr_size);
static const uint32_t LENGTHMASK = ((1 << attr_size) - 1);
int16_t *array;
int32_t base;
uint32_t TM;
uint32_t writepos;
bool trg;
int32_t FX(int32_t inL, int32_t inR, int32_t CV1, int32_t CV2) {
IL = inL;
IR = inR;
writepos = (writepos + 1) & LENGTHMASK;
array[writepos] = __SSAT(inL >> 14, 16);
array[writepos + LENGTH] = __SSAT(inR >> 14, 16);
inL = array[(writepos - TM) & LENGTHMASK] << 14;
inR = array[((writepos - TM) & LENGTHMASK) + LENGTH] << 14;
outL = inL;
outR = inR;
if (bypass > 0) {
outL = IL; // when bypass is on, sends IL to left output of effect function
outR = IR; // when bypass is on, sends IR to right output of effect function
}
};
static int16_t _array[LENGTH * 2] __attribute__((section(".sdram")));
array = &_array[0];
int i;
writepos = 0;
for (i = 0; i < LENGTH * 2; i++)
array[i] = 0;
base = inlet_delaybase;
bypass = param_bypass;
solo = param_solo;
if ((inlet_trg > 0) && !trg) {
trg = 1;
TM = (__USAT(base, 27) >> 27 - LENGTHPOW) *
((int32_t)(GenerateRandomNumber() % param_max) + 1);
} else if (inlet_trg < 1) {
trg = 0;
}