All Projects → hajimehoshi → stbvorbis.js

hajimehoshi / stbvorbis.js

Licence: Apache-2.0 License
A JavaScript port of stb_vorbis.c

Programming Languages

c
50402 projects - #5 most used programming language
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
shell
77523 projects
go
31211 projects - #10 most used programming language
powershell
5483 projects
Dockerfile
14818 projects

stbvorbis.js

A JavaScript port of stb_vorbis.c.

Usage

Download files from Releases. Copy stbvorbis.js and stbvorbis_asm.js to your file server and load stbvorbis.js via a script tag.

This library basically uses WebAssembly. stbvorbis.js also has asm.js implementation for environments where WebAssembly is not available. On iOS, stbvorbis.js always uses asm.js instead due to instability of iOS WebAssembly implementation. If stbvorbis_asm.js is in the same directory as stbvorbis.js, asm.js version works as fallback.

API

decode

stbvorbis.decode(buf: ArrayBuffer|Uint8Array, callback: function(event: Object))

decode decodes the given Ogg/Vorbis data.

The given callback is called when decoding proceeded or error happens. The argument is an object that has these keys:

name description
data An array of Float32Array that represents decoded stream for each channel.
sampleRate The sample rate like 44100.
eof True if the stream ends, otherwise false. If this is true, data is null.
error An error string if exists, otherwise null.

decodeStream

stbvorbis.decodeStream(callback: function(event: Object)): function(event: Object)

decodeStream decodes the given Ogg/Vorbis stream.

The given callback is called when decoding proceeded or error happens. The argument is an object that has these keys:

name description
data An array of Float32Array that represents decoded stream for each channel. The length can be more than or equal to 0.
sampleRate The sample rate like 44100.
eof True if the stream ends, otherwise false. If this is true, data is null.
error An error string if exists, otherwise null.

The returned function is used to push input strem. The argument is an object that has these keys:

name description
data ArrayBuffer or Uint8Array that represents encoded stream.
eof True if the stream ends, otherwise false. If this is true, data is ignored.

Compile

Install Docker and run build.sh on Posix or build.ps1 on Windows.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].