Faust Web Audio Library
Table of Content
The API is organised from low to high level as illustrated by the figure below.
The first level is the Faust compiler compiled as a wasm library named
It consists in 3 different files:
libfaust-wasm.wasm: the Faust compiler provided as a WebAssembly module
libfaust-wasm.data: a virtual file system containing the Faust libraries.
You must include
libfaust-wasm.js in your html page. The loader will take care of providing an instance of the Faust WebAssembly module and of the associated virtual file system (libfaust-wasm.data). Note that depending on the relative location of
libfaust-wasm.js, the loader may fail to find
libfaust-wasm.data; in this case, the simple solution consists in copying
libfaust-wasm.data aside the refering web page.
It provides classic Faust compilation services, which output is a raw WebAssembly module with an associated JSON description of the module.
This level takes a WebAssembly module produced by the Faust compiler or a precompiled module loaded from a file, and builds an instance of this module with the proper Wasm memory layout, ready to run, but not yet connected to any audio node. It is described in
Note that ScriptProcessor is marked as deprecated but it's the only audio architecture available on Safari. Both monophonic (generators, effects...) or polyphonic (instruments) nodes can be created.
By default, and to save CPU, created audio nodes are not processing audio buffers. They have to be explicitely started with the
start method (and possibly stopped if needed using the
Warning: AudioWorklet is a recent technology and may not be supported by all the browsers. Check the compatibility chart.
An offline processor to render a DSP in a non real-time context and get the computed frames is available. It is described in
FaustWebAudio.d.ts. It will automatically use the
stop methods internally to activate actual rendering in its
A high-level API is available to compile a DSP program and create the audio node, either monophonic or polyphonic. It is described in
index.d.ts. More generally, the
Faustxxx.d.tsfiles describe interfaces and
index.d.ts describes functions and includes the interface files.
Simply include the following to get access to types and functions:
The Faust Wasm and Audio Node levels make it possible to generate instances from Faust dsp code as well as from pre-compiled WebAssembly modules.
In the latter case, it is not necessary to include the
FaustLibrary.js is sufficient to provide the required services.
This allows to generate lighter and faster-loading HTML pages.
Note: to create a polyphonic instance from a pre-compiled WebAssembly module, an additional
mixer32.wasm file (or
mixer64.wasm when compiled in
-double ) is required and must be present at the same level as the referring HTML page. This module is part of the
FaustUtilities.d.ts: provides facilities to browse Faust generated SVG diagrams
FaustWAP.d.ts: provides Web Audio Plugins API support.
Html pages embedding the Faust compiler must be served using https, unless using http://localhost.