@grame/faustwasm 0.13.7 → 0.14.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.
Files changed (40) hide show
  1. package/assets/standalone/faustwasm/index.d.ts +3 -0
  2. package/assets/standalone/faustwasm/index.js +29 -6
  3. package/assets/standalone/faustwasm/index.js.map +2 -2
  4. package/dist/cjs/index.d.ts +3 -0
  5. package/dist/cjs/index.js +29 -6
  6. package/dist/cjs/index.js.map +2 -2
  7. package/dist/cjs-bundle/index.d.ts +3 -0
  8. package/dist/cjs-bundle/index.js +29 -6
  9. package/dist/cjs-bundle/index.js.map +2 -2
  10. package/dist/esm/index.d.ts +3 -0
  11. package/dist/esm/index.js +29 -6
  12. package/dist/esm/index.js.map +2 -2
  13. package/dist/esm-bundle/index.d.ts +3 -0
  14. package/dist/esm-bundle/index.js +29 -6
  15. package/dist/esm-bundle/index.js.map +2 -2
  16. package/package.json +1 -1
  17. package/src/FaustAudioWorkletNode.ts +14 -4
  18. package/src/FaustWebAudioDsp.ts +16 -2
  19. package/src/types.ts +2 -0
  20. package/test/faustlive-wasm/faustwasm/index.d.ts +3 -0
  21. package/test/faustlive-wasm/faustwasm/index.js +29 -6
  22. package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
  23. package/test/node/test-param-aliases.js +73 -0
  24. package/test/organ/create-node.js +252 -0
  25. package/test/organ/dsp-meta.json +131 -0
  26. package/test/organ/dsp-module.wasm +0 -0
  27. package/test/organ/faust-pwa.js +344 -0
  28. package/test/organ/faust-ui/index.css +442 -0
  29. package/test/organ/faust-ui/index.css.map +1 -0
  30. package/test/organ/faust-ui/index.d.ts +1 -0
  31. package/test/organ/faust-ui/index.js +3756 -0
  32. package/test/organ/faust-ui/index.js.map +1 -0
  33. package/test/organ/faustwasm/index.d.ts +1730 -0
  34. package/test/organ/faustwasm/index.js +5969 -0
  35. package/test/organ/faustwasm/index.js.map +7 -0
  36. package/test/organ/icon.png +0 -0
  37. package/test/organ/index.html +76 -0
  38. package/test/organ/index.js +69 -0
  39. package/test/organ/manifest.json +17 -0
  40. package/test/organ/service-worker.js +165 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grame/faustwasm",
3
- "version": "0.13.7",
3
+ "version": "0.14.0",
4
4
  "description": "WebAssembly version of Faust Compiler",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -32,6 +32,7 @@ export class FaustAudioWorkletNode<
32
32
  protected fUICallback: UIHandler;
33
33
  protected fDescriptor: FaustUIInputItem[];
34
34
  protected fCommunicator: FaustAudioWorkletNodeCommunicator;
35
+ protected fParamAliases: Record<string, string>;
35
36
  #hasAccInput = false;
36
37
  #hasGyrInput = false;
37
38
 
@@ -62,6 +63,7 @@ export class FaustAudioWorkletNode<
62
63
  this.fComputeHandler = null;
63
64
  this.fPlotHandler = null;
64
65
  this.fDescriptor = [];
66
+ this.fParamAliases = {};
65
67
 
66
68
  // Parse UI
67
69
  this.fInputsItems = [];
@@ -76,6 +78,13 @@ export class FaustAudioWorkletNode<
76
78
  // Keep inputs adresses
77
79
  this.fInputsItems.push(item.address);
78
80
  this.fDescriptor.push(item);
81
+ const registerAlias = (alias: string) => {
82
+ if (!this.fParamAliases[alias]) {
83
+ this.fParamAliases[alias] = item.address;
84
+ }
85
+ };
86
+ registerAlias(item.shortname);
87
+ registerAlias(item.label);
79
88
  if (!item.meta) return;
80
89
  item.meta.forEach((meta) => {
81
90
  const { midi, acc, gyr } = meta;
@@ -289,15 +298,16 @@ export class FaustAudioWorkletNode<
289
298
  }
290
299
 
291
300
  setParamValue(path: string, value: number) {
292
- const e = { type: 'param', data: { path, value } };
293
- this.port.postMessage(e);
301
+ const resolved = this.fParamAliases[path] || path;
302
+ this.port.postMessage({ type: 'param', data: { path: resolved, value } });
294
303
  // Set value on AudioParam (but this is not used on Processor side for now)
295
- const param = this.parameters.get(path);
304
+ const param = this.parameters.get(resolved);
296
305
  if (param) param.setValueAtTime(value, this.context.currentTime);
297
306
  }
298
307
  getParamValue(path: string) {
299
308
  // Get value of AudioParam
300
- const param = this.parameters.get(path);
309
+ const resolved = this.fParamAliases[path] || path;
310
+ const param = this.parameters.get(resolved);
301
311
  return param ? param.value : 0;
302
312
  }
303
313
 
@@ -779,9 +779,16 @@ export class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
779
779
  protected fPathTable: { [address: string]: number } = {};
780
780
  protected fUICallback: UIHandler = (item: FaustUIItem) => {
781
781
  if (item.type === 'hbargraph' || item.type === 'vbargraph') {
782
+ const registerPath = (alias: string) => {
783
+ if (this.fPathTable[alias] === undefined) {
784
+ this.fPathTable[alias] = item.index;
785
+ }
786
+ };
782
787
  // Keep bargraph adresses
783
788
  this.fOutputsItems.push(item.address);
784
- this.fPathTable[item.address] = item.index;
789
+ registerPath(item.address);
790
+ registerPath(item.shortname);
791
+ registerPath(item.label);
785
792
  } else if (
786
793
  item.type === 'vslider' ||
787
794
  item.type === 'hslider' ||
@@ -789,9 +796,16 @@ export class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
789
796
  item.type === 'checkbox' ||
790
797
  item.type === 'nentry'
791
798
  ) {
799
+ const registerPath = (alias: string) => {
800
+ if (this.fPathTable[alias] === undefined) {
801
+ this.fPathTable[alias] = item.index;
802
+ }
803
+ };
792
804
  // Keep inputs adresses
793
805
  this.fInputsItems.push(item.address);
794
- this.fPathTable[item.address] = item.index;
806
+ registerPath(item.address);
807
+ registerPath(item.shortname);
808
+ registerPath(item.label);
795
809
  this.fDescriptor.push(item);
796
810
  if (!item.meta) return;
797
811
  item.meta.forEach((meta) => {
package/src/types.ts CHANGED
@@ -167,6 +167,7 @@ export interface FaustUIInputItem {
167
167
  type: FaustUIInputType;
168
168
  label: string;
169
169
  address: string;
170
+ shortname: string;
170
171
  url: string;
171
172
  index: number;
172
173
  init?: number;
@@ -179,6 +180,7 @@ export interface FaustUIOutputItem {
179
180
  type: FaustUIOutputType;
180
181
  label: string;
181
182
  address: string;
183
+ shortname: string;
182
184
  index: number;
183
185
  min?: number;
184
186
  max?: number;
@@ -132,6 +132,7 @@ export interface FaustUIInputItem {
132
132
  type: FaustUIInputType;
133
133
  label: string;
134
134
  address: string;
135
+ shortname: string;
135
136
  url: string;
136
137
  index: number;
137
138
  init?: number;
@@ -144,6 +145,7 @@ export interface FaustUIOutputItem {
144
145
  type: FaustUIOutputType;
145
146
  label: string;
146
147
  address: string;
148
+ shortname: string;
147
149
  index: number;
148
150
  min?: number;
149
151
  max?: number;
@@ -1394,6 +1396,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
1394
1396
  protected fUICallback: UIHandler;
1395
1397
  protected fDescriptor: FaustUIInputItem[];
1396
1398
  protected fCommunicator: FaustAudioWorkletNodeCommunicator;
1399
+ protected fParamAliases: Record<string, string>;
1397
1400
  constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial<FaustAudioWorkletNodeOptions<Poly>>);
1398
1401
  protected handleMessageAux: (e: MessageEvent) => void;
1399
1402
  private handleDeviceMotion;
@@ -2526,11 +2526,25 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
2526
2526
  this.fPathTable = {};
2527
2527
  this.fUICallback = (item) => {
2528
2528
  if (item.type === "hbargraph" || item.type === "vbargraph") {
2529
+ const registerPath = (alias) => {
2530
+ if (this.fPathTable[alias] === void 0) {
2531
+ this.fPathTable[alias] = item.index;
2532
+ }
2533
+ };
2529
2534
  this.fOutputsItems.push(item.address);
2530
- this.fPathTable[item.address] = item.index;
2535
+ registerPath(item.address);
2536
+ registerPath(item.shortname);
2537
+ registerPath(item.label);
2531
2538
  } else if (item.type === "vslider" || item.type === "hslider" || item.type === "button" || item.type === "checkbox" || item.type === "nentry") {
2539
+ const registerPath = (alias) => {
2540
+ if (this.fPathTable[alias] === void 0) {
2541
+ this.fPathTable[alias] = item.index;
2542
+ }
2543
+ };
2532
2544
  this.fInputsItems.push(item.address);
2533
- this.fPathTable[item.address] = item.index;
2545
+ registerPath(item.address);
2546
+ registerPath(item.shortname);
2547
+ registerPath(item.label);
2534
2548
  this.fDescriptor.push(item);
2535
2549
  if (!item.meta) return;
2536
2550
  item.meta.forEach((meta) => {
@@ -4735,11 +4749,19 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
4735
4749
  this.fComputeHandler = null;
4736
4750
  this.fPlotHandler = null;
4737
4751
  this.fDescriptor = [];
4752
+ this.fParamAliases = {};
4738
4753
  this.fInputsItems = [];
4739
4754
  this.fUICallback = (item) => {
4740
4755
  if (item.type === "vslider" || item.type === "hslider" || item.type === "button" || item.type === "checkbox" || item.type === "nentry") {
4741
4756
  this.fInputsItems.push(item.address);
4742
4757
  this.fDescriptor.push(item);
4758
+ const registerAlias = (alias) => {
4759
+ if (!this.fParamAliases[alias]) {
4760
+ this.fParamAliases[alias] = item.address;
4761
+ }
4762
+ };
4763
+ registerAlias(item.shortname);
4764
+ registerAlias(item.label);
4743
4765
  if (!item.meta) return;
4744
4766
  item.meta.forEach((meta) => {
4745
4767
  const { midi, acc, gyr } = meta;
@@ -4894,13 +4916,14 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
4894
4916
  });
4895
4917
  }
4896
4918
  setParamValue(path, value) {
4897
- const e = { type: "param", data: { path, value } };
4898
- this.port.postMessage(e);
4899
- const param = this.parameters.get(path);
4919
+ const resolved = this.fParamAliases[path] || path;
4920
+ this.port.postMessage({ type: "param", data: { path: resolved, value } });
4921
+ const param = this.parameters.get(resolved);
4900
4922
  if (param) param.setValueAtTime(value, this.context.currentTime);
4901
4923
  }
4902
4924
  getParamValue(path) {
4903
- const param = this.parameters.get(path);
4925
+ const resolved = this.fParamAliases[path] || path;
4926
+ const param = this.parameters.get(resolved);
4904
4927
  return param ? param.value : 0;
4905
4928
  }
4906
4929
  getParams() {