fix(ngs2): retain PCM input when reporting decoded bytes #5548

Closed
JJenkx wants to merge 7 commits from upstream-pr/5548 into main
JJenkx commented 2026-10-13 23:32:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-13T23:32:03Z.


What

Retain PCM input before reporting its bytes as decoded, so a caller reusing those reported bytes cannot alter samples still waiting in the resampler. This remains an experimental draft: the console's decode granularity, repeat visibility and waveform-pointer timing are not measured.

An ordinary playable block or a clipped stream piece is copied on first use and counted in decoded_data_size then. Submission does not copy or count future input. Resampling and num_decoded_samples drain the retained data independently. Repeat callbacks release the old copy before the next iteration decodes again. Callback metadata and waveform_data keep caller addresses and playback position. Integer-phase playback avoids unused lookahead, and high-pitch advancement accounts for skipped decoded input.

Two reusable per-voice buffers each retain at most 64 KiB after consumption. Larger allocations, including a final drained piece of a starved stream, are released. Active whole-block copies remain proportional to the submitted playable range; large repeated blocks may allocate again on each loop. These limits and unverified console behavior are documented in library debt. No whole-waveform copy at submission is used.

Main now includes Ondra97's #6029 callback waveform-replacement correction. A callback replacing the waveform stops the old render path.

Tested

New current-main lifetime evidence, 2026-11-13: main e8b95881c391 already converts PCM into resampler scratch/history before reporting the bytes consumed. Its sampler path includes #11315. The focused regression proposed in #19349 passes with unchanged main production code in both NGS2 variants: six formats, mono/stereo, 44.1/48/96 kHz and pitch 0.75/1/2, 108 combinations per library.

Every case overwrites only the reported prefix after each render, patches an unreported tail within the same submitted block after the first render, compares exact samples with the expected-tail reference, and confirms the late write affects output. Separate private controls for whole-block first-read snapshots and early byte reporting both fail at the sample comparison in both libraries; restoring main returns both complete PCM suites to green. Playback stays active throughout because empty-voice state clears counters.

This establishes the tested current-main ownership property, not console decode granularity, repeat visibility, waveform-pointer timing or current Quake audio. The experimental whole-block retention/accounting changes in this draft are not thereby qualified; its public head remains unchanged. A fresh title/audio result is still needed before claiming the historical static is resolved or assigning a remaining cause.

Exact pins, verbose tests, fault-control patches, regression and manifest, SHA-256 89476a4f9853fb89c2fdc17060e279cb2f014b9a26f46c5c17c2eed284193c96; downloaded archive and all 15 manifest members verified.

Current-main integration still blocked, 2026-10-27 UTC: reviewed main 74acfad65b3f0fd4eab653f3a3989d298fba1157; the public head 3b3710efcf760296bb594a748e8ec1c64fd1dbd3 was not rewritten and this remains an open technical draft. The #10127 format/accounting integration requirement is substantive. Main's U8/I16/I24/I32/F32/F64 conversion, consumed-byte assertions, partial-input restrictions and additional NGS2 test registrations were preserved in the local analysis.

Changing only the report counter while retaining a whole-block snapshot would hide legal later writes to an unreported tail in the same block. The earlier late-fill case uses a different future block and does not establish this case. A cache containing only already reported samples has no demonstrated future use in main's monotonic consumed-cursor and repeat-reset flow. A replacement decode/read-ahead policy needs reference evidence of granularity, repeat visibility and waveform-pointer lifetime; neither weakening main's assertions nor an I16-only workaround qualifies as an integration.

The attached same-block unreported-tail and 44.1 kHz cases are test designs from source review, not executed runtime tests. No new native, console, Windows or audio validation is claimed. The local integration remains stopped at its reproducible CMake conflicts; no unqualified source change was pushed.

Exact pins, unchanged upstream PCM-test hash, staged/stopped patches, counterexample design and bounded handoff. SHA-256: aa2d6b9083a61cbd4227ff67ff88425dd29b86b608ddbe5b9fb1cd5d12a1aa2a; downloaded copy verified. Earlier passing tests below retain their exact historical scope.

2026-10-25: head ebfaae7a040a009579e4392300cfb5343234ed79, six linear topic commits on main b90d009d9f73354cbea239a74a8f7e2dcd138772. Linux GCC 16.2.1 Release. Built both NGS2 libraries and all 18 focused test executables, including main's new voice-event tests. All 20 registered CTest groups passed three repetitions (60 passes, zero skips). Restoring the candidate after the main control reproduced all 60 passes and identical hashes for both libraries and all 18 test executables.

The new --reported-regions mode runs the existing ring-buffer cases separately: mono and stereo at 48 kHz and 44.1 kHz, recycling only the bytes reported decoded, without assuming a whole-block decoded-byte count. Their function bodies are unchanged. Both main and the candidate pass these isolated cases. They do not independently demonstrate a buffer-lifetime failure on main.

The control uses this branch's tests/CMake with exactly main's Render.cpp, Voice.cpp and Ngs2Internal.hpp. Fourteen groups pass three repetitions; six fail: render, PCM-input and PCM-memory in each library variant. Full PCM-input fails at the decoded accounting assertion before the overwrite check. These failures show differences from the tests' accounting/memory policy; they must not be presented as independent proof of a copying bug or console equivalence.

The rebase retains main's input-channel/custom-mastering changes and voice-event tests. Existing PCM helper bodies are unchanged from former public head ddf93fbe14b4f036131e5c870a43874414414597; the complete render source also contains newer upstream changes. Source/whitespace checks pass. Conventions: zero errors, two existing debt-length warnings. Local merge-tree is clean against the exact tested main.

Validation archive: verbose logs, controls, source comparisons and patches. SHA-256: ecee379ddbd1c1758547169ae101f9b16340e0f820d25248275436761ad7e722; downloaded copy verified.

No new native title/audio, Windows, GPU or performance result is claimed. The draft blockers remain console decode granularity, repeat visibility and waveform-pointer timing; CPU test success does not resolve them.

Historical title evidence, retaining its original scope: @DavidAmsellem's randomized blind Quake PPSA01880 comparison used main 0fbfd91e5 against main plus this PR at 89d293cc6, the same machine/runtime and stationary scene. The tester identified the PR run as clean and main as static before revealing the order. This supports that one-scene audio result, not console semantic equivalence or a freshly repeated result. The preceding report used different scenes and is correspondingly weaker for quantitative attribution. Earlier local diagnostic audio captures also used different rendered scenes. Prior revision-specific details are preserved in the comments and archive's original description.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none (#6029 is merged)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a (CPU NGS2 tests)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4850808135 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5548). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-13T23:32:03Z. --- ### What Retain PCM input before reporting its bytes as decoded, so a caller reusing those reported bytes cannot alter samples still waiting in the resampler. This remains an **experimental draft**: the console's decode granularity, repeat visibility and waveform-pointer timing are not measured. An ordinary playable block or a clipped stream piece is copied on first use and counted in `decoded_data_size` then. Submission does not copy or count future input. Resampling and `num_decoded_samples` drain the retained data independently. Repeat callbacks release the old copy before the next iteration decodes again. Callback metadata and `waveform_data` keep caller addresses and playback position. Integer-phase playback avoids unused lookahead, and high-pitch advancement accounts for skipped decoded input. Two reusable per-voice buffers each retain at most 64 KiB after consumption. Larger allocations, including a final drained piece of a starved stream, are released. Active whole-block copies remain proportional to the submitted playable range; large repeated blocks may allocate again on each loop. These limits and unverified console behavior are documented in library debt. No whole-waveform copy at submission is used. Main now includes Ondra97's #6029 callback waveform-replacement correction. A callback replacing the waveform stops the old render path. ### Tested <!-- codex-pcm-current-main-lifetime-20261113 --> **New current-main lifetime evidence, 2026-11-13:** main `e8b95881c391` already converts PCM into resampler scratch/history before reporting the bytes consumed. Its sampler path includes #11315. The focused regression proposed in #19349 passes with unchanged main production code in both NGS2 variants: six formats, mono/stereo, 44.1/48/96 kHz and pitch 0.75/1/2, 108 combinations per library. Every case overwrites only the reported prefix after each render, patches an unreported tail within the same submitted block after the first render, compares exact samples with the expected-tail reference, and confirms the late write affects output. Separate private controls for whole-block first-read snapshots and early byte reporting both fail at the sample comparison in both libraries; restoring main returns both complete PCM suites to green. Playback stays active throughout because empty-voice state clears counters. This establishes the tested current-main ownership property, not console decode granularity, repeat visibility, waveform-pointer timing or current Quake audio. The experimental whole-block retention/accounting changes in this draft are not thereby qualified; its public head remains unchanged. A fresh title/audio result is still needed before claiming the historical static is resolved or assigning a remaining cause. [Exact pins, verbose tests, fault-control patches, regression and manifest](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/ngs2-reported-pcm-lifetime-linux-20261113.tar.gz), SHA-256 `89476a4f9853fb89c2fdc17060e279cb2f014b9a26f46c5c17c2eed284193c96`; downloaded archive and all 15 manifest members verified. <!-- codex-pcm-integration-blocker-20261027 --> **Current-main integration still blocked, 2026-10-27 UTC:** reviewed main `74acfad65b3f0fd4eab653f3a3989d298fba1157`; the public head `3b3710efcf760296bb594a748e8ec1c64fd1dbd3` was **not rewritten** and this remains an open technical draft. The #10127 format/accounting integration requirement is substantive. Main's U8/I16/I24/I32/F32/F64 conversion, consumed-byte assertions, partial-input restrictions and additional NGS2 test registrations were preserved in the local analysis. Changing only the report counter while retaining a whole-block snapshot would hide legal later writes to an unreported tail in the same block. The earlier late-fill case uses a different future block and does not establish this case. A cache containing only already reported samples has no demonstrated future use in main's monotonic consumed-cursor and repeat-reset flow. A replacement decode/read-ahead policy needs reference evidence of granularity, repeat visibility and waveform-pointer lifetime; neither weakening main's assertions nor an I16-only workaround qualifies as an integration. The attached same-block unreported-tail and 44.1 kHz cases are **test designs from source review, not executed runtime tests**. No new native, console, Windows or audio validation is claimed. The local integration remains stopped at its reproducible CMake conflicts; no unqualified source change was pushed. [Exact pins, unchanged upstream PCM-test hash, staged/stopped patches, counterexample design and bounded handoff](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/pr5548-main74ac-source-integration-blocker-20261027.tar.gz). SHA-256: `aa2d6b9083a61cbd4227ff67ff88425dd29b86b608ddbe5b9fb1cd5d12a1aa2a`; downloaded copy verified. Earlier passing tests below retain their exact historical scope. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> 2026-10-25: head `ebfaae7a040a009579e4392300cfb5343234ed79`, six linear topic commits on main `b90d009d9f73354cbea239a74a8f7e2dcd138772`. Linux GCC 16.2.1 Release. Built both NGS2 libraries and all 18 focused test executables, including main's new voice-event tests. All 20 registered CTest groups passed three repetitions (60 passes, zero skips). Restoring the candidate after the main control reproduced all 60 passes and identical hashes for both libraries and all 18 test executables. The new `--reported-regions` mode runs the existing ring-buffer cases separately: mono and stereo at 48 kHz and 44.1 kHz, recycling only the bytes reported decoded, without assuming a whole-block decoded-byte count. Their function bodies are unchanged. **Both main and the candidate pass these isolated cases.** They do not independently demonstrate a buffer-lifetime failure on main. The control uses this branch's tests/CMake with exactly main's `Render.cpp`, `Voice.cpp` and `Ngs2Internal.hpp`. Fourteen groups pass three repetitions; six fail: render, PCM-input and PCM-memory in each library variant. Full PCM-input fails at the decoded accounting assertion before the overwrite check. These failures show differences from the tests' accounting/memory policy; they must not be presented as independent proof of a copying bug or console equivalence. The rebase retains main's input-channel/custom-mastering changes and voice-event tests. Existing PCM helper bodies are unchanged from former public head `ddf93fbe14b4f036131e5c870a43874414414597`; the complete render source also contains newer upstream changes. Source/whitespace checks pass. Conventions: zero errors, two existing debt-length warnings. Local merge-tree is clean against the exact tested main. [Validation archive: verbose logs, controls, source comparisons and patches](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/pr5548-headebfaae7a-mainb90-ngs2-pcm-validation.tar.gz). SHA-256: `ecee379ddbd1c1758547169ae101f9b16340e0f820d25248275436761ad7e722`; downloaded copy verified. No new native title/audio, Windows, GPU or performance result is claimed. The draft blockers remain **console decode granularity, repeat visibility and waveform-pointer timing**; CPU test success does not resolve them. Historical title evidence, retaining its original scope: [@DavidAmsellem's randomized blind Quake PPSA01880 comparison](https://github.com/boykopovar/AnyPS5/pull/5548#issuecomment-6273440703) used main `0fbfd91e5` against main plus this PR at `89d293cc6`, the same machine/runtime and stationary scene. The tester identified the PR run as clean and main as static before revealing the order. This supports that one-scene audio result, not console semantic equivalence or a freshly repeated result. [The preceding report](https://github.com/boykopovar/AnyPS5/pull/5548#issuecomment-6271976554) used different scenes and is correspondingly weaker for quantitative attribution. Earlier local diagnostic audio captures also used different rendered scenes. Prior revision-specific details are preserved in the comments and archive's original description. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [ ] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none (#6029 is merged) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a (CPU NGS2 tests) - [x] AI-assisted: yes
CnRJay commented 2026-10-14 01:37:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T01:37:31Z.

Review: COMMENTED


The analysis is good: Quake refills a buffer for each positive delta of decoded_data_size, so on the console those bytes must already be independent of the guest buffer by the time the counter reports them. That points at where the copy should happen. Copying the whole block at AddWaveformBlocks time is earlier than the protocol implies:

  • what the title relies on is that bytes counted in decoded_data_size are no longer read from its buffer;
  • it doesn't follow that bytes not yet counted have been copied. A title that submits a block and fills or patches it shortly afterwards (common with streaming rings that queue the next block before the decoder thread writes it) would play the old contents here, and the console would play the new ones if it reads lazily.

A version that matches both observations: render from the guest buffer as main does, and copy a block's bytes into the voice's retained buffer at the moment they are counted into decoded_data_size (the same point at which the title is allowed to reuse them). Then the counter and the data lifetime are tied together by construction. Your "changing counter timing only reduced it" experiment suggests the counter currently runs ahead of the rendered position somewhere, and this would also surface that.

Smaller: the pcm vectors are allocated per block on the submission path, which is often an audio thread with tight deadlines. Reserving per voice, or pooling the vectors, avoids allocator calls there.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5512064567 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5548#pullrequestreview-5512064567). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-14T01:37:31Z. **Review:** COMMENTED --- The analysis is good: Quake refills a buffer for each positive delta of `decoded_data_size`, so on the console those bytes must already be independent of the guest buffer by the time the counter reports them. That points at **where** the copy should happen. Copying the whole block at `AddWaveformBlocks` time is earlier than the protocol implies: - what the title relies on is that bytes counted in `decoded_data_size` are no longer read from its buffer; - it doesn't follow that bytes *not yet* counted have been copied. A title that submits a block and fills or patches it shortly afterwards (common with streaming rings that queue the next block before the decoder thread writes it) would play the old contents here, and the console would play the new ones if it reads lazily. A version that matches both observations: render from the guest buffer as `main` does, and copy a block's bytes into the voice's retained buffer at the moment they are counted into `decoded_data_size` (the same point at which the title is allowed to reuse them). Then the counter and the data lifetime are tied together by construction. Your "changing counter timing only reduced it" experiment suggests the counter currently runs ahead of the rendered position somewhere, and this would also surface that. Smaller: the `pcm` vectors are allocated per block on the submission path, which is often an audio thread with tight deadlines. Reserving per voice, or pooling the vectors, avoids allocator calls there.
JJenkx commented 2026-10-14 03:17:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-14T03:17:31Z.


Agreed that the refill observation only establishes ownership for bytes counted as decoded; it does not establish that the console copies unread bytes at submission. I have returned this PR to draft and corrected the description to make that limitation explicit. I will not claim this snapshot implementation is ready to merge. The next revision needs late-fill/reuse coverage with retention tied to decoded-byte accounting, reusable storage, and a fresh Quake audio comparison.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6160094382 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5548#issuecomment-6160094382). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-14T03:17:31Z. --- Agreed that the refill observation only establishes ownership for bytes counted as decoded; it does not establish that the console copies unread bytes at submission. I have returned this PR to draft and corrected the description to make that limitation explicit. I will not claim this snapshot implementation is ready to merge. The next revision needs late-fill/reuse coverage with retention tied to decoded-byte accounting, reusable storage, and a fresh Quake audio comparison. AI-assisted: yes.
JJenkx commented 2026-10-15 22:20:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-15T22:20:23Z.


Follow-up to the submission-time-copy review: current draft head b21f78b0 copies neither PCM nor decoded-byte accounting at submission. DecodePcm retains a playable block or clipped stream piece when first decoded and adds exactly those retained bytes to decoded_data_size; late-fill-before-decode and reuse-after-accounting are covered in both NGS2 variants. Two reusable per-voice buffers retain at most 64 KiB each after consumption; larger consumed buffers are released. The existing description records the 14 passing tests and the stereo-accounting negative control.

This resolves the eager-submission-copy approach, but it does not establish that whole-block first-use decoding matches console granularity, repeat visibility or waveform-pointer timing. The PR stays draft. The Quake producer/SDL captures also show different scenes, so their discontinuity statistics do not prove a controlled audible improvement or resolve the earlier static-audio reports.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6203466094 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5548#issuecomment-6203466094). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-15T22:20:23Z. --- Follow-up to the submission-time-copy review: current draft head `b21f78b0` copies neither PCM nor decoded-byte accounting at submission. `DecodePcm` retains a playable block or clipped stream piece when first decoded and adds exactly those retained bytes to `decoded_data_size`; late-fill-before-decode and reuse-after-accounting are covered in both NGS2 variants. Two reusable per-voice buffers retain at most 64 KiB each after consumption; larger consumed buffers are released. The existing description records the 14 passing tests and the stereo-accounting negative control. This resolves the eager-submission-copy approach, but it does not establish that whole-block first-use decoding matches console granularity, repeat visibility or waveform-pointer timing. The PR stays draft. The Quake producer/SDL captures also show different scenes, so their discontinuity statistics do not prove a controlled audible improvement or resolve the earlier static-audio reports.
JJenkx commented 2026-10-16 02:56:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-16T02:56:54Z.


Closing this draft to free a slot under the 20-open-PR limit for an independently tested compiler change. This PCM draft still lacks console granularity/repeat evidence and a controlled audible improvement; it is not ready to merge.

The branch fix/ngs2-owned-pcm-input is preserved at b21f78b004f82469b8bad0dca31e26e8bb57eb5b. No code is discarded. It can be revisited when that evidence and a PR slot are available.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6207004584 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5548#issuecomment-6207004584). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-16T02:56:54Z. --- Closing this draft to free a slot under the 20-open-PR limit for an independently tested compiler change. This PCM draft still lacks console granularity/repeat evidence and a controlled audible improvement; it is not ready to merge. The branch `fix/ngs2-owned-pcm-input` is preserved at `b21f78b004f82469b8bad0dca31e26e8bb57eb5b`. No code is discarded. It can be revisited when that evidence and a PR slot are available. AI-assisted: yes.
DavidAmsellem commented 2026-10-19 16:26:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T16:26:25Z.


Listening verdict and a measurement for Quake (PPSA01880 v01.006.000), on AMD/Linux. This PR removes the constant background static. On unmodified main it is there the whole time. With this PR merged, the sound is clean to the ear, and the recorded stream backs that up.

Setup: main 0fbfd91e5 (it already has #6029 and #6476), and the same main with this PR's head merged (clean merge). Only the system libraries differ: the same relinked app.elf and app0/. AMD Radeon RX 7900 XT (RADV NAVI31), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release, PipeWire.

Method: the title opens two PipeWire playback streams. Fifteen seconds after start, both were recorded straight from the title's stream nodes for 60 s each (pw-record --target <stream serial>, 48 kHz s16 stereo), not from the speakers or a mixed sink. The title was on its menu, attract demo or in play; the scenes were not matched between the two runs.

Recording (60 s, 100 ms blocks) blocks of exact digital silence quietest RMS energy above 6 kHz in the 20 quietest 100 ms blocks
main, stream A 141 / 596 silence none (exact zero)
main, stream B 0 / 596 −72.4 dBFS −11.6 dB, always present
this PR, stream A 574 / 588 silence none (exact zero)
this PR, stream B 258 / 588 silence none (exact zero)

On main, stream B never reaches digital silence. The static is broadband: spectral flatness 0.59 between 100 Hz and 20 kHz, weighted to the low end. It has no peak at the 256-sample grain rate (187.5 Hz) or the 1024-sample port rate (46.9 Hz), and no autocorrelation at those lags. So it reads as garbage samples mixed in continuously, not as a grain-boundary fault. That fits stale PCM input being decoded, which is what this PR addresses. With the PR the floor goes to exact zero between sounds.

One observation that I do not attribute to this PR: the PR's stream B reaches full scale on 0.03 % of its samples (1,781 samples, the longest run 126 samples, i.e. 2.6 ms), all between 33 s and 40 s. The demo scene differed between the two runs, the main run never got that loud, and this looks like a loud in-game moment rather than a regression. I mention it in case the mixer's headroom matters.

Not covered: only a few minutes per build, no long session, and Quake only.

GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6271976554 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5548#issuecomment-6271976554). Originally posted by [DavidAmsellem](https://github.com/DavidAmsellem) on 2026-10-19T16:26:25Z. --- Listening verdict and a measurement for Quake (PPSA01880 v01.006.000), on AMD/Linux. **This PR removes the constant background static.** On unmodified `main` it is there the whole time. With this PR merged, the sound is clean to the ear, and the recorded stream backs that up. Setup: `main` `0fbfd91e5` (it already has #6029 and #6476), and the same `main` with this PR's head merged (clean merge). Only the system libraries differ: the same relinked `app.elf` and `app0/`. AMD Radeon RX 7900 XT (RADV NAVI31), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release, PipeWire. Method: the title opens two PipeWire playback streams. Fifteen seconds after start, both were recorded straight from the title's stream nodes for 60 s each (`pw-record --target <stream serial>`, 48 kHz s16 stereo), not from the speakers or a mixed sink. The title was on its menu, attract demo or in play; the scenes were not matched between the two runs. | Recording (60 s, 100 ms blocks) | blocks of exact digital silence | quietest RMS | energy above 6 kHz in the 20 quietest 100 ms blocks | |---|---|---|---| | `main`, stream A | 141 / 596 | silence | none (exact zero) | | `main`, **stream B** | **0 / 596** | **−72.4 dBFS** | **−11.6 dB, always present** | | this PR, stream A | 574 / 588 | silence | none (exact zero) | | this PR, **stream B** | **258 / 588** | silence | **none (exact zero)** | On `main`, stream B never reaches digital silence. The static is broadband: spectral flatness 0.59 between 100 Hz and 20 kHz, weighted to the low end. It has no peak at the 256-sample grain rate (187.5 Hz) or the 1024-sample port rate (46.9 Hz), and no autocorrelation at those lags. So it reads as garbage samples mixed in continuously, not as a grain-boundary fault. That fits stale PCM input being decoded, which is what this PR addresses. With the PR the floor goes to exact zero between sounds. One observation that I do **not** attribute to this PR: the PR's stream B reaches full scale on 0.03 % of its samples (1,781 samples, the longest run 126 samples, i.e. 2.6 ms), all between 33 s and 40 s. The demo scene differed between the two runs, the `main` run never got that loud, and this looks like a loud in-game moment rather than a regression. I mention it in case the mixer's headroom matters. Not covered: only a few minutes per build, no long session, and Quake only. GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38 AI-assisted: yes
DavidAmsellem commented 2026-10-19 17:41:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T17:41:59Z.


Follow-up with a controlled, blind comparison on the same scene, since the recordings in my previous comment came from two different play sessions.

Setup as before: Quake (PPSA01880 v01.006.000), the same relinked app.elf and app0/, and only the system libraries differ. main 0fbfd91e5 against the same main with this PR's head 89d293cc6 merged. AMD Radeon RX 7900 XT (RADV NAVI31), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release, PipeWire.

Protocol: a script picked the order at random and did not show it. Each run launched the title and recorded its PipeWire output streams for 90 s from launch, then closed it. In both runs the same actions were taken: New Game, Normal, then standing still at the start of the first map without moving or firing. I listened to each run and gave a verdict before the order was revealed.

Run Build Listening verdict (blind)
A this PR clean
B main static on top of the game sound

On the last 40 s of each recording, which is the standing-still part, measured per 1024-sample block (Hann window) on the stream that carries the game sound:

Last 40 s this PR main
Overall RMS 3311 3312
Energy above 6 kHz, median 57.6 dB 73.6 dB
Energy above 6 kHz, 10th percentile 53.9 dB 68.7 dB
Energy 100 Hz to 2 kHz, median 93.1 dB 102.5 dB

The overall level is the same on both runs. On main the band above 6 kHz is about 16 dB higher across the whole stretch, and the 100 Hz to 2 kHz band is also about 9 dB higher, which fits a broadband noise added on top of the same sound. That is the static I hear. Levels are in dB of the block FFT power, so only the differences between the two runs are meaningful.

This covers one scene in one title on one AMD/Linux machine. I have no console reference, so it says nothing about granularity or repeat behaviour.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6273440703 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5548#issuecomment-6273440703). Originally posted by [DavidAmsellem](https://github.com/DavidAmsellem) on 2026-10-19T17:41:59Z. --- Follow-up with a controlled, blind comparison on the same scene, since the recordings in my previous comment came from two different play sessions. Setup as before: Quake (PPSA01880 v01.006.000), the same relinked `app.elf` and `app0/`, and only the system libraries differ. `main` `0fbfd91e5` against the same `main` with this PR's head `89d293cc6` merged. AMD Radeon RX 7900 XT (RADV NAVI31), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release, PipeWire. Protocol: a script picked the order at random and did not show it. Each run launched the title and recorded its PipeWire output streams for 90 s from launch, then closed it. In both runs the same actions were taken: New Game, Normal, then standing still at the start of the first map without moving or firing. I listened to each run and gave a verdict before the order was revealed. | Run | Build | Listening verdict (blind) | |---|---|---| | A | this PR | clean | | B | `main` | static on top of the game sound | On the last 40 s of each recording, which is the standing-still part, measured per 1024-sample block (Hann window) on the stream that carries the game sound: | Last 40 s | this PR | `main` | |---|---|---| | Overall RMS | 3311 | 3312 | | Energy above 6 kHz, median | 57.6 dB | 73.6 dB | | Energy above 6 kHz, 10th percentile | 53.9 dB | 68.7 dB | | Energy 100 Hz to 2 kHz, median | 93.1 dB | 102.5 dB | The overall level is the same on both runs. On `main` the band above 6 kHz is about 16 dB higher across the whole stretch, and the 100 Hz to 2 kHz band is also about 9 dB higher, which fits a broadband noise added on top of the same sound. That is the static I hear. Levels are in dB of the block FFT power, so only the differences between the two runs are meaningful. This covers one scene in one title on one AMD/Linux machine. I have no console reference, so it says nothing about granularity or repeat behaviour. AI-assisted: yes
JJenkx commented 2026-10-19 17:46:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-19T17:46:49Z.


Thanks for the randomized blind same-scene follow-up. I added the attributed listening and last-40-second stream results to the description, with the exact source pins and one-scene scope. This is substantially stronger evidence for the static reduction than the earlier different-session recordings. The draft still records the unmeasured console decoder granularity, repeat visibility, and waveform-pointer timing; this comparison does not resolve those semantics.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6273531879 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5548#issuecomment-6273531879). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-19T17:46:49Z. --- Thanks for the randomized blind same-scene follow-up. I added the attributed listening and last-40-second stream results to the description, with the exact source pins and one-scene scope. This is substantially stronger evidence for the static reduction than the earlier different-session recordings. The draft still records the unmeasured console decoder granularity, repeat visibility, and waveform-pointer timing; this comparison does not resolve those semantics. AI-assisted: yes.
JJenkx commented 2026-10-21 22:40:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T22:40:52Z.


Refreshed onto main a6dcea9279 as five linear commits; head is ff47a6ae8a. The PCM production changes are unchanged, while main’s newer callback-reset, rack/render locking and nested-render checks are retained.

Fresh Release builds of both library variants and all 17 NGS2 tests pass three repetitions, zero skips. Restoring only main’s production Render.cpp, Voice.cpp and Ngs2Internal.hpp makes both ownership tests fail the decoded-byte check in each of three runs. After restoring the candidate, all 17 tests pass three repetitions again; both library and all test hashes match the first candidate build. Merge-tree and whitespace checks pass; conventions have zero errors and two debt-length warnings.

Still draft for the unmeasured native decode granularity, repeat visibility and waveform-pointer timing. This refresh adds current-main regression evidence, not a new audio/title result.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328150017 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5548#issuecomment-6328150017). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-21T22:40:52Z. --- Refreshed onto main `a6dcea9279` as five linear commits; head is `ff47a6ae8a`. The PCM production changes are unchanged, while main’s newer callback-reset, rack/render locking and nested-render checks are retained. Fresh Release builds of both library variants and all 17 NGS2 tests pass three repetitions, zero skips. Restoring only main’s production Render.cpp, Voice.cpp and Ngs2Internal.hpp makes both ownership tests fail the decoded-byte check in each of three runs. After restoring the candidate, all 17 tests pass three repetitions again; both library and all test hashes match the first candidate build. Merge-tree and whitespace checks pass; conventions have zero errors and two debt-length warnings. Still draft for the unmeasured native decode granularity, repeat visibility and waveform-pointer timing. This refresh adds current-main regression evidence, not a new audio/title result. AI-assisted: yes.

Pull request closed

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
boykopovar/AnyPS5!5548
No description provided.