P4: multi-band FramedDetector (per-band twin res, sens-scaled GAIN, min-combine); tt_base 61.40%; min-combine wrong (soothe2 uses additive accumulator 0x5407c8)
This commit is contained in:
+19
-16
@@ -3,34 +3,37 @@
|
||||
#include <complex>
|
||||
#include <vector>
|
||||
|
||||
struct DetectorBand {
|
||||
float fc; // band center freq (Hz)
|
||||
float q; // resonance Q
|
||||
float sens; // XML sens (dB); internal sens_stored = sens * 2.054
|
||||
};
|
||||
|
||||
// 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)
|
||||
// Multi-band: each active band contributes gain_k = (1-C_k)*res_k^rp,
|
||||
// final mask = min over bands (max suppression).
|
||||
// res_k[f] = |2B(z)/A(z)| (twin resonance, sens-scaled GAIN)
|
||||
// am = 2|X_k|/wsum (smoothed per-bin amplitude)
|
||||
// xv_k = log10(am / res_k)
|
||||
// C_k = G_FIT*LUT(xv_k) + W_FIT*warp(f)^A_FIT
|
||||
// gain_k = max(1-C_k, eps) * res_k^(rp0*Q_k^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);
|
||||
void setParams(const std::vector<DetectorBand>& bands);
|
||||
|
||||
// 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_;
|
||||
std::vector<DetectorBand> bands_;
|
||||
std::vector<std::vector<float>> res_; // per band, per bin |2B/A|
|
||||
std::vector<float> warp_; // per-bin warp tilt
|
||||
std::vector<float> am_; // smoothed per-bin amplitude
|
||||
std::vector<float> rp_; // per-band res power
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user