@enikey87/fluidsynth-emscripten

0.1.1 • Public • Published

FluidSynth with Emscripten-specific patch

This repository is based on FluidSynth repository, and contains some changes to build with Emscripten.

The original README is here: README.original.md

Build (enikey87)

In order to build WebAssembly version of fluidsynth by yourself:

# Optional step to include sf3 support
./build_libsdnfile.sh
# All variants of libfluidsynth-X.X.X.js + libfuluidsynth-X.X.X.wasm files will be stored to ./dist 
./build.sh

Build with Docker (enikey87)

docker-compose build        # to create the Docker image
docker-compose up           # to create the Docker container and build
docker-compose run builder  # to build again after any modification

Build (from jet2jet)

Tested with Emscripten version 3.1.10.

  1. (Optional) Update emscripten/exports.txt, containing export functions for JS program
    • The script emscripten/make-exports.js will update this automatically, gathering functions from include directory.
  2. Make sure that Emscripten is usable on the current environment
  3. Make build directory
  4. Enter build directory and execute emcmake cmake -Denable-oss=off -DCMAKE_BUILD_TYPE=Release ..
    • If no other options are specified, and cmake is running with emcmake (or emconfigure), the build configurations are initialized for Emscripten-build mode.
  5. In build directory, execute emmake make

After successful build, libfluidsynth-<version>.js will be created at build/src directory.

  • If enable-debug specified on the cmake execution (e.g. emcmake cmake -Denable-debug=on ..), a map file libfluidsynth-<version>.wasm.map is also generated.
    • Currently it seems that it cannot be used.
  • If enable-separate-wasm specified on the cmake execution (e.g. emcmake cmake -Denable-separate-wasm=on ..), libfluidsynth-<version>.wasm and libfluidsynth-<version>.wast are also generated.
    • For AudioWorklet, you cannot use *.wasm file directly.
  • In Emscripten-build mode, standalone application named fluidsynth is not emitted.

Build static library for Emscripten

Please specify -D BUILD_SHARED_LIBS=off on calling emcmake. (e.g. emcmake cmake -D BUILD_SHARED_LIBS=off ..)

In this mode, you can also build sources under doc directory (e.g. cd build/doc && make fluidsynth_simple -j16), although all exportable functions will be exported.

Usage

Place libfluidsynth-<version>.js file to your space and load libfluidsynth-<version>.js. After load, almost all FluidSynth API functions are accessible via Module object (note that all function names have the prefix _).

To use libfluidsynth-<version>.js in AudioWorklet, load it into AudioWorklet before your worklet JS file. In your worklet JS file, you can access Module object via AudioWorkletGlobalScope.wasmModule.

Miscellaneous

  • Currently only several APIs are tested. Some APIs such as for drivers may not work.

License

This program and all source codes, including the original FluidSynth program, its source codes, modifications of FluidSynth source codes for building library with Emscripten, and sources codes used only for building libfluidsynth-<version>.js, are licensed under GNU Lesser General Public License (v2.1) (LGPL v2.1).

Readme

Keywords

Package Sidebar

Install

npm i @enikey87/fluidsynth-emscripten

Weekly Downloads

64

Version

0.1.1

License

LGPL

Unpacked Size

17.9 MB

Total Files

17

Last publish

Collaborators

  • enikey87