dsp: compute the coprocessor's convolutions (room reverbs, the phone speaker) on a thread of their own #497

Open
github-bot wants to merge 3 commits from github-bot/gh-497 into main AGit
Owner

@⁠PimpMastre on GitHub · 2026-12-04 18:41 UTC · original
PimpMastre:dsp-convolution-reverb → main · +942 −35 · 2 files · 3 commits · open

Problem

The audio DSP's convolutions (chad.dll) are not computed. On main, a convolution whose response has at most 65,536 floats passes its input through at 5x and hard-clipped (b69806a, for callers' voices), and every other output is silence. Indoors this puts a second, louder copy of the dry sound on top of it, so dialogue and footsteps sound doubled. Reverbs are dry, and the phone speaker carries the clean voice with no speaker filter.

The response layout

Read from the title's own responses. VICTORY_DSP_DUMP=1 writes every distinct response a stream is activated with to <data>/dsp-dump.

  • Block k (2048 floats) is the 2048-point spectrum of the response's samples (k-1)*1024 .. (k+1)*1024. The first half of block 0 is zeros.
  • Bins 0 to 1023 are stored as interleaved real and imaginary parts. There is no Nyquist bin.
  • A footer block follows, whose first word is 0xFFFFACE1.

Read that way, the overlapping halves of neighbouring blocks agree to float rounding on all 27 responses one play activated. The speaker filters peak at exactly 1.0. The phone filter's gain in the voice band (about +10 dB) also explains why the pass-through needed 5x. The VIctory-xmem-RDNA3 fork arrived at the same layout independently, from 49 responses.

Change

  • Each 1024-frame input block is transformed zero-padded, multiplied with every response block against the input block it lines up with, and the second half of the inverse becomes the output block. This is the convolution with no latency of its own.
  • Mono 1024-frame streams are convolved, which is every stream the title activates. Other shapes, and VICTORY_DSP_REVERB=0, keep #457's rule: speaker filters, recognised by their shape, pass through, and rooms are dry.
  • The work runs on a "victory DSP" thread at time-critical priority, as the console's DSP runs beside the processor. XDspSubmitCommand copies the input block and queues the command. The thread writes the output and completes the command, well inside the block the title waits before it checks. Deactivation waits for a stream's queued commands. Run inside the call instead, it added a few percent of a core to the title's mixer thread.
  • If the audio threads PR (#149) lands, its rules (time-critical, 100+ wakeups a second, under 15 % of a core) also cover this thread.

Overlap with #457

This includes #457's speaker-shape rule and its bounded read of the response (credit to @⁠niiniiniintje), because they are the fallback here. If #457 is merged first, this rebases onto it. Otherwise this replaces it.

Measured

  • On three of the title's responses (two rooms and the phone), the block-by-block output matches a time-domain convolution with the decoded response to 0.03 to 0.1 %.
  • The longest room seen (104 blocks, 2.2 s) costs about 160 µs per 21.3 ms block. The DSP thread used about 5 % of a core in play.
  • Unit tests, all passing under Wine:
    • the transform against a direct DFT;
    • block-by-block output against a direct convolution, with silences longer than the response between sounds;
    • a mono stream through the title's calls and the DSP thread;
    • responses that are refused (none, footer only, not finite).
  • cargo clippy shows no warnings in dsp.rs, and rustfmt is clean.
  • In play on an RX 7900 XTX (CachyOS, Proton-CachyOS): rooms and car interiors have reverb, speech indoors is no longer doubled, and phone calls get the speaker filter.

Settings

Setting Effect
VICTORY_DSP_REVERB=0 Convolutions are not computed (#457's rule)
VICTORY_DSP_DUMP=1 Writes the responses and logs activations, for checking the layout

🤖 Generated with Claude Code

**@⁠PimpMastre** on GitHub · 2026-12-04 18:41 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/497) `PimpMastre:dsp-convolution-reverb` → `main` · +942 −35 · 2 files · 3 commits · open ## Problem The audio DSP's convolutions (`chad.dll`) are not computed. On `main`, a convolution whose response has at most 65,536 floats passes its input through at 5x and hard-clipped (b69806a, for callers' voices), and every other output is silence. Indoors this puts a second, louder copy of the dry sound on top of it, so dialogue and footsteps sound doubled. Reverbs are dry, and the phone speaker carries the clean voice with no speaker filter. ## The response layout Read from the title's own responses. `VICTORY_DSP_DUMP=1` writes every distinct response a stream is activated with to `<data>/dsp-dump`. - Block `k` (2048 floats) is the 2048-point spectrum of the response's samples `(k-1)*1024 .. (k+1)*1024`. The first half of block 0 is zeros. - Bins 0 to 1023 are stored as interleaved real and imaginary parts. There is no Nyquist bin. - A footer block follows, whose first word is `0xFFFFACE1`. Read that way, the overlapping halves of neighbouring blocks agree to float rounding on all 27 responses one play activated. The speaker filters peak at exactly 1.0. The phone filter's gain in the voice band (about +10 dB) also explains why the pass-through needed 5x. The VIctory-xmem-RDNA3 fork arrived at the same layout independently, from 49 responses. ## Change - Each 1024-frame input block is transformed zero-padded, multiplied with every response block against the input block it lines up with, and the second half of the inverse becomes the output block. This is the convolution with no latency of its own. - Mono 1024-frame streams are convolved, which is every stream the title activates. Other shapes, and `VICTORY_DSP_REVERB=0`, keep #457's rule: speaker filters, recognised by their shape, pass through, and rooms are dry. - The work runs on a "victory DSP" thread at time-critical priority, as the console's DSP runs beside the processor. `XDspSubmitCommand` copies the input block and queues the command. The thread writes the output and completes the command, well inside the block the title waits before it checks. Deactivation waits for a stream's queued commands. Run inside the call instead, it added a few percent of a core to the title's mixer thread. - If the audio threads PR (#149) lands, its rules (time-critical, 100+ wakeups a second, under 15 % of a core) also cover this thread. ## Overlap with #457 This includes #457's speaker-shape rule and its bounded read of the response (credit to @⁠niiniiniintje), because they are the fallback here. If #457 is merged first, this rebases onto it. Otherwise this replaces it. ## Measured - On three of the title's responses (two rooms and the phone), the block-by-block output matches a time-domain convolution with the decoded response to 0.03 to 0.1 %. - The longest room seen (104 blocks, 2.2 s) costs about 160 µs per 21.3 ms block. The DSP thread used about 5 % of a core in play. - Unit tests, all passing under Wine: - the transform against a direct DFT; - block-by-block output against a direct convolution, with silences longer than the response between sounds; - a mono stream through the title's calls and the DSP thread; - responses that are refused (none, footer only, not finite). - `cargo clippy` shows no warnings in `dsp.rs`, and `rustfmt` is clean. - In play on an RX 7900 XTX (CachyOS, Proton-CachyOS): rooms and car interiors have reverb, speech indoors is no longer doubled, and phone calls get the speaker filter. ## Settings | Setting | Effect | |---|---| | `VICTORY_DSP_REVERB=0` | Convolutions are not computed (#457's rule) | | `VICTORY_DSP_DUMP=1` | Writes the responses and logs activations, for checking the layout | 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The audio DSP's convolutions were not computed: a convolution with at most
65536 response floats passed its input through 5x louder (b69806a, for
callers' voices), every other output was silence. Indoors that put a
second, louder copy of the dry sound on top of it (the doubled dialogue and
footsteps), and reverbs were dry.

The response layout, read from the title's own responses (VICTORY_DSP_DUMP=1
writes them): block k is the 2048-point spectrum of the response's samples
(k-1)*1024 .. (k+1)*1024, the first half of block 0 zeros, bins 0 to 1023
as interleaved real and imaginary parts (no Nyquist bin), then a footer
block whose first word is 0xFFFFACE1. Read that way, the overlapping halves
of neighbouring blocks agree to float rounding on all 27 responses one play
activated, and the speaker filters peak at exactly 1.0.

Each 1024-frame input block is transformed zero-padded, multiplied with
every response block against the input block it lines up with, and the
second half of the inverse is the output block: the convolution with no
latency of its own. On three of the title's responses this matches a
time-domain convolution with the decoded response to 0.03-0.1 %. The
longest room seen (104 blocks, 2.2 s) costs about 160 us a block of
21.3 ms.

The work runs on a "victory DSP" thread at time-critical priority, as the
console's runs beside the processor: XDspSubmitCommand copies the input
block and queues the command; the thread writes the output and completes
it, well inside the block the title waits before it checks. Deactivation
waits for a stream's queued commands. Run in the call, it added a few
percent of a core to the title's mixer thread.

Mono 1024-frame convolutions are computed (all the title activates). Other
shapes, and VICTORY_DSP_REVERB=0, keep #457's rule (speaker filters by
their shape pass through, rooms are dry), which this includes.

Tested: unit tests for the transform against a DFT, block-by-block output
against a direct convolution, the title's calls through the thread, and
refused responses; in play, reverb indoors and the phone filter on calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 18:41:54 +00:00
Author
Owner

@⁠Bushyon on GitHub · 2026-12-04 19:18 UTC · original · edited 2026-12-04 19:42 UTC

tried it Fedora 44, Proton Experimental, merged with b2449c4: sound is better and the volume sliders work for me (they didn't yesterday on main)

**@⁠Bushyon** on GitHub · 2026-12-04 19:18 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/497#issuecomment-7421682308) · edited 2026-12-04 19:42 UTC tried it Fedora 44, Proton Experimental, merged with b2449c4: sound is better and the volume sliders work for me (they didn't yesterday on main)
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 19:22 UTC · original

Checked cc2542d on native Windows (didn't run the game, no game data, so this checks the math against the layout as described in the PR, not the layout itself).

cargo test -p victory-hle --lib gives 168 passed, 2 ignored on the PR and 162 passed, 1 ignored on main. The difference is exactly the new dsp tests. Clippy prints the same warnings on both and none of them are in dsp.rs. The branch merges cleanly onto current main.

I wrote a throwaway test (not pushed) that lays out responses with its own f64 FFT, runs Convolver block by block and compares against a direct f64 convolution. Cases were single taps at 0 to 5000 including every block edge, decaying noise, a 4.5 block room with silences of parts-1, parts and parts+1 blocks between sounds, and the max size the bound allows (255 partitions plus footer, run long enough for the ring to wrap).

  • The output is aligned. A tap at 0 gives output block b from input block b, no extra block of delay.
  • The only difference from the true convolution is the missing Nyquist bin. Once I subtract that term ((1/M)(-1)^n times the sum over k of X[N]H_k[N]), what's left is 2e-7 to 3e-6 in every case, max size and gaps included, so the quiet shortcut doesn't cut tails.
  • How big that term is depends on the signal. With white noise in, 0.9 to 3% of peak. With a 1 kHz sine, about 0.04%. With a lowpassed room and white input, about 0.06%, which is in the same range as the 0.03 to 0.1% in the PR.
  • One thing worth checking in the dumps is whether the imaginary slot of bin 0 is ever non-zero, since some packed real FFTs keep Nyquist there. run zeroes it (dsp.rs:815).
  • If the first half of block 0 is not zero, those samples act as a pre-echo that only reaches within the same block, so the output stops being time-invariant. That's fine as long as it's always zero, as you found. A debug log if it ever isn't might be worth adding.
  • Two streams interleaved through XDspSubmitCommand with different responses each match their own reference, so the state is per stream. Each activation builds a fresh convolver, so nothing carries over on reactivate.

A response with no footer still convolves correctly. A footer that isn't last, an odd size, a footer only, a size over the bound, or a NaN in the response all get no convolver and no pass, so the output is silence. A NaN or Inf in the input gets past the != 0.0 check (dsp.rs:768), makes exactly parts output blocks non-finite, and then the stream recovers.

Only mono 1024-frame streams are convolved (dsp.rs:456). The existing test still has a comment saying the title asks for a stereo convolution with option 2 (dsp.rs:1110), while the body says every stream it activates is mono 1024. Is that comment just old?

  • There is one global thread fed by an unbounded mpsc channel (dsp.rs:256-284). It sleeps in recv when idle, so it doesn't spin.
  • When the thread falls behind, the caller doesn't block. With the worker stalled on purpose, 3 submits took 90 µs and completed stayed at 0, so the title sees an overrun and the output is written late.
  • completed can go backwards. A command with a null output on a convolving stream skips the queue and completes at once (dsp.rs:595 falls through to 633). With 3 commands queued I saw completed go to 4, then back to 3 when the worker drained. The title probably never does this, but not completing while pending > 0 would close it.
  • XDspDeactivate gives up after 500 ms (dsp.rs:511-517). With a job held past that, deactivate returned and the job then wrote into the output buffer, which in the game could already be freed or belong to a new stream. It's unlikely with jobs this short, but waiting without a limit, or having the job check a cancelled flag before writing, would be safer.
  • Small one. The doc comment on reverb_on (dsp.rs:524-525) says "as before they were", but VICTORY_DSP_REVERB=0 gives #457's rule, not main's size rule.
Response Per block
3 parts (phone-sized) 28 µs
30 parts 53 µs
104 parts (longest seen) 132 µs
255 parts (max) 249 µs
Silent input after the tail 0.2 µs

That leaves room for about 160 streams of the longest room per 21.3 ms block on the one thread, so it keeps up easily.

This PR carries #457's code unchanged. Whichever lands second conflicts in dsp.rs. SETTINGS.md merges by itself, but #457's paragraph saying convolutions are not computed would be wrong once this one is in.

Overall the convolution looks right for the layout as described. The deactivate timeout and the backwards ticket are the two things I'd look at.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 19:22 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/497#issuecomment-7421768176) Checked cc2542d on native Windows (didn't run the game, no game data, so this checks the math against the layout as described in the PR, not the layout itself). `cargo test -p victory-hle --lib` gives 168 passed, 2 ignored on the PR and 162 passed, 1 ignored on main. The difference is exactly the new dsp tests. Clippy prints the same warnings on both and none of them are in dsp.rs. The branch merges cleanly onto current main. I wrote a throwaway test (not pushed) that lays out responses with its own f64 FFT, runs `Convolver` block by block and compares against a direct f64 convolution. Cases were single taps at 0 to 5000 including every block edge, decaying noise, a 4.5 block room with silences of parts-1, parts and parts+1 blocks between sounds, and the max size the bound allows (255 partitions plus footer, run long enough for the ring to wrap). - The output is aligned. A tap at 0 gives output block b from input block b, no extra block of delay. - The only difference from the true convolution is the missing Nyquist bin. Once I subtract that term ((1/M)(-1)^n times the sum over k of X[N]H_k[N]), what's left is 2e-7 to 3e-6 in every case, max size and gaps included, so the quiet shortcut doesn't cut tails. - How big that term is depends on the signal. With white noise in, 0.9 to 3% of peak. With a 1 kHz sine, about 0.04%. With a lowpassed room and white input, about 0.06%, which is in the same range as the 0.03 to 0.1% in the PR. - One thing worth checking in the dumps is whether the imaginary slot of bin 0 is ever non-zero, since some packed real FFTs keep Nyquist there. `run` zeroes it (dsp.rs:815). - If the first half of block 0 is not zero, those samples act as a pre-echo that only reaches within the same block, so the output stops being time-invariant. That's fine as long as it's always zero, as you found. A debug log if it ever isn't might be worth adding. - Two streams interleaved through `XDspSubmitCommand` with different responses each match their own reference, so the state is per stream. Each activation builds a fresh convolver, so nothing carries over on reactivate. A response with no footer still convolves correctly. A footer that isn't last, an odd size, a footer only, a size over the bound, or a NaN in the response all get no convolver and no pass, so the output is silence. A NaN or Inf in the input gets past the `!= 0.0` check (dsp.rs:768), makes exactly `parts` output blocks non-finite, and then the stream recovers. Only mono 1024-frame streams are convolved (dsp.rs:456). The existing test still has a comment saying the title asks for a stereo convolution with option 2 (dsp.rs:1110), while the body says every stream it activates is mono 1024. Is that comment just old? - There is one global thread fed by an unbounded mpsc channel (dsp.rs:256-284). It sleeps in `recv` when idle, so it doesn't spin. - When the thread falls behind, the caller doesn't block. With the worker stalled on purpose, 3 submits took 90 µs and `completed` stayed at 0, so the title sees an overrun and the output is written late. - `completed` can go backwards. A command with a null output on a convolving stream skips the queue and completes at once (dsp.rs:595 falls through to 633). With 3 commands queued I saw `completed` go to 4, then back to 3 when the worker drained. The title probably never does this, but not completing while `pending > 0` would close it. - `XDspDeactivate` gives up after 500 ms (dsp.rs:511-517). With a job held past that, deactivate returned and the job then wrote into the output buffer, which in the game could already be freed or belong to a new stream. It's unlikely with jobs this short, but waiting without a limit, or having the job check a cancelled flag before writing, would be safer. - Small one. The doc comment on `reverb_on` (dsp.rs:524-525) says "as before they were", but `VICTORY_DSP_REVERB=0` gives #457's rule, not main's size rule. | Response | Per block | |---|---| | 3 parts (phone-sized) | 28 µs | | 30 parts | 53 µs | | 104 parts (longest seen) | 132 µs | | 255 parts (max) | 249 µs | | Silent input after the tail | 0.2 µs | That leaves room for about 160 streams of the longest room per 21.3 ms block on the one thread, so it keeps up easily. This PR carries #457's code unchanged. Whichever lands second conflicts in dsp.rs. SETTINGS.md merges by itself, but #457's paragraph saying convolutions are not computed would be wrong once this one is in. Overall the convolution looks right for the layout as described. The deactivate timeout and the backwards ticket are the two things I'd look at. AI-assisted: yes
Author
Owner

@⁠WillyBrown69 on GitHub · 2026-12-04 19:37 UTC · original

fixed #493

**@⁠WillyBrown69** on GitHub · 2026-12-04 19:37 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/497#issuecomment-7422168727) fixed #493
- Every command of a convolving stream goes to the DSP thread, including
  one with no output (its block still enters the convolution), so
  `completed` no longer goes back when a queued command finishes after one
  completed in the call.
- Deactivation takes the stream's convolution out under its lock instead of
  waiting up to 500 ms for queued commands: a command the thread runs after
  that writes nothing into the title's buffers, which may be freed.
- Input samples that are not finite come in as silence, so one bad block no
  longer makes a response's length of output not finite.
- A response whose bin 0 has an imaginary part (a packed Nyquist bin), or
  whose block 0 has sound in its first half, is logged once. Neither occurs
  in the 27 responses of one play: bin 0's imaginary part is exactly 0 in
  every block, and block 0's first half holds at most 0.06 % of its energy.
- Docs: VICTORY_DSP_REVERB=0 gives #457's rule; the stereo test's comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠PimpMastre on GitHub · 2026-12-04 19:39 UTC · original

@⁠Kal0s-design Thanks for the thorough check. The Nyquist-term breakdown is a useful way to bound the error. Pushed ed92a79 with the fixes:

  • Tickets going backwards. Every command of a convolving stream now goes through the DSP thread, including one with a null output. Its block still enters the convolution, so the response's tail is right in the block after it. completed can no longer move backwards. There's a test that submits output / no output / output and checks that completed never decreases.

  • Deactivate timeout. The 500 ms wait is gone. Deactivation takes the stream's convolver out under its lock. The DSP thread writes the output while holding that lock, so a command that runs afterwards writes nothing into the title's buffers, and one that is mid-write finishes first. That's well under a millisecond.

  • NaN/Inf in the input is now treated as silence when the block is copied, so one bad block no longer gives parts blocks of non-finite output (covered in the same test).

  • Layout checks. I checked both against the 27 responses from the dump:

    • the imaginary part of bin 0 is exactly 0 in every block of every response, so no packed Nyquist bin;
    • the first half of block 0 holds at most 0.06 % of its energy, which is rounding.

    Both conditions are now checked when a stream is activated and logged once if either fails (with a test).

  • The stereo test's comment was stale. It now says that stereo with option 2 isn't convolved (the title's streams are mono, 1024 frames), so the speaker rule applies.

  • reverb_on's doc now says VICTORY_DSP_REVERB=0 gives #457's rule.

Tested ed92a79 in play: about 6 minutes on this branch over current main (RX 7900 XT/XTX, CachyOS), going in and out of interiors and cars, with phone calls and the pause menu. Reverb and the phone filter behave as before, and the layout check logged nothing across 18 response shapes. There were a few tiny audio dropouts, and they lined up with frame hitches of 150–400 ms (main has no real-time priority for the title's mixer without #149). No new warnings.

On #457: agreed, whichever of the two lands second conflicts in dsp.rs, and #457's SETTINGS paragraph would be wrong once this one is in. If #457 goes first, I'll rebase onto it and update the paragraph. Otherwise this PR replaces it.

@⁠Bushyon thanks for testing on the 7800 XT, good to hear the volume sliders work now.

@⁠WillyBrown69 thanks for confirming. That's the radio and phone filters (#493) coming through now that the speaker responses are computed.

**@⁠PimpMastre** on GitHub · 2026-12-04 19:39 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/497#issuecomment-7422207717) @⁠Kal0s-design Thanks for the thorough check. The Nyquist-term breakdown is a useful way to bound the error. Pushed `ed92a79` with the fixes: - **Tickets going backwards.** Every command of a convolving stream now goes through the DSP thread, including one with a null output. Its block still enters the convolution, so the response's tail is right in the block after it. `completed` can no longer move backwards. There's a test that submits output / no output / output and checks that `completed` never decreases. - **Deactivate timeout.** The 500 ms wait is gone. Deactivation takes the stream's convolver out under its lock. The DSP thread writes the output while holding that lock, so a command that runs afterwards writes nothing into the title's buffers, and one that is mid-write finishes first. That's well under a millisecond. - **NaN/Inf in the input** is now treated as silence when the block is copied, so one bad block no longer gives `parts` blocks of non-finite output (covered in the same test). - **Layout checks.** I checked both against the 27 responses from the dump: - the imaginary part of bin 0 is exactly 0 in every block of every response, so no packed Nyquist bin; - the first half of block 0 holds at most 0.06 % of its energy, which is rounding. Both conditions are now checked when a stream is activated and logged once if either fails (with a test). - **The stereo test's comment** was stale. It now says that stereo with option 2 isn't convolved (the title's streams are mono, 1024 frames), so the speaker rule applies. - **`reverb_on`'s doc** now says `VICTORY_DSP_REVERB=0` gives #457's rule. Tested `ed92a79` in play: about 6 minutes on this branch over current main (RX 7900 XT/XTX, CachyOS), going in and out of interiors and cars, with phone calls and the pause menu. Reverb and the phone filter behave as before, and the layout check logged nothing across 18 response shapes. There were a few tiny audio dropouts, and they lined up with frame hitches of 150–400 ms (main has no real-time priority for the title's mixer without #149). No new warnings. On #457: agreed, whichever of the two lands second conflicts in `dsp.rs`, and #457's SETTINGS paragraph would be wrong once this one is in. If #457 goes first, I'll rebase onto it and update the paragraph. Otherwise this PR replaces it. @⁠Bushyon thanks for testing on the 7800 XT, good to hear the volume sliders work now. @⁠WillyBrown69 thanks for confirming. That's the radio and phone filters (#493) coming through now that the speaker responses are computed.
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 19:54 UTC · original

Re-checked ed92a79 on native Windows (didn't run the game, no game data).

Tests give 170 passed, 2 ignored, against 162 and 1 on main. Clippy shows the same warnings on both, none in dsp.rs, and the branch still merges cleanly. I re-ran my earlier throwaway checks and all the points I raised are fixed. Accuracy and timing per block haven't changed. Tickets stay in order with output and no-output commands mixed and a long queue, and the blocks with no output still go into the convolution (the output matches a convolver fed every block, bit for bit). Deactivate now waits for a stalled job however long it takes, and nothing is written after it returns. NaN and Inf in the input give finite output.

One small thing, not blocking. Deactivate can end up waiting for the stream's whole queue, not just the job that's running, because the DSP thread keeps getting the lock back between jobs. In one run with 500 jobs of the 104-part room queued, it waited about 50 ms. The title shouldn't build a queue like that, but if you want the wait capped at one job, an atomic flag set before the lock and checked in Job::run would do it.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 19:54 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/497#issuecomment-7422539610) Re-checked ed92a79 on native Windows (didn't run the game, no game data). Tests give 170 passed, 2 ignored, against 162 and 1 on main. Clippy shows the same warnings on both, none in dsp.rs, and the branch still merges cleanly. I re-ran my earlier throwaway checks and all the points I raised are fixed. Accuracy and timing per block haven't changed. Tickets stay in order with output and no-output commands mixed and a long queue, and the blocks with no output still go into the convolution (the output matches a convolver fed every block, bit for bit). Deactivate now waits for a stalled job however long it takes, and nothing is written after it returns. NaN and Inf in the input give finite output. One small thing, not blocking. Deactivate can end up waiting for the stream's whole queue, not just the job that's running, because the DSP thread keeps getting the lock back between jobs. In one run with 500 jobs of the 104-part room queued, it waited about 50 ms. The title shouldn't build a queue like that, but if you want the wait capped at one job, an atomic flag set before the lock and checked in `Job::run` would do it. AI-assisted: yes
Kal0s-design's note on #497: deactivation took the stream's convolution
lock, but the DSP thread could take it back between commands, so with a
long queue deactivation waited for the whole queue (about 50 ms for 500
blocks of the longest room). Deactivation now sets a flag first; a command
of a stopped stream completes its ticket without taking the lock, so the
wait is at most the command running.

A test holds the lock, stops the stream and runs a command: it completes
and writes nothing (without the flag it waits for the lock and the test
fails).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠PimpMastre on GitHub · 2026-12-04 20:30 UTC · original

@⁠Kal0s-design Thanks for re-checking. The stop flag is in 91ab9ab. Deactivation now sets it before taking the lock, and a command of a stopped stream completes its ticket without taking the lock, so the wait is capped at the command that's running.

The new test holds the stream's lock, stops the stream and runs a queued command. The command has to complete and must not write its output. With the flag check removed, the command waits for the lock and the test fails. All 10 dsp tests pass, and there's nothing from clippy in dsp.rs.

**@⁠PimpMastre** on GitHub · 2026-12-04 20:30 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/497#issuecomment-7423388746) @⁠Kal0s-design Thanks for re-checking. The stop flag is in `91ab9ab`. Deactivation now sets it before taking the lock, and a command of a stopped stream completes its ticket without taking the lock, so the wait is capped at the command that's running. The new test holds the stream's lock, stops the stream and runs a queued command. The command has to complete and must not write its output. With the flag check removed, the command waits for the lock and the test fails. All 10 dsp tests pass, and there's nothing from clippy in `dsp.rs`.
Author
Owner

@⁠niiniiniintje on GitHub · 2026-12-05 01:46 UTC · original

Manual testing shows that the audio reproduction is basically perfect now. Good stuff

**@⁠niiniiniintje** on GitHub · 2026-12-05 01:46 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/497#issuecomment-7429621372) Manual testing shows that the audio reproduction is basically perfect now. Good stuff
Author
Owner

@⁠PimpMastre on GitHub · 2026-12-05 19:42 UTC · original

A status note, since the queue in #516 lists this under "Next" as "DSP threads; no provable defect":

  • Every review finding is fixed. Kal0s-design's points were addressed in ed92a79 and 91ab9ab, and both heads were re-checked on native Windows, with all the points confirmed fixed.
  • It sounds like the original in play. niiniiniintje's manual testing found the reproduction "basically perfect", and Bushyon reported better sound and working volume sliders. I've also played several hours of normal gameplay on it with no audio issues.
  • It's cheap to land. It still merges cleanly onto current main (a5c6484) and touches only dsp.rs and docs/SETTINGS.md.

It fixes doubled dialogue and footsteps indoors, dry reverbs, and the missing phone and radio speaker filter. With no open findings and no conflicts, it may be worth moving up the queue.

**@⁠PimpMastre** on GitHub · 2026-12-05 19:42 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/497#issuecomment-7444205979) A status note, since the queue in #516 lists this under "Next" as "DSP threads; no provable defect": - **Every review finding is fixed.** Kal0s-design's points were addressed in `ed92a79` and `91ab9ab`, and both heads were re-checked on native Windows, with all the points confirmed fixed. - **It sounds like the original in play.** niiniiniintje's manual testing found the reproduction "basically perfect", and Bushyon reported better sound and working volume sliders. I've also played several hours of normal gameplay on it with no audio issues. - **It's cheap to land.** It still merges cleanly onto current `main` (`a5c6484`) and touches only `dsp.rs` and `docs/SETTINGS.md`. It fixes doubled dialogue and footsteps indoors, dry reverbs, and the missing phone and radio speaker filter. With no open findings and no conflicts, it may be worth moving up the queue.
github-bot force-pushed github-bot/gh-497 from 91ab9ab865 to a9ef503ebc 2026-12-05 21:14:33 +00:00 Compare
Author
Owner

@⁠PimpMastre on GitHub · 2026-12-05 21:11 UTC · original

Rebased onto current main now that #457 is in, so this merges cleanly again.

  • The only conflict was in dsp.rs, where #457's speaker-shape rule and bounded response read sit. This PR already carried both as its fallback, so the resolved dsp.rs is identical to the previous head (91ab9ab).
  • The docs/SETTINGS.md note #457 added ("convolutions are not computed") now says they are computed for mono 1024-frame streams, with #457's rule as the fallback for other shapes and VICTORY_DSP_REVERB=0.
  • The diff against main is still only dsp.rs and docs/SETTINGS.md, and all the DSP tests pass under Wine.
**@⁠PimpMastre** on GitHub · 2026-12-05 21:11 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/497#issuecomment-7445441302) Rebased onto current `main` now that #457 is in, so this merges cleanly again. - The only conflict was in `dsp.rs`, where #457's speaker-shape rule and bounded response read sit. This PR already carried both as its fallback, so the resolved `dsp.rs` is identical to the previous head (`91ab9ab`). - The `docs/SETTINGS.md` note #457 added ("convolutions are not computed") now says they are computed for mono 1024-frame streams, with #457's rule as the fallback for other shapes and `VICTORY_DSP_REVERB=0`. - The diff against `main` is still only `dsp.rs` and `docs/SETTINGS.md`, and all the DSP tests pass under Wine.
Author
Owner

@⁠niiniiniintje on GitHub · 2026-12-05 23:29 UTC · original

Thank you for the rebase.

**@⁠niiniiniintje** on GitHub · 2026-12-05 23:29 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/497#issuecomment-7447613208) Thank you for the rebase.
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/497/head:github-bot/gh-497'
git switch 'github-bot/gh-497'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-497'
git switch 'github-bot/gh-497'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-497'
git switch 'github-bot/gh-497'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-497'
git switch 'main'
git merge --squash 'github-bot/gh-497'
git switch 'main'
git merge --ff-only 'github-bot/gh-497'
git switch 'main'
git merge 'github-bot/gh-497'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.