@grame/faustwasm 0.4.3 → 0.4.5

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grame/faustwasm",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "WebAssembly version of Faust Compiler",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -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.listenMotion();
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.listenMotion();
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, "-ftz 0");
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);