Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build for WedAssembly #55

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

build for WedAssembly #55

wants to merge 6 commits into from

Conversation

tomjnixon
Copy link
Member

@tomjnixon tomjnixon commented Jun 12, 2023

todo

  • add C++ tests for C API functions (currently only JS)
  • fix use of long for 64 bit types in decorrelation filters (see warning from tests)
  • represent exceptions in C API, and catch exceptions when enabled
  • add more functionality to C API

more ideas for size improvements:

  • improve representation in bs2051_layouts.cpp
    • the current structure results in a manual call to the std::string constructor and the Channel constructor (with lots of parameters on the stack), for each channel in each layout
    • write a POD channel struct which can be stored in static data, and a function that makes a Layout from a char* and a list of channel indexes
  • drop pre-computed facets, or at least change the representation of facets to be something like vector<vector<int>>, as the constructor is huge and using set is unnecessary
  • turn on wasm bulk memory operations

usage

Build with nix (only tested on linux, but may work on osx):

nix --extra-experimental-features "nix-command flakes" build .#libear_wasm

this puts libear.wasm in result/lib/libear.wasm. Alternatively just use this build:
libear.wasm.zip

There is a JS wrapper here: https://github.com/ebu/libear/blob/wasm_build/src/libear.mjs

There are some tests for that here, which show how to load the library (synchronously) and calculate some gains: https://github.com/ebu/libear/blob/wasm_build/tests/test_libear.mjs

To load from a stream in the browser use something like:

const wasm_buf = fetch('libear.wasm');
let lib = await EARLibrary.from_stream(wasm_buf);
...

@tomjnixon tomjnixon force-pushed the wasm_build branch 2 times, most recently from 5c6f1ef to 74d808b Compare January 29, 2024 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant