@grame/faustwasm 0.4.3 → 0.4.4
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 +9 -7
- package/package.json +1 -1
- package/test/faustlive-wasm/index.js +12 -12
- package/test/libfaust-in-worklet/index.js +2 -2
package/README.md
CHANGED
|
@@ -62,20 +62,20 @@ will create a set of files: `poly.js`, `poly.wasm`, `poly.json`, `poly.html` (an
|
|
|
62
62
|
You can create a standalone Progressive Web Application using the same command line:
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
|
-
|
|
66
|
-
node scripts/faust2wasm.js test/rev.dsp test/out -standalone
|
|
65
|
+
node scripts/faust2wasm.js test/rev.dsp test/rev -standalone
|
|
67
66
|
```
|
|
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 `
|
|
67
|
+
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 `rev` folder.
|
|
69
68
|
|
|
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.
|
|
69
|
+
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. To test, be sure to launch a local web server at the `test` folder level, then go inside `test\rev` folder.
|
|
71
70
|
|
|
72
71
|
A standalone polyphonic and MIDI standalone Progressive Web Application can be created with:
|
|
73
72
|
|
|
74
73
|
```bash
|
|
75
|
-
|
|
76
|
-
node scripts/faust2wasm.js test/organ1.dsp test/out -standalone
|
|
74
|
+
node scripts/faust2wasm.js test/organ1.dsp test/organ1 -poly -standalone
|
|
77
75
|
```
|
|
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 `
|
|
76
|
+
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 `organ1` folder.
|
|
77
|
+
|
|
78
|
+
To test, be sure to launch a local web server at the `test` folder level, then go inside `test\organ1` folder.
|
|
79
79
|
|
|
80
80
|
#### Generate SVG Diagrams of a Faust DSP
|
|
81
81
|
|
|
@@ -235,6 +235,8 @@ process = ba.pulsen(1, 10000) : pm.djembe(60, 0.3, 0.4, 1);
|
|
|
235
235
|
|
|
236
236
|
### Projects examples
|
|
237
237
|
|
|
238
|
+
Several examples can be tested by launching a local web server at the faustwasm root level, and going in `test/faustlive-wasm` and `libfaust-in-worklet` folders.
|
|
239
|
+
|
|
238
240
|
The package is used in the following projects:
|
|
239
241
|
|
|
240
242
|
- [faust-web-component](https://github.com/grame-cncm/faust-web-component), a package providing two web components for embedding interactive Faust snippets in web pages.
|
package/package.json
CHANGED
|
@@ -386,21 +386,21 @@ const uploadOn = (e) => {
|
|
|
386
386
|
alert("WebAssembly is not supported in this browser !");
|
|
387
387
|
reject("WebAssembly is not supported in this browser !");
|
|
388
388
|
}
|
|
389
|
-
|
|
389
|
+
|
|
390
390
|
// CASE 1 : THE DROPPED OBJECT IS A URL TO SOME FAUST CODE
|
|
391
391
|
if (e.dataTransfer.getData('URL') && e.dataTransfer.getData('URL').split(':').shift() != "file") {
|
|
392
392
|
const url = e.dataTransfer.getData('URL');
|
|
393
393
|
let filename = url.toString().split('/').pop();
|
|
394
394
|
filename = filename.toString().split('.').shift();
|
|
395
395
|
const xmlhttp = new XMLHttpRequest();
|
|
396
|
-
|
|
396
|
+
|
|
397
397
|
xmlhttp.onreadystatechange = () => {
|
|
398
398
|
if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
|
|
399
399
|
dsp_code = xmlhttp.responseText;
|
|
400
400
|
callback(dsp_code);
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
|
|
403
|
+
|
|
404
404
|
try {
|
|
405
405
|
xmlhttp.open("GET", url, false);
|
|
406
406
|
// Avoid error "mal formé" on firefox
|
|
@@ -410,10 +410,10 @@ const uploadOn = (e) => {
|
|
|
410
410
|
alert(err);
|
|
411
411
|
reject(err);
|
|
412
412
|
}
|
|
413
|
-
|
|
413
|
+
|
|
414
414
|
} else if (e.dataTransfer.getData('URL').split(':').shift() != "file") {
|
|
415
415
|
dsp_code = e.dataTransfer.getData('text');
|
|
416
|
-
|
|
416
|
+
|
|
417
417
|
// CASE 2 : THE DROPPED OBJECT IS SOME FAUST CODE
|
|
418
418
|
if (dsp_code) {
|
|
419
419
|
callback(dsp_code);
|
|
@@ -423,17 +423,17 @@ const uploadOn = (e) => {
|
|
|
423
423
|
/** @type {FileList} */
|
|
424
424
|
const files = e.target.files || e.dataTransfer.files;
|
|
425
425
|
const file = files[0];
|
|
426
|
-
|
|
426
|
+
|
|
427
427
|
if (location.host.indexOf("sitepointstatic") >= 0) return;
|
|
428
|
-
|
|
428
|
+
|
|
429
429
|
const request = new XMLHttpRequest();
|
|
430
430
|
if (request.upload) {
|
|
431
|
-
|
|
431
|
+
|
|
432
432
|
const reader = new FileReader();
|
|
433
433
|
const ext = file.name.toString().split('.').pop();
|
|
434
434
|
const filename = file.name.toString().split('.').shift();
|
|
435
435
|
let type;
|
|
436
|
-
|
|
436
|
+
|
|
437
437
|
if (ext === "dsp") {
|
|
438
438
|
type = "dsp";
|
|
439
439
|
reader.readAsText(file);
|
|
@@ -441,7 +441,7 @@ const uploadOn = (e) => {
|
|
|
441
441
|
type = "json";
|
|
442
442
|
reader.readAsText(file);
|
|
443
443
|
}
|
|
444
|
-
|
|
444
|
+
|
|
445
445
|
reader.onloadend = (e) => {
|
|
446
446
|
dsp_code = reader.result;
|
|
447
447
|
callback(dsp_code);
|
|
@@ -492,7 +492,7 @@ const activateMonoDSP = (dsp) => {
|
|
|
492
492
|
}
|
|
493
493
|
|
|
494
494
|
// Setup UI
|
|
495
|
-
DSP.
|
|
495
|
+
DSP.listenSensors();
|
|
496
496
|
faustUI = new FaustUI({ ui: DSP.getUI(), root: faustUIRoot });
|
|
497
497
|
faustUI.paramChangeByUI = (path, value) => DSP.setParamValue(path, value);
|
|
498
498
|
DSP.setOutputParamHandler(output_handler);
|
|
@@ -520,7 +520,7 @@ const activatePolyDSP = (dsp) => {
|
|
|
520
520
|
}
|
|
521
521
|
|
|
522
522
|
// Setup UI
|
|
523
|
-
DSP.
|
|
523
|
+
DSP.listenSensors();
|
|
524
524
|
faustUI = new FaustUI({ ui: DSP.getUI(), root: faustUIRoot });
|
|
525
525
|
faustUI.paramChangeByUI = (path, value) => DSP.setParamValue(path, value);
|
|
526
526
|
DSP.setOutputParamHandler(output_handler);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
//@ts-check
|
|
2
2
|
const div = document.getElementById("log");
|
|
3
3
|
const log = (/** @type {string} */str) => div.innerHTML += str.replace("\n", "<br />") + "<br />";
|
|
4
|
-
const options = "-ftz 2";
|
|
5
4
|
|
|
6
5
|
(async () => {
|
|
7
6
|
const ctx = new AudioContext();
|
|
8
7
|
globalThis.ctx = ctx;
|
|
9
8
|
globalThis.faustModule = await faustwasm.instantiateFaustModule();
|
|
10
9
|
const post = async () => {
|
|
10
|
+
const options = "-ftz 2";
|
|
11
11
|
const {
|
|
12
12
|
instantiateFaustModule,
|
|
13
13
|
LibFaust,
|
|
@@ -28,7 +28,7 @@ const options = "-ftz 2";
|
|
|
28
28
|
const libFaust = new LibFaust(faustModule);
|
|
29
29
|
const compiler = new FaustCompiler(libFaust);
|
|
30
30
|
console.log(compiler.version());
|
|
31
|
-
await gen.compile(compiler, 'dsp', code,
|
|
31
|
+
await gen.compile(compiler, 'dsp', code, options);
|
|
32
32
|
|
|
33
33
|
console.log(await gen.createAudioWorkletProcessor());
|
|
34
34
|
const processor = await gen.createOfflineProcessor(48000, 128);
|