46 lines
1.8 KiB
C++
46 lines
1.8 KiB
C++
#pragma once
|
|
// FAITHFUL mask-shaping chain (22w) — transcription of FUN_180529fe0 per
|
|
// handoff/BLOCKMAP_529fe0.md (raw asm). Replaces process_band_structural
|
|
// when RT_FAITHFUL=1.
|
|
//
|
|
// band = lvl * s (s = RT_FAITH_SCALE, decomp: /0x1a0*0x870*0x88c)
|
|
// mask = exp2(-band) (bigkernel exp2 family)
|
|
// bidir(mask, A); bidir(mask, A) // states reset each pass (52d650 + inline)
|
|
// bidir(mask, B) // pass #3
|
|
// bidir(mask, C); bidir(mask, C) // pass #4 x2
|
|
// mirror upper half; dry/wet identity.
|
|
//
|
|
// Bidirectional one-pole per FUN_18052d650: acc = up[i]*acc + down[i]*x[i],
|
|
// forward over all bins, backward n-2..1 with persistent acc, reset per call.
|
|
// Coefficients per FUN_180533340 (freq-warped): fc_bin = C/(sr/2)*nbin;
|
|
// g = fc/i below crossover, powf(fc/i, p) above; c = 1/(g*tau/mult+1);
|
|
// up[i] = exp(-2*pi*kappa*c*g*tau), down[i] = 1-up[i].
|
|
//
|
|
// Decoded defaults (FUN_180530b60 log-interp @ live 0x540878/87c = 0.5):
|
|
// setA/B tau=19.03 mult=360 ; set3/set4 tau=10.68 mult=2400 ; p=0.822 ;
|
|
// C=1000 Hz ; kappa = 1/T8 ~ 0.0094 (T8 unknown -> env).
|
|
|
|
#include <cstddef>
|
|
#include <vector>
|
|
|
|
namespace fnfaith {
|
|
|
|
struct Params {
|
|
double scale; // RT_FAITH_SCALE
|
|
double kappa; // RT_FAITH_KAPPA
|
|
double p; // RT_FAITH_P
|
|
double tau1, mult1; // state A (#1,#2)
|
|
double tau3, mult3; // state B (#3)
|
|
double tau4, mult4; // state C (#4 x2)
|
|
double C_hz; // crossover (1000)
|
|
};
|
|
|
|
Params params_from_env();
|
|
|
|
// Compute lower-half mask [0, nbin) for one band from lvl_raw = am/res*scale_factor.
|
|
void band_mask_faithful(const float* am, const float* res, size_t nbin,
|
|
float sample_rate, float scale_factor, const Params& pr,
|
|
float* mask_out /* nbin */);
|
|
|
|
} // namespace fnfaith
|