Commit Graph

28 Commits

Author SHA1 Message Date
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