Skip to content

Instantly share code, notes, and snippets.

@jakobhellermann
Created July 13, 2024 23:29
Show Gist options
  • Select an option

  • Save jakobhellermann/07a28cfe214473e56c969c3c893e3912 to your computer and use it in GitHub Desktop.

Select an option

Save jakobhellermann/07a28cfe214473e56c969c3c893e3912 to your computer and use it in GitHub Desktop.
Extract audio from nine sols wwise
from pathlib import Path
import subprocess
import xml.etree.ElementTree as xml
dir = Path(
"/home/jakob/.local/share/Steam/steamapps/common/Nine Sols/NineSols_Data/StreamingAssets/Audio/GeneratedSoundBanks/Windows"
)
out = Path("output")
soundbanks: list[xml.Element] = xml.parse(dir.joinpath("SoundbanksInfo.xml")).findall(
"SoundBanks/SoundBank"
)
out.mkdir(exist_ok=True)
for soundbank in soundbanks:
name = soundbank.findtext("ShortName")
assert name is not None
path = soundbank.findtext("Path")
soundbank_out = out.joinpath(name)
soundbank_out.mkdir(exist_ok=True)
subprocess.run(
[
"bnk-extract",
"--oggs-only",
"--audio",
dir.joinpath(path),
"--output",
soundbank_out,
]
)
for media in soundbank.findall("Media/File"):
id = media.attrib["Id"]
location = media.attrib["Location"]
media_name = Path(media.findtext("ShortName")).name
if location == "Memory":
matches = list(soundbank_out.glob(f"{id}.*"))
if len(matches) == 0:
continue
(file,) = matches
file.rename(file.with_stem(media_name))
pass
else:
path = media.findtext("Path")
subprocess.run(
[
"vgmstream-cli",
"-o",
soundbank_out.joinpath(media_name),
dir.joinpath(path),
],
stdout=subprocess.DEVNULL,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment