2 months ago
ec4f86fImplement the pure DSP layer of openkara.spectral-contract/v1 (issue #172 PR 1): a native FFT port of the float64 numpy reference that defines the waveform<->spectral transform semantics of the shipped HTDemucs graphs. - Add `realfft` (already resolved transitively via rubato; pure Rust, MIT/Apache-2.0, cargo-deny clean) as a direct dependency. - New `separator::spectral` module with reusable `SpectralPlans` (forward/inverse FFT plans, periodic-Hann window, ISTFT window-square envelope, and scratch buffers created once and reused): `spec`, `ispec`, and the `magnitude` neural-core view helper, plus the contract constants and `SPECTRAL_CONTRACT_VERSION`. - Transforms run in f64 internally and cast to f32 at the boundary, landing far under the 1e-3 fp32 contract gate (worst achieved max-abs: spec/mag 1.2e-10, ispec 7.3e-12 across the golden fixtures). - Torch/numpy-style reflect padding (no repeated edge sample; repeated reflection for very short inputs is documented as out of the validated regime). - Commit the five digest-pinned golden `.npz` fixtures plus spectral-golden-v1.json / manifest.json under tests/fixtures/spectral/. - `tests/phase7_spectral.rs` verifies every fixture's SHA-256 before use and validates spec / magnitude / ispec against the golden vectors; unit tests cover window periodicity, the COLA envelope, envelope clamp, reflect-pad edge cases, shape math, and plan reuse. - Document the native contract in docs/references/contracts/spectral.md. No production model / ORT session path in this PR (issue #172 PR 2, blocked on openkara-models#23). Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Parentbd90d76