ngs2: accept and ignore mastering control 2 that Trackmania sends (PPSA02195) #2364
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2364
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2364"
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?
@simonbronk on GitHub · 2026-11-17 22:43 UTC · original
simonbronk:fix/trackmania-ngs2-mastering→main· +33 −0 · 2 files · 2 commits · openFixes #2252.
Trackmania (PPSA02195) stops at boot with:
The game sends control 2 to a Mastering rack voice, with an 8-byte payload. The
case 0x3000branch ofNgs2VoiceControlonly handles controls 0, 1, 4 and 5, so control 2 hits theEXIT.Change
TestMasteringUnknownControlintests/Ngs2SamplerTests.cppsends{size=16, next=0, id=0x30000002}to a Mastering voice and checks it returns OK.Testing
ngs2_sampler_tests: passes with the change; without it, it aborts with the same message as the issue.AI disclosure
I'm not an experienced C++ developer. I wrote this with an AI assistant (Claude). I reviewed the diff and ran the test above with and without the change myself.
@Ekt0re on GitHub · 2026-11-17 22:45 UTC · original
Hey, I'm going to try this solution myself this Friday!
@coderabbitai[bot] on GitHub · 2026-11-17 22:47 UTC · original · edited 2026-11-21 11:10 UTC
No actionable comments were generated in the recent review.
Walkthrough
The mastering control handler now accepts control IDs 2 and 3. It logs a warning once for each ID and ignores the control. The new test submits control IDs 0x30000002 and 0x30000003, verifies that both calls return OK, and runs from the test runner.
Suggested reviewers:
nmzik,mrbigbritchesChange: Bug fix · Severity of issue fixed: Medium
Merge Risk:
Minimal · up to
bb284This change stops Trackmania from halting on mastering controls 2 and 3 by accepting and ignoring them with a one-time warning. The risk is low and contained to these two controls. The author has not yet reported an in-game retest, so the startup fix is unconfirmed.
Pre-merge checks:
4
#2252] The issue requires that Trackmania (PPSA02195) no longer stops on the fatal errorunsupported mastering control: 0x30000002. The whole-PR diff against the merge base addscase 2:and `case…src/libs/ngs2.cppandtests/Ngs2SamplerTests.cpp. The source change adds two case labels that share one warning and break path. Control 3 is included because the rep…Full details: Title check
Explanation
The title names the main change: the NGS2 mastering control 2 used by Trackmania (PPSA02195) is now accepted and ignored. The code also accepts control 3, which the title does not mention, but that is a secondary detail. The title is specific and matches the changeset.
Full details: Description check
Explanation
The description states the problem (Trackmania stops at boot on unsupported mastering control 0x30000002), the fix (accept and ignore the control with a one-time warning), the added test, testing results, and an AI disclosure. It relates directly to the changeset.
Full details: Linked Issues check
Explanation
[
#2252] The issue requires that Trackmania (PPSA02195) no longer stops on the fatal errorunsupported mastering control: 0x30000002. The whole-PR diff against the merge base addscase 2:andcase 3:to the masteringNgs2VoiceControlswitch insrc/libs/ngs2.cpp. Both cases log a one-time warning per control ID and then break, so neither reaches the fatal default path. The per-ID warning flag usesparam->id & 1u, which maps IDs 2 and 3 to separate flags.TestMasteringUnknownControlintests/Ngs2SamplerTests.cppsends a 16-byte header with a 2-element zeroed payload for0x30000002and0x30000003, checks both returnOK, and is called frommain. The objectives report an in-game test where control0x30000002was ignored and the game then stopped on0x30000003. Control 3 handling is therefore needed for the reported startup path. The issue's expected outcome, that the game reaches the logos, is a runtime result. No retest result is provided, so that outcome is not verified. The coding requirement to remove the fatal failure is implemented and covered by a test.Full details: Out of Scope Changes check
Explanation
The whole-PR diff touches only
src/libs/ngs2.cppandtests/Ngs2SamplerTests.cpp. The source change adds two case labels that share one warning and break path. Control 3 is included because the reported in-game test stopped on0x30000003after control 2 was accepted. This links the change to#2252. The test adds one function that covers both controls and one call inmain. No unrelated files or hunks appear. The controls are ignored, not emulated, which matches the PR description. The PR description still mentions only control 2, but the current code and test cover control 3 as well. This is a stale description, not an unrelated change.Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
128941c7-c0e5-483f-af8f-7f74acd80b3dReviewing files that changed from the base of the PR and between
8a8f53ba9dandbb2840be4c.src/libs/ngs2.cpptests/Ngs2SamplerTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@coderabbitai[bot] on GitHub · 2026-11-17 22:47 UTC · original · edited 2026-11-21 11:07 UTC
On
src/libs/ngs2.cppline 3003 (outdated):Use an atomic exchange for the one-time mastering control warning.
The
warnedflag is a plainstatic boolshared by all callers. Each caller holds only its own system's lock (voice->rack->ngs->mutex), so calls on voices from different systems can accesswarnedat the same time. That is a data race. It can also log the warning more than once.Replace the flag with an atomic.
exchangesets the flag and returns the previous value, so exactly one call logs the warning.Suggested fix
✅ Addressed in commit
bb2840b@coderabbitai[bot] on GitHub · 2026-11-17 22:47 UTC · original · reviewed
Actionable comments posted: 1
2717387e-e538-413e-a82b-6c75efa43f95Reviewing files that changed from the base of the PR and between
2638b1b076and8a8f53ba9d.src/libs/ngs2.cpptests/Ngs2SamplerTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@Ekt0re on GitHub · 2026-11-19 21:13 UTC · original
@simonbronk Hi, I tested your fix!
The game crashes with the following error:
Without the crash, it is as follows:
@simonbronk on GitHub · 2026-11-21 11:08 UTC · original
Thanks for testing! I pushed
bb2840be: mastering control 3 (0x30000003) is now accepted and ignored like control 2, and the warning flag is atomic per CodeRabbit's review. Could you retest? If anotherunsupported mastering controlshows up, please post the id and I'll extend it.@Ekt0re on GitHub · 2026-11-21 13:20 UTC · original
@simonbronk Hi, I tested your fix!
Now there is a new error:
@Ekt0re on GitHub · 2026-11-21 13:36 UTC · original
Hey, I'm personally working on a fix for the game! And for the NGS2 module.
I'm using your fix and adding the following:
I was able to access the game menus.
I encountered an infinite loop caused by:
Unresolved import stub called: IZ-qjhRqvjk[Http2_v1][Http2_v1.1][Func]By disabling it online in the emulator settings, I got past the login screen and reached a crash:
@Ekt0re on GitHub · 2026-11-21 13:52 UTC · original · edited 2026-11-21 13:53 UTC
Bug fix: Not implemented (format.waveform_type != 0x12) in src/libs/ngs2.cpp:1220
The error was caused by the fact that the NGS2 Sampler assumed that all linear PCM streams were exclusively 16-bit (0x12 / SCE_NGS2_WAVEFORM_TYPE_PCM_I16L). When a game (such as Trackmania) or an application configures the voice with another standard PCM format (for example, 0x18 for 32-bit floating-point PCM, 0x11 for 8-bit, 0x14 for 24-bit, 0x16 for 32-bit integer, 0x1a for 64-bit floating-point), the strict check EXIT_NOT_IMPLEMENTED(format.waveform_type != 0x12) would halt execution.
@Ekt0re on GitHub · 2026-11-21 15:27 UTC · original
@simonbronk Hi, I've created a pull request with the fix I made for Trackmania, which extends NGS2. (I've added you as a collaborator.)
Link: https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/2493
@simonbronk on GitHub · 2026-11-21 17:52 UTC · original
Thanks a lot for testing it and for going much further! #2493 covers my change and the rest of the NGS2 work, so I'll close this PR once yours is merged.
@lordra9-svg on GitHub · 2026-11-25 13:02 UTC · original
This branch looks superseded by main now. The controls it accepts-and-ignores are implemented there:
0x30000002is the LFE enable/cutoff:case 2setslfe_enable_flagand callsNgs2SetMasteringLfe(src/libs/ngs2.cpp:4111-4116on main), frome04070ad"ngs2: low-pass the mastering voice's LFE channel" (2026-11-23).0x30000003is the limiter:case 3setslimiter_enable_flag, threshold, attack and release(
src/libs/ngs2.cpp:4118-4128), from11dc92d6"ngs2: limit the mastering voice with a linked32-sample peak limiter" (2026-11-23).
0x30000006is the peak meter detect type:case 6(src/libs/ngs2.cpp:4139-4144), frombb1a4dbb"ngs2: meter the mastering voice's input and output peaks" (2026-11-23).GitHub reports this branch
CONFLICTING(base2638b1b0, headbb2840be). Resolving it bykeeping the added
case 2/case 3would shadow the LFE filter and limiter with no-ops instead ofapplying them.
Since #2493 already extends the NGS2 surface for Trackmania and covers the remaining controls,
closing this in favour of #2493 looks right; nothing from this branch is needed on current main.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.