frac32buffer r
frac32buffer theta ar
frac32 rotation angle
frac32 modulation of theta by input
frac32 modulation of theta by feedback signal
frac32 feedback low pass cutoff
frac32 feedback high pass cutoff
frac32buffer output signal
frac32buffer feedback signal
frac32.s.map modulation of theta by input
frac32.s.map modulation of theta by feedback signal
frac32.s.map feedback cutoff frequency
frac32.s.map feedback cutoff frequency
int32 delay
frac32.u.map rotation angle
int32_t sin2t_q27(uint32_t p) {
int32_t a = (p & ((1 << 20) - 1)) << 8; // q28
uint32_t i = p >> 20;
return ___SMMLA(a, sine2t[i + 1] - sine2t[i], sine2t[i] >> 4);
}
int32_t cos2t_q27(uint32_t p) { return sin2t_q27(p + (1UL << 30)); }
int32_t d[256];
uint8_t dc;
int32_t in_i;
int32_t modI, modR, theta;
int32_t a_r;
int32_t LPCoeff, lp;
int32_t HPCoeff, hp;
dc = 0;
in_i = 0;
modI = 0;
modR = 0;
theta = 1 << 28;
a_r = 0;
LPCoeff = 1 << 28;
lp = 0;
HPCoeff = 1 << 28;
hp = 0;
for (int i = 0; i < 256; i++)
d[i] = 0;
int delay = param_delay - 1;
int32_t cutoff = param_LP + inlet_LP;
if (cutoff > 64 << 21)
cutoff = 64 << 21;
int32_t nLPCoeff;
MTOFEXTENDED(cutoff, nLPCoeff);
cutoff = param_HP + inlet_HP;
if (cutoff > 64 << 21)
cutoff = 64 << 21;
int32_t nHPCoeff;
MTOFEXTENDED(cutoff, nHPCoeff);
// deltas for linear interpolations at audio rate
int32_t dLPCoeff = (nLPCoeff - LPCoeff) >> 4;
int32_t dHPCoeff = (nHPCoeff - HPCoeff) >> 4;
int32_t nModI = param_mod_space_i + inlet_mod_space_i;
int32_t nModR = param_mod_space_r + inlet_mod_space_r;
int32_t dTheta = (param_theta + inlet_theta_space_kr - theta) >> 4;
// jump
if (abs(dTheta) > (1 << 20)) {
theta = param_theta + inlet_theta_space_kr;
dTheta = 0;
}
// update modulation on zero crossings
if (a_r > 0 != inlet_r > 0)
modR = nModR;
a_r = inlet_r;
theta += dTheta;
uint32_t a = theta;
a += ___SMMLA(in_i, modI, ___SMMUL(inlet_r, modR)) << 6;
a += inlet_theta_space_ar;
a &= 0x07FFFFFF;
a <<= 5;
int32_t c = cos2t_q27(a);
int32_t s = sin2t_q27(a);
outlet_r = ___SMMLS(in_i, s, ___SMMUL(inlet_r, c)) << 5;
outlet_i = ___SMMLA(in_i, c, ___SMMUL(inlet_r, s)) << 5;
// feedback through filters and delay
hp = ___SMMLA(HPCoeff += dHPCoeff, (outlet_i - hp) << 1, hp);
// delay
dc--;
// hp is actually 'outlet_i - hp'
d[dc] = outlet_i - hp;
lp = ___SMMLA(LPCoeff += dLPCoeff, (d[(uint8_t)(dc + delay)] - lp) << 1, lp);
lp = __SSAT(lp, 29);
// update modulation on zero crossings
if (in_i > 0 != lp > 0)
modI = nModI;
in_i = lp;