feat(libSceNgs2): process the custom Gain module #9233

Merged
EdouardSence merged 4 commits from upstream-pr/9233 into main 2026-10-23 02:32:09 +00:00
EdouardSence commented 2026-10-21 15:55:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-21T15:55:28Z.


What

Follow-up to #8609: the custom submixer rack (0x4002) now processes the Gain module (0x15), as fma-rc read it from the PS5 12.70 module in #8039 (comment).

  • Voice parameter 0x40001500 | module index, Ngs2CustomVoiceGainParam: 37 floats, one linear level per channel. A smaller parameter is rejected like other short parameters.
  • Levels start at 0, the module's default, so a Gain module whose voice never receives the parameter outputs silence.
  • Each grain multiplies the voice's samples, in module order with the other custom modules, by a level that ramps linearly from the previous level to the new one. The grain's first sample is one step past the previous level, and its last sample is at the new level. The ramp position is not confirmed, and the debt entry says so.
  • Still throws:
    • a level outside -32 to 32 (fma-rc's table range; what the library does with one is unknown);
    • Gain on a custom sampler rack (0x4001), whose parameter index fma-rc reads as one higher;
    • Reverb, PitchShift and Convolution.
  • Ngs2CheckCustomRack takes the rack id for that check.
  • Debt: Gain leaves the "not processed" list of the custom module ids entry, and a new entry lists what is unverified.

Overlap: #5548 changes the declaration next to Ngs2CheckCustomRack in Ngs2Internal.hpp, #8692 a nearby line of Ngs2Types.hpp, and #8851 the same debt entry. All are textual.

Tested

  • Linux (CachyOS, GCC), -DBUILD_TESTING=ON: the 13 ngs2_* tests pass. The new TestCustomGain in Ngs2Custom.cpp feeds a 0.5 sampler through a Gain submixer. It checks silence without a parameter, the ramp to 2 and -0.5 on the first grain, the steady level on the next grain, the ramp back down to 1, and the rejections (level 33, wrong module index, sampler voice, short parameter). TestCustomRackChecks now creates a Gain rack on the submixer and expects a throw on the custom sampler rack.
  • Rise of the Ronin (PPSA04540 01.009.000), Linux, RX 9070 XT / RADV Mesa 26.2.4. Build: main + #8341 + #8609 + this. Its Gain racks now pass creation, and the title stops ~30 s in on the next module of the same rack: NGS2: the custom Reverb module is not implemented. That stop comes at rack creation, so Gain processing itself has not run in the title yet. One 150 s run.
  • Not tested: Windows, other titles.

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: #8609
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Tested and written by Claude (AI assistant) on a contributor's machine.
AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4954460562 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9233). Originally posted by [EdouardSence](https://github.com/EdouardSence) on 2026-10-21T15:55:28Z. --- ### What Follow-up to #8609: the custom submixer rack (`0x4002`) now processes the Gain module (`0x15`), as fma-rc read it from the PS5 12.70 module in #8039 ([comment](https://github.com/boykopovar/AnyPS5/issues/8039#issuecomment-6319332943)). - Voice parameter `0x40001500 | module index`, `Ngs2CustomVoiceGainParam`: 37 floats, one linear level per channel. A smaller parameter is rejected like other short parameters. - Levels start at 0, the module's default, so a Gain module whose voice never receives the parameter outputs silence. - Each grain multiplies the voice's samples, in module order with the other custom modules, by a level that ramps linearly from the previous level to the new one. The grain's first sample is one step past the previous level, and its last sample is at the new level. The ramp position is not confirmed, and the debt entry says so. - Still throws: - a level outside -32 to 32 (fma-rc's table range; what the library does with one is unknown); - Gain on a custom sampler rack (`0x4001`), whose parameter index fma-rc reads as one higher; - Reverb, PitchShift and Convolution. - `Ngs2CheckCustomRack` takes the rack id for that check. - Debt: Gain leaves the "not processed" list of the custom module ids entry, and a new entry lists what is unverified. Overlap: #5548 changes the declaration next to `Ngs2CheckCustomRack` in `Ngs2Internal.hpp`, #8692 a nearby line of `Ngs2Types.hpp`, and #8851 the same debt entry. All are textual. ### Tested - Linux (CachyOS, GCC), `-DBUILD_TESTING=ON`: the 13 `ngs2_*` tests pass. The new `TestCustomGain` in `Ngs2Custom.cpp` feeds a 0.5 sampler through a Gain submixer. It checks silence without a parameter, the ramp to 2 and -0.5 on the first grain, the steady level on the next grain, the ramp back down to 1, and the rejections (level 33, wrong module index, sampler voice, short parameter). `TestCustomRackChecks` now creates a Gain rack on the submixer and expects a throw on the custom sampler rack. - Rise of the Ronin (PPSA04540 01.009.000), Linux, RX 9070 XT / RADV Mesa 26.2.4. Build: `main` + #8341 + #8609 + this. Its Gain racks now pass creation, and the title stops ~30 s in on the next module of the same rack: `NGS2: the custom Reverb module is not implemented`. That stop comes at rack creation, so Gain processing itself has not run in the title yet. One 150 s run. - Not tested: Windows, other titles. ### 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: #8609 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes *Tested and written by Claude (AI assistant) on a contributor's machine.* AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
KernelPanicNT commented 2026-10-21 19:03:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by KernelPanicNT on 2026-10-21T19:03:21Z.


Nice work, and thanks for testing it on Ronin straight away! Your runs on #8609 have been a big help in getting these racks right. I had a Gain branch going too, but yours covers the same ground on 0x4002, so I'll drop mine. Keeping Gain to 0x4002 for now is a good call: the 0x4001 parameter index is still an open question with fma-rc (question 5 here).

Two small things I noticed while comparing:

  1. A Gain module with an option. Right now a Gain module with a non-null option passes creation and runs: CheckBuiltInModule only looks at Gain's state size, and Ngs2CheckCustomRack then reaches the continue for Gain on 0x4002. fma-rc's first reading says "Gain and UserFx take no option and no state" (comment), and your debt entry already lists the error for a Gain option as unknown, so I think it should throw. Something like this before the continue:
    if (option.module[m].option != nullptr) throw std::runtime_error("NGS2: an option for the custom Gain module is not implemented");
    
  2. Debt wording. Now that Gain works, the "custom submixer rack" entry's "Only these two modules on one buffer work" should include it. The stale 0x1d lines in that entry and in "custom module ids" are mine, from #8609, written before fma-rc said 0x1d is Delay. I'll fix those in a small follow-up once #8609 lands, so you won't need to rebase for it.

In case they're useful, my tests for the option rejection, NaN and the ±32 limits are in Ngs2Custom.cpp on this commit (TestCustomRackChecks, TestCustomGain). Feel free to take anything. On the ramp, you use (i+1)/n and I had i/n; neither is confirmed yet (question 6 to fma-rc), so your debt note is the right way to leave it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6324168539 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9233#issuecomment-6324168539). Originally posted by [KernelPanicNT](https://github.com/KernelPanicNT) on 2026-10-21T19:03:21Z. --- Nice work, and thanks for testing it on Ronin straight away! Your runs on #8609 have been a big help in getting these racks right. I had a Gain branch going too, but yours covers the same ground on `0x4002`, so I'll drop mine. Keeping Gain to `0x4002` for now is a good call: the `0x4001` parameter index is still an open question with fma-rc ([question 5 here](https://github.com/boykopovar/AnyPS5/issues/8039#issuecomment-6320348229)). Two small things I noticed while comparing: 1. **A Gain module with an option.** Right now a Gain module with a non-null `option` passes creation and runs: `CheckBuiltInModule` only looks at Gain's state size, and `Ngs2CheckCustomRack` then reaches the `continue` for Gain on `0x4002`. fma-rc's first reading says "Gain and UserFx take no option and no state" ([comment](https://github.com/boykopovar/AnyPS5/issues/8039#issuecomment-6294323150)), and your debt entry already lists the error for a Gain option as unknown, so I think it should throw. Something like this before the `continue`: ```cpp if (option.module[m].option != nullptr) throw std::runtime_error("NGS2: an option for the custom Gain module is not implemented"); ``` 2. **Debt wording.** Now that Gain works, the "custom submixer rack" entry's "Only these two modules on one buffer work" should include it. The stale `0x1d` lines in that entry and in "custom module ids" are mine, from #8609, written before fma-rc said `0x1d` is Delay. I'll fix those in a small follow-up once #8609 lands, so you won't need to rebase for it. In case they're useful, my tests for the option rejection, NaN and the ±32 limits are in [`Ngs2Custom.cpp` on this commit](https://github.com/KernelPanicNT/AnyPS5/commit/9a10093c8131300a8384d16f3c30a8210a066030) (`TestCustomRackChecks`, `TestCustomGain`). Feel free to take anything. On the ramp, you use `(i+1)/n` and I had `i/n`; neither is confirmed yet (question 6 to fma-rc), so your debt note is the right way to leave it.
ycbuzi commented 2026-10-21 20:49:16 +00:00 (Migrated from github.com)

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


Windows run of 8c9444b5ae merged onto main 0c6a5bd593 (98e9ede9a9, 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_custom_tests with no errors or warnings. ctest --repeat until-fail:2 on ngs2_custom: passes on both repeats. Not run: a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6326236554 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9233#issuecomment-6326236554). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T20:49:16Z. --- Windows run of 8c9444b5ae merged onto `main` 0c6a5bd593 (98e9ede9a9, 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_custom_tests` with no errors or warnings. `ctest --repeat until-fail:2` on `ngs2_custom`: passes on both repeats. Not run: a title.
EdouardSence commented 2026-10-22 07:11:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-22T07:11:20Z.


@KernelPanicNT thanks for the review, both points are in 8f6f1eac8:

  1. A Gain module with a non-null option now throws NGS2: an option for the custom Gain module is not implemented at rack creation, before the submixer continue. TestCustomRackChecks covers it (fails on the previous head at that check, passes now).
  2. The custom submixer debt entry now reads "Only these two modules and Gain on one buffer work", and the Gain entry says an option throws because the library's error for one is unknown. I left the 0x1d lines for your follow-up.

All 13 ngs2_* tests pass on Linux. I kept the (i+1)/n ramp with its debt note until fma-rc answers question 6.

Written by Claude (AI assistant) on a contributor's machine.
AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6334983626 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9233#issuecomment-6334983626). Originally posted by [EdouardSence](https://github.com/EdouardSence) on 2026-10-22T07:11:20Z. --- @KernelPanicNT thanks for the review, both points are in 8f6f1eac8: 1. A Gain module with a non-null `option` now throws `NGS2: an option for the custom Gain module is not implemented` at rack creation, before the submixer `continue`. `TestCustomRackChecks` covers it (fails on the previous head at that check, passes now). 2. The custom submixer debt entry now reads "Only these two modules and Gain on one buffer work", and the Gain entry says an option throws because the library's error for one is unknown. I left the `0x1d` lines for your follow-up. All 13 `ngs2_*` tests pass on Linux. I kept the `(i+1)/n` ramp with its debt note until fma-rc answers question 6. *Written by Claude (AI assistant) on a contributor's machine.* AI-assisted: yes
ycbuzi commented 2026-10-22 08:34:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-22T08:34:28Z.


Windows run of 8f6f1eac86, the update since my earlier run, merged onto main d6eafa54d0 (3889ea1863, clean). 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_custom_tests with no errors or warnings. ctest --repeat until-fail:2 on ngs2_custom: passes on both repeats. Not run: a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336426281 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9233#issuecomment-6336426281). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-22T08:34:28Z. --- Windows run of 8f6f1eac86, the update since my earlier run, merged onto `main` d6eafa54d0 (3889ea1863, clean). 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_custom_tests` with no errors or warnings. `ctest --repeat until-fail:2` on `ngs2_custom`: passes on both repeats. Not run: a title.
JJenkx commented 2026-10-22 09:07:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T09:07:26Z.


Title data point: BLUE REFLECTION Quartet (PPSA33655). Its racks are listed in #8851:

  • MixerB: 0x19;
  • ReverbB: 0x15 Gain + 0x1b Reverb (12-byte option);
  • DuckingCompSB: 0x19 ×2, 2 buffers.

The stop moves forward with each PR. Same scripted runs, natively on Linux 7.2.9, Radeon RX 6650 XT, RADV Mesa 26.2.4, GCC Release:

Build Stop
main d6eafa54d0 2 s: NGS2: custom module id 0x19 is not implemented
d6eafa54d0 + #9337 ea6fc50b30 4 s: NGS2: the custom Gain module is not implemented
d6eafa54d0 + #9337 + #9233 8f6f1eac86 2 s: NGS2: the custom Reverb module is not implemented

So:

  • with #9337, the 0x19 modules in MixerB pass creation as UserFx;
  • with #9233 added, the Gain module in ReverbB passes;
  • the next stop is Reverb (0x1b), which neither PR covers;
  • after that comes DuckingCompSB, which needs 2-buffer racks.

No audio was produced or checked; this only shows rack creation getting further. Combining the two PRs conflicted in Ngs2Types.hpp: I kept both SCE_NGS2_CUSTOM_VOICE_PARAM_GAIN and #9337's UserFx id 0x40001900. It also conflicted in the test and debt files, where I kept #9337's side; those are not built in this test.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6337031553 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9233#issuecomment-6337031553). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-22T09:07:26Z. --- Title data point: **BLUE REFLECTION Quartet (PPSA33655)**. Its racks are listed in #8851: - `MixerB`: 0x19; - `ReverbB`: 0x15 Gain + 0x1b Reverb (12-byte option); - `DuckingCompSB`: 0x19 ×2, 2 buffers. The stop moves forward with each PR. Same scripted runs, natively on Linux 7.2.9, Radeon RX 6650 XT, RADV Mesa 26.2.4, GCC Release: | Build | Stop | |---|---| | `main` `d6eafa54d0` | 2 s: `NGS2: custom module id 0x19 is not implemented` | | `d6eafa54d0` + #9337 `ea6fc50b30` | 4 s: `NGS2: the custom Gain module is not implemented` | | `d6eafa54d0` + #9337 + #9233 `8f6f1eac86` | 2 s: `NGS2: the custom Reverb module is not implemented` | So: - with #9337, the 0x19 modules in `MixerB` pass creation as UserFx; - with #9233 added, the Gain module in `ReverbB` passes; - the next stop is Reverb (0x1b), which neither PR covers; - after that comes `DuckingCompSB`, which needs 2-buffer racks. No audio was produced or checked; this only shows rack creation getting further. Combining the two PRs conflicted in `Ngs2Types.hpp`: I kept both `SCE_NGS2_CUSTOM_VOICE_PARAM_GAIN` and #9337's UserFx id `0x40001900`. It also conflicted in the test and debt files, where I kept #9337's side; those are not built in this test.
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!9233
No description provided.