feat(libSceNgs2.native): implement sceNgs2ParseWaveformFile and parse 16-bit PCM waveforms #1020
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1020"
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 boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-07T00:38:21Z.
What
Implements
sceNgs2ParseWaveformFile(path, offset, info)(resolves the guest path, reads the file fromoffsetto its end, and reusessceNgs2ParseWaveformData) and adds 16-bit PCM RIFF parsing tosceNgs2ParseWaveformData. Previously only ATRAC9 was parsed and any other format tag threw. Adatachunk that runs past the buffer or ends inside a frame returnsSCE_NGS2_ERROR_INVALID_WAVEFORM_DATA(assumed, recorded in TechnicalDebt); looped PCM and other PCM formats still throw.PPSA21402 (Balatro) imports
sceNgs2ParseWaveformFile. Its call site sets only three argument registers (path, offset, info), which is where the signature comes from. It loads its sound effects as 16-bit PCM.wavfiles (80 of 80 have adatachunk that exactly fills the file). It failed at startup with an unresolved import, then withparsing waveform format tag 0x1 is not implemented.Tested
ctest -R ngs2passes (render, atrac9, filter, custom), including new tests for PCM parsing (adatachunk past the buffer or ending inside a frame, 8-bit and zero-channel files are rejected) and file parsing (offset, offset past the end, null path and info).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-07T01:48:05Z.
Thanks. A named title with the exact stop on main is what we look for, and the change fits the existing ATRAC9 parser well (linking
libcandlibkernelforResolvePath_nid_no_patchmatcheslibSceAjm.native).Two small things before it can go in:
TestParseFile,out.write("", 3)reads three bytes from a one-byte string literal, which is undefined behaviour. Something likeconst char pad[3]{}; out.write(pad, sizeof(pad));does the same thing safely.ParsePcm16quietly shortens adatachunk that runs past the end of the buffer (your truncated test expectsSCE_NGS2_OKwith 50 samples). We don't know that the console does that. Could you either returnSCE_NGS2_ERROR_INVALID_WAVEFORM_DATAthere, or add the truncation to your TechnicalDebt line as an assumption? If Balatro's files hit that case, please say so; that decides it.The CI run needs a maintainer's approval because this is your first PR here; that's on our side.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T01:48:16Z.
Progress report (
3c05400→fb56ff2)📈 System libraries: 86.14% (+0.01%, +1 implemented functions)
✅ 1 implemented
sceNgs2ParseWaveformFileImported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-07T01:54:22Z.
Thanks for the review. Pushed an update (e59b99b):
TestParseFile: nowconst char pad[3]{}; out.write(pad, sizeof(pad));. (For the record, the original literal held raw 0x01 0x02 0x03 bytes that GitHub does not render, so it wrote 3 of its 4 bytes, but raw control characters in source are fragile anyway.)datachunk: none of Balatro's 80.wavfiles hit it (everydatachunk exactly fills its file), so I dropped the truncation. Adatachunk that runs past the buffer or ends inside a frame now returnsSCE_NGS2_ERROR_INVALID_WAVEFORM_DATA, with tests, and the error code is listed as an assumption in TechnicalDebt.sceNgs2ParseWaveformFiletakes three arguments,(path, offset, info), not four. PPSA21402's call site only sets rdi, rsi and rdx. I had added asizeargument, which made the title'sinfopointer come from a stale register. Fixed, with the test, the test header and the TechnicalDebt entry updated.ctest -R ngs2passes on Windows 11. I also updated the PR description, which still described the four-argument version.Imported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-07T02:10:12Z.
The Linux
ngs2_atrac9failure was the new test, not the implementation. It wrote its temporary file to the host's/tmp, butsceNgs2ParseWaveformFileresolves/tmp/...as a guest path, and on Linux every absolute guest path is mapped under the working directory (on Windows a path with a drive letter is passed through unchanged, which is why that job passed).Pushed 13f0370: the test now asks
ResolvePath_nid_no_patchfor the host path of a guest path (/aps5_ngs2_parse_file.wav) and writes the file there. I could only run it on Windows, where a driveless guest path takes the same working-directory mapping route, so the Linux run is the real check. This push supersedes the run still waiting for approval on e59b99b.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-07T04:56:40Z.
Thanks for the fixes. The Linux CI job still fails on the new head, in the ATRAC9 test this PR changes:
ngs2_atrac9aborts ("Subprocess aborted", after 0.09 s), while the Windows job passes. The log is here: https://github.com/boykopovar/AnyPS5/actions/runs/37561141516/job/112620804339Could you take a look? It can go in once both jobs are green.