Implement standalone CPU convolution in chad.dll DSP #1

Manually merged
github merged 1 commit from gh-pr/1/head into gh-pr/1/base 2026-12-05 17:21:16 +00:00
Owner

@⁠Logard0 on GitHub · 2026-12-05 11:57 UTC · original
Logard0:fix/chad-cpu-convolution → main · +394 −11 · 1 files · 1 commits · merged 2026-12-05 14:45 UTC

Implements standalone CPU partitioned frequency-domain convolution in chad.dll (crates/larp-hle/src/modules/dsp.rs) for mono 1024-sample convolution streams, replacing the silence-only stub while preserving the guest ABI and status publication ordering.

Summary of changes

  • IR parsing (ConvolutionState::from_desc): Parses 2048-float partitions of interleaved complex bins (1024 positive bins per partition) and skips the final partition if its first word is 0xFFFFACE1.
  • Frequency-domain convolution (ConvolutionState::process): Zero-pads each 1024-sample input block to 2048, runs an in-place radix-2 DIT FFT, pushes positive bins into a spectrum ring buffer, accumulates X[t - k] * IR[k], zeroes Nyquist (bin 1024), mirrors conjugate bins (1025..2047), runs an unnormalized inverse FFT, and outputs samples 1024..2047 scaled by 2 / 2048 and the linear command.gains[0]..gains[1] ramp.
  • ABI & completion ordering (XDspSubmitCommand): Preserves all guest structs/signatures, outputs silence for unsupported stream modes, and issues a Release fence after writing output before publishing status.completed.
  • Unit tests: Added unit tests covering bin scaling + gain ramp, 0xFFFFACE1 sentinel handling, multi-partition spectrum ring delay, and silence/completion for unsupported modes.

Verification

  • cargo test --locked -p larp-hle dsp: 4 passed, 0 failed
  • cargo clippy --locked --tests -p larp-hle: 0 warnings in dsp.rs

Made with the help of Gemini 4 Neon.

**@⁠Logard0** on GitHub · 2026-12-05 11:57 UTC · [original](https://github.com/gamingwithhomie/larp/pull/1) `Logard0:fix/chad-cpu-convolution` → `main` · +394 −11 · 1 files · 1 commits · merged 2026-12-05 14:45 UTC Implements standalone CPU partitioned frequency-domain convolution in `chad.dll` (`crates/larp-hle/src/modules/dsp.rs`) for mono 1024-sample convolution streams, replacing the silence-only stub while preserving the guest ABI and status publication ordering. ### Summary of changes - **IR parsing (`ConvolutionState::from_desc`):** Parses 2048-float partitions of interleaved complex bins (`1024` positive bins per partition) and skips the final partition if its first word is `0xFFFFACE1`. - **Frequency-domain convolution (`ConvolutionState::process`):** Zero-pads each 1024-sample input block to 2048, runs an in-place radix-2 DIT FFT, pushes positive bins into a spectrum ring buffer, accumulates `X[t - k] * IR[k]`, zeroes Nyquist (`bin 1024`), mirrors conjugate bins (`1025..2047`), runs an unnormalized inverse FFT, and outputs samples `1024..2047` scaled by `2 / 2048` and the linear `command.gains[0]..gains[1]` ramp. - **ABI & completion ordering (`XDspSubmitCommand`):** Preserves all guest structs/signatures, outputs silence for unsupported stream modes, and issues a `Release` fence after writing output before publishing `status.completed`. - **Unit tests:** Added unit tests covering bin scaling + gain ramp, `0xFFFFACE1` sentinel handling, multi-partition spectrum ring delay, and silence/completion for unsupported modes. ### Verification - `cargo test --locked -p larp-hle dsp`: 4 passed, 0 failed - `cargo clippy --locked --tests -p larp-hle`: 0 warnings in `dsp.rs` Made with the help of Gemini 4 Neon.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 17:21:13 +00:00
github manually merged commit 7bf92cb8e5 into gh-pr/1/base 2026-12-05 17:21:16 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.