Web Assembly audio decoders extremely optimized for measurement and efficiency

Web Assembly audio decoders extremely optimized for measurement and efficiency

WASM Audio Decoders is a set of Web Assembly audio decoder libraries which might be extremely optimized for browser use. Each module helps synchronous decoding on the principle thread in addition to asynchronous (threaded) decoding via a inbuilt Web Worker implementation.

Web Assembly is a binary instruction format for a stack-based digital machine that enables for close to native code execution pace inside an internet browser. In follow, these decoders are simply as quick, and in some circumstances sooner, than the browser implementation.

Each decoder is constructed with inline WASM to scale back bundling complexity with transpilers like Webpack. The inlined WASM is encoded utilizing yEnc for environment friendly binary encoding and is gzip compressed for decreased file measurement.

Pre-built minified JS information can be found from NPM and in every decoder’s dist folder.

Decodes MPEG Layer I/II/III into PCM

  • 84.6 KiB minified bundle measurement
  • Browser and NodeJS help
  • Built in Web Worker help
  • Based on mpg123
  • Install utilizing NPM

Decodes FLAC and Ogg FLAC information into PCM

  • 65.3 KiB minified bundle measurement
  • Browser and NodeJS help
  • Built in Web Worker help
  • Multichannel decoding (as much as 8 channels)
  • Supports full FLAC bit depth and pattern price.
  • Based on libFLAC and codec-parser
  • Install utilizing NPM

Decodes Ogg Opus information into PCM

  • 108.9 KiB minified bundle measurement
  • Browser and NodeJS help
  • Built in Web Worker help
  • Multichannel decoding (as much as 255 channels)
  • Based on libopus and codec-parser
  • Install utilizing NPM

Decodes uncooked Opus audio frames into PCM

  • 85.0 KiB minified bundle measurement
  • Browser and NodeJS help
  • Built in Web Worker help
  • Multichannel decoding (as much as 255 channels)
  • Intended for customers that have already got Opus frames extracted from a container, i.e. (Ogg, Matroska (WEBM), or ISOBMFF (mp4))
  • Based on libopus
  • Install utilizing NPM

Decodes Ogg Vorbis information into PCM

  • 97.9 KiB minified bundle measurement
  • Browser and NodeJS help
  • Built in Web Worker help
  • Multichannel decoding (as much as 255 channels)
  • Supports full Vorbis pattern price.
  • Based on libvorbis and codec-parser
  • Install utilizing NPM
  1. Linux, or a Linux-like setting to construct (i.e. WSL).
  2. NodeJS 18.x or greater.
  3. Emscripten 3.1.51
  1. Clone this repo.
  2. Change listing to this repo and run git submodule replace --init to clone the git sub-modules.
git clone https://github.com/eshaz/wasm-audio-decoders.git
cd wasm-audio-decoders
git submodule replace --init

  1. Run npm set up to put in the construct dependencies.
  2. Run npm run install-decoders to put in the dependencies for every decoder.
npm set up
npm run install-decoders

  1. supply the Emscripten path within the terminal you need construct in.
    • i.e. $ supply path_to_your_emscripten_installation/emsdk_env.sh
  2. Run npm run configure to configure the libraries. (solely required for first time construct, or after updating the Makefile)
  3. Run npm run construct to construct the libraries.
    • The builds might be situated in every library’s dist folder.
# solely required for first time construct, OR after updating the `Makefile`
npm run configure
# builds the undertaking
npm run construct

  1. Run npm run take a look at to run the take a look at suite.
  1. Make your modifications
  2. If you up to date any dependencies, ensure to set up them.
  3. If you up to date any configuration within the Makefile, ensure to configure the undertaking.
  4. Rebuild the undertaking.
  5. Ensure the assessments nonetheless cross by operating npm run take a look at.

All contributions are welcome!

  • Questions / feedback needs to be entered into a difficulty.
  • Changes needs to be entered right into a PR.
  • Please learn via the present points to test in case your query / remark has already been addressed, however do not hesitate to succeed in out in case you nonetheless have unanswered questions.
  • Please ensure to obviously describe your query / remark, or the function / repair you want to contribute.
    • Sharing pattern information as an indication is often one of the simplest ways to do that.
  • Adding take a look at circumstances for brand spanking new options or fixes is very appreciated.

All contributes / interactions with this repository should observe the code of conduct.

  • Show your help by ‘starring’ this repo, contributing, or donating via Github sponsors.
  • OggOpusDecoder was initially primarily based on AnthumChris/opus-stream-decoder.
    • This model has been optimized for measurement and for easy bundling in net functions:
      • Everything is bundled in a single minified Javascript file for ease of use.
      • Multichannel decoding (all 255 Opus channels) is supported.
      • WASM binary is encoded inline utilizing yEnc binary encoding and compressed utilizing DEFLATE to considerably scale back bundle measurement.
      • WASM compiler, minifier, and bundler choices are tuned for absolute best measurement and efficiency.
  • puff is included as a WASM construct from madler/zlib and is used to decompress the WASM binary.

The supply code that originates on this undertaking is licensed underneath the MIT license. Please word that any exterior supply code included by repository, such because the decoding libraries included as git submodules and compiled into the dist information, might have completely different licensing phrases.

HI-FI News

by way of Hacker News https://ift.tt/iJZDq35

October 31, 2024 at 01:13PM