hle: implement the xapu conversion kinds (Opus decode+convert, PCM convert) #184

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

@⁠SovietBearz0r on GitHub · 2026-12-05 22:28 UTC · original
SovietBearz0r:larp-audio → main · +452 −43 · 1 files · 1 commits · open

Summary

The console audio decoder (xapu.dll) has three connection kinds: plain Opus decode, Opus decode and sample-rate conversion, and float-PCM conversion. Our HLE accepted only plain decode and refused the other two with E_NOTIMPL (crates/victory-hle/src/modules/apu.rs), so the title's phone-call/voice path - which connects for converted output - had no decoded audio.

This port adds DECODE_CONVERT_OPUS and CONVERT_PCM:

  • a per-stream sample-rate converter: linear interpolation between input frames, pitch input frames per output frame, moved toward each command's target_pitch by its pitch_ramp per output frame (1/8..8 clamp), as the console's hardware does;
  • whole outputs of the connection's frames_per_output (256/480/512/960/1024) with the XApuState bits and state_data, Flush for the remainder, deinterleaved input/output, and reset (decoder only, or decoder and converter);
  • plain Opus connections keep their existing path and results unchanged.

Ported from gamingwithhomie/larp 1250552dd9e17421011ba9d971f62dac247d30f4 ("Fix phone call audio: port xapu DECODE_CONVERT_OPUS/CONVERT_PCM and XMA2 overlap carry"), GPL-3.0-or-later; the converter is their linear-interpolation one. Not ported from that commit: the XMA2 overlap carry/resume in formats/xma.rs (separate, bigger change) - a stream that resumes a decoder from another's overlap buffer may still glitch.

Verification

  • cargo test --locked -p victory-hle --lib apu: 5 passed (new the_converter_follows_its_pitch, new pcm_converts_in_whole_outputs end to end through XApuConnect/Activate/Process/DequeueResult, plus the three existing Opus decode tests).
  • cargo clippy --locked -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 442 files ok.
  • Not run in game: the phone-call path itself still wants an in-game listen (scripts/bench.ps1 can record a run, but a call is manual).

Why now

From the LARP borrow review: this was the highest-QOL item - missing phone-call/dialogue voice with correct-looking logs. If you want, the XMA2 overlap-carry half can be a follow-up port.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 22:28 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/183) `SovietBearz0r:larp-audio` → `main` · +452 −43 · 1 files · 1 commits · open ## Summary The console audio decoder (`xapu.dll`) has three connection kinds: plain Opus decode, Opus decode **and** sample-rate conversion, and float-PCM conversion. Our HLE accepted only plain decode and refused the other two with `E_NOTIMPL` (`crates/victory-hle/src/modules/apu.rs`), so the title's phone-call/voice path - which connects for converted output - had no decoded audio. This port adds `DECODE_CONVERT_OPUS` and `CONVERT_PCM`: - a per-stream sample-rate converter: linear interpolation between input frames, `pitch` input frames per output frame, moved toward each command's `target_pitch` by its `pitch_ramp` per output frame (1/8..8 clamp), as the console's hardware does; - whole outputs of the connection's `frames_per_output` (256/480/512/960/1024) with the `XApuState` bits and `state_data`, `Flush` for the remainder, deinterleaved input/output, and reset (decoder only, or decoder and converter); - plain Opus connections keep their existing path and results unchanged. Ported from **gamingwithhomie/larp `1250552dd9e17421011ba9d971f62dac247d30f4`** ("Fix phone call audio: port xapu DECODE_CONVERT_OPUS/CONVERT_PCM and XMA2 overlap carry"), GPL-3.0-or-later; the converter is their linear-interpolation one. **Not** ported from that commit: the XMA2 overlap carry/resume in `formats/xma.rs` (separate, bigger change) - a stream that resumes a decoder from another's overlap buffer may still glitch. ## Verification - `cargo test --locked -p victory-hle --lib apu`: 5 passed (new `the_converter_follows_its_pitch`, new `pcm_converts_in_whole_outputs` end to end through `XApuConnect`/`Activate`/`Process`/`DequeueResult`, plus the three existing Opus decode tests). - `cargo clippy --locked -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 442 files ok. - **Not run in game**: the phone-call path itself still wants an in-game listen (`scripts/bench.ps1` can record a run, but a call is manual). ## Why now From the LARP borrow review: this was the highest-QOL item - missing phone-call/dialogue voice with correct-looking logs. If you want, the XMA2 overlap-carry half can be a follow-up port.
The console's audio decoder connections come in three processing kinds. Our
xapu implementation accepted only plain Opus decoding: a title connecting for
decode-and-convert or PCM-convert was refused with E_NOTIMPL, so the
phone-call/voice path that uses those connections got no decoded audio.

This adds the other two kinds (DECODE_CONVERT_OPUS, CONVERT_PCM): a per-stream
sample-rate converter (linear interpolation; the pitch moves toward each
command's target by its ramp rate, as on the console's hardware), whole
outputs of the connection's frames_per_output size with the XApuState bits and
state_data, Flush, deinterleaved input/output, and reset (decoder only or
both). Plain Opus connections keep their path and results.

Ported from gamingwithhomie/larp 1250552dd9e17421011ba9d971f62dac247d30f4
("Fix phone call audio: port xapu DECODE_CONVERT_OPUS/CONVERT_PCM and XMA2
overlap carry"), GPL-3.0-or-later. Not ported from it: the XMA2 overlap
carry/resume in formats/xma.rs, which is a separate, larger change; a title
stream that resumes a decoder from another's overlap may still glitch.

Verified by unit tests: the converter's pitch/ramp behaviour, and the PCM
conversion end to end through XApuConnect/Activate/Process/DequeueResult; the
existing Opus decode tests pass. The title's phone-call path itself was not
run (no game run); that still wants an in-game check.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 22:31:08 +00:00
Author
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 22:55 UTC · original

In-game smoke on this box (RX 9070 XT, diag build, bench.ps1 builtin:cruise): INCONCLUSIVE for the conversion path — the route never requested the new kinds.

Evidence: audio decoder connected streams=256 process=1 chunk=0 … (process=1 = DECODE_OPUS only; DECODE_CONVERT_OPUS=2 / CONVERT_PCM=3 were never asked), 0× processing kind not implemented, 0× E_NOTIMPL, 0 ERROR, 0 device removals, exit 0, normal Opus/DSP activity. The binary does contain the new code. The new conversion path needs a voice/phone-call route (a phone call in game) to be exercised; the bench route doesn't call it. Log: data\logs\larp-audio.log, report data\ingame-verify\larp-results.md.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 22:55 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/183#issuecomment-7447169883) In-game smoke on this box (RX 9070 XT, diag build, `bench.ps1` builtin:cruise): **INCONCLUSIVE for the conversion path** — the route never requested the new kinds. Evidence: `audio decoder connected streams=256 process=1 chunk=0 …` (`process=1` = `DECODE_OPUS` only; `DECODE_CONVERT_OPUS`=2 / `CONVERT_PCM`=3 were never asked), 0× `processing kind not implemented`, 0× `E_NOTIMPL`, 0 ERROR, 0 device removals, exit 0, normal Opus/DSP activity. The binary does contain the new code. The new conversion path needs a voice/phone-call route (a phone call in game) to be exercised; the bench route doesn't call it. Log: `data\logs\larp-audio.log`, report `data\ingame-verify\larp-results.md`.
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/184/head:github-bot/gh-183'
git switch 'github-bot/gh-183'

Merge

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