DSP: convolve reverb streams on the host #240

Open
github-bot wants to merge 1 commit from github-bot/gh-240 into main AGit
Owner

@⁠Quat3rnion on GitHub · 2026-11-24 01:43 UTC · original
Quat3rnion:victory-dsp-reverb → main · +513 −10 · 3 files · 1 commits · open

What

DSP convolution streams returned silence because the impulse-response layout
was unknown. The Xbox docs describe it: frequency-domain complex pairs split
into filter blocks of blockFrameCount pairs, with an optional per-channel
stereo IR. This adds a portable partitioned FFT convolver that decodes that
layout and wires it into XDspSubmitCommand, so reverb returns are wet. FFT
and IFFT streams still return silence; their buffers are spectra, not audio.

The console does not store the Nyquist bin, so it is reconstructed by
conjugate symmetry. A unity impulse therefore comes back within about 0.2
percent instead of exactly, and the convolver allocates block scratch per
call; both are noted in the code.

An AI tool wrote part of this change.

Tested

  • Linux: cargo test --workspace with PR #112's Linux build fix applied locally (not part of this PR): 171 passed, 0 failed, 3 ignored. The convolution tests compare against direct time-domain convolution and exercise the API end to end.
  • Windows cross-build: cargo check --target x86_64-pc-windows-gnu --workspace --tests passes. The Windows-only tests were not run; there is no Windows host here.
  • Not tested: a real title or the console DSP hardware. The exact mapping of activation option bits 2 and 8 follows the existing stream test (bit 2 deinterleaved, bit 8 stereo IR).

Checklist

  • cargo fmt on the changed files; workspace tests and Windows cross-check pass as described.
  • cargo xtask policy passes (151 files ok). No game files or data from them were added.
  • AI authorship is disclosed above.
**@⁠Quat3rnion** on GitHub · 2026-11-24 01:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/240) `Quat3rnion:victory-dsp-reverb` → `main` · +513 −10 · 3 files · 1 commits · open ## What DSP convolution streams returned silence because the impulse-response layout was unknown. The Xbox docs describe it: frequency-domain complex pairs split into filter blocks of `blockFrameCount` pairs, with an optional per-channel stereo IR. This adds a portable partitioned FFT convolver that decodes that layout and wires it into `XDspSubmitCommand`, so reverb returns are wet. FFT and IFFT streams still return silence; their buffers are spectra, not audio. The console does not store the Nyquist bin, so it is reconstructed by conjugate symmetry. A unity impulse therefore comes back within about 0.2 percent instead of exactly, and the convolver allocates block scratch per call; both are noted in the code. An AI tool wrote part of this change. ## Tested - Linux: `cargo test --workspace` with PR #112's Linux build fix applied locally (not part of this PR): 171 passed, 0 failed, 3 ignored. The convolution tests compare against direct time-domain convolution and exercise the API end to end. - Windows cross-build: `cargo check --target x86_64-pc-windows-gnu --workspace --tests` passes. The Windows-only tests were not run; there is no Windows host here. - Not tested: a real title or the console DSP hardware. The exact mapping of activation option bits 2 and 8 follows the existing stream test (bit 2 deinterleaved, bit 8 stereo IR). ## Checklist - [x] `cargo fmt` on the changed files; workspace tests and Windows cross-check pass as described. - [x] `cargo xtask policy` passes (151 files ok). No game files or data from them were added. - [x] AI authorship is disclosed above.
The console supplies reverb impulse responses as partitioned frequency-domain complex pairs. Decode that layout into a portable partitioned convolver so convolution streams return wet audio instead of silence. FFT/IFFT streams still return silence. Add seven unit tests for the convolver and an end-to-end test through XDspActivate and XDspSubmitCommand.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:56:08 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 05:05 UTC · original

Thanks @⁠Quat3rnion for the host-side DSP convolution path. I tested the open PR at head 9f77a9a27d620ee5f88384f7f98c517f2d38741f with:

cargo test --locked -p victory-hle --lib dsp_convolve -- --test-threads=1

Result: 6 passed, 0 failed, 0 ignored. The tests cover FFT round-tripping, impulse response copying, block convolution against a direct reference, stereo channel separation, gain ramps/reset, and malformed layout/buffer rejection. This validates the synthetic convolution math and buffer handling; it does not measure behavior with a live title audio stream or real host audio device.

Code: dsp_convolve.rs, dsp.rs.

**@⁠jeremygold02** on GitHub · 2026-11-24 05:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/240#issuecomment-7122609745) Thanks @⁠Quat3rnion for the host-side DSP convolution path. I tested the open PR at head `9f77a9a27d620ee5f88384f7f98c517f2d38741f` with: ``` cargo test --locked -p victory-hle --lib dsp_convolve -- --test-threads=1 ``` Result: 6 passed, 0 failed, 0 ignored. The tests cover FFT round-tripping, impulse response copying, block convolution against a direct reference, stereo channel separation, gain ramps/reset, and malformed layout/buffer rejection. This validates the synthetic convolution math and buffer handling; it does not measure behavior with a live title audio stream or real host audio device. Code: [dsp_convolve.rs](https://github.com/Marvisak/VIctory/blob/9f77a9a27d620ee5f88384f7f98c517f2d38741f/crates/victory-hle/src/modules/dsp_convolve.rs), [dsp.rs](https://github.com/Marvisak/VIctory/blob/9f77a9a27d620ee5f88384f7f98c517f2d38741f/crates/victory-hle/src/modules/dsp.rs).
Author
Owner

@⁠Yaekai on GitHub · 2026-11-24 16:28 UTC · original

Independent test & review on Windows 11 (Rust 1.98.1) at head 723f4a2:

  • cargo test -p victory-hle --lib: 101 passed, 0 failed.
  • Live GTA VI (1.0.2.1, --console series-s): audio runs cleanly with no panics or crashes.
  • CI blocker (cargo clippy -p victory-hle -- -D warnings): fails with 5 lints in dsp_convolve.rs before merge:
    1. dead_code: method reset is never used
    2. dead_code: function encode_ir is never used
    3. undocumented_unsafe_blocks: unsafe block missing a safety comment
    4. needless_range_loop: the loop variable frame is used to index spectrum
    5. needless_range_loop: the loop variable bin is only used to index spectrum
**@⁠Yaekai** on GitHub · 2026-11-24 16:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/240#issuecomment-7137721227) Independent test & review on Windows 11 (Rust 1.98.1) at head `723f4a2`: - `cargo test -p victory-hle --lib`: 101 passed, 0 failed. - Live GTA VI (`1.0.2.1`, `--console series-s`): audio runs cleanly with no panics or crashes. - **CI blocker (`cargo clippy -p victory-hle -- -D warnings`)**: fails with 5 lints in `dsp_convolve.rs` before merge: 1. `dead_code`: `method reset is never used` 2. `dead_code`: `function encode_ir is never used` 3. `undocumented_unsafe_blocks`: `unsafe block missing a safety comment` 4. `needless_range_loop`: `the loop variable frame is used to index spectrum` 5. `needless_range_loop`: `the loop variable bin is only used to index spectrum`
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-24 17:41 UTC · original · edited 2026-11-24 18:26 UTC

Correction to my earlier comment: the CI run of this PR did run and fails on clippy. For reference, what cargo clippy -p victory-hle --all-targets --locked -- -D warnings reports on this PR merged onto main at ffe310e:

  • dsp_convolve.rs:173: method reset is never used (dead code)
  • dsp_convolve.rs:246: function encode_ir is never used (dead code)
  • dsp.rs:179: unsafe block missing a safety comment
  • dsp_convolve.rs:203 and :256: needless_range_loop (the loop variables only index spectrum)
  • dsp_convolve.rs:328: casting f32 to f32 is unnecessary (test build)

The tests pass. AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-24 17:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/240#issuecomment-7139568309) · edited 2026-11-24 18:26 UTC Correction to my earlier comment: the CI run of this PR did run and fails on clippy. For reference, what `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` reports on this PR merged onto `main` at `ffe310e`: - `dsp_convolve.rs:173`: method `reset` is never used (dead code) - `dsp_convolve.rs:246`: function `encode_ir` is never used (dead code) - `dsp.rs:179`: unsafe block missing a safety comment - `dsp_convolve.rs:203` and `:256`: `needless_range_loop` (the loop variables only index `spectrum`) - `dsp_convolve.rs:328`: casting `f32` to `f32` is unnecessary (test build) The tests pass. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:26 UTC · original

Automated triage for the maintainers.

Needs work. CI fails on clippy in crates/victory-hle/src/modules/dsp_convolve.rs (needless_range_loop around line 256, unnecessary_cast at line 328, and others).

Beyond that, this changes emulation behaviour without stated evidence: the impulse-response layout Convolver::new decodes (complex pairs in blocks of frames, the Nyquist bin dropped, one run per channel with option bit 8) is asserted, while main's module doc in dsp.rs says the layout is unknown. The new checks in valid() also change the activation call's return values, and the tests use the PR's own encode_ir, so they only check that the code agrees with itself. Please cite public documentation for the layout or show it against the title's own data, and reword the comment that uses an identifier copied from the console SDK headers.

CI: failing (clippy).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/240#issuecomment-7148518583) <!-- victory-triage v1 head=723f4a296a00aebc416d60747f04e5c796ee0675 verdict=needs-work at=2026-11-25T00:18:46Z --> Automated triage for the maintainers. **Needs work.** CI fails on clippy in `crates/victory-hle/src/modules/dsp_convolve.rs` (`needless_range_loop` around line 256, `unnecessary_cast` at line 328, and others). Beyond that, this changes emulation behaviour without stated evidence: the impulse-response layout `Convolver::new` decodes (complex pairs in blocks of `frames`, the Nyquist bin dropped, one run per channel with option bit 8) is asserted, while main's module doc in `dsp.rs` says the layout is unknown. The new checks in `valid()` also change the activation call's return values, and the tests use the PR's own `encode_ir`, so they only check that the code agrees with itself. Please cite public documentation for the layout or show it against the title's own data, and reword the comment that uses an identifier copied from the console SDK headers. CI: failing (clippy). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠kais7654 on GitHub · 2026-11-25 14:44 UTC · original

The check job fails on clippy -D warnings: five warnings in the new
code, no test failure. Rebased onto main 940d32f's layout with the
fixes and opened a PR: the needless_range_loop pair, reset and
encode_ir marked cfg(test) (their only callers are tests), the IR
slice's SAFETY note moved against its unsafe block, and a doubled cast.
Your convolution tests all pass on a Windows host (victory-hle: 150/0),
so the change itself is sound — the head was one clippy pass away.

AI-assisted (Mistral Vibe).

**@⁠kais7654** on GitHub · 2026-11-25 14:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/240#issuecomment-7165739776) The check job fails on clippy -D warnings: five warnings in the new code, no test failure. Rebased onto main 940d32f's layout with the fixes and opened a PR: the needless_range_loop pair, `reset` and `encode_ir` marked cfg(test) (their only callers are tests), the IR slice's SAFETY note moved against its unsafe block, and a doubled cast. Your convolution tests all pass on a Windows host (victory-hle: 150/0), so the change itself is sound — the head was one clippy pass away. AI-assisted (Mistral Vibe).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/240/head:github-bot/gh-240'
git switch 'github-bot/gh-240'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-240'
git switch 'github-bot/gh-240'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-240'
git switch 'github-bot/gh-240'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-240'
git switch 'main'
git merge --squash 'github-bot/gh-240'
git switch 'main'
git merge --ff-only 'github-bot/gh-240'
git switch 'main'
git merge 'github-bot/gh-240'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!240
No description provided.