P2: level-tracker UPDATE-loop located (inline bidirectional IIR in FUN_180529fe0), structural module leveltrack (iir_first_order/bidirectional/unrolled4); scalar==unrolled verified; remaining = live A[] coeffs

This commit is contained in:
2026-08-19 23:53:01 +03:00
parent cff28a605c
commit 433a0026e6
5 changed files with 116 additions and 1 deletions
+42
View File
@@ -0,0 +1,42 @@
#include "leveltrack.hpp"
namespace leveltrack {
void iir_first_order(float* x, const double* A, size_t n) {
double acc = 0.0;
for (size_t i = 0; i < n; i++) {
double y = static_cast<double>(x[i]) * A[i] + acc;
acc = y;
x[i] = static_cast<float>(y);
}
}
void iir_bidirectional(float* x, const double* A, size_t n) {
iir_first_order(x, A, n);
// reverse pass over reversed indices back into x (keep array order).
double acc = 0.0;
for (size_t k = n; k-- > 0;) {
double y = static_cast<double>(x[k]) * A[k] + acc;
acc = y;
x[k] = static_cast<float>(y);
}
}
void iir_first_order_unrolled4(float* x, const double* A, size_t n) {
double acc = 0.0;
size_t i = 0;
for (; i + 4 <= n;) {
for (int u = 0; u < 4; u++, i++) {
double y = static_cast<double>(x[i]) * A[i] + acc;
acc = y;
x[i] = static_cast<float>(y);
}
}
for (; i < n; i++) {
double y = static_cast<double>(x[i]) * A[i] + acc;
acc = y;
x[i] = static_cast<float>(y);
}
}
} // namespace leveltrack