List and edit in-memory sounds in soundbanks
This commit is contained in:
@@ -5,7 +5,9 @@
|
||||
Outputs
|
||||
data/catalog/characters.csv name -> verified speaker, from data/catalog/source/<lang>/*.txt
|
||||
data/catalog/<ARCHIVE>.csv every sound of one archive (schema: data/catalog/README.md)
|
||||
data/catalog/index.json WAD fingerprints the CSVs were built from + counts
|
||||
data/catalog/BANK.csv in-memory sounds (soundbanks in SFX/*.bnk and the .upk packages)
|
||||
data/catalog/BANK_locations.csv.gz every stored copy of them + the prefetch heads of speech lines
|
||||
data/catalog/index.json fingerprints the CSVs were built from + counts
|
||||
Run it only on clean game files (`ackit status` must say nothing is modified).
|
||||
"""
|
||||
import argparse
|
||||
@@ -15,10 +17,11 @@ import hashlib
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
from ackit import settings # noqa: E402
|
||||
from ackit.catalog import scan_archive, write_csv, hash_names # noqa: E402
|
||||
from ackit import banks, settings # noqa: E402
|
||||
from ackit.catalog import scan_archive, scan_banks, write_csv, hash_names # noqa: E402
|
||||
from ackit.classify import USER_LABELS # noqa: E402
|
||||
from ackit.game import Game, default_game_dir, wad_fingerprint # noqa: E402
|
||||
from ackit.inject import read_target # noqa: E402
|
||||
@@ -107,6 +110,24 @@ def main():
|
||||
"sounds": len(sounds), "groups": dict(g),
|
||||
"with_character": sum(1 for s in sounds if s.character)}
|
||||
print("%s.csv: %d sounds %s" % (arch, len(sounds), dict(g)))
|
||||
|
||||
# in-memory sounds: loose SFX\*.bnk + banks inside the .upk packages (a few minutes)
|
||||
t0 = time.time()
|
||||
sounds, locs, sc = scan_banks(game, progress=lambda k, n: print(" banks: %d/%d files" % (k, n), flush=True)
|
||||
if k % 500 == 0 else None, characters=charmap)
|
||||
write_csv(os.path.join(out_dir, "%s.csv" % banks.ARCHIVE), sounds)
|
||||
banks.write_locations(os.path.join(out_dir, banks.LOCATIONS), locs)
|
||||
g = collections.Counter(s.group for s in sounds)
|
||||
heads = [l for l in locs if l.kind == banks.PREFETCH_HEAD]
|
||||
index["archives"][banks.ARCHIVE] = {
|
||||
"fingerprint": banks.game_fingerprint(game.cooked), "sounds": len(sounds), "groups": dict(g),
|
||||
"copies": sum(1 for l in locs if l.kind == banks.MEMORY), "files": len(sc.files),
|
||||
"named_by_event": sum(1 for s in sounds if not s.name.lower().startswith(s.bank.lower() + "_")),
|
||||
"prefetch_heads": {"lines": len({l.media for l in heads}), "copies": len(heads),
|
||||
"unmapped": len({l.media for l in heads if not l.sound})},
|
||||
"issues": ["%s: %s" % i for i in sc.issues]}
|
||||
print("%s.csv: %d sounds %s, %d copies in %d files, %d prefetch heads (%.0fs)"
|
||||
% (banks.ARCHIVE, len(sounds), dict(g), len(locs) - len(heads), len(sc.files), len(heads), time.time() - t0))
|
||||
# flatten for catalog.load_archive
|
||||
flat = {a: v for a, v in index["archives"].items()}
|
||||
json.dump(dict(flat, _info=index["built_from"]), open(os.path.join(out_dir, "index.json"), "w", newline="\n"), indent=1)
|
||||
|
||||
Reference in New Issue
Block a user