List and edit in-memory sounds in soundbanks

This commit is contained in:
2026-10-09 20:12:10 +02:00
parent 61bbf26f3b
commit 5d6c2447f7
36 changed files with 71568 additions and 54823 deletions

View File

@@ -66,11 +66,23 @@ def run(ws, sample=300, log=print):
break
log("%-4s layout %s, rebuilt %d/%d sample WEMs byte-identical" % (arch, "OK" if not probs else probs[:2], good, n))
ok &= not probs and good >= n - 2 # 4 looping music tracks are known exceptions
bank = [s for s in ws.catalog.sounds if s.archive == "BANK"]
if bank:
n = good = 0
for s in random.Random(1).sample(bank, min(len(bank), sample)):
n += 1
try:
good += rebuild_identical(ws.current_bytes(s))
except Exception:
pass
log("BANK in-memory sounds: rebuilt %d/%d sample WEMs byte-identical" % (good, n))
ok &= good == n
# 3
t = np.arange(48000 * 2) / 48000.0
sig = (0.3 * np.sin(2 * np.pi * 330 * t) * np.sin(2 * np.pi * 1.5 * t)).astype(np.float32)[:, None]
for s in [x for x in ws.catalog.sounds if x.group == "Speech"][:1] + \
[x for x in ws.catalog.sounds if x.group == "Music"][:1]:
[x for x in ws.catalog.sounds if x.group == "Music"][:1] + \
[x for x in ws.catalog.sounds if x.archive == "BANK" and x.seconds >= 1.5][:1]:
wem, info = ws.prepare(s, sig, 48000)
y, sr = audio.decode_wem(wem)
ref = audio.to_channels(audio.resample(sig, 48000, sr), y.shape[1])