P4: port framed_render.py model to C++ (FramedDetector: twin-res -> level -> Pchip LUT -> warp -> res^rp gain), replace empirical Detector; tt_base 49.93%->61.45% (single-band); multi-band refs still 100% (model is single-band)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include <complex>
|
||||
#include <vector>
|
||||
|
||||
// FramedDetector — C++ port of framed_render.py (Phase 5 pilot, mean=0.175 dB).
|
||||
// Per-frame per-bin mask:
|
||||
// res[f] = |2B(z)/A(z)| (twin resonance, detkernel::twin)
|
||||
// am = 2|X_k|/wsum (per-bin input amplitude, smoothed attack/release)
|
||||
// xv = log10(am / res)
|
||||
// C = G_FIT*LUT(xv) + W_FIT*warp(f)^A_FIT
|
||||
// gain = max(1-C, eps) * res^(rp0*Q^drp)
|
||||
class FramedDetector {
|
||||
public:
|
||||
FramedDetector(size_t nfft, float sample_rate);
|
||||
~FramedDetector();
|
||||
|
||||
// fc = band center freq, q = resonance Q (>=1). Precomputes res[] + warp[].
|
||||
void setParams(float fc, float q);
|
||||
|
||||
// spectrum = forward FFT of one windowed frame (nfft/2+1 bins used).
|
||||
// mask output = per-bin complex gain (nfft entries, mirror applied).
|
||||
void processFrame(const std::complex<double>* spectrum, float* mask);
|
||||
|
||||
private:
|
||||
size_t nfft_;
|
||||
float sample_rate_;
|
||||
float fc_;
|
||||
float q_;
|
||||
double wsum_;
|
||||
|
||||
std::vector<float> res_; // per-bin |2B/A|
|
||||
std::vector<float> warp_; // per-bin warp tilt
|
||||
std::vector<float> am_; // smoothed per-bin amplitude state
|
||||
bool inited_;
|
||||
};
|
||||
Reference in New Issue
Block a user