None
None
frac32.s.map.kpitch rate
bool32.tgl LFO
bool32.tgl bypass
bool32.tgl solo
frac32.u.map depth
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 Time;
int32_t depth;
int32_t phs;
int32_t pitch;
uint32_t writepos;
int LFO;
int32_t FX(int32_t inL, int32_t inR, int32_t CV1, int32_t CV2) {
IL = inL; // this saves the left input so the effect can be bypassed
IR = inR; // this saves the right input so the effect can be bypassed
// enter code below: //here you can enter your code. Use inL and inR
// to get the audio left&right input.
// the below code puts the calculated audio into "outL" and "outR" as output
// of the FX.
writepos = (writepos + 1) & LENGTHMASK;
array[writepos] = __SSAT(inL >> 14, 16);
array[writepos + LENGTH] = __SSAT(inR >> 14, 16);
int32_t rate;
MTOFEXTENDED(pitch + CV1, rate)
rate = rate >> 2 + 7 * LFO;
phs += rate;
int32_t s;
SINE2TINTERP(phs, s)
int32_t Depth = __SSAT(depth + CV2, 28);
int32_t S = ___SMMUL(Depth, s) + (Depth >> 1);
uint32_t tmp_d = __USAT(S, 27);
uint32_t tmp_di = writepos - (tmp_d >> (27 - LENGTHPOW)) - 1;
uint32_t tmp_w1 = (tmp_d << (LENGTHPOW + 3)) & 0x3FFFFFFF;
uint32_t tmp_w2 = (1 << 30) - tmp_w1;
int32_t tmp_a1 = array[tmp_di & LENGTHMASK] << 16;
int32_t tmp_a2 = array[(tmp_di + 1) & LENGTHMASK] << 16;
int32_t tmp_r = ___SMMUL(tmp_a1, tmp_w1);
inL = ___SMMLA(tmp_a2, tmp_w2, tmp_r);
S = -___SMMUL(Depth, s) + (Depth >> 1);
tmp_d = __USAT(S, 27);
tmp_di = writepos - (tmp_d >> (27 - LENGTHPOW)) - 1;
tmp_w1 = (tmp_d << (LENGTHPOW + 3)) & 0x3FFFFFFF;
tmp_w2 = (1 << 30) - tmp_w1;
tmp_a1 = array[(tmp_di & LENGTHMASK) + LENGTH] << 16;
tmp_a2 = array[((tmp_di + 1) & LENGTHMASK) + LENGTH] << 16;
tmp_r = ___SMMUL(tmp_a1, tmp_w1);
inR = ___SMMLA(tmp_a2, tmp_w2, tmp_r);
outL = inL; // this is the left output of the fx (puts inL into outL)
outR = inR; // this is the right output of the fx (puts inR into outR)
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;
pitch = param_rate;
depth = param_depth;
LFO = param_LFO;
bypass = param_bypass;
solo = param_solo;