#include #include #include #include #include #include "levelpath.hpp" int main() { bool ok = true; auto chk = [&](const char* n, double got, double exp, double tol) { bool p = std::fabs(got - exp) < tol; ok = ok && p; std::printf(" %-28s got=%.6f exp=%.6f (%s)\n", n, got, exp, p ? "ok" : "MISMATCH"); }; // ---- twin_mask_factory (FUN_18056e3e0): fill 2π/(count·SR) ---- { std::vector b(0x241000, 0); *reinterpret_cast(b.data() + 0x240080) = 1024; *reinterpret_cast(b.data() + 0x24) = 48000.0f; twin_mask_factory(b.data(), 0, 1024); float expect = static_cast(6.283185307179586 / (1024.0 * 48000.0)); float* mask = reinterpret_cast(b.data() + 0x4198); chk("twin_mask_factory fill", mask[0], expect, 1e-9); chk("twin_mask_factory uniform", mask[511], expect, 1e-9); } // ---- band_lut_apply (FUN_180563a60): t^gamma linear curve ---- { std::vector b(0x12000, 0); float bandcfg[8] = {0.0f, 1.0f, 0.0f, 2.0f, 0.0f, 0, 0, 0}; // A=0,B=1,gamma=2,flag=0 *reinterpret_cast(b.data() + 0x180) = bandcfg; std::vector level_gain(0x800 * 6, 0.0f); for (int band = 0; band < 6; band++) { *reinterpret_cast(b.data() + 0xe0 + band * 0x18) = level_gain.data() + band * 0x800; } double* mask = reinterpret_cast(b.data() + 0x4198); // mask[0] = 1.0 -> dB=0 -> t=(0-0)/(1-0)=0 -> val=0^2=0 // mask[1] = 0.3162277 (=-10dB) -> t=(-10-0)/1=-10 -> clamp 0 -> 0 // mask[2] = 1.0 -> 0 for (int i = 0; i < 0x400 * 6; i++) mask[i] = 1.0; // one bin at dB = +0.5 (mask = 10^(0.5/20) = 1.059254) -> t = 0.5 -> 0.5^2 = 0.25 mask[0] = 1.0592537251772883; // +0.5 dB band_lut_apply(b.data()); chk("band_lut_apply level_axis[0]", level_gain[0], 0.0f, 1e-6); // bin 0 * 1/1024 chk("band_lut_apply gain[0] t^gamma", level_gain[1], 0.25f, 1e-3); // 0.5^2 // bin at index 512: level = 512/1024 = 0.5 chk("band_lut_apply level_axis[512]", level_gain[1024], 0.5f, 1e-6); } // ---- combine kernels (0x8d60/0x5a20/0x3c40) ---- { double out[4] = {0, 0, 0, 0}; double a[4] = {5, 2, -1, 8}; double b[4] = {3, 7, 4, 2}; combine_sub(out, a, b, 4); chk("combine_sub[0] a-b", out[0], 2.0, 1e-12); chk("combine_sub[2] a-b", out[2], -5.0, 1e-12); acc_add(out, a, 4); // out = (a-b) + a chk("acc_add[0]", out[0], 7.0, 1e-12); // (5-3)+5 = 7 acc_fma(out, b, a, 4); // out += b*a // out[1] = (2-7)+2 = -3, then -3 + b[1]*a[1] = -3 + 7*2 = 11 chk("acc_fma[1]", out[1], 11.0, 1e-12); } std::printf(ok ? "ALL OK\n" : "FAILURES\n"); return ok ? 0 : 1; }