Code Monkey home page Code Monkey logo

wasm-audio-decoders's Introduction

WASM Audio Decoders

WASM Audio Decoders is a collection of Web Assembly audio decoder libraries that are highly optimized for browser use. Each module supports synchronous decoding on the main thread as well as asynchronous (threaded) decoding through a built in Web Worker implementation.

Web Assembly is a binary instruction format for a stack-based virtual machine that allows for near native code execution speed inside of a web browser. In practice, these decoders are just as fast, and in some cases faster, than the browser implementation.

Decoders

Each decoder is built with inline WASM to reduce bundling complexity with transpilers like Webpack. The inlined WASM is encoded using yEnc for efficient binary encoding and is gzip compressed for reduced file size.

Pre-built minified JS files are available from NPM and in each decoder's dist folder.

Decodes MPEG Layer I/II/III into PCM

  • 71.3 KiB minified bundle size
  • Browser and NodeJS support
  • Built in Web Worker support
  • Based on mpg123
  • Install using NPM

Decodes Ogg Opus data into PCM

  • 108.4 KiB minified bundle size
  • Browser and NodeJS support
  • Built in Web Worker support
  • Multichannel decoding (up to 8 channels)
  • Based on libopusfile
  • Install using NPM

Decodes raw Opus audio frames into PCM

  • 83.0 KiB minified bundle size
  • Browser and NodeJS support
  • Built in Web Worker support
  • Multichannel decoding (up to 255 channels)
  • Based on libopus
  • Install using NPM

Developing

Prerequisites

  1. Install Emscripten by following these instructions.
    • This repository has been tested with Emscripten 2.0.34.

Building

  1. Make sure to source the Emscripten path in the terminal you want build in.
    • i.e. $ source path/to/emsdk/emsdk_env.sh
  2. Run git submodule update --init to clone down the git sub-modules.
  3. Run npm i to install the build tool dependencies.
  4. Run make clean and make to build the libraries.
    • You can run make -j8 where 8 is the number of CPU cores on your system to speed up the build.
  5. The builds will be located in each library's dist folder:
    • opus-decoder: src/opus-decoder/dist/
    • ogg-opus-decoder: src/ogg-opus-decoder/dist/
    • mpg123-decoder: src/mpg123-decoder/dist/

Testing

  1. Run npm i to install the build tool and test dependencies.
  2. Run npm run test to run the test suite.

Attributions

  • OggOpusDecoder was originally based on AnthumChris/opus-stream-decoder.
    • This version has been optimized for size and for simple bundling in web applications:
      • Everything is bundled in a single minified Javascript file for ease of use.
      • WASM binary is encoded inline using yEnc binary encoding and compressed using DEFLATE to significantly reduce bundle size.
      • WASM compiler, minifier, and bundler options are tuned for best possible size and performance.
  • tiny-inflate is included from foliojs/tiny-inflate and is used to decompress the WASM binary.

Licensing

The source code that originates in this project is licensed under the MIT license. Please note that any external source code included by repository, such as the decoding libraries included as git submodules and compiled into the dist files, may have different licensing terms.

wasm-audio-decoders's People

Contributors

banjerluke avatar eshaz avatar tambien avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.