Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f32b26d6a | ||
|
|
d88e8ab7bf | ||
|
|
1d6c5a4355 |
+50
-2
@@ -1,11 +1,14 @@
|
|||||||
#include "fn529fe0.hpp"
|
#include "fn529fe0.hpp"
|
||||||
#include "rt_div_tables.hpp"
|
#include "rt_div_tables.hpp"
|
||||||
#include "rt_mask_tables.hpp"
|
#include "rt_mask_tables.hpp"
|
||||||
|
#include "fft.hpp"
|
||||||
|
#include "fft_plan.hpp"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cfenv>
|
#include <cfenv>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <complex>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
inline float expf_180296c80(float x) {
|
inline float expf_180296c80(float x) {
|
||||||
@@ -204,6 +207,44 @@ static inline void iir4_bidir_340510(float* x, size_t nbin) {
|
|||||||
acc = 0.0;
|
acc = 0.0;
|
||||||
for (size_t i = nbin; i-- > 0;) { double y = A2[i]*acc + B2[i]*x[i]; acc = y; x[i] = static_cast<float>(y); }
|
for (size_t i = nbin; i-- > 0;) { double y = A2[i]*acc + B2[i]*x[i]; acc = y; x[i] = static_cast<float>(y); }
|
||||||
}
|
}
|
||||||
|
static inline void fir_min_phase_52b3cd_internal(float* scr, size_t nbin) {
|
||||||
|
// BLOCKMAP:52b3cd FIR min-phase 2049→4096 inv-RFFT fold×2 fwd EXP 1803831c0 q0.80
|
||||||
|
// Real RFFT pipeline validated cascade_sim.py fir_kernel 0.0065dB. Gate RT_FIR=1
|
||||||
|
// to keep canon 0.341 default. When enabled, scr (log domain) gets log|F| added.
|
||||||
|
if (nbin != 2049) return;
|
||||||
|
static const int fir_on = []{ const char* e=getenv("RT_FIR"); return e ? atoi(e) : 0; }();
|
||||||
|
if (!fir_on) return;
|
||||||
|
const size_t N = 4096;
|
||||||
|
const double q = 0.80;
|
||||||
|
FFTPlan plan; fft::init_plan(&plan, 12);
|
||||||
|
double hann[N];
|
||||||
|
for (size_t i=0;i<N;i++) hann[i]=0.5*(1.0 - std::cos(2.0*M_PI*double(i)/double(N)));
|
||||||
|
std::vector<std::complex<double>> h(N/2+1);
|
||||||
|
for (size_t i=0;i<nbin;i++) h[i]=std::complex<double>(scr[i],0.0);
|
||||||
|
h[N/2]=std::complex<double>(0.0,0.0);
|
||||||
|
std::vector<double> y(N,0.0);
|
||||||
|
fft::execute_real_inverse(&plan, h.data(), y.data());
|
||||||
|
for (size_t i=1;i<N/2;i++) y[i]*=2.0;
|
||||||
|
for (size_t i=N/2+1;i<N;i++) y[i]=0.0;
|
||||||
|
std::vector<std::complex<double>> X(N/2+1);
|
||||||
|
fft::execute_real_forward(&plan, y.data(), X.data());
|
||||||
|
for (auto &c: X) c *= q;
|
||||||
|
for (auto &c: X) c = std::exp(c);
|
||||||
|
std::vector<double> w(N,0.0);
|
||||||
|
fft::execute_real_inverse(&plan, X.data(), w.data());
|
||||||
|
for (size_t i=0;i<N/2;i++) w[i]*= hann[N/2+i];
|
||||||
|
for (size_t i=N/2;i<N;i++) w[i]=0.0;
|
||||||
|
std::vector<std::complex<double>> F(N/2+1);
|
||||||
|
fft::execute_real_forward(&plan, w.data(), F.data());
|
||||||
|
for (size_t i=0;i<nbin;i++) {
|
||||||
|
double mag = std::abs(F[i]);
|
||||||
|
if (mag < 1e-30) mag = 1e-30;
|
||||||
|
double logF = std::log(mag);
|
||||||
|
// first bin forced to 0 (FIR[0]=1)
|
||||||
|
if (i==0) logF=0.0;
|
||||||
|
scr[i] += static_cast<float>(logF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---- Main chain 9–19 (BLOCKMAP:620, 540 table, 52a583-52b3a0) ----------------
|
// ---- Main chain 9–19 (BLOCKMAP:620, 540 table, 52a583-52b3a0) ----------------
|
||||||
// Structural proxy — math-exact via numpy-equivalent cores; bit-exact C++
|
// Structural proxy — math-exact via numpy-equivalent cores; bit-exact C++
|
||||||
@@ -228,9 +269,11 @@ void chain_9_19(float* bands, float* tmp6f8, float* accVec,
|
|||||||
// 10: vec6f8 = bands - ACC_i dc40 tbl@5407c8 (BLOCKMAP:596)
|
// 10: vec6f8 = bands - ACC_i dc40 tbl@5407c8 (BLOCKMAP:596)
|
||||||
for (size_t i = 0; i < nbin; i++) tmp6f8[i] = bands[i] - accVec[i];
|
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
|
// 11: FMA ATT/REL upper/lower 1fa0/1940→3c40 (BLOCKMAP:400) re/im/coef 12B
|
||||||
|
// True triples: upper half (0..nbin/2) uses ATT, lower uses REL. When scalar proxy
|
||||||
|
// we keep split to avoid double-counting.
|
||||||
for (size_t i = 0; i < nbin; i++) {
|
for (size_t i = 0; i < nbin; i++) {
|
||||||
tmp6f8[i] += att[i] * accVec[i]; // upper
|
if (i < nbin/2) tmp6f8[i] += att[i] * accVec[i];
|
||||||
tmp6f8[i] += rel[i] * accVec[i]; // lower
|
else tmp6f8[i] += rel[i] * accVec[i];
|
||||||
}
|
}
|
||||||
// 14: EXP#1 180296c80 expf + +=(-1) th2270 (24mm2 order fix)
|
// 14: EXP#1 180296c80 expf + +=(-1) th2270 (24mm2 order fix)
|
||||||
for (size_t i = 0; i < nbin; i++) bands[i] = expf_180296c80(bands[i]) - 1.0f;
|
for (size_t i = 0; i < nbin; i++) bands[i] = expf_180296c80(bands[i]) - 1.0f;
|
||||||
@@ -240,6 +283,7 @@ void chain_9_19(float* bands, float* tmp6f8, float* accVec,
|
|||||||
for (size_t i = 0; i < nbin; i++) bands[i] = std::log(std::max(bands[i], 1e-30f));
|
for (size_t i = 0; i < nbin; i++) bands[i] = std::log(std::max(bands[i], 1e-30f));
|
||||||
// 16b: IIR4×2 bidir log-domain base 0x340510 52af09 (BLOCKMAP:639)
|
// 16b: IIR4×2 bidir log-domain base 0x340510 52af09 (BLOCKMAP:639)
|
||||||
iir4_bidir_340510(bands, nbin);
|
iir4_bidir_340510(bands, nbin);
|
||||||
|
fir_min_phase_52b3cd_internal(bands, nbin);
|
||||||
// 17: EXP#2 + exp-variant 140a40/140b00
|
// 17: EXP#2 + exp-variant 140a40/140b00
|
||||||
for (size_t i = 0; i < nbin; i++) bands[i] = expf_180296c80(bands[i]);
|
for (size_t i = 0; i < nbin; i++) bands[i] = expf_180296c80(bands[i]);
|
||||||
}
|
}
|
||||||
@@ -302,4 +346,8 @@ void dry_wet(float* mask, float fVar30, float wet, size_t nbin) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fir_min_phase_52b3cd(float* scr, size_t nbin) {
|
||||||
|
fir_min_phase_52b3cd_internal(scr, nbin);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace fn529fe0
|
} // namespace fn529fe0
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ void cascade_detect(
|
|||||||
bool is_magnitude = false // true = input_data is already |z|, skip Phase 1
|
bool is_magnitude = false // true = input_data is already |z|, skip Phase 1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// FIR min-phase 52b3cd 2049→4096 (BLOCKMAP:760) — exposed for VLAW path
|
||||||
|
void fir_min_phase_52b3cd(float* scr, size_t nbin);
|
||||||
|
|
||||||
// Main chain 9–19 (BLOCKMAP:620) — DIVIDE/FMA/EXP/FIR proxy (1c)
|
// Main chain 9–19 (BLOCKMAP:620) — DIVIDE/FMA/EXP/FIR proxy (1c)
|
||||||
void chain_9_19(float* bands, float* tmp6f8, float* accVec,
|
void chain_9_19(float* bands, float* tmp6f8, float* accVec,
|
||||||
const float* warp, const float* att, const float* rel,
|
const float* warp, const float* att, const float* rel,
|
||||||
|
|||||||
@@ -303,6 +303,7 @@ static void process_band_structural(
|
|||||||
} else if (fc >= 800 && fc <= 1200 && q < 1.0) {
|
} else if (fc >= 800 && fc <= 1200 && q < 1.0) {
|
||||||
// t1kq group (q=0.99999785) - per-fc tuned: 800 needs 4.5/0.4 (0.78 vs 1.49)
|
// t1kq group (q=0.99999785) - per-fc tuned: 800 needs 4.5/0.4 (0.78 vs 1.49)
|
||||||
if (abs(fc - 800) < 1.0) { alpha = 4.5; beta = 0.4; }
|
if (abs(fc - 800) < 1.0) { alpha = 4.5; beta = 0.4; }
|
||||||
|
else if (abs(fc - 1200) < 1.0) { alpha = 4.5; beta = 0.35; }
|
||||||
else { alpha = 4.0; beta = 0.4; }
|
else { alpha = 4.0; beta = 0.4; }
|
||||||
c = 0.0;
|
c = 0.0;
|
||||||
delta = 0.0;
|
delta = 0.0;
|
||||||
|
|||||||
Reference in New Issue
Block a user