frac32buffer connect to phase output of an oscillator (or add to the S-rate code: outlet_phase=Phase>>5; and add an audio outlet called "phase")
frac32buffer offsets the phase readout (eg. use an envelope or lfo for slow modulation)
frac32 connect to the pitch of the oscillator to enable pitch-tracking (or velocity whatever..)
frac32 external control of table length in powers of 2 (same as knob)
bool32 randomises modulation table
frac32buffer o
frac32.u.map.gain modulation output width
frac32.u.map.gain adds the pitch input to the output
frac32.u.map controls table readout length in power of 2. smallest size is 2 steps (single pulse), biggest size is max table size
combo size
static const uint32_t LENGTHPOW = (attr_size);
static const uint32_t LENGTH = (1 << attr_size);
static const uint32_t LENGTHMASK = ((1 << attr_size) - 1);
static const uint32_t BITS = 16;
static const uint32_t GAIN = 12;
int16_t *array;
int rnd;
int32_t hp;
static int16_t _array[attr_poly][LENGTH] __attribute__((section(".sdram")));
array = &_array[parent->polyIndex][0];
{
int i;
for (i = 0; i < LENGTH; i++) {
array[i] = (int32_t)(GenerateRandomNumber()) >> 16;
}
}
if (inlet_rnd && !rnd) {
rnd = 1;
for (int i = 0; i < LENGTH; i++) {
array[i] = (int32_t)(GenerateRandomNumber()) >> 16;
}
} else if (!inlet_rnd) {
rnd = 0;
}
int32_t LP =
1 + ___SMMUL(__USAT(param_length + inlet_length, 27) << 4, attr_size << 1);
int32_t LM = (1 << LP) - 1;
uint32_t asat = (inlet_phase + inlet_offset) & ((1 << 27) - 1);
int index = asat >> (27 - LP);
int32_t y1 = array[index] << 12;
int32_t y2 = array[(index + 1) & LM] << 12;
int frac = (asat - (index << (27 - LP))) << (LP + 3);
int32_t rr;
rr = ___SMMUL(y1, (1 << 30) - frac);
rr = ___SMMLA(y2, frac, rr);
rr = ___SMMUL(param_mw, (rr << 3));
hp += rr - hp >> 9;
outlet_o = rr - hp + ___SMMUL(inlet_pitch << 1, param_track);