frac32buffer in
frac32 freq1
frac32 freq2
frac32 freq3
frac32 freq4
frac32 freq5
frac32 freq6
frac32 freq7
frac32 fb
frac32buffer out
class APC {
public:
int32_t v[7];
int32_t g[7];
void init(void) {
for (int i = 0; i < 7; i++)
v[i] = 0;
}
int32_t aProc(int32_t x) {
int32_t y = x;
for (int p = 0; p < 7; p++) {
int32_t u = ___SMMLA(g[p], v[p] << 1, y);
y = ___SMMLS(g[p], u << 1, v[p]);
v[p] = u;
}
return y;
}
};
APC apc;
int32_t v;
apc.init();
v = 0;
apc.g[0] = 0x7FFFFFFF - (__USAT(inlet_freq1, 27) << 4);
apc.g[1] = 0x7FFFFFFF - (__USAT(inlet_freq2, 27) << 4);
apc.g[2] = 0x7FFFFFFF - (__USAT(inlet_freq3, 27) << 4);
apc.g[3] = 0x7FFFFFFF - (__USAT(inlet_freq4, 27) << 4);
apc.g[4] = 0x7FFFFFFF - (__USAT(inlet_freq5, 27) << 4);
apc.g[5] = 0x7FFFFFFF - (__USAT(inlet_freq6, 27) << 4);
apc.g[6] = 0x7FFFFFFF - (__USAT(inlet_freq7, 27) << 4);
int32_t fb = __USAT((inlet_fb), 27) << 4; // q31
// nested all pass chain
int32_t u = ___SMMLA(fb, v << 1, inlet_in);
outlet_out = ___SMMLS(fb, u << 1, v);
v = apc.aProc(u >> 8) << 8;