@grame/faustwasm 0.4.4 → 0.4.6

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.
Files changed (38) hide show
  1. package/COPYING.txt +520 -0
  2. package/README.md +3 -0
  3. package/assets/standalone/faust-ui/index.css +8 -0
  4. package/assets/standalone/faust-ui/index.css.map +1 -1
  5. package/assets/standalone/faust-ui/index.js +56 -30
  6. package/assets/standalone/faust-ui/index.js.map +1 -1
  7. package/assets/standalone/faustwasm/index.d.ts +18 -10
  8. package/assets/standalone/faustwasm/index.js +69 -24
  9. package/assets/standalone/faustwasm/index.js.map +2 -2
  10. package/dist/cjs/index.d.ts +18 -10
  11. package/dist/cjs/index.js +69 -24
  12. package/dist/cjs/index.js.map +2 -2
  13. package/dist/cjs-bundle/index.d.ts +18 -10
  14. package/dist/cjs-bundle/index.js +72 -27
  15. package/dist/cjs-bundle/index.js.map +2 -2
  16. package/dist/esm/index.d.ts +18 -10
  17. package/dist/esm/index.js +69 -24
  18. package/dist/esm/index.js.map +2 -2
  19. package/dist/esm-bundle/index.d.ts +18 -10
  20. package/dist/esm-bundle/index.js +72 -27
  21. package/dist/esm-bundle/index.js.map +2 -2
  22. package/libfaust-wasm/libfaust-wasm.data +0 -0
  23. package/libfaust-wasm/libfaust-wasm.js +1 -1
  24. package/libfaust-wasm/libfaust-wasm.wasm +0 -0
  25. package/node +0 -0
  26. package/package.json +4 -2
  27. package/src/FaustAudioWorkletNode.ts +13 -24
  28. package/src/FaustAudioWorkletProcessor.ts +28 -1
  29. package/src/FaustDspGenerator.ts +18 -9
  30. package/src/FaustFFTAudioWorkletProcessor.ts +27 -0
  31. package/src/instantiateFaustModule.js +82 -0
  32. package/test/faustlive-wasm/faust-ui/index.css +8 -0
  33. package/test/faustlive-wasm/faust-ui/index.css.map +1 -1
  34. package/test/faustlive-wasm/faust-ui/index.js +56 -30
  35. package/test/faustlive-wasm/faust-ui/index.js.map +1 -1
  36. package/test/faustlive-wasm/faustwasm/index.d.ts +18 -10
  37. package/test/faustlive-wasm/faustwasm/index.js +69 -24
  38. package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
@@ -440,7 +440,7 @@ const _AbstractItem = class _AbstractItem extends _AbstractComponent__WEBPACK_IM
440
440
  const fromX = prevX - rect.left;
441
441
  const fromY = prevY - rect.top;
442
442
  const prevValue = this.state.value;
443
- this.handlePointerDown({ x: fromX, y: fromY, originalEvent: e });
443
+ this.handleMouseOrTouchDown({ pointerId: -1, x: fromX, y: fromY, originalEvent: e });
444
444
  const handleTouchMove = (e2) => {
445
445
  e2.preventDefault();
446
446
  const clientX = e2.changedTouches[0].clientX;
@@ -451,13 +451,13 @@ const _AbstractItem = class _AbstractItem extends _AbstractComponent__WEBPACK_IM
451
451
  prevY = clientY;
452
452
  const x = clientX - rect.left;
453
453
  const y = clientY - rect.top;
454
- this.handlePointerDrag({ prevValue, x, y, fromX, fromY, movementX, movementY, originalEvent: e2 });
454
+ this.handleMouseOrTouchMove({ pointerId: -1, prevValue, x, y, fromX, fromY, movementX, movementY, originalEvent: e2 });
455
455
  };
456
456
  const handleTouchEnd = (e2) => {
457
457
  e2.preventDefault();
458
458
  const x = e2.changedTouches[0].clientX - rect.left;
459
459
  const y = e2.changedTouches[0].clientY - rect.top;
460
- this.handlePointerUp({ x, y, originalEvent: e2 });
460
+ this.handleMouseOrTouchUp({ pointerId: -1, x, y, originalEvent: e2 });
461
461
  document.removeEventListener("touchmove", handleTouchMove);
462
462
  document.removeEventListener("touchend", handleTouchEnd);
463
463
  };
@@ -475,18 +475,18 @@ const _AbstractItem = class _AbstractItem extends _AbstractComponent__WEBPACK_IM
475
475
  const fromX = e.clientX - rect.left;
476
476
  const fromY = e.clientY - rect.top;
477
477
  const prevValue = this.state.value;
478
- this.handlePointerDown({ x: fromX, y: fromY, originalEvent: e });
478
+ this.handleMouseOrTouchDown({ pointerId: -1, x: fromX, y: fromY, originalEvent: e });
479
479
  const handleMouseMove = (e2) => {
480
480
  e2.preventDefault();
481
481
  const x = e2.clientX - rect.left;
482
482
  const y = e2.clientY - rect.top;
483
- this.handlePointerDrag({ prevValue, x, y, fromX, fromY, movementX: e2.movementX, movementY: e2.movementY, originalEvent: e2 });
483
+ this.handleMouseOrTouchMove({ pointerId: -1, prevValue, x, y, fromX, fromY, movementX: e2.movementX, movementY: e2.movementY, originalEvent: e2 });
484
484
  };
485
485
  const handleMouseUp = (e2) => {
486
486
  e2.preventDefault();
487
487
  const x = e2.clientX - rect.left;
488
488
  const y = e2.clientY - rect.top;
489
- this.handlePointerUp({ x, y, originalEvent: e2 });
489
+ this.handleMouseOrTouchUp({ pointerId: -1, x, y, originalEvent: e2 });
490
490
  document.removeEventListener("mousemove", handleMouseMove);
491
491
  document.removeEventListener("mouseup", handleMouseUp);
492
492
  };
@@ -500,10 +500,38 @@ const _AbstractItem = class _AbstractItem extends _AbstractComponent__WEBPACK_IM
500
500
  this.handleContextMenu = (e) => {
501
501
  };
502
502
  this.handlePointerDown = (e) => {
503
+ e.preventDefault();
504
+ e.currentTarget.focus();
505
+ const { pointerId } = e;
506
+ const rect = e.currentTarget.getBoundingClientRect();
507
+ const fromX = e.clientX - rect.left;
508
+ const fromY = e.clientY - rect.top;
509
+ const prevValue = this.state.value;
510
+ this.handleMouseOrTouchDown({ pointerId, x: fromX, y: fromY, originalEvent: e });
511
+ const handlePointerMove = (e2) => {
512
+ if (e2.pointerId !== pointerId) return;
513
+ e2.preventDefault();
514
+ const x = e2.clientX - rect.left;
515
+ const y = e2.clientY - rect.top;
516
+ this.handleMouseOrTouchMove({ pointerId, prevValue, x, y, fromX, fromY, movementX: e2.movementX, movementY: e2.movementY, originalEvent: e2 });
517
+ };
518
+ const handlePointerUp = (e2) => {
519
+ if (e2.pointerId !== pointerId) return;
520
+ e2.preventDefault();
521
+ const x = e2.clientX - rect.left;
522
+ const y = e2.clientY - rect.top;
523
+ this.handleMouseOrTouchUp({ pointerId, x, y, originalEvent: e2 });
524
+ document.removeEventListener("pointermove", handlePointerMove);
525
+ document.removeEventListener("pointerup", handlePointerUp);
526
+ };
527
+ document.addEventListener("pointermove", handlePointerMove);
528
+ document.addEventListener("pointerup", handlePointerUp);
529
+ };
530
+ this.handleMouseOrTouchDown = (e) => {
503
531
  };
504
- this.handlePointerDrag = (e) => {
532
+ this.handleMouseOrTouchMove = (e) => {
505
533
  };
506
- this.handlePointerUp = (e) => {
534
+ this.handleMouseOrTouchUp = (e) => {
507
535
  };
508
536
  this.handleFocusIn = (e) => this.setState({ focus: true });
509
537
  this.handleFocusOut = (e) => this.setState({ focus: false });
@@ -729,10 +757,13 @@ class Button extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
729
757
  this.btn.style.fontFamily = `${fontname}, sans-serif`;
730
758
  this.btn.style.fontStyle = fontface;
731
759
  };
732
- this.handlePointerDown = () => {
760
+ this.handleContextMenu = (e) => {
761
+ e.preventDefault();
762
+ };
763
+ this.handleMouseOrTouchDown = () => {
733
764
  this.setValue(1);
734
765
  };
735
- this.handlePointerUp = () => {
766
+ this.handleMouseOrTouchUp = () => {
736
767
  this.setValue(0);
737
768
  };
738
769
  }
@@ -767,8 +798,8 @@ class Button extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
767
798
  }
768
799
  componentDidMount() {
769
800
  super.componentDidMount();
770
- this.btn.addEventListener("mousedown", this.handleMouseDown);
771
- this.btn.addEventListener("touchstart", this.handleTouchStart);
801
+ this.btn.addEventListener("pointerdown", this.handlePointerDown);
802
+ this.btn.addEventListener("contextmenu", this.handleContextMenu);
772
803
  this.on("style", () => this.schedule(this.setStyle));
773
804
  const labelChange = () => this.span.innerText = this.state.label;
774
805
  this.on("label", () => this.schedule(labelChange));
@@ -798,10 +829,10 @@ class Checkbox extends _Button__WEBPACK_IMPORTED_MODULE_0__["default"] {
798
829
  constructor() {
799
830
  super(...arguments);
800
831
  this.className = "checkbox";
801
- this.handlePointerDown = () => {
832
+ this.handleMouseOrTouchDown = () => {
802
833
  this.setValue(1 - this.state.value);
803
834
  };
804
- this.handlePointerUp = () => {
835
+ this.handleMouseOrTouchUp = () => {
805
836
  };
806
837
  }
807
838
  }
@@ -1315,7 +1346,7 @@ class Knob extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
1315
1346
  this.handleChange = (e) => {
1316
1347
  const value = parseFloat(e.currentTarget.value);
1317
1348
  if (isFinite(value)) {
1318
- const changed = this.setValue(+this.inputNumber.value);
1349
+ const changed = this.setValue(+value);
1319
1350
  if (changed) return;
1320
1351
  }
1321
1352
  this.input.value = this.inputNumber.value + (this.state.unit || "");
@@ -1369,7 +1400,7 @@ class Knob extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
1369
1400
  ctx.lineTo(valuePosX, valuePosY);
1370
1401
  ctx.stroke();
1371
1402
  };
1372
- this.handlePointerDrag = (e) => {
1403
+ this.handleMouseOrTouchMove = (e) => {
1373
1404
  const newValue = this.getValueFromDelta(e);
1374
1405
  if (newValue !== this.state.value) this.setValue(newValue);
1375
1406
  };
@@ -1413,8 +1444,7 @@ class Knob extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
1413
1444
  componentDidMount() {
1414
1445
  super.componentDidMount();
1415
1446
  this.input.addEventListener("change", this.handleChange);
1416
- this.canvas.addEventListener("mousedown", this.handleMouseDown);
1417
- this.canvas.addEventListener("touchstart", this.handleTouchStart, { passive: false });
1447
+ this.canvas.addEventListener("pointerdown", this.handlePointerDown);
1418
1448
  this.on("style", () => {
1419
1449
  this.schedule(this.setStyle);
1420
1450
  this.schedule(this.paint);
@@ -1590,8 +1620,7 @@ class Led extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
1590
1620
  }
1591
1621
  componentDidMount() {
1592
1622
  super.componentDidMount();
1593
- this.canvas.addEventListener("mousedown", this.handleMouseDown);
1594
- this.canvas.addEventListener("touchstart", this.handleTouchStart, { passive: false });
1623
+ this.canvas.addEventListener("pointerdown", this.handlePointerDown);
1595
1624
  this.on("style", () => this.schedule(this.setStyle));
1596
1625
  this.on("label", () => this.schedule(this.paintLabel));
1597
1626
  this.on("value", () => this.schedule(this.paint));
@@ -2067,9 +2096,9 @@ class Soundfile extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
2067
2096
  this.btn.style.fontFamily = `${fontname}, sans-serif`;
2068
2097
  this.btn.style.fontStyle = fontface;
2069
2098
  };
2070
- this.handlePointerDown = () => {
2099
+ this.handleMouseOrTouchDown = () => {
2071
2100
  };
2072
- this.handlePointerUp = () => {
2101
+ this.handleMouseOrTouchUp = () => {
2073
2102
  };
2074
2103
  }
2075
2104
  static get defaultProps() {
@@ -2103,8 +2132,7 @@ class Soundfile extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
2103
2132
  }
2104
2133
  componentDidMount() {
2105
2134
  super.componentDidMount();
2106
- this.btn.addEventListener("mousedown", this.handleMouseDown);
2107
- this.btn.addEventListener("touchstart", this.handleTouchStart);
2135
+ this.btn.addEventListener("pointerdown", this.handlePointerDown);
2108
2136
  this.on("style", () => this.schedule(this.setStyle));
2109
2137
  const labelChange = () => this.span.innerText = this.state.label;
2110
2138
  this.on("label", () => this.schedule(labelChange));
@@ -2273,8 +2301,7 @@ class VBargraph extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
2273
2301
  }
2274
2302
  componentDidMount() {
2275
2303
  super.componentDidMount();
2276
- this.canvas.addEventListener("mousedown", this.handleMouseDown);
2277
- this.canvas.addEventListener("touchstart", this.handleTouchStart, { passive: false });
2304
+ this.canvas.addEventListener("pointerdown", this.handlePointerDown);
2278
2305
  this.on("style", () => {
2279
2306
  this.schedule(this.setStyle);
2280
2307
  this.schedule(this.paint);
@@ -2388,13 +2415,13 @@ class VSlider extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
2388
2415
  ctx.fillStyle = slidercolor;
2389
2416
  (0,_utils__WEBPACK_IMPORTED_MODULE_1__.fillRoundedRect)(ctx, left - drawWidth, top + drawHeight * (1 - distance) - drawWidth, drawWidth * 3, drawWidth * 2, borderRadius);
2390
2417
  };
2391
- this.handlePointerDown = (e) => {
2418
+ this.handleMouseOrTouchDown = (e) => {
2392
2419
  const { value } = this.state;
2393
2420
  if (e.x < this.interactionRect[0] || e.x > this.interactionRect[0] + this.interactionRect[2] || e.y < this.interactionRect[1] || e.y > this.interactionRect[1] + this.interactionRect[3]) return;
2394
2421
  const newValue = this.getValueFromPos(e);
2395
2422
  if (newValue !== value) this.setValue(this.getValueFromPos(e));
2396
2423
  };
2397
- this.handlePointerDrag = (e) => {
2424
+ this.handleMouseOrTouchMove = (e) => {
2398
2425
  const newValue = this.getValueFromPos(e);
2399
2426
  if (newValue !== this.state.value) this.setValue(newValue);
2400
2427
  };
@@ -2442,8 +2469,7 @@ class VSlider extends _AbstractItem__WEBPACK_IMPORTED_MODULE_0__["default"] {
2442
2469
  componentDidMount() {
2443
2470
  super.componentDidMount();
2444
2471
  this.input.addEventListener("change", this.handleChange);
2445
- this.canvas.addEventListener("mousedown", this.handleMouseDown);
2446
- this.canvas.addEventListener("touchstart", this.handleTouchStart, { passive: false });
2472
+ this.canvas.addEventListener("pointerdown", this.handlePointerDown);
2447
2473
  this.on("style", () => {
2448
2474
  this.schedule(this.setStyle);
2449
2475
  this.schedule(this.paint);