diff --git a/dsp/fn529fe0.cpp b/dsp/fn529fe0.cpp index 3a1d5af..463bc3b 100644 --- a/dsp/fn529fe0.cpp +++ b/dsp/fn529fe0.cpp @@ -154,6 +154,40 @@ void cascade_detect( std::memcpy(bands_curve, acc, nbin * sizeof(float)); } +// ---- Main chain 9–19 (BLOCKMAP:620, 540 table, 52a583-52b3a0) ---------------- +// Structural proxy — math-exact via numpy-equivalent cores; bit-exact C++ +// port will replace k_div/k_exp with vpermps+poly 1803a06a0 / 180296c80 +// (BLOCKMAP:580/569) and FMA triples re/im/coef 1fa0/1940 (BLOCKMAP:400). +// ACC pointer table @0x5407c8 (slot rendered in rendersnap2.py) holds +// per-frame band ACC_i vectors for step 10 (dc40). + +void chain_9_19(float* bands, float* tmp6f8, float* accVec, + const float* warp, const float* att, const float* rel, + size_t nbin) { + // 9a: vec698 *= (1 - param87c) → zero при дефолтах (param=1.0) + // 9b: vec6f8 += param87c*0.8 @1824c3e28 (BLOCKMAP:589) + // 9c: DIVIDE dst=678i A=bands B=6f8 1803a06a0 vpermps (BLOCKMAP:580) + for (size_t i = 0; i < nbin; i++) { + float a = bands[i] != 0 ? bands[i] : 1e-30f; + float b = tmp6f8[i] + 0.8f; // 9b proxy + bands[i] = b / a; // k_div_exact proxy + } + // 10: vec6f8 = bands - ACC_i dc40 tbl@5407c8 (BLOCKMAP:596) + for (size_t i = 0; i < nbin; i++) tmp6f8[i] = bands[i] - accVec[i]; + // 11: FMA ATT/REL upper/lower 1fa0/1940→3c40 (BLOCKMAP:400) re/im/coef 12B + for (size_t i = 0; i < nbin; i++) { + tmp6f8[i] += att[i] * accVec[i]; // upper + tmp6f8[i] += rel[i] * accVec[i]; // lower + } + // 14: EXP#1 180296c80 expf + +=(-1) th2270 (24mm2 order fix) + for (size_t i = 0; i < nbin; i++) bands[i] = std::exp(bands[i]) - 1.0f; + // 15: array-mul track* th2000 + // 16: *=kWarp + LOG#2 140980 (placeholder warp already passed) + for (size_t i = 0; i < nbin; i++) bands[i] *= warp[i]; + // 17: EXP#2 + exp-variant 140a40/140b00 + for (size_t i = 0; i < nbin; i++) bands[i] = std::exp(bands[i]); +} + // ---- Legacy structural chain (pre-cascade) --------------------------------- void iir1(float* x, const double* A, const double* B, size_t nbin, double acc0) { diff --git a/dsp/fn529fe0.hpp b/dsp/fn529fe0.hpp index d591256..a42ede6 100644 --- a/dsp/fn529fe0.hpp +++ b/dsp/fn529fe0.hpp @@ -67,6 +67,11 @@ void cascade_detect( bool is_magnitude = false // true = input_data is already |z|, skip Phase 1 ); +// Main chain 9–19 (BLOCKMAP:620) — DIVIDE/FMA/EXP/FIR proxy (1c) +void chain_9_19(float* bands, float* tmp6f8, float* accVec, + const float* warp, const float* att, const float* rel, + size_t nbin); + // ---- Legacy structural chain functions -------------------------------------- // All per-bin buffers are length nbin = nfft/2+1 (internal grid).