Skip to content

awc_manifest: one row per stream and per music channel, named as awc_opus exports them (ASSET-446) - #5319

Open
leozinhoszg wants to merge 2 commits into
ItsNotRexed:mainfrom
leozinhoszg:awc-manifest-music-rows
Open

leozinhoszg wants to merge 2 commits into
ItsNotRexed:mainfrom
leozinhoszg:awc-manifest-music-rows

Conversation

@leozinhoszg

Copy link
Copy Markdown
Contributor

ASSET-446 (claim), the follow-up named in #5279.

Depends on: #5279. This branch is built on it, so its first commit (d477528a) is #5279's; the change here is the second commit, a759c19d.

Problem

tools/awc_manifest.py _bank_rows let a streamed-music channel replace the row of an earlier stream or channel with the same id (the "as before" branch, kept from when rows were a dict keyed by id). With #5279's synthetic banks:

bank manifest rows on #5279 files export_bank writes
Opus stream 0x456 + music channel 0x456 1 (the music row; the stream is gone) 00000456.ogg, 00000456~2.ogg
three music channels 0x123 1 00000123.ogg, ~2.ogg, ~3.ogg

Fix

  • The naming moves into awc_opus.bank_stems(stream_ids, channels), and both export_bank and _bank_rows call it, so the manifest and the exporter cannot drift.
  • A channel is written, and named, when it holds Opus packets. The test for that is packet channels > 0, which music_channels computes the same way with and without collect_packets. The metadata-only manifest gets the same answer as the exporter.
  • A channel that is not written (non-Opus, no packets) takes no ~N. Same behaviour as awc_opus: name streamed-music channels with export_stems, after the streams (ASSET-309) #5279, now spelled through the shared predicate.
  • The manifest lists one row per stream and per channel. A repeated id's row notes awc_opus exports it as <id>~N, worded like the existing stream note. streamed_music_channel_count now counts every channel.
  • Stream stems are unchanged (still export_stems over the stream table), so awc_shorts.py and the existing stream notes are unaffected.
  • docs/audio.md (streamed-music section) and the awc_manifest.py docstring describe the rows.

Tests

Added to tests/test_awc_music_names.py. It is #5279's new file, and staying out of tests/test_awc_manifest.py avoids #4742, #4190 and #4516, which edit that file.

  • a channel sharing a stream's id: two rows, the stream row has no note, the channel's notes 00000456~2;
  • three music channels with one id: three rows noting None, ~2, ~3;
  • a non-Opus channel before an Opus one with the same id: both listed, no note; the exporter writes only 00000123.ogg, holding the Opus channel;
  • for every test bank, the names the rows give equal the files export_bank writes;
  • collect() over two banks: 5 rows, 4 streamed-music channels;
  • bank_stems: the same result from music_channels with and without packets, and bool(packets) == bool(packet channels).

Against #5279's awc_opus.py and awc_manifest.py, 8 of the 12 tests fail (6 failures, 2 errors on the missing bank_stems). The other 4 are #5279's own. With this change all 12 pass.

Run on Windows 11 Pro (26200), CPython 3.14.7, CPU only (no GPU involved):

  • python -I tests/test_awc_music_names.py: 12 OK
  • python -I tests/test_awc_manifest.py: 18 OK
  • python -I tests/test_awc_opus.py: 47 OK
  • python -I tests/test_awc_shorts.py: 13 OK
  • python -I tests/test_awc_names.py: 27 OK
  • python -I tests/test_docs_design_rows.py, tests/test_i18n_index.py: OK
  • python -m compileall -q, git diff --check: clean

No game files were used. On a real copy the change shows up only in banks that repeat an id between a stream and a channel or between channels; that count is still open (see #5279).

#4742 adds a function right after _bank_rows's return rows. This change keeps that line and the blank lines after it, so the two should merge without a conflict.

AI-assisted.

@dimaszoo

Copy link
Copy Markdown

On seven local Xbox 1.0.2.1 banks at a759c19d, the metadata-only manifest predicted the exact set of filenames that export_bank wrote in every bank. There were 1,921 rows and 1,920 files (1,918 Ogg and two WAV). The remaining row described an XMA stream that the exporter skips. An independent read of the ADAT stream and channel tables agreed with the row counts and IDs, including multiplicity.

The sample included a bank with 1,886 ordinary Opus streams and one repeated ID. Both files survived, and the second got the ~2 suffix. Two streamed-music banks yielded one and two Ogg files respectively. Repeating the same seven inputs on parent d477528a gave identical manifest rows, names and file contents.

This checks compatibility on real banks. The sample contained no music-channel collision with another channel or an ordinary stream. The PR’s synthetic cases cover those paths. For the separate frequency question, the four-archive survey on #5279 already reports counts for 5,743 exportable music channels.

Linux, CPython 3.12.3, CPU only. AI-assisted independent check.

@sovljanskii

Copy link
Copy Markdown
Contributor

Reviewed a759c19d merged onto main 3faac557 (clean) on macOS, Apple M4, Python 3.15.2 and 3.12.16. I read the second commit, a759c19d, on its own (the first is #5279's). Pass.

Tests, same on both versions:

  • test_awc_music_names: 12 OK;
  • test_awc_manifest: 18 OK;
  • test_awc_opus: 47 OK;
  • test_awc_shorts: 13 OK;
  • test_awc_names: 27 OK (1 skipped);
  • test_docs_design_rows: 4 OK.

compileall and git diff --check are clean.

Mutation: with awc_manifest.py and awc_opus.py as at d477528a, test_awc_music_names gives 6 failures and 2 errors, matching the description.

Read:

  • export_bank used to filter on channel[4] (packets). bank_stems now uses channel[5] (packet channels). In music_channels that field starts at 0 (tools/awc_opus.py:265) and is set only when a block yields packets (line 291). The first block of a channel can't be a pure repeat, so the two tests agree.
  • The manifest and the exporter now name channels through one function.

Nit, already on main: the music_channels docstring (tools/awc_opus.py:244) says packet channels "defaults to 1 when no packet is present". The code leaves it at 0, and bank_stems relies on that. Since this PR makes it the written/not-written test, it's worth correcting the sentence.

Not checked: how often real banks repeat an id. Extracting the banks from audio.rpf didn't fit on this disk.

AI-assisted.

@King1565

Copy link
Copy Markdown

**Tested a759c19 on Linux, Python 3.13 (CPU only, no GPU, no game files): pass

Ran

Read
No defect found. One note: a non-Opus channel row (channels 0) carries the same stream value as the Opus channel that does get written, and nothing in its notes says it isn't exported. Adding something like "not exported by awc_opus" would let a reader match rows to files by id alone.

AI-assisted (Claude Code).


Generated by Claude Code**

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Head a759c19.

Commands: python -I tests/test_awc_music_names.py -> 12 OK; python -I tests/test_awc_manifest.py -> 18 OK (2 skipped, symlink privilege); python -I tests/test_awc_opus.py -> 47 OK; python -I tests/test_awc_shorts.py -> 13 OK; python -I tests/test_awc_names.py -> 27 OK; git diff --check -> 0.

bank_stems now names channels after streams and earlier channels, and both export_bank and _bank_rows use it. Verdict: pass on the branch, but it depends on open #5279: the first commit d477528 is #5279's head. Merge #5279 first or expect that commit to travel with this PR.

@kacper-serewis kacper-serewis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted independent CPU review at a759c19. Across six local streamed-music banks, all 17 channel IDs had the expected manifest multiplicity and all 17 stems matched files produced by the exporter. Those banks had no duplicate IDs. Synthetic stream/channel and three-channel collisions yielded 2/2 and 3/3 rows/files, versus 1/2 and 1/3 on d477528. A channel without packets retained its manifest row and produced no file.

…treams (ASSET-309)

export_bank wrote each streamed-music channel as <id>.ogg outside export_stems. A second channel with
the same id, or a channel sharing an Opus stream's id, overwrote that file while the counts still
listed both. Music channels now take their stems from the same export_stems call as the ordinary
streams, placed after every stream: the stream names stay the ones awc_manifest and awc_shorts
report, and a repeated id gets the next ~N stem. Synthetic tests in tests/test_awc_music_names.py
fail on main (4/4) and pass here.
…opus exports them

awc_manifest let a streamed-music channel replace the row of an earlier stream or channel with the
same id, so a bank with an Opus stream 0x456 and a music channel 0x456 listed one row while
export_bank (after ItsNotRexed#5279) writes 00000456.ogg and 00000456~2.ogg; the stream vanished from the
manifest.

The naming now lives in awc_opus.bank_stems(), used by both export_bank and _bank_rows. A channel is
written, and named, when it holds Opus packets (packet channels > 0, the same with and without
packet collection), so the metadata-only manifest and the exporter agree. The manifest lists every
row and notes "awc_opus exports it as <id>~N" on a repeated one; streamed_music_channel_count counts
every channel. Stream stems are unchanged.

Tests in tests/test_awc_music_names.py: 8 of the 12 fail on ItsNotRexed#5279's tools and pass here.
@leozinhoszg
leozinhoszg force-pushed the awc-manifest-music-rows branch from a759c19 to facd8b6 Compare November 23, 2026 12:01
@leozinhoszg

Copy link
Copy Markdown
Contributor Author

Rebased onto main 561b65a8: it conflicted after today's merges. The new head is facd8b60. The first commit, #5279's, is now 97127615, and the change itself is facd8b60 (was a759c19d). For the reviewers who checked a759c19d, two things changed:

  • tools/awc_opus.py: main added bank_output_dir() right where bank_stems() goes. Both are kept, and export_bank uses both. No other code change.
  • One test fixture: since 2f798a5a (awc_opus: validate streamed-music channel rate and codec #3194), music_channels rejects a whole descriptor that has a non-Opus channel. The "channel without packets" banks used a non-Opus group, so after the rebase music_channels returned [] for them, and two tests failed. The fixture now makes that group an Opus group with no subblocks instead. It still has no packets (packet channels 0 with and without packet collection), and the assertions are unchanged.

Windows 11, CPython 3.14.7, CPU only:

  • tests/test_awc_music_names.py: 12 OK. Against the first commit's tools, 8 of 12 still fail (6 failures, 2 errors), as before.
  • test_awc_opus 55, test_awc_manifest 20, test_awc_shorts 13, test_awc_names 30, test_awc_markers 8: all OK.
  • compileall and git diff --check: clean.

AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested facd8b6 merged with main 561b65a on Linux (WSL2) Python 3.12.16: pass

tests/test_awc_music_names.py (new): 12 run, 12 passed, 0 failed. Touched-module suites on the merged tree: test_awc_manifest 20, test_awc_opus 55, test_awc_markers 8, test_awc_names 30 (1 skipped), test_awc_shorts 13, test_audio_config 21, test_audio_stage_resume 12, test_audio_wav 40 (16 skipped), test_rsc8_audio 37, plus test_opus_tags, test_resource_hygiene, test_csv_line_endings, test_file_mode, test_pool_workers (2 skipped), test_report_paths: all OK, 0 failures. tests/test_docs_*.py (11 files): all OK.
Negative control: with tools/awc_manifest.py and tools/awc_opus.py restored to main, test_awc_music_names.py runs 12 and fails 8 with 2 errors (bank_stems does not exist on main, and a music channel that repeats a stream id overwrites it instead of getting ~2).
Read the full diff: export_bank and the manifest both take their names from awc_opus.bank_stems, so the manifest note and the written file name cannot disagree; a channel without Opus packets takes no name; stream stems are unchanged. Linux only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants