feat(ngs2): parse forward ATRAC9 waveform loops #1301

Merged
TibixDev merged 1 commit from upstream-pr/1301 into main 2026-10-08 10:53:12 +00:00
TibixDev commented 2026-10-07 22:45:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-07T22:45:46Z.


What

Parse one forward ATRAC9 loop from a RIFF smpl chunk. Split the waveform into intro, loop, and tail blocks with decoder history and encoder delay preserved. Read sampler chunks after the audio data, and reject malformed or unsupported loops.

Tested

Fedora 44, Release: all six NGS2 tests pass. Loop tests compare rendered samples with LibAtrac9 decoding. They cover finite repeats, loop exit, trailing sampler chunks, truncated chunks, and invalid ranges. Sources and unverified console behavior are recorded in TechnicalDebt.md.

Checklist

  • Current main; no duplicate open PR.
  • One topic.
  • No new code comments.
  • Unsupported paths still throw; UI stubs are documented.
  • No notes, logs, or images in the repository.
  • No new third-party code.
  • General behavior.
  • Depends on: none.
  • AI-assisted: yes.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4779392343 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1301). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-07T22:45:46Z. --- ### What Parse one forward ATRAC9 loop from a RIFF `smpl` chunk. Split the waveform into intro, loop, and tail blocks with decoder history and encoder delay preserved. Read sampler chunks after the audio data, and reject malformed or unsupported loops. ### Tested Fedora 44, Release: all six NGS2 tests pass. Loop tests compare rendered samples with LibAtrac9 decoding. They cover finite repeats, loop exit, trailing sampler chunks, truncated chunks, and invalid ranges. Sources and unverified console behavior are recorded in `TechnicalDebt.md`. ### Checklist - [x] Current `main`; no duplicate open PR. - [x] One topic. - [x] No new code comments. - [x] Unsupported paths still throw; UI stubs are documented. - [x] No notes, logs, or images in the repository. - [x] No new third-party code. - [x] General behavior. - [x] Depends on: none. - [x] AI-assisted: yes.
TibixDev commented 2026-10-08 07:01:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T07:01:02Z.


Rebased on bc1fbe81. Kept the upstream PCM stream tests. The ATRAC9 loop implementation is unchanged.

Fedora 44 Release: ngs2_core_render_tests, ngs2_render_tests, ngs2_atrac9_tests, ngs2_filter_tests, ngs2_custom_tests, ngs2_parse_tests, ngs2_stream_tests build; the targeted tests and contribution checks pass. Windows CI is pending.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6054409575 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1301#issuecomment-6054409575). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-08T07:01:02Z. --- Rebased on `bc1fbe81`. Kept the upstream PCM stream tests. The ATRAC9 loop implementation is unchanged. Fedora 44 Release: `ngs2_core_render_tests`, `ngs2_render_tests`, `ngs2_atrac9_tests`, `ngs2_filter_tests`, `ngs2_custom_tests`, `ngs2_parse_tests`, `ngs2_stream_tests` build; the targeted tests and contribution checks pass. Windows CI is pending.
adriadam10 commented 2026-10-08 10:53:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T10:53:09Z.


Checked build and full ctest (440/440), ngs2_atrac9 fails without the change and passes with it; the loop tests compare against LibAtrac9, not the PR's own output. The smpl layout and the inclusive end / encoder-delay subtraction match vgmstream riff.c at the cited commit. Linux, Windows and conventions are green; merging.

Two notes, not blocking:

  • ReadChunks now also rejects a chunk (including data) larger than the declared RIFF size, where main accepted it truncated. Fine, but it isn't mentioned in the description or TechnicalDebt.md.
  • #1300 will conflict with this one in TechnicalDebt.md (adjacent lines), and its "num_repeats == 0 means streamed block" check also matches the intro/tail blocks created here. Please re-check that after rebasing #1300.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6058278911 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1301#issuecomment-6058278911). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T10:53:09Z. --- Checked build and full ctest (440/440), `ngs2_atrac9` fails without the change and passes with it; the loop tests compare against LibAtrac9, not the PR's own output. The `smpl` layout and the inclusive end / encoder-delay subtraction match vgmstream `riff.c` at the cited commit. Linux, Windows and conventions are green; merging. Two notes, not blocking: - `ReadChunks` now also rejects a chunk (including `data`) larger than the declared RIFF size, where `main` accepted it truncated. Fine, but it isn't mentioned in the description or `TechnicalDebt.md`. - #1300 will conflict with this one in `TechnicalDebt.md` (adjacent lines), and its "`num_repeats == 0` means streamed block" check also matches the intro/tail blocks created here. Please re-check that after rebasing #1300.
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!1301
No description provided.