ogg_decoder.wasm

A simple .ogg(vorbis) decoder in wasm, ported using Emscripten.

Usage

Put libvorbis.wasm in your bundler's output dictionary.

import { createInstance, decode, toBlobUrl } from "index.js";
let instance = await createInstance();
let [success, result] = decode(new Uint8Array(audio_buf), instance)
// result will be an Uint8Array (.wav) if success
if (success) {
  let url = toBlobUrl(result);
  document.getElementById("player").setAttribute("src", url);
}

you can send an Module object to createInstance to control the execution of code. Learn more

let instance = await createInstance({printErr: (text) => {console.log(text)}});

Build_from_source

$ git clone https://github.com/daflyinbed/ogg_decoder.wasm.git
$ git submodule update --init --recursive
$ ./build-with-docker.sh

If nothing goes wrong, you can find build/libvorbis.wasm build/libvorbis.mjs index.d.ts

Relative repos

libogg

libvorbis

vorbis tools

ffmepg.wasm

ffmpeg.wasm-core

vorbis.js