feat(libSceNgs2.native): parse 8-, 24- and 32-bit PCM and float waveforms #9148

Merged
MarrasFederico merged 2 commits from upstream-pr/9148 into main 2026-10-25 22:01:52 +00:00
MarrasFederico commented 2026-10-21 13:32:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-10-21T13:32:43Z.


What

sceNgs2ParseWaveformData read only 16-bit PCM and ATRAC9: other PCM depths returned INVALID_WAVEFORM_FORMAT, and float or extensible-PCM files threw. prosper's reading of libSceNgs2.native.sprx gives the module's routes:

  • Integer PCM: tag 1, or WAVE_FORMAT_EXTENSIBLE with the PCM GUID. 8, 16, 24 and 32 bits become types 0x11, 0x12, 0x14 and 0x16.
  • Float: tag 3. 32 and 64 bits become 0x18 and 0x1a.
  • Any other depth returns 0x804A8432 (UNKNOWN_WAVEFORM_FORMAT).

These are the PCM and float type numbers #8338 already maps in sceNgs2CalcWaveformBlock.

The 16-bit parser now serves all of these. It reports the frame size as channels × bytes per sample, with one sample and one unit per frame as for 16 bits. It keeps every check of the 16-bit path, which prosper's reading does not apply: channels 1 to 8, a rate of 1 to 192000, the block align, whole frames within the file, and a throw for a looped smpl chunk. Voices still play only 16-bit PCM and ATRAC9, so this changes what the parser reports, not what plays. A new debt entry records both points.

Tested

Ubuntu 26.04.1, kernel 7.0.0-38, GCC 15.2.0, Release, full build with BUILD_TESTING=ON. Windows was not compiled. No title was run.

  • ngs2_parse:
    • Accepted: three-channel 48 kHz files of 8, 16, 24 and 32-bit PCM, 32 and 64-bit float, and 8 and 24-bit WAVE_FORMAT_EXTENSIBLE PCM. Each reports its type, data offset and size, sample count, frame layout and single block.
    • Refused: 12 and 64-bit PCM, 16 and 24-bit float and 12-bit extensible PCM return UNKNOWN_WAVEFORM_FORMAT.
    • Unchanged: the existing 16-bit, truncated, partial-frame and zero-channel cases.
  • The test fails on main. Mapping 24 bits to another type, or returning INVALID_WAVEFORM_FORMAT for an unknown depth, makes it fail. All 13 ngs2 tests pass.
  • tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py finds no conflicting lines. It could not compare #5797 (HE-VAG, which changes how sceNgs2ParseWaveformFile calls the parser, not the PCM path) and #8609, which conflict with main.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4952444863 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9148). Originally posted by [MarrasFederico](https://github.com/MarrasFederico) on 2026-10-21T13:32:43Z. --- ### What `sceNgs2ParseWaveformData` read only 16-bit PCM and ATRAC9: other PCM depths returned `INVALID_WAVEFORM_FORMAT`, and float or extensible-PCM files threw. [prosper's reading of `libSceNgs2.native.sprx`](https://github.com/mattias800/prosper/blob/30572df43ae20ff28f995db56149f7af42235741/prosper/src/hle/audio/ngs2_waveform.cpp#L194-L223) gives the module's routes: - **Integer PCM:** tag 1, or `WAVE_FORMAT_EXTENSIBLE` with the PCM GUID. 8, 16, 24 and 32 bits become types 0x11, 0x12, 0x14 and 0x16. - **Float:** tag 3. 32 and 64 bits become 0x18 and 0x1a. - **Any other depth** returns 0x804A8432 (`UNKNOWN_WAVEFORM_FORMAT`). These are the PCM and float type numbers #8338 already maps in `sceNgs2CalcWaveformBlock`. The 16-bit parser now serves all of these. It reports the frame size as channels × bytes per sample, with one sample and one unit per frame as for 16 bits. It keeps every check of the 16-bit path, which prosper's reading does not apply: channels 1 to 8, a rate of 1 to 192000, the block align, whole frames within the file, and a throw for a looped `smpl` chunk. Voices still play only 16-bit PCM and ATRAC9, so this changes what the parser reports, not what plays. A new debt entry records both points. ### Tested <!-- 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. --> Ubuntu 26.04.1, kernel 7.0.0-38, GCC 15.2.0, Release, full build with `BUILD_TESTING=ON`. Windows was not compiled. No title was run. - `ngs2_parse`: - **Accepted:** three-channel 48 kHz files of 8, 16, 24 and 32-bit PCM, 32 and 64-bit float, and 8 and 24-bit `WAVE_FORMAT_EXTENSIBLE` PCM. Each reports its type, data offset and size, sample count, frame layout and single block. - **Refused:** 12 and 64-bit PCM, 16 and 24-bit float and 12-bit extensible PCM return `UNKNOWN_WAVEFORM_FORMAT`. - **Unchanged:** the existing 16-bit, truncated, partial-frame and zero-channel cases. - The test fails on `main`. Mapping 24 bits to another type, or returning `INVALID_WAVEFORM_FORMAT` for an unknown depth, makes it fail. All 13 `ngs2` tests pass. - `tools/check_conventions.py --base origin/main` passes. `tools/pr_overlap.py` finds no conflicting lines. It could not compare #5797 (HE-VAG, which changes how `sceNgs2ParseWaveformFile` calls the parser, not the PCM path) and #8609, which conflict with `main`. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) - [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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
ycbuzi commented 2026-10-21 20:49:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T20:49:10Z.


Windows run of 428cd4e3ee merged onto main 0c6a5bd593 (f52100f4db, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceNgs2.native and ngs2_parse_tests with no errors or warnings. ctest --repeat until-fail:2 on ngs2_parse: passes on both repeats. Not run: a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6326234914 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9148#issuecomment-6326234914). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T20:49:10Z. --- Windows run of 428cd4e3ee merged onto `main` 0c6a5bd593 (f52100f4db, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `libSceNgs2.native` and `ngs2_parse_tests` with no errors or warnings. `ctest --repeat until-fail:2` on `ngs2_parse`: passes on both repeats. Not run: a title.
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!9148
No description provided.