Commit Graph

45 Commits

Author SHA1 Message Date
d85e326eb7 opus_tags: reject duplicate CSV headers used for tagging 2026-11-24 00:46:14 -05:00
3e5596bf4b Convert exported music cue sheets to per-channel Audacity labels (#6819)
Squash-merged after diff review of PR #6819 - ASSET-576: Convert exported AWC music cues to per-channel Audacity label tracks
2026-11-23 09:52:32 -06:00
0a8a5522f9 Invalidate previous music cue regions before a bank re-export (#6867)
Squash-merged after diff review of PR #6867 - Invalidate previous music cue regions before a bank re-export
2026-11-23 09:48:53 -06:00
5f47ed2b39 docs/audio: document hashdict.py --lookup, the reverse name lookup (#6912)
Squash-merged after diff review of PR #6912 - docs/audio: document hashdict.py --lookup, the reverse name lookup (EGEN-HASHDICT-LOOKUP-DOC)
2026-11-23 09:44:48 -06:00
b90a2ce741 docs/audio: the naming table's second column is what awc_names counts, distinct bank/ID pairs (#6906)
Squash-merged after diff review of PR #6906 - docs/audio: name the naming table column for what awc_names counts (EGEN-AWCNAMES-ID-PAIRS-DOC)
2026-11-23 09:43:16 -06:00
21134fb8ea opus_tags: refuse conflicting dialogue rows before tagging (#5476)
Squash-merged after review of PR #5476 - opus_tags: refuse conflicting dialogue rows before modifying audio
2026-11-23 08:09:20 -06:00
784f4019f8 Merge pull request #3916 from Emma
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:09:32 -05:00
9cf2350779 Merge origin/main into asset-303-awc-chunk-bd
main gained the 0xbd cue-record decoder in rsc8_audio.py (4cf7e3e7). The
section in docs/audio_config.md now points at docs/rsc8_audio.md for the
record layout and keeps what is specific to the music banks; a test holds
awc_markers.events() to rsc8_audio.decode_marker_records().

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 00:25:57 +02:00
4de3ef8587 docs, tools: document AWC tag 0xBD marker events, add awc_markers.py (ASSET-303)
docs/audio_config.md gains the measured 16-byte event layout of AWC tag 0xBD,
whole-corpus counts and the event-type table (hashes and counts only).
tools/awc_markers.py reports those counts from an archive, a bank or a folder
of banks; tests/test_awc_markers.py covers it with hand-built banks.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 00:19:16 +02:00
cee93c6018 Merge pull request #3604 from towade
# Conflicts:
#	docs/audio.md
2026-11-22 17:02:58 -05:00
5ddc9dd2e1 Merge pull request #3266 from James
# Conflicts:
#	docs/restofworld.md
2026-11-22 17:01:10 -05:00
2d5d73a42b Merge pull request #3257 from zGLados 2026-11-22 17:01:08 -05:00
7e0809fcbc docs: the Home Sweet Home song is in audio.rpf as loop stems (PROC-178)
The mission-music section said the song audio is not in 1.0.2.1. @jefftern4
found it in the plain audio.rpf bank at 0x300695000: 73 stereo Opus streams,
47 of them 771,213 samples long, stems that play together, so no single
stream matches. Record the bank's shape (counts and lengths only), point the
all-banks coverage row at it, and replace the residual-uncertainty note with
what is still open: how the game sequences the stems.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:04:32 +01:00
53f22894fc docs: RSC8 is decoded; correct the audio, story and rest-of-world pages (ASSET-260)
docs/audio.md still listed a custom RSC8 audio resource as the only
mission-side container not decoded, and story.md and restofworld.md
still called the RSC8 bodies opaque. rsc8_audio.md (ASSET-56) decoded
them: all 641,428 raw RSC8 headers in the package are AWC tag 0x5c
facial/lip-sync clips beside their Opus dialogue line, none outside an
ADAT bank and none holding an audio container. Re-measured on a local
1.0.2.1 copy with tools/rsc8_audio.py over all 22 archives (counts only).

restofworld.md also said its archives hold no audio banks; story-rest
holds 15 ADAT banks, the other five none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:54:31 -08:00
1f5a7c0fd0 Merge pull request #3272 from kotorvr 2026-11-22 15:16:23 -05:00
c6cdc785c2 rsc8_audio: frame the 0x5a entries as {position, pitch, ...} with an f32 trailer
@kotorvr's finding in #3232: the entries start 4 bytes earlier than the
decoder read them. Each is {u32 sample position, f32 value, 6 x u16},
and the table ends in an f32 trailer (2/3 on 1,182 streams). Read 4
bytes later, every entry paired one entry's fields with the next one's
position, the first position looked like a header "unknown" and the
trailer looked like the last counter.

Recounted on my copy: positions ascend strictly and stay below the 0x76
sample count on all 1,185 streams; one entry lasts one period of its
value (within 1% on 365,803 of 386,048 pairs), so value reads as a
pitch in Hz; p is a multiple of 512 on every entry.

decode_grid20_table returns position_first/last/increasing and the
trailer as tail_f32; the tally key becomes grid20_position_past_samples.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:09:56 +01:00
4cf7e3e718 rsc8_audio: decode the AWC 0xbd tag as cue records, not a header with a magic
The tool read only the first word of a 0xbd tag and called it a magic
(0xE5C74063); docs/rsc8_audio.md described the tag as a 16-byte header.
Over all of audio.rpf the tag is a headerless list of 16-byte records
{name joaat, value, sample offset, extra}, sorted by offset, and that
value is the first word of only 88,082 of 420,168 tags.

decode_marker_records() decodes the list, every scan counts it in new
marker_* summary keys, and the doc carries the measured counts. The
record layout and the tag-id rule (low byte of the chunk name's joaat)
were read in TrinitronClient/GTA6-Asset-Info structure/03-audio-awc.md
(029e4c3) and re-measured here; no code was copied.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 19:57:12 +00:00
07af37519e Merge pull request #2332 from Julio Facal 2026-11-22 13:13:56 -05:00
44e9921160 Merge current main into the streamed AWC fix
Keep the per-chunk checks and repeated Opus packet verification alongside the short-final-block fix already on main. Set accurate mono and stereo sample counts in the overlap fixture so it also exercises the current Ogg trimming behavior. AI-assisted.
2026-11-22 17:46:47 +01:00
eaa98054fc Audio: read Python AWC inventories when naming streams 2026-11-22 13:41:47 -03:00
7edd7a187d docs: the Opus length check must read decoded frames, not the granule duration 2026-11-22 14:15:48 +00:00
4925b00ca7 docs: say +0x0C was measured on 0.5% of the corpus 2026-11-22 13:38:47 +00:00
5056ee85a2 audio: emit the Opus EOS page at the trim point, not the last page
Clamping only the last page's granule made it smaller than the previous
page's when the trim target fell before that page started: a 27-packet
real-libopus fixture declared 24,000 frames but decoded 24,960, and the
Ogg granule went 24,960 -> 24,000. Emit the EOS page at the first packet
that reaches pre_skip + length and drop the remaining padding packets.

Also require +0x0C to agree with the interleaved +0 count before using
it, and clamp an oversized pre-skip to the stream length so the final
granule never falls below it.

Measured on real streams: with pre-skip 0, the 5%/10% attack point is
312 samples (30 streams from four banks, median 312; the 10% point ranges
278..868, none near 1920), so the default is measured, not just assumed
from libopus. 20 real streams at 48 and 32 kHz now decode to exactly
their declared counts.
2026-11-22 13:38:46 +00:00
9842d6f2ea Validate streamed AWC chunks and repeated Opus packets
Confine music channel tables and payloads to their own chunks, accept short final chunks, and verify that a declared repeat matches whole packets from the same channel group. Metadata scans and exports now reject the same malformed descriptors while sibling streams still export.

Tested on Linux with synthetic banks. A three-chunk libopus example with repeated packets decoded to exactly the same 6,720 PCM samples as the reference. AI-assisted.
2026-11-22 13:58:28 +01:00
2197cf3f9c tools: write stream names and dialogue subtitles into Ogg Opus tags
awc_opus.py exports streams with an empty OpusTags header, so players show
only the stream id. opus_tags.py fills that header in place from the
awc_names.py CSV (TITLE) and the text_tables.py dialogue CSV (LABEL,
SPEAKER, SUBTITLE and SUBTITLE_<LANG>). Only page 1 is rewritten; the audio
pages stay byte for byte. Synthetic tests only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:31:29 +01:00
1b7adb4451 Merge pull request #1483 from abilliontokens
# Conflicts:
#	docs/README.md
2026-11-22 07:07:51 -05:00
085e00dc47 Merge pull request #1449 from Kam471 2026-11-22 07:07:47 -05:00
9eec21a7f0 Merge pull request #1421 from Nikolas Sturm 2026-11-22 07:07:46 -05:00
80e00fcd00 docs(audio): count the story000_restofworld conversation stream
Its dialogue pairs give the 1,019 lines the measured run was missing;
with it the conversation path names 267,800 streams. Also state the
dictionary size and that it came from our own harvest, not hashdict.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:46:22 +01:00
7099cf520f rsc8_audio: decode the undocumented 0x5a/0xd9 AWC companion tags
- decode_grid20_table: 8-byte header (u32 12345678 marker + unknown) and N 20-byte
  entries, with the invariants measured on all 1,185 audio.rpf streams that carry
  the tag (counter strictly increasing, p a multiple of 32; 387,233 entries,
  0 violations).
- decode_index_runs: K groups of {u32 2; u32 len; u32 hash; len ascending u32s}
  whose values index the sibling 0x5a entries (804 streams, 4,853 groups,
  0 violations, 0 overruns).
- Per-stream tallies in decode_awc_bank and the scan summaries (grid20_*/indexrun_*
  keys), facts in _decode_companion_tags; other archives carry 0 of either tag.
- Five synthetic tests (hand-built bytes only); docs rows in rsc8_audio.md,
  audio.md and the docs index, hypotheses labelled as such.
2026-11-22 03:41:52 -08:00
d9b9b002bf Merge pull request #1449 from Kam471 2026-11-22 06:38:06 -05:00
fba4605513 audio: use the format block's per-channel Opus frame count (+0x0C)
The format block carries the per-channel count at +0x0C: equal to +0 for mono
and half of it for stereo in 7,451 measured streams (0 mismatches), matching
rpf9-explorer's OpusFrameCountPerChannel. Use it (with +0/channels as fallback)
instead of inferring the division, and document the field.
2026-11-22 11:38:02 +00:00
73552dfcd3 audio: write the Opus pre-skip and correct plain-stream lengths (ASSET-104)
OpusHead declared pre-skip 0, so every exported stream started with 312
samples of libopus priming and the end trim removed the same amount of real
audio. Write the lookahead (312 by default, --pre-skip overrides it) and make
the trimmed final granule pre_skip + length.

The plain-stream length also scaled the format tag's sample count by
48000/rate and ignored stereo interleaving. Measured over 1,598,151 plain
streams: packet samples - declared is 1920..2879 for every 48 kHz and 32 kHz
stream, which is only possible if the declared count is already 48 kHz frames;
after halving stereo counts the same 1920..2879 window holds for all 17,983
stereo streams. Scaling a 32 kHz stream by 1.5 left the padding untrimmed.

Tests cover the pre-skip, the 48 kHz frame count, stereo halving and the
--pre-skip bounds. libopus round-trip: the fixed output matches the reference
Ogg sample-for-sample (max |diff| 0); before the fix it was shifted 312
samples and differed by up to 12,188.
2026-11-22 11:31:02 +00:00
d344fcb275 tools: name AWC streams from dictionary hits on their joaat ids
AWC stream tables keep only joaat(lowercase name) & 0x1FFFFFFF. With ~1.8M
distinct ids in a 2^29 space, ~0.3% of arbitrary words collide, so
awc_names.py accepts a hit only as an exact dialogue-wave word
(<root>au_<4 letters>_<NN>) or as a numbered family in one bank (3+
members or 2 adjacent, common-token base, one member a dictionary word).
A salted control run estimates the false names and sets each rule's
threshold per source.

The dictionary takes word lists or a hashdict.py JSON, and builds dialogue
wave names from conversation key/label pairs (<key>_01.._N per label).
Banks come from .awc files, directories or rpf9dump's audio_manifest.json.

On 1.0.2.1: 266,781 of 1.85M ids named (story000 73.7%, audio 5.7%),
with 417 control hits. Standard library only; tests are synthetic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:16:06 +01:00
7b8da60192 Merge pull request #809 from nicolas 2026-11-21 22:37:47 -05:00
80186d3578 Audio: preserve recordings across native filesystem name collisions 2026-11-21 20:15:07 -07:00
3d4249ffda Merge pull request #716 from Kam471 2026-11-21 21:37:51 -05:00
d605067cb8 Docs: record the Home Sweet Home mission-music search
The credited song is the Home Sweet Home mission song, not a radio track. The mission and its localized objective/fail strings are in data.rpf; the song audio is absent from every searched container.

Records the measured coverage (story000 streamed/plain/Bink, movies.rpf Bink, audio.rpf short and all banks, loop banks, packs/data/script/common inflated, raw levels.rpf ADAT/KB2), the 19,807-file / 653-hour Chromaprint sweep with its tempo range, the positive controls, the 12 joaat(burn) data hashes that are not audio, and the remaining levels.rpf/RSC8 uncertainty. No game audio or localized strings are included.
2026-11-22 02:16:53 +00:00
7fc9d562ca Keep every link when decoding chained Ogg Opus to WAV 2026-11-21 19:03:53 -07:00
7fdabf3ff3 Preserve nested bank paths during AWC audio export 2026-11-21 21:28:04 -03:00
258efccde7 Tests: cover multi-group stereo streamed music 2026-11-21 21:28:09 +00:00
91db8ec6e1 Tests: cover stereo streamed-music manifest fields 2026-11-21 21:23:30 +00:00
503c8716e4 Tools: export stereo streamed-music AWC channels correctly 2026-11-21 21:00:20 +00:00
d2a7fb643b Docs: link the audio-config table from the audio guide 2026-11-21 20:08:08 +00:00
4f749583f1 Docs: audio guide, related projects, and a README truth pass
README: audio row now says lossless Ogg Opus, PCM codec 0/2 as WAV, XMA2 via ffmpeg and 16-bit --wav; D3D12 row reflects the design doc and xmem/d3d12_xs shims with no device proxy; LLVM_MC is documented as a whole command; link the two new docs. docs/audio.md covers the ADAT layout, tags, codecs, exporters, song/station/venue distinctions and the no-sharing rule. docs/related_projects.md records the PercyStar and americas-recomp licence boundaries.
2026-11-21 17:42:01 +00:00