Audio DSP: compute mono convolutions, so TVs, phone calls and reverb are heard #1491

Open
Omnicrash wants to merge 1 commit from upstream-pr/1491 into main
Omnicrash commented 2026-11-27 16:54:10 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Omnicrash on 2026-11-27T16:54:10Z.


The title sends the sound of speakers in the world (TVs, phone calls) through the audio DSP (chad.dll) alone, and its reverb sends go through it too. The DSP's outputs were zeros, so TVs and phone calls were silent and reverb was dry. This computes the DSP's mono convolutions on the CPU. Fixes fxceless/victory-fork#1470.

What is in it

  • crates/victory-hle/src/modules/dsp/convolve.rs: a uniformly partitioned FFT convolution that reads the title's impulse responses in the coprocessor's layout: blocks of 2048 floats, each the unscaled 2048-point FFT of a 2048-sample window of the response (window k covers samples (k-1)*1024 .. (k+1)*1024), bins 0-1023 interleaved re/im, then a schedule block that starts with 0xFFFFACE1. I read the layout from the responses the retail title passes to XDspActivate: under that reading, the time-domain halves of every pair of neighbouring blocks match, across all 21 responses dumped. Streams whose inputs have been silent for a whole response cost nothing.
  • crates/victory-hle/src/modules/dsp.rs: mono convolution streams of 1024-frame blocks get a convolver at activation; XDspSubmitCommand writes the convolution instead of zeros. VICTORY_DSP_CONVOLVE=0 turns it off. VICTORY_DSP_GAIN scales the output (default 2, see below).
  • Tests: a sample-by-sample comparison with a direct convolution across five blocks, a silent ring giving silence, and a mono stream driven through XDspActivate / XDspSubmitCommand.

Tested

  • RTX 3090, Windows, Rust 1.98.1, release build (LTO, x86-64-v3), Series X profile, in the open world, a TV indoors and a phone call
  • In one session the title opened 127 DSP streams, all kind=1, mono, 1024 frames, responses of 19 to 103 windows. All of them were computed (computed=true in the debug log). TVs and phone calls are heard, with their speaker colouring, and reverb comes back.
  • cargo test --locked -p victory-hle --lib: 174 passed, 0 failed, 2 ignored (on this repo's main with the commit on top)

Not tested

  • The level. How the hardware scales its result is not known. With the textbook 1/2048 of the inverse FFT, TVs and phone calls sounded quiet next to the rest of the mix, so the default is 2x, picked by ear at a TV. The same factor raises every reverb in the game, because both go through the same DSP streams. I have not checked the reverb level inside buildings or under bridges against dialogue and music at 2x; it may come out too strong. VICTORY_DSP_GAIN changes it without a rebuild.
  • Stereo convolutions, 512-frame blocks and the other block transform (kind 2): the title did not use them, and they still give zeros.
  • AMD and Intel GPUs (the change is CPU-side only), and the CPU cost on slower CPUs (up to about 100k complex multiply-adds per stream block for the longest responses).

AI use

  • Claude Code with Claude Opus 5.5: found the cause, worked out the layout from the dumps, wrote the code, the tests and this description. I listened to the result in game.
<!-- greyfinch-sync:fxceless/victory-fork:issue:5530243438 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1491). Originally posted by [Omnicrash](https://github.com/Omnicrash) on 2026-11-27T16:54:10Z. --- The title sends the sound of speakers in the world (TVs, phone calls) through the audio DSP (`chad.dll`) alone, and its reverb sends go through it too. The DSP's outputs were zeros, so TVs and phone calls were silent and reverb was dry. This computes the DSP's mono convolutions on the CPU. Fixes fxceless/victory-fork#1470. **What is in it** - `crates/victory-hle/src/modules/dsp/convolve.rs`: a uniformly partitioned FFT convolution that reads the title's impulse responses in the coprocessor's layout: blocks of 2048 floats, each the unscaled 2048-point FFT of a 2048-sample window of the response (window k covers samples (k-1)\*1024 .. (k+1)\*1024), bins 0-1023 interleaved re/im, then a schedule block that starts with `0xFFFFACE1`. I read the layout from the responses the retail title passes to `XDspActivate`: under that reading, the time-domain halves of every pair of neighbouring blocks match, across all 21 responses dumped. Streams whose inputs have been silent for a whole response cost nothing. - `crates/victory-hle/src/modules/dsp.rs`: mono convolution streams of 1024-frame blocks get a convolver at activation; `XDspSubmitCommand` writes the convolution instead of zeros. `VICTORY_DSP_CONVOLVE=0` turns it off. `VICTORY_DSP_GAIN` scales the output (default 2, see below). - Tests: a sample-by-sample comparison with a direct convolution across five blocks, a silent ring giving silence, and a mono stream driven through `XDspActivate` / `XDspSubmitCommand`. **Tested** - RTX 3090, Windows, Rust 1.98.1, release build (LTO, x86-64-v3), Series X profile, in the open world, a TV indoors and a phone call - In one session the title opened 127 DSP streams, all `kind=1`, mono, 1024 frames, responses of 19 to 103 windows. All of them were computed (`computed=true` in the debug log). TVs and phone calls are heard, with their speaker colouring, and reverb comes back. - `cargo test --locked -p victory-hle --lib`: 174 passed, 0 failed, 2 ignored (on this repo's main with the commit on top) **Not tested** - **The level.** How the hardware scales its result is not known. With the textbook 1/2048 of the inverse FFT, TVs and phone calls sounded quiet next to the rest of the mix, so the default is 2x, picked by ear at a TV. The same factor raises every reverb in the game, because both go through the same DSP streams. I have not checked the reverb level inside buildings or under bridges against dialogue and music at 2x; it may come out too strong. `VICTORY_DSP_GAIN` changes it without a rebuild. - Stereo convolutions, 512-frame blocks and the other block transform (`kind` 2): the title did not use them, and they still give zeros. - AMD and Intel GPUs (the change is CPU-side only), and the CPU cost on slower CPUs (up to about 100k complex multiply-adds per stream block for the longest responses). **AI use** - Claude Code with Claude Opus 5.5: found the cause, worked out the layout from the dumps, wrote the code, the tests and this description. I listened to the result in game.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1491:upstream-pr/1491'
git switch 'upstream-pr/1491'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1491'
git switch 'upstream-pr/1491'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1491'
git switch 'upstream-pr/1491'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1491'
git switch 'main'
git merge --squash 'upstream-pr/1491'
git switch 'main'
git merge --ff-only 'upstream-pr/1491'
git switch 'main'
git merge 'upstream-pr/1491'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
fxceless/victory-fork!1491
No description provided.