@grame/faustwasm 0.0.25 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -2
- package/package.json +4 -2
- package/library.md +0 -91
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# FaustWasm
|
|
2
2
|
|
|
3
|
-
WebAssembly version of [Faust Compiler](https://github.com/grame-cncm/faust) for [Node.js](https://nodejs.org) and web browsers, built with [Emscripten](https://emscripten.org/) 3.1.31
|
|
3
|
+
The Faust Web Audio library provides a high level Javascript API over the [Faust](https://faust.grame.fr) compiler. The interface is designed to be used with [TypeScript](https://www.typescriptlang.org/), but describes and documents the API for pure Javascript as well. The WebAssembly version of [Faust Compiler](https://github.com/grame-cncm/faust) is for [Node.js](https://nodejs.org) and web browsers, built with [Emscripten](https://emscripten.org/) 3.1.31.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
@@ -178,4 +178,89 @@ process = ba.pulsen(1, 10000) : pm.djembe(60, 0.3, 0.4, 1);
|
|
|
178
178
|
})();
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
## Documentation
|
|
182
|
+
|
|
183
|
+
- [Organisation of the API](#org)
|
|
184
|
+
|
|
185
|
+
- [Faust Compiler WebAssembly module](#module)
|
|
186
|
+
- [Faust Compiler Javascript Interface](#compiler)
|
|
187
|
+
- [Faust Wasm Instance](#wasm)
|
|
188
|
+
- [Faust Audio Nodes Instances and Offline Processor ](#audio)
|
|
189
|
+
- [High-level API](#high)
|
|
190
|
+
- [How to use with typescript](#tsuse)
|
|
191
|
+
- [Dynamic and Static Instances](#ds)
|
|
192
|
+
- [Misc. services](#misc)
|
|
193
|
+
- [Important note](#note)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
## Organisation of the API <a name="org"></a>
|
|
197
|
+
|
|
198
|
+
The API is organised from low to high level as illustrated by the figure below.
|
|
199
|
+
|
|
200
|
+
<img src="rsrc/overview.png" class="mx-auto d-block" width="60%">
|
|
201
|
+
|
|
202
|
+
### Faust Compiler WebAssembly module <a name="module"></a>
|
|
203
|
+
|
|
204
|
+
The first level is the Faust compiler compiled as a wasm library named `libfaust-wasm`.
|
|
205
|
+
It consists in 3 different files:
|
|
206
|
+
|
|
207
|
+
- `libfaust-wasm.wasm` : the Faust compiler provided as a WebAssembly module
|
|
208
|
+
- `libfaust-wasm.js` : a Javascript loader of the WebAssembly module
|
|
209
|
+
- `libfaust-wasm.data` : a virtual file system containing the Faust libraries.
|
|
210
|
+
|
|
211
|
+
The C++ code is compiled with [Emscripten](https://emscripten.org) and interfaced in `LibFaust.ts` and `types.ts`files. The loader will take care of providing an instance of the Faust WebAssembly module and of the associated virtual file system (libfaust-wasm.data).
|
|
212
|
+
|
|
213
|
+
### Faust Compiler Javascript Interface <a name="compiler"></a>
|
|
214
|
+
|
|
215
|
+
The Faust Compiler Javascript interface is described in `FaustCompiler.ts`.
|
|
216
|
+
It provides *classic* Faust compilation services, which output is a raw WebAssembly module with an associated JSON description of the module.
|
|
217
|
+
|
|
218
|
+
### Faust Wasm Instance <a name="wasm"></a>
|
|
219
|
+
|
|
220
|
+
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 `FaustDspGenerator.ts`, `FaustWasmInstantiator.ts`, `FaustWebAudioDsp.ts` and `FaustDspInstance.ts` files.
|
|
221
|
+
|
|
222
|
+
### Faust Audio Nodes Instances and Offline Processor <a name="audio"></a>
|
|
223
|
+
|
|
224
|
+
This level takes a Faust Wasm instance to build an audio node. [AudioWorklet](https://developer.mozilla.org/fr/docs/Web/API/AudioWorklet) and [ScriptProcessor](https://developer.mozilla.org/en-US/docs/Web/API/ScriptProcessorNode) nodes are supported. It is described in `FaustAudioWorkletNode.ts` and `FaustAudioWorkletProcessor.ts` files.
|
|
225
|
+
|
|
226
|
+
**Warning**: AudioWorklet is a recent technology and may not be supported by all the browsers. Check the [compatibility](https://developer.mozilla.org/fr/docs/Web/API/AudioWorklet) chart.
|
|
227
|
+
|
|
228
|
+
Note that ScriptProcessor is marked as [deprecated](https://developer.mozilla.org/en-US/docs/Web/API/ScriptProcessorNode) but it's the only audio architecture available in older Safari versions. Both monophonic (generators, effects...) or polyphonic (instruments) nodes can be created. It is described in `FaustScriptProcessorNode.ts` file.
|
|
229
|
+
|
|
230
|
+
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 `stop`method).
|
|
231
|
+
|
|
232
|
+
An offline processor to render a DSP in a non real-time context and get the computed frames is available. It is described in `FaustOfflineProcessor.ts`. It will automatically use the `start` and `stop` methods internally to activate actual rendering in its `plot` method.
|
|
233
|
+
|
|
234
|
+
### High-level API <a name="high"></a>
|
|
235
|
+
|
|
236
|
+
A high-level API is available to compile a DSP program and create the audio node, either monophonic or polyphonic using `createNode`. Offline processing monophonic or polyphonic nodes can be created using `createOfflineProcessor`. FFT processing nodes can be created using `createFFTNode`. It is described in `FaustDspGenerator.ts`.
|
|
237
|
+
|
|
238
|
+
### How to use with typescript <a name="tsuse"></a>
|
|
239
|
+
|
|
240
|
+
Simply include the following to get access to types and functions:
|
|
241
|
+
~~~~~~~~~~~~~~~
|
|
242
|
+
///<reference types="@grame/faustwasm"/>
|
|
243
|
+
~~~~~~~~~~~~~~~
|
|
244
|
+
|
|
245
|
+
## Dynamic and Static Instances <a name="ds"></a>
|
|
246
|
+
|
|
247
|
+
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.
|
|
248
|
+
In the latter case, it is not necessary to include the `libfaust-wasm.js` library, `index.js` is sufficient to provide the required services.
|
|
249
|
+
This allows to generate lighter and faster-loading HTML pages.
|
|
250
|
+
|
|
251
|
+
## Misc. services <a name="misc"></a>
|
|
252
|
+
|
|
253
|
+
- `FaustSvgDiagrams.ts`: provides facilities to browse Faust generated SVG diagrams
|
|
254
|
+
- `FaustFFTAudioWorkletProcessor`: provides FFT processing
|
|
255
|
+
|
|
256
|
+
## Important note <a name="note"></a>
|
|
257
|
+
|
|
258
|
+
Html pages embedding the Faust compiler must be served using https, unless using http://localhost.
|
|
259
|
+
|
|
260
|
+
----
|
|
261
|
+
<a href="http://faust.grame.fr"><img src=https://faust.grame.fr/community/logos/img/LOGO_FAUST_COMPLET_ORANGE.png width=200 /></a>
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grame/faustwasm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"description": "WebAssembly version of Faust Compiler",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"keywords": [
|
|
24
24
|
"faust",
|
|
25
|
-
"webassembly"
|
|
25
|
+
"webassembly",
|
|
26
|
+
"audio",
|
|
27
|
+
"signal processing"
|
|
26
28
|
],
|
|
27
29
|
"author": "Grame-CNCM",
|
|
28
30
|
"license": "LGPL-3.0",
|
package/library.md
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# Faust Web Audio Library
|
|
2
|
-
|
|
3
|
-
The Faust Web Audio library provides a high level Javascript API over the [Faust](https://faust.grame.fr) compiler. The interface is designed to be used with [TypeScript](https://www.typescriptlang.org/), but describes and documents the API for pure Javascript as well. This document provides an overview of the differents levels of the API. Examples of use are also provided in the `test` folder.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
## Table of Content
|
|
7
|
-
|
|
8
|
-
- [Organisation of the API](#org)
|
|
9
|
-
|
|
10
|
-
- [Faust Compiler WebAssembly module](#module)
|
|
11
|
-
- [Faust Compiler Javascript Interface](#compiler)
|
|
12
|
-
- [Faust Wasm Instance](#wasm)
|
|
13
|
-
- [Faust Audio Nodes Instances and Offline Processor ](#audio)
|
|
14
|
-
- [High-level API](#high)
|
|
15
|
-
- [How to use with typescript](#tsuse)
|
|
16
|
-
- [Dynamic and Static Instances](#ds)
|
|
17
|
-
- [Misc. services](#misc)
|
|
18
|
-
- [Important note](#note)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
## Organisation of the API <a name="org"></a>
|
|
22
|
-
|
|
23
|
-
The API is organised from low to high level as illustrated by the figure below.
|
|
24
|
-
|
|
25
|
-
<img src="rsrc/overview.png" class="mx-auto d-block" width="60%">
|
|
26
|
-
|
|
27
|
-
### Faust Compiler WebAssembly module <a name="module"></a>
|
|
28
|
-
|
|
29
|
-
The first level is the Faust compiler compiled as a wasm library named `libfaust-wasm`.
|
|
30
|
-
It consists in 3 different files:
|
|
31
|
-
|
|
32
|
-
- `libfaust-wasm.wasm` : the Faust compiler provided as a WebAssembly module
|
|
33
|
-
- `libfaust-wasm.js` : a Javascript loader of the WebAssembly module
|
|
34
|
-
- `libfaust-wasm.data` : a virtual file system containing the Faust libraries.
|
|
35
|
-
|
|
36
|
-
The C++ code is compiled with [Emscripten](https://emscripten.org) and interfaced in `LibFaust.ts` and `types.ts`files. The loader will take care of providing an instance of the Faust WebAssembly module and of the associated virtual file system (libfaust-wasm.data).
|
|
37
|
-
|
|
38
|
-
### Faust Compiler Javascript Interface <a name="compiler"></a>
|
|
39
|
-
|
|
40
|
-
The Faust Compiler Javascript interface is described in `FaustCompiler.ts`.
|
|
41
|
-
It provides *classic* Faust compilation services, which output is a raw WebAssembly module with an associated JSON description of the module.
|
|
42
|
-
|
|
43
|
-
### Faust Wasm Instance <a name="wasm"></a>
|
|
44
|
-
|
|
45
|
-
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 `FaustDspGenerator.ts`, `FaustWasmInstantiator.ts`, `FaustWebAudioDsp.ts` and `FaustDspInstance.ts` files.
|
|
46
|
-
|
|
47
|
-
### Faust Audio Nodes Instances and Offline Processor <a name="audio"></a>
|
|
48
|
-
|
|
49
|
-
This level takes a Faust Wasm instance to build an audio node. [AudioWorklet](https://developer.mozilla.org/fr/docs/Web/API/AudioWorklet) and [ScriptProcessor](https://developer.mozilla.org/en-US/docs/Web/API/ScriptProcessorNode) nodes are supported. It is described in `FaustAudioWorkletNode.ts` and `FaustAudioWorkletProcessor.ts` files.
|
|
50
|
-
|
|
51
|
-
**Warning**: AudioWorklet is a recent technology and may not be supported by all the browsers. Check the [compatibility](https://developer.mozilla.org/fr/docs/Web/API/AudioWorklet) chart.
|
|
52
|
-
|
|
53
|
-
Note that ScriptProcessor is marked as [deprecated](https://developer.mozilla.org/en-US/docs/Web/API/ScriptProcessorNode) but it's the only audio architecture available in older Safari versions. Both monophonic (generators, effects...) or polyphonic (instruments) nodes can be created. It is described in `FaustScriptProcessorNode.ts` file.
|
|
54
|
-
|
|
55
|
-
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 `stop`method).
|
|
56
|
-
|
|
57
|
-
An offline processor to render a DSP in a non real-time context and get the computed frames is available. It is described in `FaustOfflineProcessor.ts`. It will automatically use the `start` and `stop` methods internally to activate actual rendering in its `plot` method.
|
|
58
|
-
|
|
59
|
-
### High-level API <a name="high"></a>
|
|
60
|
-
|
|
61
|
-
A high-level API is available to compile a DSP program and create the audio node, either monophonic or polyphonic using `createNode`. Offline processing monophonic or polyphonic nodes can be created using `createOfflineProcessor`. FFT processing nodes can be created using `createFFTNode`. It is described in `FaustDspGenerator.ts`.
|
|
62
|
-
|
|
63
|
-
### How to use with typescript <a name="tsuse"></a>
|
|
64
|
-
|
|
65
|
-
Simply include the following to get access to types and functions:
|
|
66
|
-
~~~~~~~~~~~~~~~
|
|
67
|
-
///<reference types="@grame/libfaust"/>
|
|
68
|
-
~~~~~~~~~~~~~~~
|
|
69
|
-
|
|
70
|
-
## Dynamic and Static Instances <a name="ds"></a>
|
|
71
|
-
|
|
72
|
-
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.
|
|
73
|
-
In the latter case, it is not necessary to include the `libfaust-wasm.js` library, `index.js` is sufficient to provide the required services.
|
|
74
|
-
This allows to generate lighter and faster-loading HTML pages.
|
|
75
|
-
|
|
76
|
-
## Misc. services <a name="misc"></a>
|
|
77
|
-
|
|
78
|
-
- `FaustSvgDiagrams.ts`: provides facilities to browse Faust generated SVG diagrams
|
|
79
|
-
- `FaustFFTAudioWorkletProcessor`: provides FFT processing
|
|
80
|
-
|
|
81
|
-
## Important note <a name="note"></a>
|
|
82
|
-
|
|
83
|
-
Html pages embedding the Faust compiler must be served using https, unless using http://localhost.
|
|
84
|
-
|
|
85
|
-
----
|
|
86
|
-
<a href="http://faust.grame.fr"><img src=https://faust.grame.fr/community/logos/img/LOGO_FAUST_COMPLET_ORANGE.png width=200 /></a>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|