frac32buffer audio in
frac32.bipolar semitone control over pitch
frac32.positive resonance length control
frac32buffer out
bool32.tgl mode
frac32.s.map pitch
frac32.u.map resonance
frac32.u.map gain
frac32.u.map max
int32_t real;
int32_t imaginary;
float32_t f0;
float32_t sinw0;
float32_t cosw0;
float32_t pi;
float32_t Fs;
float32_t f1;
int32_t out;
pi = 3.1415926535897932384626433832795028841971693993751058209749445;
Fs = 48000;
imaginary = 0;
real = 0;
int32_t frq;
int32_t pitch = __SSAT(inlet_pitch + param_pitch, 28) - (12 << 21);
float32_t power = powf(2, ((float)(pitch)) / (12 << 21));
f0 = 440 * power;
int32_t res = __USAT(param_resonance + inlet_resonance, 27);
res = res;
float32_t ras = ((float)res) / (1 << 27);
float r =
0.0001 * power + 1 - (1 - ((float)res + (1 << 30)) / (9 << 27)) / power;
// f1=-((float)110)/f0;
// float r=1.000+(ras*f1);
float32_t w0 = 2 * pi * f0 / Fs;
sinw0 = sinf(w0) * r;
cosw0 = cosf(w0) * r;
imaginary = real * sinw0 + imaginary * cosw0;
real = (inlet_in >> 4) + real * cosw0 - imaginary * sinw0;
outlet_out = imaginary;
if (param_mode == 0) {
out = imaginary;
} else {
out = real;
}
int dir = out > 0 ? 1 : -1;
int32_t in = out > 0 ? out : -out;
int32_t gian = ___SMMUL(param_gain << 3, param_gain << 2);
float32_t gain = ___SMMUL((gian + (1 << 17)) << 2, in << 3);
gain = 1 + gain / (1 << 19);
outlet_out = ((param_max) - ((param_max)-in) / gain) * dir;