Skip to content

Commit

Permalink
add direct m4a export
Browse files Browse the repository at this point in the history
  • Loading branch information
K0lb3 committed Jan 2, 2024
1 parent c731cb0 commit 6a60ccf
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions UnityPy/export/AudioClipConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ def import_pyfmodex():
else:
ext = "dylib" if system == "Darwin" else "so"
os.environ["PYFMODEX_DLL_PATH"] = os.path.join(LIB_PATH, f"libfmod.{ext}")

# hotfix ctypes for pyfmodex for non windows
ctypes.windll = getattr(ctypes, "windll", None)

import pyfmodex


Expand All @@ -79,11 +79,13 @@ def extract_audioclip_samples(audio) -> dict:
# eg. StreamedResource not available
return {}

magic = memoryview(audio.m_AudioData)[:4]
if magic == b"OggS":
return {"%s.ogg" % audio.name: audio.m_AudioData}
elif magic == b"RIFF":
return {"%s.wav" % audio.name: audio.m_AudioData}
magic = memoryview(audio.m_AudioData)[:8]
if magic[:4] == b"OggS":
return {f"{audio.m_Name}.ogg": audio.m_AudioData}
elif magic[:4] == b"RIFF":
return {f"{audio.m_Name}.wav": audio.m_AudioData}
elif magic[4:8] == b"ftyp":
return {f"{audio.m_Name}.m4a": audio.m_AudioData}
return dump_samples(audio)


Expand Down

0 comments on commit 6a60ccf

Please sign in to comment.