Skip to main content
The AudioConverter class provides audio format conversion using FFmpeg and vgmstream for WEM files, and Wwise for WAV to WEM conversion.

Constructor

from src.audio_converter import AudioConverter

converter = AudioConverter()
Behavior:
  • Automatically detects FFmpeg location
  • Automatically detects vgmstream-cli location
  • Initializes Wwise Console if available

Methods

wem_to_wav

Converts a Wwise WEM file to WAV format.
output_file = converter.wem_to_wav(
    wem_file,
    output_file=None
)
wem_file
str | Path
required
Path to input WEM file.
output_file
str | Path
default:"None"
Output WAV path. If None, uses same name with .wav extension.
output_file
Path
Path to the converted WAV file.
Raises:
  • RuntimeError: If conversion tools not found or conversion fails
Behavior:
  • Tries vgmstream-cli first (recommended for WEM)
  • Falls back to FFmpeg if vgmstream fails
  • Provides installation instructions on failure

any_to_wav

Converts any audio format to WAV (MP3, FLAC, OGG, M4A, etc.).
output_file = converter.any_to_wav(
    input_file,
    output_file=None,
    sample_rate=48000,
    channels=2,
    normalize=True
)
input_file
str | Path
required
Path to input audio file (any format FFmpeg supports).
output_file
str | Path
default:"None"
Output WAV path. If None, uses same name with .wav extension.
sample_rate
int
default:"48000"
Output sample rate in Hz. Default 48000 matches game audio.
channels
int
default:"2"
Number of audio channels (1=mono, 2=stereo).
normalize
bool
default:"True"
If True, normalizes audio to -9 LUFS for consistent volume.
output_file
Path
Path to the converted WAV file.
Raises:
  • RuntimeError: If FFmpeg not found or conversion fails
Normalization Settings:
  • Integrated loudness: -9 LUFS
  • True peak: -1.5 dBTP
  • Loudness range: 11 LU

wav_to_wem

Converts a WAV file to Wwise WEM format.
output_file = converter.wav_to_wem(
    wav_file,
    output_file=None,
    wwise_dir=None
)
wav_file
str | Path
required
Path to input WAV file.
output_file
str | Path
default:"None"
Output WEM path. If None, uses same name with .wem extension.
wwise_dir
str | Path
default:"None"
Custom Wwise installation directory. If None, uses default.
output_file
Path
Path to the converted WEM file.
Raises:
  • RuntimeError: If Wwise not installed or conversion fails
Requirements:
  • Wwise must be installed (see Wwise Wrapper)
  • WAV should be 48kHz, 16-bit for best results

batch_convert_wem_to_wav

Converts all WEM files in a directory to WAV.
converted = converter.batch_convert_wem_to_wav(
    input_dir,
    output_dir=None
)
input_dir
str | Path
required
Directory containing WEM files.
output_dir
str | Path
default:"None"
Output directory. If None, creates ‘wav’ subdirectory in input_dir.
converted
list[Path]
List of successfully converted WAV file paths.
Behavior:
  • Processes all *.wem files
  • Continues on error
  • Prints progress for each file

batch_convert_to_wav

Converts all audio files in a directory to WAV.
converted = converter.batch_convert_to_wav(
    input_dir,
    output_dir=None,
    pattern='*',
    normalize=True
)
input_dir
str | Path
required
Directory containing audio files.
output_dir
str | Path
default:"None"
Output directory. If None, creates ‘wav’ subdirectory in input_dir.
pattern
str
default:"'*'"
File pattern to match (currently unused, processes all audio extensions).
normalize
bool
default:"True"
Whether to normalize audio volume.
converted
list[Path]
List of successfully converted WAV file paths.
Supported Extensions:
  • .mp3
  • .flac
  • .ogg
  • .m4a
  • .aac
  • .opus
  • .wma

batch_convert_wav_to_wem

Converts all WAV files in a directory to WEM.
converted = converter.batch_convert_wav_to_wem(
    input_dir,
    output_dir=None
)
input_dir
str | Path
required
Directory containing WAV files.
output_dir
str | Path
default:"None"
Output directory. If None, creates ‘wem’ subdirectory in input_dir.
converted
list[Path]
List of successfully converted WEM file paths.
Raises:
  • RuntimeError: If Wwise not installed
Behavior:
  • Uses Wwise batch conversion for efficiency
  • Returns empty list if no WAV files found

Tool Detection

FFmpeg

Windows:
  • Checks tools/audio/ffmpeg/ffmpeg-master-latest-win64-gpl/bin/ffmpeg.exe
  • Checks tools/audio/ffmpeg/bin/ffmpeg.exe
  • Falls back to system PATH
Linux:
  • Requires system installation: sudo pacman -S ffmpeg

vgmstream-cli

Windows:
  • Checks tools/audio/vgmstream/vgmstream-cli.exe
Linux:
  • Checks system PATH
  • Install: sudo pacman -S vgmstream (Arch) or build from source

Wwise

See Wwise Wrapper for installation details.

Example Usage

Convert WEM to WAV

from src.audio_converter import AudioConverter

converter = AudioConverter()

# Single file
wav_file = converter.wem_to_wav("134133939.wem")
print(f"Converted: {wav_file}")

# Batch conversion
converted = converter.batch_convert_wem_to_wav("./extracted/sfx")
print(f"Converted {len(converted)} files")

Convert MP3 to WAV for Modding

from src.audio_converter import AudioConverter

converter = AudioConverter()

# Convert with normalization (recommended)
wav_file = converter.any_to_wav(
    "my_music.mp3",
    output_file="converted.wav",
    sample_rate=48000,
    channels=2,
    normalize=True
)

# Then convert to WEM for game
wem_file = converter.wav_to_wem(wav_file)
print(f"Ready for game: {wem_file}")

Batch Convert Music Files

from src.audio_converter import AudioConverter
from pathlib import Path

converter = AudioConverter()

music_dir = Path("my_music")
wav_dir = Path("converted_wav")
wem_dir = Path("converted_wem")

# Step 1: Convert all music to WAV
wav_files = converter.batch_convert_to_wav(
    music_dir,
    wav_dir,
    normalize=True
)

print(f"Converted {len(wav_files)} files to WAV")

# Step 2: Convert WAV to WEM for game
wem_files = converter.batch_convert_wav_to_wem(
    wav_dir,
    wem_dir
)

print(f"Converted {len(wem_files)} files to WEM")

Compare Audio Quality

from src.audio_converter import AudioConverter

converter = AudioConverter()

# Extract original game audio
converter.wem_to_wav("original.wem", "original.wav")

# Create replacement without normalization
converter.any_to_wav(
    "replacement.mp3",
    "replacement_raw.wav",
    normalize=False
)

# Create replacement with normalization
converter.any_to_wav(
    "replacement.mp3",
    "replacement_normalized.wav",
    normalize=True
)

# Listen and compare volumes

Command-Line Usage

Convert WEM to WAV

python -m src.audio_converter sound.wem
# Creates sound.wav

# Batch convert directory
python -m src.audio_converter ./extracted/

Convert Any Format to WAV

python -m src.audio_converter music.mp3 output.wav --mode=any2wav

# Batch convert
python -m src.audio_converter ./music_folder/ ./wav_output --mode=any2wav

Convert WAV to WEM

python -m src.audio_converter audio.wav --mode=wav2wem

# Batch convert
python -m src.audio_converter ./wav_folder/ ./wem_output --mode=wav2wem

Audio Specifications

Game Audio Format

  • Sample Rate: 48000 Hz
  • Bit Depth: 16-bit PCM (for WAV)
  • Channels: 1 (mono) or 2 (stereo)
  • Codec: Vorbis (inside WEM)
For voice replacements:
converter.any_to_wav(
    "voice.mp3",
    sample_rate=48000,
    channels=1,  # Mono for voice
    normalize=True
)
For music replacements:
converter.any_to_wav(
    "music.flac",
    sample_rate=48000,
    channels=2,  # Stereo for music
    normalize=True
)

Error Handling

from src.audio_converter import AudioConverter

converter = AudioConverter()

try:
    wav_file = converter.wem_to_wav("sound.wem")
except RuntimeError as e:
    if "not found" in str(e):
        print("Please install audio tools from Settings")
    else:
        print(f"Conversion failed: {e}")

Platform-Specific Notes

Windows

  • Audio tools can be installed from ZZAR Settings page
  • Tools stored in tools/audio/ directory
  • No system dependencies required

Linux

  • Requires system packages: vgmstream ffmpeg
  • Arch: sudo pacman -S vgmstream ffmpeg
  • Ubuntu: sudo apt install vgmstream-cli ffmpeg

Flatpak

  • Uses host system’s tools via flatpak-spawn
  • Wine required for Wwise (WAV to WEM)

Notes

  • WEM is a proprietary Wwise format based on Ogg Vorbis
  • vgmstream provides the best WEM decoding quality
  • FFmpeg can decode some WEM files but not all
  • Normalization ensures consistent volume across mods
  • WAV to WEM conversion requires Wwise (see setup guides)
  • Always use 48kHz sample rate to match game audio

Build docs developers (and LLMs) love