Repository navigation
feat(libSceNgs2): implement the native mastering limiter - #22536
Conversation
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against e17fff2043:
- Conventions:
tools/check_conventions.pypassed. - Build:
ngs2_core_render_tests,ngs2_render_testsbuilt cleanly. - CTest (
ngs2_core_render,ngs2_render):1/2 Test #4642: ngs2_render ...................... Passed 3.49 sec 2/2 Test #4632: ngs2_core_render ................. Passed 7.03 sec 100% tests passed, 0 tests failed out of 2 - Negative control: with
core/libs/prx/libSceNgs2.native/src/Render.cpp,core/libs/prx/libSceNgs2.native/src/Voice.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/2 Test #4642: ngs2_render ......................Subprocess aborted***Exception: 0.86 sec 2/2 Test #4632: ngs2_core_render ................. Passed 7.41 sec 50% tests passed, 1 tests failed out of 2 - Code reading:
- Verified Render.cpp ProcessCompressor mastering limiter branch threshold/x target calculation and attack/release coefficient smoothing over 32-sample blocks.
- Verified Voice.cpp CheckMasteringEffect and ApplyParam handling for SCE_NGS2_MASTERING_VOICE_PARAM_LIMITER, including NaN handling, enable/disable flags, and threshold range [0.0, 1.0].
- Verified ResetSetup() in Voice.cpp resets compressor state and gain array to 1.0f on voice configuration changes.
- Verified docs/dev/debt/changes/feat-ngs2-mastering-limiter.md debt fragment adherence to AGENTS.md conventions.
- Verified Ngs2Render.cpp unit tests exercise enabled, disabled, NaN threshold, and multi-grain limiter rendering against reference exponential decay models.
Looks Good To Me
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed the mastering limiter — no blocking findings
Nothing blocks this; the points below are optional. The change matches its description at the head reviewed, but I did not build or run the tests in this review.
What I ran
Head e17fff2043638042c86b69f5e94a96f79fd89aac, base main. Read-only review of the diff and the head repository through the reader:
python3 repo_read.py search "struct Ngs2SubmixerVoiceCompressorParam" core/libs/prx/libSceNgs2.native
python3 repo_read.py cat core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp 490 502
No build, no test run, no merge preview.
Results
| Check | Result | Note |
|---|---|---|
| Changed hunks read | passed | Render.cpp, Voice.cpp, test hunks |
| Compressor param layout | passed | Matches the aggregate init in Voice.cpp:624 |
| Build and tests (mine) | not run | No build in this review |
| Tests (author-reported) | not run | Author reports a Linux GCC run; not verified here |
| Negative control | not run | Not performed |
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceNgs2.native/src/Voice.cpp:624: a threshold of exactly0is accepted. Withtarget = threshold / x(Render.cpp:449) the gain then decays to0, so the voice goes silent. That may be the intended linear limit, but it is not covered by a test. Either add a test for it or reject0as the submixer path does.core/libs/prx/libSceNgs2.native/tests/Ngs2Render.cpp:1757: the new limiter test checks one threshold (0.25), one attack and release pair, and the NaN and disable paths. Knee-free only, which is the only path mastering uses, so this is acceptable for now.
Not verified
- Build and test results on this head. I did not run the four test suites named in the PR.
- Firmware behaviour: placement, sample-rate source, lifecycle flags and bit-exact output. The PR says these remain unverified and I did not check them.
- Gain state across unrendered blocks:
ProcessCompressoris not called when a voice is not playing, so the gain resumes from its last value. The debt note says lifecycle is unverified; I did not test this. - Full text of
Ngs2Render.cpp,Render.cppandVoice.cppoutside the changed hunks. I read the changed regions and their direct callers only.
To get this to a good state
Nothing is required.
Optional: decide whether threshold 0 should be accepted, and add a test for it if it is.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Windows result for head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, The tests this PR adds or extends, AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
|
Compared the limiter at The DSP matches the #21876 reading: Three points differ from the #8039 measurement:
Not checked: the rate source, placement relative to channel mapping, and the mixer inputs. AI-assisted: yes (Claude Code) |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing in the inspected changes blocks merging; the author-reported checks were not run during this review.
What I ran
Reviewed head e301b1244b67993a45c537691d21488ff700dfac using repo_read.py to inspect the prepared diff and changed source at that head. No commands or tests were run by me; no merged-preview check was performed.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed code review | passed | All four changed files read |
| Tests | not run | Reported by author, not run here |
| Console behavior | not run | Firmware behavior remains partly unverified |
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests or console runs were performed by me. The author reports Linux x86-64 Release test runs, but those results were not independently verified. Firmware placement, limiter sample rate source, event lifecycle flags, and bit-exact output remain unverified per the change documentation. Read all changed files listed in the manifest: Render.cpp, Voice.cpp, Ngs2Render.cpp, and feat-ngs2-mastering-limiter.md; no changed files were excluded.
To get this to a good state
Nothing is required.
What
Implement the standard PS5 NGS2 mastering limiter (
0x30000003) using a linked peak detector over 32-sample blocks, with 10 ms attack and 100 ms release. Reuse the compressor render path and apply the limiter before output channel mapping and mastering gain. Follow the published firmware 13.42 DSP analysis.This addresses the limiter portion of #21876. The LFE effect remains open. The firmware placement, sample rate source and event lifecycle flags remain unverified. The review update follows the PS5 13.590.001 measurements: NaN disables the limiter, mastering setup clears it, and thresholds clamp to [0, 1].
The overlap tool could not automatically compare #1384 and #5548 against main. I manually compared both diffs and the nearby custom mastering PR #18501. Their overlapping files cover reverb, sampler PCM input and custom mastering modules respectively.
Tested
Linux x86-64, GCC 16.2.1, Release, rebased on
cc2b8933b1.ngs2_render,ngs2_core_render,ngs2_routing, andngs2_jobcontrolall passed. The new render regression compares step and sine input against a reference envelope across two linked channels and checks NaN and bypass behavior. No title or console run.Review update at
e301b1244b: Linux x86-64 Release, rebuilt and passedngs2_core_renderandngs2_render. The native suite checks that NaN and a fresh setup bypass the limiter on above-threshold input, that zero attenuates, and that out-of-range values (including infinities) match the corresponding endpoint. Conventions passed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)