feat(libSceAudioPropagation): render three-point material paths from console measurements #27216

Merged
aKazm1 merged 3 commits from upstream-pr/27216 into main 2026-11-26 05:54:26 +00:00
aKazm1 commented 2026-11-25 13:26:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by aKazm1 on 2026-11-25T13:26:41Z.


What

sceAudioPropagationSourceRender now renders active audio paths for the case SAROS uses, instead of throwing nonempty audio path rendering is not implemented. The model comes from console measurements, source 1 in REVERSE_ENGINEERING.md: impulse responses of the console's own /system/common/lib/libSceAudioPropagation.sprx, driven by a homebrew payload.

  • Firmware: 13.00 in Settings, while sceKernelGetSystemSwVersion returns 13.590.001.
  • Results are posted in #1504 (discussioncomment-19889844).

What the console showed, and what this PR implements:

  • When values are fixed: SetAudioPath fixes a path's delay and gains from the source attributes current at that call. The material absorption now comes from offset 32 of the 0x40 record, stored by RegisterMaterial; the PCM record is attribute 4, and its samples are copied when it is set and used by one render (measured: a later rewrite of the buffer is not heard, and a render without a new PCM attribute is silent).
  • Delay: (pathLength - |sourcePosition|) · 48000 / speed + 256, plus one frame when the source position is nonzero. Fractional samples are read by linear interpolation.
  • Gains:
    • rolloff: the OpenAL distance models 0–5 on the path length, from attribute 2 {model, maxDistance, factor, referenceDistance};
    • cone: the OpenAL cone (attribute 3, half angles) between the source direction and the reflection point;
    • the product of the path gain and the point gains.
  • Output:
    • ACN W, Y, Z, X with SN3D, where Y = −x, Z = y and X = z of the middle point;
    • the result is added to the destination, and channelCount stays 0;
    • a change ramps linearly over one frame;
    • int16 PCM is scaled by 1/32767.
  • Material filter: δ − Σ aₖ·gₖ. The six bands are generated, not copied: sine crossovers Tᵢ(k) = 0.5 − 0.5·sin(π/2·clamp((k − mᵢ)/wᵢ, −1, 1)) at bins mᵢ = 2^(i+2)+1 (5, 9, 17, 33, 65) with wᵢ = (mᵢ − 1)/3 on a 1024-point grid, band differences, inverse FFT, and 513 taps under 0.54 + 0.46·cos(πj/256). This matches the measured console responses to 4.2e-8. The console's filter is linear in absorption to 4e-8, and the bands sum to 1.

Every case that was not measured still throws (std::runtime_error, as the existing tests expect):

  • formats other than 0;
  • frame sizes other than 1024;
  • PCM types other than 0 and 1;
  • paths that don't have exactly three points with a material on the middle one;
  • rolloff models above 5.

The debt fragment records the limits. The other pending fragment's entry for this library said rendering adds no path contributions, so it is updated in place, as debt_fold.py requires.

Known difference: for a fractional delay the console splits the impulse slightly differently, 0.074 of the peak where this model gives 0.068 at 1979.07 samples. The sum and the position match.

Out of scope, seen on the console:

  • the source path capacity is 6 with reflection order 1, where the library assumes 36;
  • SetAudioPath rejects every 2-point path.

Tested

  • Windows 11 26200, WinLibs GCC, RTX 4080 (driver 621.40).
  • guest_audio_propagation passes, including five new checks of console numbers:
    • the bent-path impulse (delay, gain and Y/Z);
    • exponent rolloff with the source-relative delay;
    • one material band against its measured response;
    • the one-frame ramp.
  • check_conventions.py and debt_fold.py --check pass.
  • SAROS PPSA07631 01.005.002 on this branch's base with this library, from a fresh save (Cross pressed after openingterminal.mp4):
    • it no longer stops at the 144 s SourceRender abort;
    • it reaches controllable gameplay (the movement tutorial, HUD and pause menu), at about 2.5 fps;
    • it keeps running through repeated deaths and respawns.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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
  • Fixes: none
  • Unblocks: PPSA07631 #1504
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted: Yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5492225460 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27216). Originally posted by [aKazm1](https://github.com/aKazm1) on 2026-11-25T13:26:41Z. --- ### What `sceAudioPropagationSourceRender` now renders active audio paths for the case SAROS uses, instead of throwing `nonempty audio path rendering is not implemented`. The model comes from console measurements, source 1 in REVERSE_ENGINEERING.md: impulse responses of the console's own `/system/common/lib/libSceAudioPropagation.sprx`, driven by a homebrew payload. - Firmware: 13.00 in Settings, while `sceKernelGetSystemSwVersion` returns 13.590.001. - Results are posted in #1504 (discussioncomment-19889844). What the console showed, and what this PR implements: - **When values are fixed:** `SetAudioPath` fixes a path's delay and gains from the source attributes current at that call. The material absorption now comes from offset 32 of the 0x40 record, stored by `RegisterMaterial`; the PCM record is attribute 4, and its samples are copied when it is set and used by one render (measured: a later rewrite of the buffer is not heard, and a render without a new PCM attribute is silent). - **Delay:** `(pathLength - |sourcePosition|) · 48000 / speed + 256`, plus one frame when the source position is nonzero. Fractional samples are read by linear interpolation. - **Gains:** - rolloff: the OpenAL distance models 0–5 on the path length, from attribute 2 `{model, maxDistance, factor, referenceDistance}`; - cone: the OpenAL cone (attribute 3, half angles) between the source direction and the reflection point; - the product of the path gain and the point gains. - **Output:** - ACN `W, Y, Z, X` with SN3D, where `Y = −x`, `Z = y` and `X = z` of the middle point; - the result is added to the destination, and `channelCount` stays 0; - a change ramps linearly over one frame; - int16 PCM is scaled by 1/32767. - **Material filter:** `δ − Σ aₖ·gₖ`. The six bands are generated, not copied: sine crossovers `Tᵢ(k) = 0.5 − 0.5·sin(π/2·clamp((k − mᵢ)/wᵢ, −1, 1))` at bins `mᵢ = 2^(i+2)+1` (5, 9, 17, 33, 65) with `wᵢ = (mᵢ − 1)/3` on a 1024-point grid, band differences, inverse FFT, and 513 taps under `0.54 + 0.46·cos(πj/256)`. This matches the measured console responses to 4.2e-8. The console's filter is linear in absorption to 4e-8, and the bands sum to 1. Every case that was not measured still throws (`std::runtime_error`, as the existing tests expect): - formats other than 0; - frame sizes other than 1024; - PCM types other than 0 and 1; - paths that don't have exactly three points with a material on the middle one; - rolloff models above 5. The debt fragment records the limits. The other pending fragment's entry for this library said rendering adds no path contributions, so it is updated in place, as `debt_fold.py` requires. Known difference: for a fractional delay the console splits the impulse slightly differently, 0.074 of the peak where this model gives 0.068 at 1979.07 samples. The sum and the position match. Out of scope, seen on the console: - the source path capacity is 6 with reflection order 1, where the library assumes 36; - `SetAudioPath` rejects every 2-point path. ### Tested - Windows 11 26200, WinLibs GCC, RTX 4080 (driver 621.40). - `guest_audio_propagation` passes, including five new checks of console numbers: - the bent-path impulse (delay, gain and Y/Z); - exponent rolloff with the source-relative delay; - one material band against its measured response; - the one-frame ramp. - `check_conventions.py` and `debt_fold.py --check` pass. - SAROS PPSA07631 01.005.002 on this branch's base with this library, from a fresh save (Cross pressed after `openingterminal.mp4`): - it no longer stops at the 144 s SourceRender abort; - it reaches controllable gameplay (the movement tutorial, HUD and pause menu), at about 2.5 fps; - it keeps running through repeated deaths and respawns. ### Checklist - [x] 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) and the licence notice of code adapted from upstream (see AGENTS.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 - [x] Fixes: none - [x] Unblocks: PPSA07631 #1504 - [x] GPUs tested: n/a - [x] AI-assisted: yes AI-assisted: Yes.
MarcZX10 commented 2026-11-25 13:37:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T13:37:26Z.

Review: COMMENTED


Reviewed — comments

No blocking defect is verified, but I did not read every changed file or run the reported checks, so a formal decision is not justified.

What I ran

Reviewed head c4a1f690193501ecccd00087e925bcc7641eeff9. Read the prepared description, commits, manifest, and diff, plus lines 1–150 and 300–420 of Export.cpp. No commands or tests were run.

Results

Check Result Note
Change review not run Partial source review only
Tests not run Author reports results; not run here

Findings

Blocking

None verified.

Non-blocking

None.

Not verified

The full implementation and behavior remain unverified. The changed files listed in the manifest are Export.cpp, MaterialBands.hpp, GuestAudioPropagation.cpp, audiopropagation-source-render.md, and fix-audiopropagation-zero-ray-paths.md; only portions of Export.cpp were read. The other changed files, the rest of Export.cpp, and any excluded files were not read. The reported tests and console behavior were not independently checked.

To get this to a good state

Nothing is required. Optional: review the remaining changed files and run the reported checks before relying on the console behavior claims.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6058612837 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27216#pullrequestreview-6058612837). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T13:37:26Z. **Review:** COMMENTED --- # Reviewed — comments No blocking defect is verified, but I did not read every changed file or run the reported checks, so a formal decision is not justified. ## What I ran Reviewed head `c4a1f690193501ecccd00087e925bcc7641eeff9`. Read the prepared description, commits, manifest, and diff, plus lines 1–150 and 300–420 of `Export.cpp`. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Change review | not run | Partial source review only | | Tests | not run | Author reports results; not run here | ## Findings ### Blocking None verified. ### Non-blocking None. ## Not verified The full implementation and behavior remain unverified. The changed files listed in the manifest are `Export.cpp`, `MaterialBands.hpp`, `GuestAudioPropagation.cpp`, `audiopropagation-source-render.md`, and `fix-audiopropagation-zero-ray-paths.md`; only portions of `Export.cpp` were read. The other changed files, the rest of `Export.cpp`, and any excluded files were not read. The reported tests and console behavior were not independently checked. ## To get this to a good state Nothing is required. Optional: review the remaining changed files and run the reported checks before relying on the console behavior claims.
MarcZX10 commented 2026-11-25 18:27:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T18:27:24Z.

Review: DISMISSED


Reviewed — changes requested

Changes are required before merge: preserve correct PCM samples when the game updates the source PCM buffer between render calls.

What I ran

Reviewed head 9418db2a635d278b1d1dd04a5aba18b6ff65f5e8. I read the prepared description, commit list, manifest, diff, and every added line in the four changed files. I inspected the relevant source attribute and render code with repo_read.py. No tests were run.

Results

Check Result Note
Changed code review failed PCM state can be replayed across frames
Tests not run No test execution performed

Findings

Blocking

  • core/libs/prx/libSceAudioPropagation/Export.cpp:335: The source PCM pointer and byte count are retained from the last attribute update, but each render copies samples starting at that same buffer address into history. If the caller reuses and updates a PCM buffer for each frame, as the added tests do at core/libs/tests/GuestAudioPropagation.cpp:973-977, rendering frame 2 and later reads frame 1's now-overwritten memory as though it were current input. Conversely, if the caller supplies a new PCM buffer each frame, the render uses the stale pointer because SourceSetAttributes is the only place that replaces it. Track/copy each frame's current PCM input through the supported API lifecycle so delayed paths receive the actual source stream rather than repeated or stale samples.

Non-blocking

None.

Not verified

No tests or builds were run. The description's console measurements and SAROS run were author-reported and not independently verified. All four changed files were read; no changed files were excluded by the prepared manifest.

To get this to a good state

Update PCM capture so each render frame uses the current source samples, then add coverage that changes PCM data across consecutive frames and verifies a delayed path emits those distinct samples.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6062873312 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27216#pullrequestreview-6062873312). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T18:27:24Z. **Review:** DISMISSED --- # Reviewed — changes requested Changes are required before merge: preserve correct PCM samples when the game updates the source PCM buffer between render calls. ## What I ran Reviewed head `9418db2a635d278b1d1dd04a5aba18b6ff65f5e8`. I read the prepared description, commit list, manifest, diff, and every added line in the four changed files. I inspected the relevant source attribute and render code with `repo_read.py`. No tests were run. ## Results | Check | Result | Note | |---|---|---| | Changed code review | failed | PCM state can be replayed across frames | | Tests | not run | No test execution performed | ## Findings ### Blocking - `core/libs/prx/libSceAudioPropagation/Export.cpp:335`: The source PCM pointer and byte count are retained from the last attribute update, but each render copies samples starting at that same buffer address into history. If the caller reuses and updates a PCM buffer for each frame, as the added tests do at `core/libs/tests/GuestAudioPropagation.cpp:973-977`, rendering frame 2 and later reads frame 1's now-overwritten memory as though it were current input. Conversely, if the caller supplies a new PCM buffer each frame, the render uses the stale pointer because `SourceSetAttributes` is the only place that replaces it. Track/copy each frame's current PCM input through the supported API lifecycle so delayed paths receive the actual source stream rather than repeated or stale samples. ### Non-blocking None. ## Not verified No tests or builds were run. The description's console measurements and SAROS run were author-reported and not independently verified. All four changed files were read; no changed files were excluded by the prepared manifest. ## To get this to a good state Update PCM capture so each render frame uses the current source samples, then add coverage that changes PCM data across consecutive frames and verifies a delayed path emits those distinct samples.
MarcZX10 commented 2026-11-25 20:33:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T20:33:59Z.

Review: COMMENTED


Reviewed — no blocking findings

The implementation and added tests support the measured three-point rendering behavior, but I could not run the checks in this review environment, so approval is not justified.

What I ran

Inspected the prepared diff and changed files at head 2458de0c6f6f7e7bb3c0d7ab89b45fd8f0af37a6. No commands or tests were run.

Results

Check Result Note
Diff and changed code review passed All four changed files inspected
Automated checks not run Command execution unavailable
Console behavior not run Author-reported results only

Negative control

Not run; command execution was unavailable.

Findings

Blocking

None.

Non-blocking

None.

Sources

Reviewed the prepared diff and source at the pinned head; no external behavior claims are made.

Not verified

The reported guest_audio_propagation, check_conventions.py, debt_fold.py --check, and SAROS run were not independently verified. Files reviewed: core/libs/prx/libSceAudioPropagation/Export.cpp, core/libs/tests/GuestAudioPropagation.cpp, docs/dev/debt/changes/audiopropagation-source-render.md, and docs/dev/debt/changes/fix-audiopropagation-zero-ray-paths.md. No changed files were excluded from review.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6064582828 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27216#pullrequestreview-6064582828). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T20:33:59Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The implementation and added tests support the measured three-point rendering behavior, but I could not run the checks in this review environment, so approval is not justified. ## What I ran Inspected the prepared diff and changed files at head `2458de0c6f6f7e7bb3c0d7ab89b45fd8f0af37a6`. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code review | passed | All four changed files inspected | | Automated checks | not run | Command execution unavailable | | Console behavior | not run | Author-reported results only | ## Negative control Not run; command execution was unavailable. ## Findings ### Blocking None. ### Non-blocking None. ## Sources Reviewed the prepared diff and source at the pinned head; no external behavior claims are made. ## Not verified The reported `guest_audio_propagation`, `check_conventions.py`, `debt_fold.py --check`, and SAROS run were not independently verified. Files reviewed: `core/libs/prx/libSceAudioPropagation/Export.cpp`, `core/libs/tests/GuestAudioPropagation.cpp`, `docs/dev/debt/changes/audiopropagation-source-render.md`, and `docs/dev/debt/changes/fix-audiopropagation-zero-ray-paths.md`. No changed files were excluded from review. ## To get this to a good state Nothing is required.
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!27216
No description provided.