npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

stb-vorbis

v0.0.6

Published

Synchronous Ogg Vorbis decoder for JavaScript and WebAssembly

Readme

stb-vorbis

A small synchronous Vorbis decoder for JavaScript using stb_vorbis through WebAssembly.

This decoder is designed for restricted environments, such as an AudioWorklet. It doesn't use fetch or any APIs not available in AudioWorklets and provides a fully synchronous decode method, shipping one JS file. The WebAssembly binary is stored as base64-encoded data in the JS file.

Made for use in spessasynth_core, but can be used separately.

Installation

npm install stb-vorbis

Example

import { StbVorbis } from "stb-vorbis";

// Initialize the decoder
await StbVorbis.ready;

const ogg = await fetch("/audio/example.ogg").then((response) =>
    response.arrayBuffer()
);

// Decode the audio data
const audio = StbVorbis.decode(ogg); // f32 by default

console.log(audio.sampleRate); // For example: 44100
console.log(audio.channels.length); // Number of channels
console.log(audio.channels[0]); // Float32Array containing channel 1

A proper example can be found in the examples/ directory. It plays the specified Ogg Vorbis file through ffplay. Run it using tsx.

API reference

ready

await StbVorbis.ready;

Resolves when the decoder has been initialized. Call await StbVorbis.ready before calling StbVorbis.decode().

decode

StbVorbis.decode(data);

Synchronously decodes a complete Vorbis stream in an Ogg Container.

  • data - ArrayBufferLike or Uint8Array - the binary Ogg Vorbis data.

Throws if the decoder has not been initialized, if the input cannot be decoded, or if WASM memory allocation fails.

The returned object is described below.

DecodedAudio

interface DecodedAudio {
    readonly sampleRate: number;
    readonly channels: Float32Array[];
}
  • sampleRate - sample rate in Hz.
  • channels - an array of Float32Array channel PCM data. All arrays have the same length.

Building from source

The build requires Emscripten. The build script looks for emcc in this order:

  1. The EMCC environment variable.
  2. $EMSDK/upstream/emscripten/emcc.
  3. /usr/lib/emscripten/emcc.
  4. ~/emsdk/upstream/emscripten/emcc.
  5. emcc on PATH directly.

For a custom installation, either activate Emscripten in the shell or set EMCC explicitly:

EMCC=/path/to/emsdk/upstream/emscripten/emcc npm run build

To build from source, run:

git clone https://github.com/spessasus/stb-vorbis
cd stb-vorbis
npm install
npm run build

The final build publishes dist/index.js, which contains the code and type declarations.

License

Apache License 2.0.

The included stb_vorbis.c source retains its original public-domain dedication. See the bottom of the file for details.

Special Thanks