APU: decode-convert and PCM rate conversion #218
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/218"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by Quat3rnion on 2026-11-24T01:32:27Z.
What
The console's APU accepted only
DecodeOpus. Titles that connected forDecodeConvertOpusorConvertPCMgotE_NOTIMPL, so their resampled audiowas silent. This adds both process types with the documented
maxFrameCountPerOutputvalues, pitch and frame-count handling, anddeinterleaved input and output. A portable streaming resampler holds the
conversion arithmetic and has its own unit tests.
An AI tool wrote part of this change.
Tested
cargo check --target x86_64-pc-windows-gnu -p victory-hle --testspasses. The three new APU tests compile but were not run; there is no Windows host here.cargo test --workspaceon a tree carrying PR #112's Linux build fix: 172 passed, 0 failed, 3 ignored. All eight resampler tests pass. Basemaindoes not build the workspace on Linux yet, which is what #112 addresses.Checklist
cargo fmton the changed files; clippy and workspace tests pass on a tree with #112's build fix.cargo xtask policypasses (151 files ok). No game files or data from them were added.Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T05:12:52Z.
Thanks @Quat3rnion for adding decode-convert and PCM rate conversion coverage.
I tested commit
200943e067b78bc1a469fd8d24a450be17522e12with:The aggregate
apurun had 10 passed and 2 failed (80 filtered). The dedicated resampler filter passed all 8 tests (84 filtered), covering unit/half/double pitch, stereo pairing, carry between commands, flush of a partial frame, pitch ramps, and invalid shapes. The title-driven Opus decode test and both conversion-kind connection setup also passed.The two failures reproduce when run individually:
converts_float_pcm_at_the_target_pitchexpected S_OK, 8 frames, pitch 2.0, and 32 output bytes; it received S_OK, 15 frames, pitch 1.0, and 60 bytes at the assertion on line 845.decodes_and_converts_an_opus_streamfails the half-pitch assertion that converted output contains more than 960 frames (line 895).These two failing tests are introduced in this PR and are absent from base commit
d2a4bae1f49533ef5cb512fd1b1ba1513f2e1989, so their same-name baseline behavior could not be tested there. This covers synthetic PCM/Opus buffers and the resampler; it does not exercise audio playback through a real title or output device.Imported from Marvisak/VIctory. Originally posted by etcetera-yt on 2026-11-24T05:36:32Z.
On
main(d2a4bae) plus #218 alone, Windows 10 19045, Rust 1.98.1,cargo test -p victory-hle modules::apu:The resampler's own tests (
apu_resample::tests::*, 8) pass, so the target pitch seems not to reach the resamplerthrough the APU command path: the result has pitch 1.0 and the unconverted frame count. Possibly host-dependent
(output device or sample rate); worth checking on another machine.
AI use: Claude Code, Claude Opus 5.5.
Imported from Marvisak/VIctory. Originally posted by KevinPratap on 2026-11-24T07:13:55Z.
The two failing tests here (
converts_float_pcm_at_the_target_pitch,decodes_and_converts_an_opus_stream) come from a zeropitch_rampnever moving the pitch. Fix with a test, against this branch: https://github.com/Quat3rnion/VIctory/pull/1 (10 → 13 passing incargo test -p victory-hle --lib apu). AI-assisted.Imported from Marvisak/VIctory. Originally posted by Quat3rnion on 2026-11-24T07:30:02Z.
Rebased on current main and added a fix for the two failing conversion tests: a zero pitch ramp left the resampler at its initial 1.0, so target_pitch was ignored. The pitch is now set directly when no ramp is set. New head
7175608. The APU tests are Windows-gated, so I could not run them here — could you re-run the two reported failures? Thanks.Imported from Marvisak/VIctory. Originally posted by lameloball2813-ui on 2026-11-24T08:15:16Z.
Re-ran the APU tests at the new head
7175608on Windows 11, Rust 1.98.1, debug:cargo test -p victory-hle --lib modules::apu. All 13 passed, 0 failed, including the two that failed before:modules::apu::tests::converts_float_pcm_at_the_target_pitch... okmodules::apu::tests::decodes_and_converts_an_opus_stream... okThe new
apu_resampletests pass too (a_zero_ramp_applies_the_target_immediately,pitch_ramps_towards_the_target,stereo_channels_stay_pairedand the rest).Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-24T17:41:38Z.
Correction to my earlier comment: the CI run of this PR did run and fails on the same lints. For reference, the three errors of
cargo clippy --workspace --all-targets --locked -- -D warningson this PR merged ontomainatffe310e, all inmodules/apu.rs:needless_option_as_deref(decoder.as_deref_mut()on anOption<&mut _>; usedecoder)manual_is_multiple_of(frames % multiple != 0; use!frames.is_multiple_of(multiple))chunks_exact_to_as_chunks(.chunks_exact(4); useas_chunks::<4>().0.iter())Clippy suggests each fix. The tests pass. AI-assisted (Claude Code); no game data.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:00:47Z.
Automated triage for the maintainers. Closing because it breaks a repository rule (see
docs/asset-policy.mdand the project rules): nothing taken from the console SDK or the game, no weakening of the asset policy, and the title stays offline.If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed