Skip to content

fix(assets): preserve duplicate short audio channels - #2849

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:codex/awc-shorts-duplicate-channels
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:codex/awc-shorts-duplicate-channels

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as duplicate short audio channels.

What and why

Give selected channels with a repeated stream ID distinct output filenames using the existing AWC exporter convention. The original stream ID still appears in the catalog. Each catalog path points to its own clip.

Tested

  • A source-built two-channel bank previously returned two rows for the same filename, leaving one Ogg clip on disk. Both filenames now exist and contain their own original Opus packet byte and channel count.
  • On Windows CPU, python -m pytest -q tests/test_awc_shorts.py tests/test_awc_opus.py passed 50 tests and 33 subtests with the pinned dependencies.
  • AI-assisted (Codex).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

A streamed-music bank can reuse a channel ID. Shared filenames then overwrite an earlier clip and leave both catalog rows pointing to the last stream.
@padhossein

Copy link
Copy Markdown
Contributor

Independent duplicate-channel filtering check (4e50e3a5). All 50 audio tests passed. I built a synthetic bank with four packet streams sharing one stream ID, of which a stereo channel fell outside the duration filter. Base published three rows pointing to a single overwritten clip. This head published the three selected channels as base, ~2 and ~3, in order, preserving their exact packet bytes (78, 7c, 98 hex) and channel counts. The filtered clip did not consume a suffix.

AI-assisted (Codex).

@tupacfan04

Copy link
Copy Markdown
Contributor

Code read of 4e50e3a5 (I didn't run it). Looks right. The channels are collected first, so awc.export_stems can give a repeated stream ID ~2, ~3, …, and the CSV rows still carry the real stream ID next to the actual file name, so no clip silently overwrites another.

Overlap: #2900 (open) restructures the same export_bank. It moves os.makedirs(od, ...) inside the per-channel loop so banks with nothing to export leave no empty folder, and adds os.walk(onerror=...). This PR keeps the unconditional makedirs and rewrites the loop around it, so the two will conflict. Whichever lands second should keep both behaviours (create the folder only when selected is non-empty).

AI-assisted review (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.

Verified on current origin/main (162821017, merges cleanly): python -I tests/test_awc_shorts.py -> 13/13, test_awc_opus.py -> 37/37. On main the new test fails with both rows pointing at duplicate/00001234.ogg; the head writes .ogg and ~2.ogg. CLI verified with --jobs 1 and --jobs 2; the two outputs differ. Synthetic byte data only; no game data or absolute paths. Approve.

Non-blocking: docs/awc_shorts.md still documents only <stream id>.ogg; numbering is over selected channels, so it can differ from awc_opus when an earlier duplicate is filtered out.

@JRamos1993

Copy link
Copy Markdown
Contributor

Ran this on main 77444fa (Windows 11, Python 3.14). It merges cleanly: tests/test_awc_shorts.py 13 OK. test_csv_line_endings.py, test_awc_opus.py (37), test_text_write_line_endings.py and test_tool_stdout_encoding.py pass. With main's tools/awc_shorts.py the new test fails ('duplicate/00001234.ogg' twice).

Two notes, not blocking:

  • Names depend on the duration range. The ~N suffix counts only channels inside the duration range, so a clip's name depends on --min/--max-seconds. With the test's two-channel bank, the stereo channel is 00001234~2.ogg for [0, 1] but 00001234.ogg for [0.005, 0.015]. If names should stay stable across runs, number over all music channels as export_stems does.
  • Same bug elsewhere: tools/awc_opus.py:314 (music channels in its export_bank) still writes <id>.ogg with no suffix. On the same bank it reports music: 2 and leaves one file, holding the second channel. Maybe a follow-up.

AI-assisted (Claude Code).

@Marukooh

Copy link
Copy Markdown
Contributor

Tested 4e50e3a5 on CachyOS Linux, Python 3.14. tests/test_awc_shorts.py: 13 passed, 6 subtests passed.

The base fails the synthetic duplicate-channel export test. On the head it preserves both streams and the multiprocess suite passes.

AI-assisted, synthetic inputs only.

@tupacfan04

Copy link
Copy Markdown
Contributor

Tested at the head on Windows 11 / Python 3.13.0: the new test 1/1, tests/test_awc_shorts.py + tests/test_awc_opus.py 50 passed + 33 subtests (matches the body), wider suite 84 passed, 2 skipped. Negative control: with tools/awc_shorts.py from origin/main the new test fails (both duplicate entries get identical file lists). Merge with main clean.

Two notes:

  • It conflicts with open awc_shorts: create per-bank folders only on export and surface scan errors #2900 in tools/awc_shorts.py:58 (that PR moves os.makedirs into the loop); whichever lands second needs a rebase that keeps the empty-selected guard.
  • Naming: tools/awc_shorts.py:65 numbers stems over the selected channels, while tools/awc_opus.py:317 numbers over the full stream table. A bank whose first duplicate is not a short exports X.ogg here and X~2.ogg from the full exporter. Uniqueness holds, but the two tools disagree; deriving the stem from the whole stream table would align them.
  • Minor: lines 60-65 now materialise every selected channel's packets before writing (it streamed before), a modest per-bank peak-memory increase.

Approve with those notes. AI-assisted review, no game files.

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