Skip to content

AudioClip -> WAV/OGG (FSB5 + Vorbis) #48

Open
1 of 3 issues completed
Open

Description

@fatal10110

Trigger: need playable audio.
Own package unity-asset-reader-audio. FSB5 container parser in TS; Vorbis setup-header rebuild via own wasm repo (libogg + libvorbis, emscripten, single-threaded). Replaces FMOD. PCM/ADPCM/MP3 need no wasm.


Plan: docs/unity-asset-reader-plan.md. Behavior source of truth: Razviar/assetstudio (MIT). Golden oracle: UnityPy (MIT). MIT-derivative port: keep upstream copyright notices. Do not copy or import @arkntools/unity-js (AGPL-3.0), tests included. No C# compiled to WASM - C# is reference only, hand-ported to TS; WASM is built from C/C++ only (plan D2). Layout: npm-workspaces monorepo under packages/; dependencies point feature package -> core only (plan D7/D8, rules R13/R14).

Activity

  1. fatal10110 commented on Oct 6, 2026

    @fatal10110
    OwnerAuthor

    Research notes (2026-10-06): FSB5 → OGG/WAV needs no WASM

    The libogg + libvorbis WASM package in this issue's body is not needed for OGG export.

    Fmod5Sharp (C#, MIT) rebuilds FSB5 Vorbis without libvorbis and without any audio maths (FmodVorbisRebuilder.cs):

    • The Vorbis setup header that FSB5 strips is looked up by the CRC32 in the VORBISDATA chunk, in a precomputed table (embedded resource vorbis_headers_converted.json).
    • The rest is repackaging: it builds the info, comment and setup packets, wraps the existing compressed frames in Ogg pages, and recalculates granule positions. OggVorbisEncoder is used only for Ogg container writing, never for encoding.
    • It also decodes PCM8/16/32, GCADPCM, IMAADPCM and FADPCM in managed code. MPEG, CELT, AT9, Opus, XMA and PCMFLOAT are not supported there.

    Proposed approach

    • Hand-port the logic to TS, with the C# read-only and cloned outside the repo (R2), in its own package unity-asset-reader-audio. It is pure TS and sync, so D4 holds.
    • Use python-fsb5 (MIT) as the second reference.
    • Writing the Ogg pages (page header + Ogg CRC32) is about 100–200 lines of TS; no Ogg library is needed.

    Open question before porting

    Where does the setup-header table come from, and under what licence? It appears to be extracted from FMOD, which is proprietary, and is presumably the same table python-fsb5 ships. Neither point is verified.

    • If the table cannot be shipped, the fallback is generating setup headers from the stream parameters. That pulls in Vorbis encoder logic and makes the port much larger.

    Oracle

    There is no FMOD-free oracle. AssetStudio uses the FMOD Studio API, and UnityPy's export/AudioClipConverter.py calls fmod_toolkit.raw_to_wav.

    • Expected output could come from Fmod5Sharp or python-fsb5 run outside the repo, with the verdict recorded per plan §6. Comparing WAV after decoding is another option.
    • For OGG output, an independent check is that the result is a valid Ogg Vorbis stream whose decoded PCM is close to the source tone.wav.

    Optional: decoding Vorbis to PCM

    • Not needed for OGG export.
    • If ever wanted: @wasm-audio-decoders/ogg-vorbis (MIT, prebuilt libvorbis, ~99 KiB minified), or the browser's decodeAudioData, which is async and so stays outside the parse path per D4.

    Fixtures

    Already committed: the audio bundles of fixtures/BUILDING.md §11 (2019.4.41f2, 2020.3.30f1, 6000.3.25f1) hold tone-pcm (PCM) and tone-vorbis (Vorbis) as FSB5 in the .resource node.

    Rough size

    About 2 PRs (FSB5 parser + PCM/ADPCM → WAV; Vorbis → OGG), roughly 1–1.5M agent tokens with the usual review loop. This assumes the header-table question is settled first.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogOn-demand, no named consumer yet

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions