Module wav

Module wav 

Source
Expand description

WAV audio container support. WAV reader and writer with KotOR obfuscation handling.

KotOR uses multiple wrappers around audio payloads:

  • standard RIFF/WAVE files,
  • SFX files with a 470-byte prefix header,
  • MP3-in-WAV wrappers (58-byte prefix followed by raw MP3 data).

This module implements container-level parsing/serialization only. It does not decode PCM/ADPCM sample streams.

§Format Layout

Standard WAVE:
+------------------------------+ 0x0000
| "RIFF" + size + "WAVE"       |
+------------------------------+
| Chunks ("fmt ", "data", ...) |
+------------------------------+

KotOR SFX wrapper:
+------------------------------+ 0x0000
| 470-byte SFX header          |
| starts with FF F3 60 C4      |
+------------------------------+ 0x01DA
| Standard RIFF/WAVE payload   |
+------------------------------+

MP3-in-WAV wrapper:
+------------------------------+ 0x0000
| 58-byte wrapper              |
| starts with "RIFF", size=50  |
+------------------------------+ 0x003A
| Raw MP3 payload              |
+------------------------------+

Modules§

adpcm
ADPCM decoding helpers for WAV data.
pcm
PCM decoding helpers for WAV data.

Structs§

Wav
In-memory WAV payload.
WavEncodingCode
Lossless WAVE encoding tag wrapper.
WavWaveMetadata
Metadata fields for WAVE-format payloads.
WavWriteOptions
WAV writer options.

Enums§

WavAudioFormat
Audio payload format represented by Wav.
WavEncoding
Known WAVE encoding tags.
WavError
WAV parse/write errors.
WavType
KotOR-facing wrapper type used when writing.
WavWrapperKind
WAV wrapper variant detected in source bytes.
WavWriteMode
WAV write target mode.

Functions§

read_wav
Reads WAV data from a reader.
read_wav_from_bytes
Reads WAV data from bytes.
write_wav
Writes WAV data to a writer using WavWriteMode::Game.
write_wav_to_vec
Serializes WAV data to a byte vector using WavWriteMode::Game.
write_wav_to_vec_with_options
Serializes WAV data to a byte vector with explicit options.
write_wav_with_options
Writes WAV data to a writer with explicit options.