frac32buffer.bipolar in
frac32buffer.bipolar left
frac32buffer.bipolar right
frac32.u.map minRate
frac32.u.map maxRate
combo NBD
combo LENGTH
static const int NBD = attr_NBD;
static const int LENGTH = attr_LENGTH;
static const int RANGE = LENGTH - 5;
float p[NBD];
float env[NBD];
float amp[NBD];
float dp[NBD];
int32_t d[NBD];
float *array;
int ind = 0;
int32_t rnd = 137178354;
static float _array[attr_poly][LENGTH]; // __attribute__ ((section (".sdram")));
array = &_array[parent->polyIndex][0];
rnd += GenerateRandomNumber();
for (int i = 0; i < LENGTH; i++)
array[i] = 0;
for (int i = 0; i < NBD; i++) {
p[i] = 2.0f * i / ((float)NBD);
rnd *= 69069;
// d[i] = ___SMMUL(rnd & 0x7FFFFFFF, RANGE << 1);
d[i] = 2 + ___SMMUL(___SMMUL(rnd, rnd), RANGE << 2);
amp[i] = (i % 2) ? 1 : -1; // ]-1,1[
rnd *= 69069;
}
for (int i = 0; i < NBD; i++) {
p[i] += dp[i];
if (p[i] > 2) {
p[i] -= 2;
rnd *= 69069;
d[i] = 2 + ___SMMUL(___SMMUL(rnd, rnd), RANGE << 2);
}
float e = p[i];
if (e > 1) {
e = 2 - e;
}
// e = e * e * (3 - 2 * e);
env[i] = e * amp[i];
float a = i * (1 / (attr_NBD - 1.0f)); // rnd * 4.656e-10f;
dp[i] = ((2 / 3000.0f) * (6.4f / (1 << 27))) *
((1 << 20) + param_minRate + a * a * (param_maxRate - param_minRate));
}
ind++;
ind %= LENGTH;
array[ind] = (float)inlet_in;
float acc = 0.0f;
for (int i = 0; i < NBD / 2; i++) {
acc += env[i] * array[(ind + LENGTH - d[i]) % LENGTH];
}
outlet_left = (int32_t)acc;
acc = 0.0f;
for (int i = NBD / 2; i < NBD; i++) {
acc += env[i] * array[(ind + LENGTH - d[i]) % LENGTH];
}
outlet_right = (int32_t)acc;