ngs2: degrade custom user-FX modules instead of aborting #1684

Closed
github-bot wants to merge 3 commits from gh-pr/1684/head into gh-pr/1684/base
Owner

@⁠theantipopau on GitHub · 2026-10-19 01:55 UTC · original
theantipopau:ngs2-custom-module-fallbacks → main · +168 −9 · 2 files · 3 commits · closed without merging

Sequel to #1683: with creation tolerated, the next custom-module aborts (failed FX setup, buffer-routed or handler-less modules, failed processing, unhandled/mismatched controls, failed cleanup) would each still kill the title. Convert them to warn-and-skip-module semantics — a failing module stays skipped and its voice plays through unprocessed; teardown always succeeds. Adds TestCustomModuleFallbacks (setup-failure skip, routing skip with sample passthrough, ignored mismatched control, warn-once process failure) to ngs2_sampler_tests.

**@⁠theantipopau** on GitHub · 2026-10-19 01:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1684) `theantipopau:ngs2-custom-module-fallbacks` → `main` · +168 −9 · 2 files · 3 commits · closed without merging Sequel to #1683: with creation tolerated, the next custom-module aborts (failed FX setup, buffer-routed or handler-less modules, failed processing, unhandled/mismatched controls, failed cleanup) would each still kill the title. Convert them to warn-and-skip-module semantics — a failing module stays skipped and its voice plays through unprocessed; teardown always succeeds. Adds TestCustomModuleFallbacks (setup-failure skip, routing skip with sample passthrough, ignored mismatched control, warn-once process failure) to ngs2_sampler_tests.
Follow-up to the num_buffers tolerance: the remaining custom-module
aborts (failed setup, buffer-routed or handler-less modules, failed
processing, unhandled/mismatched controls, failed cleanup) each killed
the title. Convert them to warn-and-skip-module so voices keep playing
unprocessed; teardown never fails.

Adds TestCustomModuleFallbacks covering setup failure, buffer routing,
control mismatch, and failing process handlers.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:03:10 +00:00
github-bot closed this pull request 2026-11-26 10:03:10 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-19 01:58 UTC · original · edited 2026-10-19 02:30 UTC

Review in Change Stack →

📝 Walkthrough

Custom-module setup and cleanup failures no longer abort rack operations. Rendering bypasses skipped modules and skips modules with buffer routing or no process handler. A failed process call marks the module skipped. Unhandled controls and parameter-size mismatches are ignored. Tests cover these failure paths and continued rendering after a process failure.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: 🔵 Low · up to 8e0a6

A failing custom effect can cause an audible glitch instead of cleanly passing audio through. Restore the original samples on failure before merging, or explicitly accept this bounded risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: custom user-FX modules now degrade instead of aborting.
Description check Passed The description directly explains the warn-and-skip behavior, affected failure cases, teardown behavior, and added test coverage.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-19 01:58 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1684#issuecomment-6258030132) · edited 2026-10-19 02:30 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1684?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> Custom-module setup and cleanup failures no longer abort rack operations. Rendering bypasses skipped modules and skips modules with buffer routing or no process handler. A failed process call marks the module skipped. Unhandled controls and parameter-size mismatches are ignored. Tests cover these failure paths and continued rendering after a process failure. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"8e0a6c1758ef5a1be5745eddda96b1e6fdf727cc" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🔵 Low</strong> · up to <code>8e0a6</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `8e0a6` --> <!-- final_review_risk_coverage:{"sourceCommitId":"8e0a6c1758ef5a1be5745eddda96b1e6fdf727cc","coveredCommitId":"8e0a6c1758ef5a1be5745eddda96b1e6fdf727cc","kind":"reviewed"} --> A failing custom effect can cause an audible glitch instead of cleanly passing audio through. Restore the original samples on failure before merging, or explicitly accept this bounded risk. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 2 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: custom user-FX modules now degrade instead of aborting. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the warn-and-skip behavior, affected failure cases, teardown behavior, and added test coverage. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1684)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -1440,0 +1447,4 @@
// Teardown must not fail; the rack is being destroyed anyway.
Log::WriteToConsoleAndLog(fmt::sprintf(
"warning: NGS2 user-FX cleanup failed for module %zu\n", m));
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-19 01:58 UTC · original · edited 2026-10-19 02:21 UTC

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1200,1222p;1436,1456p' src/libs/ngs2.cpp
rg -n 'define LOGF' src | head
rg -n 'LOGF\(|WriteToConsoleAndLog' src/libs/ngs2.cpp | head -40

Repository: KytyPS5/KytyPS5

Length of output: 4693


🏁 Script executed:

sed -n '45,75p' src/common/logging/log.h
printf '%s\n' '--- skipped references ---'
rg -n -F -- 'module.skipped' src/libs/ngs2.cpp tests src 2>/dev/null || test "$?" -eq 1
printf '%s\n' '--- user-FX declarations and cleanup references ---'
rg -n -F -e 'Ngs2UserFxContext' -e 'cleanup' -e 'TestCustomModuleFallbacks' src tests 2>/dev/null || test "$?" -eq 1
printf '%s\n' '--- focused diff ---'
git diff 099de8dea62cbf17c8e06a6c24e72b38475d1566 9590800b201de8de3f201ca4583fcd8109488380 -- src/libs/ngs2.cpp src/common/logging/log.h

Repository: KytyPS5/KytyPS5

Length of output: 12609


🏁 Script executed:

sed -n '330,390p;1588,1660p' src/libs/ngs2.cpp tests/Ngs2SamplerTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 4743


🏁 Script executed:

sed -n '1595,1660p' tests/Ngs2SamplerTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 3081


🏁 Script executed:

rg -n -F -e 'void Write(' -e 'WriteToConsoleAndLog' -e 'Log::Write(' -e 'IsSilent' src/common/logging src | head -80
sed -n '1,55p' src/common/logging/log.h

Repository: KytyPS5/KytyPS5

Length of output: 6288


🏁 Script executed:

sed -n '120,205p' src/common/logging/log.cpp

Repository: KytyPS5/KytyPS5

Length of output: 2019


Use Log::WriteToConsoleAndLog for the cleanup warning.

LOGF is not compiled out in release builds, but it calls Log::Write and can suppress output when Log::IsSilent() is true. Log::WriteToConsoleAndLog also writes to stdout and matches the surrounding custom-module warnings.

Do not add a module.skipped guard without a defined cleanup contract. The current test covers failed setup with a cleanup callback, and the source does not establish that cleanup is unsafe after setup failure.

Suggested fix
-						LOGF("warning: NGS2 user-FX cleanup failed for module %zu\n", m);
+						Log::WriteToConsoleAndLog(fmt::sprintf(
+						    "warning: NGS2 user-FX cleanup failed for module %zu\n", m));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

					if (fx.cleanup(&context) != OK) {
						// Teardown must not fail; the rack is being destroyed anyway.
						Log::WriteToConsoleAndLog(fmt::sprintf(
						    "warning: NGS2 user-FX cleanup failed for module %zu\n", m));
					}

✅ Addressed in commit 7f40fa8

**@⁠coderabbitai[bot]** on GitHub · 2026-10-19 01:58 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1684#discussion_r4309745945) · edited 2026-10-19 02:21 UTC **📐 Maintainability & Code Quality** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '1200,1222p;1436,1456p' src/libs/ngs2.cpp rg -n 'define LOGF' src | head rg -n 'LOGF\(|WriteToConsoleAndLog' src/libs/ngs2.cpp | head -40 ``` Repository: KytyPS5/KytyPS5 Length of output: 4693 --- 🏁 Script executed: ```bash sed -n '45,75p' src/common/logging/log.h printf '%s\n' '--- skipped references ---' rg -n -F -- 'module.skipped' src/libs/ngs2.cpp tests src 2>/dev/null || test "$?" -eq 1 printf '%s\n' '--- user-FX declarations and cleanup references ---' rg -n -F -e 'Ngs2UserFxContext' -e 'cleanup' -e 'TestCustomModuleFallbacks' src tests 2>/dev/null || test "$?" -eq 1 printf '%s\n' '--- focused diff ---' git diff 099de8dea62cbf17c8e06a6c24e72b38475d1566 9590800b201de8de3f201ca4583fcd8109488380 -- src/libs/ngs2.cpp src/common/logging/log.h ``` Repository: KytyPS5/KytyPS5 Length of output: 12609 --- 🏁 Script executed: ```bash sed -n '330,390p;1588,1660p' src/libs/ngs2.cpp tests/Ngs2SamplerTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 4743 --- 🏁 Script executed: ```bash sed -n '1595,1660p' tests/Ngs2SamplerTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 3081 --- 🏁 Script executed: ```bash rg -n -F -e 'void Write(' -e 'WriteToConsoleAndLog' -e 'Log::Write(' -e 'IsSilent' src/common/logging src | head -80 sed -n '1,55p' src/common/logging/log.h ``` Repository: KytyPS5/KytyPS5 Length of output: 6288 --- 🏁 Script executed: ```bash sed -n '120,205p' src/common/logging/log.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 2019 --- </details> **Use `Log::WriteToConsoleAndLog` for the cleanup warning.** `LOGF` is not compiled out in release builds, but it calls `Log::Write` and can suppress output when `Log::IsSilent()` is true. `Log::WriteToConsoleAndLog` also writes to stdout and matches the surrounding custom-module warnings. Do not add a `module.skipped` guard without a defined cleanup contract. The current test covers failed setup with a cleanup callback, and the source does not establish that cleanup is unsafe after setup failure. <details> <summary>Suggested fix</summary> ```diff - LOGF("warning: NGS2 user-FX cleanup failed for module %zu\n", m); + Log::WriteToConsoleAndLog(fmt::sprintf( + "warning: NGS2 user-FX cleanup failed for module %zu\n", m)); ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion if (fx.cleanup(&context) != OK) { // Teardown must not fail; the rack is being destroyed anyway. Log::WriteToConsoleAndLog(fmt::sprintf( "warning: NGS2 user-FX cleanup failed for module %zu\n", m)); } ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:2b78dbc7c49daefe3c7f7ea7 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 7f40fa8
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-19 01:58 UTC · original · reviewed

Actionable comments posted: 1

🧹 Nitpick comments: 1
tests/Ngs2SamplerTests.cpp: 1

1697-1698: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

The test message does not match the assertion.

process_calls == 1 proves the module is skipped after the first failure. It does not prove a warning is emitted once. The test does not capture log output. Rename the message to describe the skip behavior, or capture the log and assert the warning count.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3a301f49-7cf4-42d5-ad41-7ac999470a38
📥 Commits

Reviewing files that changed from the base of the PR and between 099de8dea6 and 9590800b20.

📒 Files selected for processing: 2
  • src/libs/ngs2.cpp
  • tests/Ngs2SamplerTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-19 01:58 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1684#pullrequestreview-5566200910) · **reviewed** **Actionable comments posted: 1** <details> <summary>🧹 Nitpick comments: 1</summary><blockquote> <details> <summary>tests/Ngs2SamplerTests.cpp: 1</summary><blockquote> `1697-1698`: **📐 Maintainability & Code Quality** | **🔵 Trivial** | **💤 Low value** **The test message does not match the assertion.** `process_calls == 1` proves the module is skipped after the first failure. It does not prove a warning is emitted once. The test does not capture log output. Rename the message to describe the skip behavior, or capture the log and assert the warning count. <!-- cr-comment:v1:72eaa5a5dd05364b6a7c54b7 --> </blockquote></details> </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `3a301f49-7cf4-42d5-ad41-7ac999470a38` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 099de8dea62cbf17c8e06a6c24e72b38475d1566 and 9590800b201de8de3f201ca4583fcd8109488380. </details> <details> <summary>📒 Files selected for processing: 2</summary> * `src/libs/ngs2.cpp` * `tests/Ngs2SamplerTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=76203767-c3f4-402f-a951-4bc7df71e9f4 attempt=af98afaf-051c-4f0b-a21e-0b8dcf1571d5 batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-19 02:26 UTC · original · reviewed

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Restore the current grain when custom processing fails. · ngs2.cpp:1868-1880

src/libs/ngs2.cpp:1868-1880
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Restore the current grain when custom processing fails.

fx.process(&context) receives pointers into voice.samples. A callback can modify those samples and then return a failure. The error branch only marks the module as skipped; it does not restore voice.samples. The current render can therefore emit partial custom-module output instead of unprocessed audio.

Suggested fix
 				Ngs2UserFxProcessContext context {channels.data(),
 				                                  voice.rack->common[m].data(),
 				                                  module.param.data(),
 				                                  module.work.data(),
@@
 				                                  grain,
 				                                  voice.rack->ngs->option.sample_rate};
+				auto samples_before = voice.samples;
 				if (fx.process(&context) != OK) {
+					voice.samples.swap(samples_before);
 					// A failing module stays skipped so one bad grain cannot spam

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1e8efc67-dbb2-4f04-b8d7-5c73f13dd5f6
📥 Commits

Reviewing files that changed from the base of the PR and between 9590800b20 and 7f40fa8b87.

📒 Files selected for processing: 1
  • src/libs/ngs2.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-19 02:26 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1684#pullrequestreview-5566321447) · **reviewed** > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (1)** > > <details> > <summary><strong>🟡 Minor</strong> · Restore the current grain when custom processing fails. · <code>ngs2.cpp:1868-1880</code></summary><blockquote> > > `src/libs/ngs2.cpp:1868-1880` > **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** > > **Restore the current grain when custom processing fails.** > > `fx.process(&context)` receives pointers into `voice.samples`. A callback can modify those samples and then return a failure. The error branch only marks the module as `skipped`; it does not restore `voice.samples`. The current render can therefore emit partial custom-module output instead of unprocessed audio. > > <details> > <summary>Suggested fix</summary> > > ```diff > Ngs2UserFxProcessContext context {channels.data(), > voice.rack->common[m].data(), > module.param.data(), > module.work.data(), > @@ > grain, > voice.rack->ngs->option.sample_rate}; > + auto samples_before = voice.samples; > if (fx.process(&context) != OK) { > + voice.samples.swap(samples_before); > // A failing module stays skipped so one bad grain cannot spam > ``` > > </details> > > <!-- cr-comment:v1:0b61cc0cfcba1d2b242719be --> > > </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `1e8efc67-dbb2-4f04-b8d7-5c73f13dd5f6` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 9590800b201de8de3f201ca4583fcd8109488380 and 7f40fa8b878708290a1bdcab93159e1c99627252. </details> <details> <summary>📒 Files selected for processing: 1</summary> * `src/libs/ngs2.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=9c43b411-838c-4d3b-8cce-7c5435a224fe attempt=145e19d2-ddd0-4348-a1ad-7eeba168e491 batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-19 02:30 UTC · original · reviewed

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Restore samples after a failed custom process callback. · ngs2.cpp:1813-1877

src/libs/ngs2.cpp:1813-1877
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Restore samples after a failed custom process callback.

fx.process(&context) receives writable pointers into voice.samples. A callback can modify those samples and then return an error. The failure path skips the module without restoring the samples. The voice can therefore render modified samples instead of the intended unprocessed passthrough.

Suggested fix
+				auto unprocessed_samples = voice.samples;
 				std::vector<float*> channels(voice.channels);
 				for (uint32_t c = 0; c < voice.channels; ++c) {
 					channels[c] = voice.samples.data() + c * grain;
 				}
...
 				if (fx.process(&context) != OK) {
+					voice.samples = std::move(unprocessed_samples);
 					// A failing module stays skipped so one bad grain cannot spam

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cd21e779-aa95-48ea-8b7b-1fae8cc42b36
📥 Commits

Reviewing files that changed from the base of the PR and between 7f40fa8b87 and 8e0a6c1758.

📒 Files selected for processing: 1
  • tests/Ngs2SamplerTests.cpp
🚧 Files skipped from review as they are similar to previous changes: 1
  • tests/Ngs2SamplerTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-19 02:30 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1684#pullrequestreview-5566336825) · **reviewed** > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (1)** > > <details> > <summary><strong>🟡 Minor</strong> · Restore samples after a failed custom process callback. · <code>ngs2.cpp:1813-1877</code></summary><blockquote> > > `src/libs/ngs2.cpp:1813-1877` > **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** > > **Restore samples after a failed custom process callback.** > > `fx.process(&context)` receives writable pointers into `voice.samples`. A callback can modify those samples and then return an error. The failure path skips the module without restoring the samples. The voice can therefore render modified samples instead of the intended unprocessed passthrough. > > <details> > <summary>Suggested fix</summary> > > ```diff > + auto unprocessed_samples = voice.samples; > std::vector<float*> channels(voice.channels); > for (uint32_t c = 0; c < voice.channels; ++c) { > channels[c] = voice.samples.data() + c * grain; > } > ... > if (fx.process(&context) != OK) { > + voice.samples = std::move(unprocessed_samples); > // A failing module stays skipped so one bad grain cannot spam > ``` > > </details> > > <!-- cr-comment:v1:79cac4412c97e5a28eef2631 --> > > </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `cd21e779-aa95-48ea-8b7b-1fae8cc42b36` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 7f40fa8b878708290a1bdcab93159e1c99627252 and 8e0a6c1758ef5a1be5745eddda96b1e6fdf727cc. </details> <details> <summary>📒 Files selected for processing: 1</summary> * `tests/Ngs2SamplerTests.cpp` </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes: 1</summary> * tests/Ngs2SamplerTests.cpp </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=23d77794-51fa-4c44-aadb-07c84beac598 attempt=fc775403-64e4-4e67-b8ce-8f10f61ebb66 batch=1/1 -->
Author
Owner

@⁠Nmzik on GitHub · 2026-10-20 13:45 UTC · original

Fixed

**@⁠Nmzik** on GitHub · 2026-10-20 13:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1684#issuecomment-6292335616) Fixed

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.