@grame/faustwasm 0.3.2 → 0.4.0
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 +10 -4
- package/assets/standalone/faustwasm/index.d.ts +6 -0
- package/assets/standalone/faustwasm/index.js +12 -4
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/assets/standalone/icon.png +0 -0
- package/assets/standalone/index-poly.js +11 -0
- package/assets/standalone/index.html +4 -2
- package/assets/standalone/index.js +11 -0
- package/assets/standalone/manifest.json +18 -0
- package/assets/standalone/service-worker.js +48 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +12 -4
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +6 -0
- package/dist/cjs-bundle/index.js +12 -4
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +12 -4
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +6 -0
- package/dist/esm-bundle/index.js +12 -4
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +1 -1
- package/src/FaustAudioWorkletNode.ts +0 -3
- package/src/SoundfileReader.ts +16 -2
- package/src/copyWebStandaloneAssets.js +11 -1
- package/test/faustlive-wasm/faustwasm/index.d.ts +6 -0
- package/test/faustlive-wasm/faustwasm/index.js +12 -4
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/osc2.dsp +1 -1
- package/0001-Invert-x-y-z-accelerometer-on-Android.patch +0 -194
- package/build +0 -17
package/README.md
CHANGED
|
@@ -4,6 +4,10 @@ The FaustWasm library presents a convenient, high-level API that wraps around [F
|
|
|
4
4
|
|
|
5
5
|
The library offers functionality for compiling Faust DSP code into WebAssembly, enabling its utilization as WebAudio nodes within a standard WebAudio node graph. Moreover, it supports offline rendering scenarios. Furthermore, supplementary tools can be employed for generating SVGs from Faust DSP programs.
|
|
6
6
|
|
|
7
|
+
Synthesizer and effect mono nodes, as well as [polyphonic](https://faustdoc.grame.fr/manual/midi/#midi-polyphony-support) poly nodes can be created. MIDI support is activated as soon as [MIDI metadata](https://faustdoc.grame.fr/manual/midi/#configuring-midi-in-faust) are used in the DSP code for mono nodes, and always in polyphonic mode.
|
|
8
|
+
|
|
9
|
+
[Sensors](https://faustdoc.grame.fr/manual/syntax/#sensors-control-metadatas) (accelerometer and gyroscope) are supported, as well as the [Progressive Web Application](https://en.wikipedia.org/wiki/Progressive_web_app) model.
|
|
10
|
+
|
|
7
11
|
## Usage
|
|
8
12
|
|
|
9
13
|
Please use a stable version of [Node.js](https://nodejs.org) 16+ to work with this project.
|
|
@@ -55,21 +59,23 @@ node scripts/faust2wasm.js test/poly.dsp test/out -poly
|
|
|
55
59
|
```
|
|
56
60
|
will create a set of files: `poly.js`, `poly.wasm`, `poly.json`, `poly.html` (and possibly `poly_effect.wasm`, `poly_effect.json`) in the `out` folder.
|
|
57
61
|
|
|
58
|
-
You can create a standalone
|
|
62
|
+
You can create a standalone Progressive Web Application using the same command line:
|
|
59
63
|
|
|
60
64
|
```bash
|
|
61
65
|
rm -rf test/out # make sure you are under the faustwasm directory.
|
|
62
66
|
node scripts/faust2wasm.js test/rev.dsp test/out -standalone
|
|
63
67
|
```
|
|
64
|
-
will create a set of files: `rev.js`, `rev.wasm`, `rev.json`, `
|
|
68
|
+
will create a set of files: `icon.png`, `service-worker.js`, `manifest.json`, `rev.js`, `rev.wasm`, `rev.json`, `index.html`, and the `faustwasm`, `faust-ui` folders in the `out` folder.
|
|
69
|
+
|
|
70
|
+
The folder contains the necessary ressources to deploy the Faust application as a PWA on a server, to be installed and used offline. Note that audio files used by the `soundfile` primitives in the DSP code will have to be mannually added in the folder.
|
|
65
71
|
|
|
66
|
-
|
|
72
|
+
A standalone polyphonic and MIDI standalone Progressive Web Application can be created with:
|
|
67
73
|
|
|
68
74
|
```bash
|
|
69
75
|
rm -rf test/out # make sure you are under the faustwasm directory.
|
|
70
76
|
node scripts/faust2wasm.js test/organ1.dsp test/out -standalone
|
|
71
77
|
```
|
|
72
|
-
will create a set of files: `organ1.js`, `organ1.wasm`, `organ1.json`, `organ1_effect.wasm`, `organ1_effect.json`, `
|
|
78
|
+
will create a set of files: `icon.png`, `service-worker.js`, `manifest.json`, `organ1.js`, `organ1.wasm`, `organ1.json`, `organ1_effect.wasm`, `organ1_effect.json`, `index.html`, and the `faustwasm`, `faust-ui` folders in the `out` folder.
|
|
73
79
|
|
|
74
80
|
#### Generate SVG Diagrams of a Faust DSP
|
|
75
81
|
|
|
@@ -1211,6 +1211,12 @@ export declare class WavDecoder {
|
|
|
1211
1211
|
/** Read metadata and fetch soundfiles */
|
|
1212
1212
|
export declare class SoundfileReader {
|
|
1213
1213
|
static get fallbackPaths(): string[];
|
|
1214
|
+
/**
|
|
1215
|
+
* Extract the parent URL from an URL.
|
|
1216
|
+
* @param url : the URL
|
|
1217
|
+
* @returns : the parent URL
|
|
1218
|
+
*/
|
|
1219
|
+
private static getParentUrl;
|
|
1214
1220
|
/**
|
|
1215
1221
|
* Convert an audio buffer to audio data.
|
|
1216
1222
|
*
|
|
@@ -3496,8 +3496,17 @@ var WavDecoder_default = WavDecoder;
|
|
|
3496
3496
|
|
|
3497
3497
|
// src/SoundfileReader.ts
|
|
3498
3498
|
var SoundfileReader = class {
|
|
3499
|
+
// Set the fallback paths
|
|
3499
3500
|
static get fallbackPaths() {
|
|
3500
|
-
return [location.href, location.origin];
|
|
3501
|
+
return [location.href, this.getParentUrl(location.href), location.origin];
|
|
3502
|
+
}
|
|
3503
|
+
/**
|
|
3504
|
+
* Extract the parent URL from an URL.
|
|
3505
|
+
* @param url : the URL
|
|
3506
|
+
* @returns : the parent URL
|
|
3507
|
+
*/
|
|
3508
|
+
static getParentUrl(url) {
|
|
3509
|
+
return url.substring(0, url.lastIndexOf("/") + 1);
|
|
3501
3510
|
}
|
|
3502
3511
|
/**
|
|
3503
3512
|
* Convert an audio buffer to audio data.
|
|
@@ -3538,7 +3547,8 @@ var SoundfileReader = class {
|
|
|
3538
3547
|
static async checkFileExists(url) {
|
|
3539
3548
|
try {
|
|
3540
3549
|
console.log(`"checkFileExists" url: ${url}`);
|
|
3541
|
-
const response = await fetch(url
|
|
3550
|
+
const response = await fetch(url);
|
|
3551
|
+
console.log(`"checkFileExists" response.ok: ${response.ok}`);
|
|
3542
3552
|
return response.ok;
|
|
3543
3553
|
} catch (error) {
|
|
3544
3554
|
console.error("Fetch error:", error);
|
|
@@ -3659,8 +3669,6 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
3659
3669
|
async listenSensors() {
|
|
3660
3670
|
if (this.hasAccInput) {
|
|
3661
3671
|
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
3662
|
-
console.log(navigator.userAgent);
|
|
3663
|
-
console.log(isAndroid);
|
|
3664
3672
|
let handleDeviceMotion = null;
|
|
3665
3673
|
if (isAndroid) {
|
|
3666
3674
|
handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|