Skip to main content

Crate unityrs_audio

Crate unityrs_audio 

Source
Expand description

AudioClip dispatch and FSB5 PCM/ADPCM/Vorbis exports, with no FMOD dependency.

plan validates the real bank boundaries and bounds WAV output before decoding. Its metadata, every output name and payload are metered and allocated fallibly. Vorbis uses an explicit runtime setup provider; lewton alone allocates infallibly, so audio stays off batch. Plans borrow the input, preventing decode against a different bank. Work is charged before traversal or output writes.

UnityPy’s magic dispatch is export/AudioClipConverter.py:35-49. Contrary to older converters, this release never dispatches on m_Type; legacy non-passthrough data is Error::UnsupportedContainer (Tier U). extension reproduces the shared-enum table and property, independently of sample dispatch (classes/legacy_patch/AudioClip.py:5-6).

Integer PCM is copied, float defaults to numpy’s saturated int16 rule. WAVs shorter than four data bytes are Tier C (fmod_toolkit raises). A bank with an empty first subsound is Tier U and refused. Other codecs are typed unsupported errors, deferred to optional future work.

Structs§

Header
Bank section lengths are checked against the actual slice before allocation.
Plan
A validated, borrowed decode recipe. Output bytes exclude filenames and metadata; their allocations are also charged by decode before creation.
Sample
One sample export, retaining the charges for its raw UTF-8/surrogateescape filename bytes and file content. Callers apply their own path policy.
Subsound
A validated subsound. Bank names borrow bytes (no lossy UTF-8 decoding). Unknown extra chunks remain available verbatim for future codecs.
VorbisHeaders
Runtime setup headers, retaining their memory charge. The caller supplies a path; there is no default path, network fetch or embedded fallback.

Enums§

Error
A malformed bank field, a deliberate format refusal, or resource exhaustion.

Functions§

decode
Materialize the plan’s files. Names follow fmod_toolkit 0.1.3 fmod.py lines 77-98: the clip name, then a numeric suffix; the bank’s own name table does not determine export filenames.
decode_with_vorbis
Decode with an explicit runtime Vorbis setup provider. WAV output is charged before lewton is entered. Lewton’s internal allocations are infallible and unmetered (P3 decision 19); never use this on a batch path.
extension
The final 20 keys of UnityPy’s AUDIO_TYPE_EXTEMSION table. Values 1 and 2 are overwritten by compression formats (enums/Audio.py:33-56).
plan
Inspect magic, then validate an FSB5 bank and compute its total WAV size. This reads metadata only, never allocates or decodes a PCM payload.