libSceNgs2: VAG and HE-VAG waveforms are not parsed or decoded, so Steins;Gate Re:Boot (PPSA36591) loses its game-start sound #5677

Closed
opened 2026-10-14 06:03:53 +00:00 by milescoviello · 2 comments
milescoviello commented 2026-10-14 06:03:53 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-14T06:03:53Z.


Steins;Gate Re:Boot (PPSA36591) passes a VAG file to sceNgs2ParseWaveformData when a button is pressed at its title screen, and NGS2 returns SCE_NGS2_ERROR_UNKNOWN_WAVEFORM_FORMAT (0x804A8432), because ReadChunks accepts only RIFF/WAVE. The title then sets up the voice with an all-zero format (the path #5660 stops from crashing), so the sound is not played.

The data, read at the call (Linux, main 75690a117 plus #5660):

  • VAGp header: version 0x00020001, data size 0x25540 (152,896 bytes), sample rate 48000, byte 0x1E = 2 (channels), name gamestart, frames from 0x30.
  • The frames are HE-VAG, not the original VAG: the predictor nibble of byte 0 takes all values 0-15 (the original codec has 5 filters), and byte 1's high nibble is 0x2-0x7 in about 5,700 of 9,556 frames, its low nibble (the flags) 0, 1 or 7. That matches vgmstream's HE-VAG layout: shift in the low nibble of byte 0, a 7-bit predictor index from the high nibbles of bytes 1 and 0, four history samples.

What supporting it needs:

  1. sceNgs2ParseWaveformData (and ParseWaveformFile) recognising VAGp: waveform type 0x1C (the value sharpemu uses), the big-endian size and rate, the channel byte, 16-byte units of 28 samples per channel.
  2. A VAG decoder in the sampler voice, with the original 5-filter table and HE-VAG's 128x4 table.

The open question is the HE-VAG table. The only public source I know is vgmstream's psv_decoder.c (ISC-style license, so it can be used with its notice; vgmstream says it was reverse engineered from Sony's PC tools). CONTRIBUTING asks for third-party code as a submodule, and vgmstream is large for one table. Would a table copied with vgmstream's notice and a debt entry be acceptable, or is a submodule wanted? I can implement it either way.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5842817254 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5677). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-14T06:03:53Z. --- Steins;Gate Re:Boot (PPSA36591) passes a VAG file to `sceNgs2ParseWaveformData` when a button is pressed at its title screen, and NGS2 returns `SCE_NGS2_ERROR_UNKNOWN_WAVEFORM_FORMAT` (`0x804A8432`), because `ReadChunks` accepts only `RIFF`/`WAVE`. The title then sets up the voice with an all-zero format (the path #5660 stops from crashing), so the sound is not played. The data, read at the call (Linux, `main` 75690a117 plus #5660): - `VAGp` header: version `0x00020001`, data size `0x25540` (152,896 bytes), sample rate 48000, byte `0x1E` = 2 (channels), name `gamestart`, frames from `0x30`. - The frames are HE-VAG, not the original VAG: the predictor nibble of byte 0 takes all values 0-15 (the original codec has 5 filters), and byte 1's high nibble is 0x2-0x7 in about 5,700 of 9,556 frames, its low nibble (the flags) 0, 1 or 7. That matches [vgmstream](https://github.com/vgmstream/vgmstream/blob/master/src/coding/psv_decoder.c)'s HE-VAG layout: shift in the low nibble of byte 0, a 7-bit predictor index from the high nibbles of bytes 1 and 0, four history samples. What supporting it needs: 1. `sceNgs2ParseWaveformData` (and `ParseWaveformFile`) recognising `VAGp`: waveform type `0x1C` (the value [sharpemu](https://github.com/sharpemu/sharpemu/blob/main/src/SharpEmu.Libs/Ngs2/Ngs2WaveformParser.cs) uses), the big-endian size and rate, the channel byte, 16-byte units of 28 samples per channel. 2. A VAG decoder in the sampler voice, with the original 5-filter table and HE-VAG's 128x4 table. The open question is the HE-VAG table. The only public source I know is vgmstream's `psv_decoder.c` (ISC-style license, so it can be used with its notice; vgmstream says it was reverse engineered from Sony's PC tools). CONTRIBUTING asks for third-party code as a submodule, and vgmstream is large for one table. Would a table copied with vgmstream's notice and a debt entry be acceptable, or is a submodule wanted? I can implement it either way. AI-assisted: yes
MarcZX10 commented 2026-10-14 06:28:43 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T06:28:43Z.


I checked the repository guidance before taking this on: CONTRIBUTING.md says new third-party code should be added as a submodule and built from source. The vgmstream COPYING file grants permission under ISC terms, but copying its HE-VAG table into the tree would still need to fit that project rule. I would treat a vgmstream submodule as the compliant route, or write an independent decoder only if the coefficient table can be sourced/generated without importing that third-party data. Is a focused vgmstream submodule acceptable here, or should we keep this issue open pending an independently sourced table? This affects whether a PR can deliver the actual HE-VAG playback rather than only recognize the VAGp header.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162356364 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5677#issuecomment-6162356364). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T06:28:43Z. --- I checked the repository guidance before taking this on: `CONTRIBUTING.md` says new third-party code should be added as a submodule and built from source. The vgmstream `COPYING` file grants permission under ISC terms, but copying its HE-VAG table into the tree would still need to fit that project rule. I would treat a vgmstream submodule as the compliant route, or write an independent decoder only if the coefficient table can be sourced/generated without importing that third-party data. Is a focused vgmstream submodule acceptable here, or should we keep this issue open pending an independently sourced table? This affects whether a PR can deliver the actual HE-VAG playback rather than only recognize the VAGp header.
MarcZX10 commented 2026-10-14 13:31:54 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T13:31:54Z.


There is now a draft implementation in #5797 that follows the repository guidance by building the HE-VAG decoder from a pinned vgmstream submodule and including its license in release archives. It adds synthetic parser/renderer coverage but explicitly has not validated PPSA36591 playback; the author also records remaining cross-block and console-semantics questions. This addresses the submodule-versus-copy question with a compliant implementation route, while title playback remains unverified.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6169549489 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/5677#issuecomment-6169549489). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T13:31:54Z. --- There is now a draft implementation in [#5797](https://github.com/boykopovar/AnyPS5/pull/5797) that follows the repository guidance by building the HE-VAG decoder from a pinned vgmstream submodule and including its license in release archives. It adds synthetic parser/renderer coverage but explicitly has not validated PPSA36591 playback; the author also records remaining cross-block and console-semantics questions. This addresses the submodule-versus-copy question with a compliant implementation route, while title playback remains unverified.
Sign in to join this conversation.
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#5677
No description provided.