# @psalomo/wasm-music-faust

The [Faust](https://faust.grame.fr/) compiler — the Rust implementation,
[faust-rs](https://github.com/grame-cncm/faust-rs) — built for
`wasm32-unknown-unknown` with the **AssemblyScript backend** enabled and the
Faust standard libraries embedded.

This package ships one artifact, `faust-compiler-module.wasm`, and no JavaScript. It is
the compiler module loaded by
[WebAssembly Music](https://github.com/petersalomonsen/javascriptmusic) to turn `.dsp` sources into AssemblyScript.

## Using it

The module is a plain wasm32 module: no emscripten loader, no MEMFS, no
imports.

```js
const bytes = await (await fetch(
  'https://cdn.jsdelivr.net/npm/@psalomo/wasm-music-faust@0.2.0/faust-compiler-module.wasm'
)).arrayBuffer();
const { instance } = await WebAssembly.instantiate(bytes, {});
```

Compilation goes through `faust_wasm_generate_aux_files_json(name, source, args)`,
with strings written into memory via `faust_wasm_alloc`. Failures carry a
structured diagnostics-v2 report on the result handle
(`faust_wasm_text_result_diagnostics_ptr`/`_len`). See
[faust-rs-transpile.js](https://github.com/petersalomonsen/javascriptmusic/blob/master/wasmaudioworklet/faust/faust-rs-transpile.js)
for a complete working host, and the
[faust-rs error model](https://github.com/grame-cncm/faust-rs) for the
diagnostics schema.

Because `import("stdfaust.lib")` resolves from libraries embedded at build
time, no library files need to be provided at runtime. Sibling sources travel
inline as `--virtual-source <path>=<base64>` arguments.

## This build

| | |
|---|---|
| compiler module | `faust-rs-wasm-ffi/0.8.0` |
| faust-rs commit | `eabee390de0435d97e6663e9d845971dad47002a` |
| faustlibraries commit | `ecf2fdc238148c44c18352102333a1229ca7a8d3` |

Built and published by
[this workflow](https://github.com/petersalomonsen/javascriptmusic/blob/master/.github/workflows/publish-faust-compiler-module.yml),
which validates every module before release.

## License

The compiler is **GRAME's** work, not this project's:

> faust-rs — a Rust port of the FAUST compiler
> Copyright (C) 2026 GRAME, Centre National de Creation Musicale
> Derived from the FAUST compiler, Copyright (C) 2003-2024 GRAME.

Licensed under **LGPL-2.1-or-later**; the full text is in `LICENSE`, copied
from the faust-rs revision this module was built from. This package only
repackages that build for npm.
