@grame/faustwasm 0.12.0 → 0.12.2

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 +1 -1
  2. package/assets/standalone/faustwasm/index.js +201 -335
  3. package/assets/standalone/faustwasm/index.js.map +2 -2
  4. package/dist/cjs/index.d.ts +1 -1
  5. package/dist/cjs/index.js +203 -338
  6. package/dist/cjs/index.js.map +2 -2
  7. package/dist/cjs-bundle/index.d.ts +1 -1
  8. package/dist/cjs-bundle/index.js +385 -687
  9. package/dist/cjs-bundle/index.js.map +2 -2
  10. package/dist/esm/index.d.ts +1 -1
  11. package/dist/esm/index.js +201 -335
  12. package/dist/esm/index.js.map +2 -2
  13. package/dist/esm-bundle/index.d.ts +1 -1
  14. package/dist/esm-bundle/index.js +385 -687
  15. package/dist/esm-bundle/index.js.map +2 -2
  16. package/package.json +2 -3
  17. package/src/FaustDspGenerator.ts +2 -1
  18. package/src/FaustWebAudioDsp.ts +2 -2
  19. package/src/SoundfileReader.ts +3 -3
  20. package/src/types.ts +1 -1
  21. package/test/faustlive-wasm/faustwasm/index.d.ts +1 -1
  22. package/test/faustlive-wasm/faustwasm/index.js +201 -335
  23. package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
  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 +1705 -0
  34. package/test/organ/faustwasm/index.js +4773 -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/dist/cjs/index.js CHANGED
@@ -5,11 +5,13 @@
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
8
11
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
12
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
13
  }) : x)(function(x) {
11
- if (typeof require !== "undefined")
12
- return require.apply(this, arguments);
14
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
15
  throw Error('Dynamic require of "' + x + '" is not supported');
14
16
  });
15
17
  var __copyProps = (to, from, except, desc) => {
@@ -28,24 +30,10 @@
28
30
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
31
  mod
30
32
  ));
31
- var __accessCheck = (obj, member, msg) => {
32
- if (!member.has(obj))
33
- throw TypeError("Cannot " + msg);
34
- };
35
- var __privateGet = (obj, member, getter) => {
36
- __accessCheck(obj, member, "read from private field");
37
- return getter ? getter.call(obj) : member.get(obj);
38
- };
39
- var __privateAdd = (obj, member, value) => {
40
- if (member.has(obj))
41
- throw TypeError("Cannot add the same private member more than once");
42
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
43
- };
44
- var __privateSet = (obj, member, value, setter) => {
45
- __accessCheck(obj, member, "write to private field");
46
- setter ? setter.call(obj, value) : member.set(obj, value);
47
- return value;
48
- };
33
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
34
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
35
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
36
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
49
37
 
50
38
  // src/instantiateFaustModuleFromFile.ts
51
39
  var instantiateFaustModuleFromFile = async (jsFile, dataFile = jsFile.replace(/c?js$/, "data"), wasmFile = jsFile.replace(/c?js$/, "wasm")) => {
@@ -97,8 +85,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
97
85
  const faustModule = await FaustModule({
98
86
  wasmBinary,
99
87
  getPreloadedPackage: (remotePackageName, remotePackageSize) => {
100
- if (remotePackageName === "libfaust-wasm.data")
101
- return dataBinary;
88
+ if (remotePackageName === "libfaust-wasm.data") return dataBinary;
102
89
  return new ArrayBuffer(0);
103
90
  }
104
91
  });
@@ -124,8 +111,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
124
111
  const analysePolyParameters = (item) => {
125
112
  const polyKeywords = ["/gate", "/freq", "/gain", "/key", "/vel", "/velocity"];
126
113
  const isPolyReserved = "address" in item && !!polyKeywords.find((k) => item.address.endsWith(k));
127
- if (poly && isPolyReserved)
128
- return null;
114
+ if (poly && isPolyReserved) return null;
129
115
  if (item.type === "vslider" || item.type === "hslider" || item.type === "nentry") {
130
116
  return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };
131
117
  } else if (item.type === "button" || item.type === "checkbox") {
@@ -143,37 +129,30 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
143
129
  this.paramValuesCache[pd.name] = pd.defaultValue || 0;
144
130
  });
145
131
  const { moduleId, instanceId } = options.processorOptions;
146
- if (!moduleId || !instanceId)
147
- return;
132
+ if (!moduleId || !instanceId) return;
148
133
  this.wamInfo = { moduleId, instanceId };
149
134
  }
150
135
  static get parameterDescriptors() {
151
136
  const params = [];
152
137
  const callback = (item) => {
153
138
  const param = analysePolyParameters(item);
154
- if (param)
155
- params.push(param);
139
+ if (param) params.push(param);
156
140
  };
157
141
  FaustBaseWebAudioDsp2.parseUI(dspMeta.ui, callback);
158
- if (effectMeta)
159
- FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, callback);
142
+ if (effectMeta) FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, callback);
160
143
  return params;
161
144
  }
162
145
  setupWamEventHandler() {
163
146
  var _a;
164
- if (!this.wamInfo)
165
- return;
147
+ if (!this.wamInfo) return;
166
148
  const { moduleId, instanceId } = this.wamInfo;
167
149
  const { webAudioModules } = globalThis;
168
150
  const ModuleScope = webAudioModules.getModuleScope(moduleId);
169
151
  const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId];
170
- if (!paramMgrProcessor)
171
- return;
172
- if (paramMgrProcessor.handleEvent)
173
- return;
152
+ if (!paramMgrProcessor) return;
153
+ if (paramMgrProcessor.handleEvent) return;
174
154
  paramMgrProcessor.handleEvent = (event) => {
175
- if (event.type === "wam-midi")
176
- this.midiMessage(event.data.bytes);
155
+ if (event.type === "wam-midi") this.midiMessage(event.data.bytes);
177
156
  };
178
157
  }
179
158
  process(inputs, outputs, parameters) {
@@ -203,10 +182,12 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
203
182
  handleMessageAux(e) {
204
183
  const msg = e.data;
205
184
  switch (msg.type) {
185
+ // Generic MIDI message
206
186
  case "midi": {
207
187
  this.midiMessage(msg.data);
208
188
  break;
209
189
  }
190
+ // Typed MIDI message
210
191
  case "ctrlChange": {
211
192
  this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);
212
193
  break;
@@ -223,10 +204,12 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
223
204
  this.keyOff(msg.data[0], msg.data[1], msg.data[2]);
224
205
  break;
225
206
  }
207
+ // Generic data message
226
208
  case "param": {
227
209
  this.setParamValue(msg.data.path, msg.data.value);
228
210
  break;
229
211
  }
212
+ // Plot handler set on demand
230
213
  case "setPlotHandler": {
231
214
  if (msg.data) {
232
215
  this.fDSPCode.setPlotHandler((output, index, events) => this.port.postMessage({ type: "plot", value: output, index, events }));
@@ -330,12 +313,9 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
330
313
  const channel = data[0] & 15;
331
314
  const data1 = data[1];
332
315
  const data2 = data[2];
333
- if (cmd === 8 || cmd === 9 && data2 === 0)
334
- this.keyOff(channel, data1, data2);
335
- else if (cmd === 9)
336
- this.keyOn(channel, data1, data2);
337
- else
338
- super.midiMessage(data);
316
+ if (cmd === 8 || cmd === 9 && data2 === 0) this.keyOff(channel, data1, data2);
317
+ else if (cmd === 9) this.keyOn(channel, data1, data2);
318
+ else super.midiMessage(data);
339
319
  }
340
320
  // Public API
341
321
  keyOn(channel, pitch, velocity) {
@@ -401,10 +381,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
401
381
  while (spilled < spillLength) {
402
382
  const $spillLength = Math.min(spillLength - spilled, toLength - $to, fromLength - $from);
403
383
  const $fromEnd = $from + $spillLength;
404
- if ($from === 0 && $fromEnd === fromLength)
405
- to.set(from, $to);
406
- else
407
- to.set(from.subarray($from, $fromEnd), $to);
384
+ if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);
385
+ else to.set(from.subarray($from, $fromEnd), $to);
408
386
  $to = ($to + $spillLength) % toLength;
409
387
  $from = $fromEnd % fromLength;
410
388
  spilled += $spillLength;
@@ -413,8 +391,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
413
391
  };
414
392
  const analyseParameters = (item) => {
415
393
  const isFFTReserved = "address" in item && !!fftParamKeywords.find((k) => item.address.endsWith(k));
416
- if (isFFTReserved)
417
- return null;
394
+ if (isFFTReserved) return null;
418
395
  if (item.type === "vslider" || item.type === "hslider" || item.type === "nentry") {
419
396
  return { name: item.address, defaultValue: item.init || 0, minValue: item.min || 0, maxValue: item.max || 0 };
420
397
  } else if (item.type === "button" || item.type === "checkbox") {
@@ -455,23 +432,26 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
455
432
  var _a, _b, _c;
456
433
  const msg = e.data;
457
434
  switch (msg.type) {
435
+ // Generic MIDI message
458
436
  case "midi":
459
437
  this.midiMessage(msg.data);
460
438
  break;
439
+ // Typed MIDI message
461
440
  case "ctrlChange":
462
441
  this.ctrlChange(msg.data[0], msg.data[1], msg.data[2]);
463
442
  break;
464
443
  case "pitchWheel":
465
444
  this.pitchWheel(msg.data[0], msg.data[1]);
466
445
  break;
446
+ // Generic data message
467
447
  case "param":
468
448
  this.setParamValue(msg.data.path, msg.data.value);
469
449
  break;
450
+ // Plot handler set on demand
470
451
  case "setPlotHandler": {
471
452
  if (msg.data) {
472
453
  this.fPlotHandler = (output, index, events) => {
473
- if (events)
474
- this.fCachedEvents.push(...events);
454
+ if (events) this.fCachedEvents.push(...events);
475
455
  };
476
456
  } else {
477
457
  this.fPlotHandler = null;
@@ -513,8 +493,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
513
493
  this.soundfiles = factory.soundfiles;
514
494
  this.initFFT();
515
495
  const { moduleId, instanceId } = options.processorOptions;
516
- if (!moduleId || !instanceId)
517
- return;
496
+ if (!moduleId || !instanceId) return;
518
497
  this.wamInfo = { moduleId, instanceId };
519
498
  }
520
499
  get fftProcessorBufferSize() {
@@ -529,8 +508,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
529
508
  const params = [];
530
509
  const callback = (item) => {
531
510
  const param = analyseParameters(item);
532
- if (param)
533
- params.push(param);
511
+ if (param) params.push(param);
534
512
  };
535
513
  FaustBaseWebAudioDsp2.parseUI(dspMeta.ui, callback);
536
514
  return [
@@ -563,19 +541,15 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
563
541
  }
564
542
  setupWamEventHandler() {
565
543
  var _a;
566
- if (!this.wamInfo)
567
- return;
544
+ if (!this.wamInfo) return;
568
545
  const { moduleId, instanceId } = this.wamInfo;
569
546
  const { webAudioModules } = globalThis;
570
547
  const ModuleScope = webAudioModules.getModuleScope(moduleId);
571
548
  const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId];
572
- if (!paramMgrProcessor)
573
- return;
574
- if (paramMgrProcessor.handleEvent)
575
- return;
549
+ if (!paramMgrProcessor) return;
550
+ if (paramMgrProcessor.handleEvent) return;
576
551
  paramMgrProcessor.handleEvent = (event) => {
577
- if (event.type === "wam-midi")
578
- this.midiMessage(event.data.bytes);
552
+ if (event.type === "wam-midi") this.midiMessage(event.data.bytes);
579
553
  };
580
554
  }
581
555
  processFFT() {
@@ -593,10 +567,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
593
567
  fftToSignal(ffted, inputs[i * 3], inputs[i * 3 + 1], inputs[i * 3 + 2]);
594
568
  }
595
569
  for (let i = this.fftInput.length * 3; i < inputs.length; i++) {
596
- if (i % 3 === 2)
597
- inputs[i].forEach((v, j) => inputs[i][j] = j);
598
- else
599
- inputs[i].fill(0);
570
+ if (i % 3 === 2) inputs[i].forEach((v, j) => inputs[i][j] = j);
571
+ else inputs[i].fill(0);
600
572
  }
601
573
  }, (outputs) => {
602
574
  fftProcessorOutputs = outputs;
@@ -621,14 +593,12 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
621
593
  for (let j = 0; j < iffted.length - this.fftHopSize; j++) {
622
594
  $ = mod(this.$outputWrite + j, this.fftBufferSize);
623
595
  this.fftOutput[i][$] += iffted[j];
624
- if (i === 0)
625
- this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;
596
+ if (i === 0) this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;
626
597
  }
627
598
  for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {
628
599
  $ = mod(this.$outputWrite + j, this.fftBufferSize);
629
600
  this.fftOutput[i][$] = iffted[j];
630
- if (i === 0)
631
- this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;
601
+ if (i === 0) this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;
632
602
  }
633
603
  }
634
604
  this.$outputWrite += this.fftHopSize;
@@ -636,10 +606,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
636
606
  }
637
607
  }
638
608
  process(inputs, outputs, parameters) {
639
- if (this.destroyed)
640
- return false;
641
- if (!this.FFT)
642
- return true;
609
+ if (this.destroyed) return false;
610
+ if (!this.FFT) return true;
643
611
  const input = inputs[0];
644
612
  const output = outputs[0];
645
613
  const inputChannels = (input == null ? void 0 : input.length) || 0;
@@ -647,11 +615,9 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
647
615
  const bufferSize = (input == null ? void 0 : input.length) ? Math.max(...input.map((c) => c.length)) || 128 : 128;
648
616
  this.noIFFT = !!parameters.noIFFT[0];
649
617
  this.resetFFT(~~parameters.fftSize[0], ~~parameters.fftOverlap[0], ~~parameters.windowFunction[0], inputChannels, outputChannels, bufferSize);
650
- if (!this.fDSPCode)
651
- return true;
618
+ if (!this.fDSPCode) return true;
652
619
  for (const path in parameters) {
653
- if (!!fftParamKeywords.find((k) => `/${path}`.endsWith(k)))
654
- continue;
620
+ if (!!fftParamKeywords.find((k) => `/${path}`.endsWith(k))) continue;
655
621
  const [paramValue] = parameters[path];
656
622
  if (paramValue !== this.paramValuesCache[path]) {
657
623
  this.setParamValue(path, paramValue);
@@ -745,8 +711,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
745
711
  this.$outputWrite = 0;
746
712
  this.$outputRead = -latency;
747
713
  this.fftBufferSize = Math.max(fftSize * 2 - this.fftHopSize, bufferSize * 2);
748
- if (!fftSizeChanged && this.fftHopSizeParam)
749
- (_a = this.fDSPCode) == null ? void 0 : _a.setParamValue(this.fftHopSizeParam, this.fftHopSize);
714
+ if (!fftSizeChanged && this.fftHopSizeParam) (_a = this.fDSPCode) == null ? void 0 : _a.setParamValue(this.fftHopSizeParam, this.fftHopSize);
750
715
  }
751
716
  if (fftSizeChanged) {
752
717
  (_b = this.rfft) == null ? void 0 : _b.dispose();
@@ -758,8 +723,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
758
723
  this.windowFunction = windowFunction;
759
724
  this.window = new Float32Array(fftSize);
760
725
  this.window.fill(1);
761
- if (windowFunction)
762
- apply(this.window, windowFunction);
726
+ if (windowFunction) apply(this.window, windowFunction);
763
727
  this.windowSumSquare = new Float32Array(this.fftBufferSize);
764
728
  }
765
729
  if (this.fftInput.length > inputChannels) {
@@ -798,16 +762,13 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
798
762
  const params = this.fDSPCode.getParams();
799
763
  this.fDSPCode.start();
800
764
  for (const path in this.paramValuesCache) {
801
- if (!!fftParamKeywords.find((k) => `/${path}`.endsWith(k)))
802
- continue;
765
+ if (!!fftParamKeywords.find((k) => `/${path}`.endsWith(k))) continue;
803
766
  this.fDSPCode.setParamValue(path, this.paramValuesCache[path]);
804
767
  }
805
768
  const fftSizeParam = params.find((s) => s.endsWith("/fftSize"));
806
- if (fftSizeParam)
807
- this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);
769
+ if (fftSizeParam) this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);
808
770
  this.fftHopSizeParam = params.find((s) => s.endsWith("/fftHopSize"));
809
- if (this.fftHopSizeParam)
810
- this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);
771
+ if (this.fftHopSizeParam) this.fDSPCode.setParamValue(this.fftHopSizeParam, this.fftHopSize);
811
772
  this.fftProcessorZeros = new Float32Array(this.fftProcessorBufferSize);
812
773
  }
813
774
  destroy() {
@@ -860,8 +821,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
860
821
  }
861
822
  function __generator(thisArg, body) {
862
823
  var _ = { label: 0, sent: function() {
863
- if (t[0] & 1)
864
- throw t[1];
824
+ if (t[0] & 1) throw t[1];
865
825
  return t[1];
866
826
  }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
867
827
  return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
@@ -873,64 +833,58 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
873
833
  };
874
834
  }
875
835
  function step(op) {
876
- if (f)
877
- throw new TypeError("Generator is already executing.");
878
- while (g && (g = 0, op[0] && (_ = 0)), _)
879
- try {
880
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
881
- return t;
882
- if (y = 0, t)
883
- op = [op[0] & 2, t.value];
884
- switch (op[0]) {
885
- case 0:
886
- case 1:
836
+ if (f) throw new TypeError("Generator is already executing.");
837
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
838
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
839
+ if (y = 0, t) op = [op[0] & 2, t.value];
840
+ switch (op[0]) {
841
+ case 0:
842
+ case 1:
843
+ t = op;
844
+ break;
845
+ case 4:
846
+ _.label++;
847
+ return { value: op[1], done: false };
848
+ case 5:
849
+ _.label++;
850
+ y = op[1];
851
+ op = [0];
852
+ continue;
853
+ case 7:
854
+ op = _.ops.pop();
855
+ _.trys.pop();
856
+ continue;
857
+ default:
858
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
859
+ _ = 0;
860
+ continue;
861
+ }
862
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
863
+ _.label = op[1];
864
+ break;
865
+ }
866
+ if (op[0] === 6 && _.label < t[1]) {
867
+ _.label = t[1];
887
868
  t = op;
888
869
  break;
889
- case 4:
890
- _.label++;
891
- return { value: op[1], done: false };
892
- case 5:
893
- _.label++;
894
- y = op[1];
895
- op = [0];
896
- continue;
897
- case 7:
898
- op = _.ops.pop();
899
- _.trys.pop();
900
- continue;
901
- default:
902
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
903
- _ = 0;
904
- continue;
905
- }
906
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
907
- _.label = op[1];
908
- break;
909
- }
910
- if (op[0] === 6 && _.label < t[1]) {
911
- _.label = t[1];
912
- t = op;
913
- break;
914
- }
915
- if (t && _.label < t[2]) {
916
- _.label = t[2];
917
- _.ops.push(op);
918
- break;
919
- }
920
- if (t[2])
921
- _.ops.pop();
922
- _.trys.pop();
923
- continue;
924
- }
925
- op = body.call(thisArg, _);
926
- } catch (e) {
927
- op = [6, e];
928
- y = 0;
929
- } finally {
930
- f = t = 0;
870
+ }
871
+ if (t && _.label < t[2]) {
872
+ _.label = t[2];
873
+ _.ops.push(op);
874
+ break;
875
+ }
876
+ if (t[2]) _.ops.pop();
877
+ _.trys.pop();
878
+ continue;
931
879
  }
932
- if (op[0] & 5)
933
- throw op[1];
880
+ op = body.call(thisArg, _);
881
+ } catch (e) {
882
+ op = [6, e];
883
+ y = 0;
884
+ } finally {
885
+ f = t = 0;
886
+ }
887
+ if (op[0] & 5) throw op[1];
934
888
  return { value: op[0] ? op[1] : void 0, done: true };
935
889
  }
936
890
  }
@@ -1019,7 +973,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
1019
973
  // node_modules/@aws-crypto/sha256-js/build/module/RawSha256.js
1020
974
  var RawSha256 = (
1021
975
  /** @class */
1022
- function() {
976
+ (function() {
1023
977
  function RawSha2562() {
1024
978
  this.state = Int32Array.from(INIT);
1025
979
  this.temp = new Int32Array(64);
@@ -1111,7 +1065,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
1111
1065
  state[7] += state7;
1112
1066
  };
1113
1067
  return RawSha2562;
1114
- }()
1068
+ })()
1115
1069
  );
1116
1070
 
1117
1071
  // node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js
@@ -1144,7 +1098,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
1144
1098
  // node_modules/@aws-crypto/sha256-js/build/module/jsSha256.js
1145
1099
  var Sha256 = (
1146
1100
  /** @class */
1147
- function() {
1101
+ (function() {
1148
1102
  function Sha2562(secret) {
1149
1103
  this.secret = secret;
1150
1104
  this.hash = new RawSha256();
@@ -1198,7 +1152,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
1198
1152
  }
1199
1153
  };
1200
1154
  return Sha2562;
1201
- }()
1155
+ })()
1202
1156
  );
1203
1157
  function bufferFromSecret(secret) {
1204
1158
  var input = convertToBuffer(secret);
@@ -1346,8 +1300,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
1346
1300
  async getAsyncInternalMixerModule(isDouble = false) {
1347
1301
  const bufferKey = isDouble ? "mixer64Buffer" : "mixer32Buffer";
1348
1302
  const moduleKey = isDouble ? "mixer64Module" : "mixer32Module";
1349
- if (this[moduleKey])
1350
- return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };
1303
+ if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };
1351
1304
  const path = isDouble ? "/usr/rsrc/mixer64.wasm" : "/usr/rsrc/mixer32.wasm";
1352
1305
  const mixerBuffer = this.fs().readFile(path, { encoding: "binary" });
1353
1306
  this[bufferKey] = mixerBuffer;
@@ -1358,8 +1311,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
1358
1311
  getSyncInternalMixerModule(isDouble = false) {
1359
1312
  const bufferKey = isDouble ? "mixer64Buffer" : "mixer32Buffer";
1360
1313
  const moduleKey = isDouble ? "mixer64Module" : "mixer32Module";
1361
- if (this[moduleKey])
1362
- return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };
1314
+ if (this[moduleKey]) return { mixerBuffer: this[bufferKey], mixerModule: this[moduleKey] };
1363
1315
  const path = isDouble ? "/usr/rsrc/mixer64.wasm" : "/usr/rsrc/mixer32.wasm";
1364
1316
  const mixerBuffer = this.fs().readFile(path, { encoding: "binary" });
1365
1317
  this[bufferKey] = mixerBuffer;
@@ -1700,10 +1652,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
1700
1652
  this.fHi = Math.max(x, y);
1701
1653
  }
1702
1654
  clip(x) {
1703
- if (x < this.fLo)
1704
- return this.fLo;
1705
- if (x > this.fHi)
1706
- return this.fHi;
1655
+ if (x < this.fLo) return this.fLo;
1656
+ if (x > this.fHi) return this.fHi;
1707
1657
  return x;
1708
1658
  }
1709
1659
  };
@@ -2112,8 +2062,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2112
2062
  console.log(`fSR: ${this.fSR}`);
2113
2063
  console.log(`fOffset: ${this.fOffset}`);
2114
2064
  const HEAP32 = this.fAllocator.getInt32Array();
2115
- if (mem)
2116
- console.log(`HEAP32: ${HEAP32}`);
2065
+ if (mem) console.log(`HEAP32: ${HEAP32}`);
2117
2066
  console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);
2118
2067
  console.log(`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[this.fPtr + this.fPtrSize >> 2]}`);
2119
2068
  console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[this.fPtr + 2 * this.fPtrSize >> 2]}`);
@@ -2167,8 +2116,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2167
2116
  this.fInputsItems.push(item.address);
2168
2117
  this.fPathTable[item.address] = item.index;
2169
2118
  this.fDescriptor.push(item);
2170
- if (!item.meta)
2171
- return;
2119
+ if (!item.meta) return;
2172
2120
  item.meta.forEach((meta) => {
2173
2121
  var _a, _b, _c, _d, _e, _f;
2174
2122
  const { midi, acc, gyr } = meta;
@@ -2264,19 +2212,13 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2264
2212
  propagateAcc(accelerationIncludingGravity, invert = false) {
2265
2213
  const { x, y, z } = accelerationIncludingGravity;
2266
2214
  if (invert) {
2267
- if (x !== null)
2268
- this.fAcc.x.forEach((handler) => handler(-x));
2269
- if (y !== null)
2270
- this.fAcc.y.forEach((handler) => handler(-y));
2271
- if (z !== null)
2272
- this.fAcc.z.forEach((handler) => handler(-z));
2215
+ if (x !== null) this.fAcc.x.forEach((handler) => handler(-x));
2216
+ if (y !== null) this.fAcc.y.forEach((handler) => handler(-y));
2217
+ if (z !== null) this.fAcc.z.forEach((handler) => handler(-z));
2273
2218
  } else {
2274
- if (x !== null)
2275
- this.fAcc.x.forEach((handler) => handler(x));
2276
- if (y !== null)
2277
- this.fAcc.y.forEach((handler) => handler(y));
2278
- if (z !== null)
2279
- this.fAcc.z.forEach((handler) => handler(z));
2219
+ if (x !== null) this.fAcc.x.forEach((handler) => handler(x));
2220
+ if (y !== null) this.fAcc.y.forEach((handler) => handler(y));
2221
+ if (z !== null) this.fAcc.z.forEach((handler) => handler(z));
2280
2222
  }
2281
2223
  }
2282
2224
  get hasGyrInput() {
@@ -2284,12 +2226,9 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2284
2226
  }
2285
2227
  propagateGyr(event) {
2286
2228
  const { alpha, beta, gamma } = event;
2287
- if (alpha !== null)
2288
- this.fGyr.x.forEach((handler) => handler(alpha));
2289
- if (beta !== null)
2290
- this.fGyr.y.forEach((handler) => handler(beta));
2291
- if (gamma !== null)
2292
- this.fGyr.z.forEach((handler) => handler(gamma));
2229
+ if (alpha !== null) this.fGyr.x.forEach((handler) => handler(alpha));
2230
+ if (beta !== null) this.fGyr.y.forEach((handler) => handler(beta));
2231
+ if (gamma !== null) this.fGyr.z.forEach((handler) => handler(gamma));
2293
2232
  }
2294
2233
  /** Build the accelerometer handler */
2295
2234
  setupAccHandler(path, axis, curve, amin, amid, amax, min, init, max) {
@@ -2344,8 +2283,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2344
2283
  console.log(`Soundfile ${name} paths: ${url}`);
2345
2284
  const soundfileIds = _FaustBaseWebAudioDsp.splitSoundfileNames(url);
2346
2285
  const item = this.fSoundfiles.find((item2) => item2.url === url);
2347
- if (!item)
2348
- throw new Error(`Soundfile with ${url} cannot be found !}`);
2286
+ if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);
2349
2287
  if (item.basePtr !== -1) {
2350
2288
  const HEAP32 = allocator.getInt32Array();
2351
2289
  console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);
@@ -2368,7 +2306,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2368
2306
  for (const soundfileId of soundfileIdList) {
2369
2307
  let chan = 0;
2370
2308
  let len = 0;
2371
- const audioData = soundfiles[soundfileId];
2309
+ const audioData = soundfiles == null ? void 0 : soundfiles[soundfileId];
2372
2310
  if (audioData) {
2373
2311
  chan = audioData.audioBuffer.length;
2374
2312
  len = audioData.audioBuffer[0].length;
@@ -2384,7 +2322,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2384
2322
  let offset = 0;
2385
2323
  for (let part = 0; part < soundfileIdList.length; part++) {
2386
2324
  const soundfileId = soundfileIdList[part];
2387
- const audioData = soundfiles[soundfileId];
2325
+ const audioData = soundfiles == null ? void 0 : soundfiles[soundfileId];
2388
2326
  if (audioData) {
2389
2327
  soundfile.copyToOut(part, maxChan, offset, audioData);
2390
2328
  offset += audioData.audioBuffer[0].length;
@@ -2460,16 +2398,13 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2460
2398
  return -1;
2461
2399
  }
2462
2400
  midiMessage(data) {
2463
- if (this.fPlotHandler)
2464
- this.fCachedEvents.push({ data, type: "midi" });
2401
+ if (this.fPlotHandler) this.fCachedEvents.push({ data, type: "midi" });
2465
2402
  const cmd = data[0] >> 4;
2466
2403
  const channel = data[0] & 15;
2467
2404
  const data1 = data[1];
2468
2405
  const data2 = data[2];
2469
- if (cmd === 11)
2470
- return this.ctrlChange(channel, data1, data2);
2471
- if (cmd === 14)
2472
- return this.pitchWheel(channel, data2 * 128 + data1);
2406
+ if (cmd === 11) return this.ctrlChange(channel, data1, data2);
2407
+ if (cmd === 14) return this.pitchWheel(channel, data2 * 128 + data1);
2473
2408
  if (cmd === 9) {
2474
2409
  if (data2 > 0)
2475
2410
  return this.keyOn(channel, data1, data2);
@@ -2481,68 +2416,58 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2481
2416
  }
2482
2417
  }
2483
2418
  ctrlChange(channel, ctrl, value) {
2484
- if (this.fPlotHandler)
2485
- this.fCachedEvents.push({ type: "ctrlChange", data: [channel, ctrl, value] });
2419
+ if (this.fPlotHandler) this.fCachedEvents.push({ type: "ctrlChange", data: [channel, ctrl, value] });
2486
2420
  if (this.fCtrlLabel[ctrl].length) {
2487
2421
  this.fCtrlLabel[ctrl].forEach((ctrl2) => {
2488
2422
  const { path, chan } = ctrl2;
2489
2423
  if (chan === 0 || channel === chan - 1) {
2490
2424
  this.setParamValue(path, _FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl2.min, ctrl2.max));
2491
- if (this.fOutputHandler)
2492
- this.fOutputHandler(path, this.getParamValue(path));
2425
+ if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));
2493
2426
  }
2494
2427
  });
2495
2428
  }
2496
2429
  }
2497
2430
  keyOn(channel, pitch, velocity) {
2498
- if (this.fPlotHandler)
2499
- this.fCachedEvents.push({ type: "keyOn", data: [channel, pitch, velocity] });
2431
+ if (this.fPlotHandler) this.fCachedEvents.push({ type: "keyOn", data: [channel, pitch, velocity] });
2500
2432
  this.fMidiKeyOnLabel[pitch].forEach((key) => {
2501
2433
  const { path, chan } = key;
2502
2434
  if (chan === 0 || channel === chan - 1) {
2503
2435
  this.setParamValue(path, _FaustBaseWebAudioDsp.remap(velocity, 0, 127, key.min, key.max));
2504
- if (this.fOutputHandler)
2505
- this.fOutputHandler(path, this.getParamValue(path));
2436
+ if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));
2506
2437
  }
2507
2438
  });
2508
2439
  this.fMidiKeyLabel[pitch].forEach((key) => {
2509
2440
  const { path, chan } = key;
2510
2441
  if (chan === 0 || channel === chan - 1) {
2511
2442
  this.setParamValue(path, _FaustBaseWebAudioDsp.remap(velocity, 0, 127, key.min, key.max));
2512
- if (this.fOutputHandler)
2513
- this.fOutputHandler(path, this.getParamValue(path));
2443
+ if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));
2514
2444
  }
2515
2445
  });
2516
2446
  }
2517
2447
  keyOff(channel, pitch, velocity) {
2518
- if (this.fPlotHandler)
2519
- this.fCachedEvents.push({ type: "keyOff", data: [channel, pitch, velocity] });
2448
+ if (this.fPlotHandler) this.fCachedEvents.push({ type: "keyOff", data: [channel, pitch, velocity] });
2520
2449
  this.fMidiKeyOffLabel[pitch].forEach((key) => {
2521
2450
  const { path, chan } = key;
2522
2451
  if (chan === 0 || channel === chan - 1) {
2523
2452
  this.setParamValue(path, _FaustBaseWebAudioDsp.remap(velocity, 0, 127, key.min, key.max));
2524
- if (this.fOutputHandler)
2525
- this.fOutputHandler(path, this.getParamValue(path));
2453
+ if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));
2526
2454
  }
2527
2455
  });
2528
2456
  this.fMidiKeyLabel[pitch].forEach((key) => {
2529
2457
  const { path, chan } = key;
2530
2458
  if (chan === 0 || channel === chan - 1) {
2531
2459
  this.setParamValue(path, 0);
2532
- if (this.fOutputHandler)
2533
- this.fOutputHandler(path, this.getParamValue(path));
2460
+ if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));
2534
2461
  }
2535
2462
  });
2536
2463
  }
2537
2464
  pitchWheel(channel, wheel) {
2538
- if (this.fPlotHandler)
2539
- this.fCachedEvents.push({ type: "pitchWheel", data: [channel, wheel] });
2465
+ if (this.fPlotHandler) this.fCachedEvents.push({ type: "pitchWheel", data: [channel, wheel] });
2540
2466
  this.fPitchwheelLabel.forEach((pw) => {
2541
2467
  const { path, chan } = pw;
2542
2468
  if (chan === 0 || channel === chan - 1) {
2543
2469
  this.setParamValue(path, _FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));
2544
- if (this.fOutputHandler)
2545
- this.fOutputHandler(path, this.getParamValue(path));
2470
+ if (this.fOutputHandler) this.fOutputHandler(path, this.getParamValue(path));
2546
2471
  }
2547
2472
  });
2548
2473
  }
@@ -2643,10 +2568,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2643
2568
  }
2644
2569
  // Public API
2645
2570
  compute(input, output) {
2646
- if (this.fDestroyed)
2647
- return false;
2648
- if (!this.fProcessing)
2649
- return true;
2571
+ if (this.fDestroyed) return false;
2572
+ if (!this.fProcessing) return true;
2650
2573
  if (this.fFirstCall) {
2651
2574
  this.initMemory();
2652
2575
  this.fFirstCall = false;
@@ -2667,8 +2590,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2667
2590
  }
2668
2591
  }
2669
2592
  }
2670
- if (this.fComputeHandler)
2671
- this.fComputeHandler(this.fBufferSize);
2593
+ if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);
2672
2594
  this.fInstance.api.compute(this.fDSP, this.fBufferSize, this.fAudioInputs, this.fAudioOutputs);
2673
2595
  this.updateOutputs();
2674
2596
  let forPlot = this.fOutChannels;
@@ -2697,8 +2619,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2697
2619
  return this.fInstance.api.getNumOutputs(this.fDSP);
2698
2620
  }
2699
2621
  setParamValue(path, value) {
2700
- if (this.fPlotHandler)
2701
- this.fCachedEvents.push({ type: "param", data: { path, value } });
2622
+ if (this.fPlotHandler) this.fCachedEvents.push({ type: "param", data: { path, value } });
2702
2623
  this.fInstance.api.setParamValue(this.fDSP, this.fPathTable[path], value);
2703
2624
  }
2704
2625
  getParamValue(path) {
@@ -2824,8 +2745,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2824
2745
  this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);
2825
2746
  this.fJSONEffect = this.fInstance.effectAPI && this.fInstance.effectJSON ? JSON.parse(this.fInstance.effectJSON) : null;
2826
2747
  FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);
2827
- if (this.fJSONEffect)
2828
- FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);
2748
+ if (this.fJSONEffect) FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);
2829
2749
  this.fEndMemory = this.initMemory();
2830
2750
  this.fVoiceTable = [];
2831
2751
  for (let voice = 0; voice < this.fInstance.voices; voice++) {
@@ -2837,8 +2757,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2837
2757
  sampleRate
2838
2758
  ));
2839
2759
  }
2840
- if (this.fInstance.effectAPI)
2841
- this.fInstance.effectAPI.init(this.fEffect, sampleRate);
2760
+ if (this.fInstance.effectAPI) this.fInstance.effectAPI.init(this.fEffect, sampleRate);
2842
2761
  if (this.fSoundfiles.length > 0) {
2843
2762
  const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);
2844
2763
  for (let voice = 0; voice < this.fInstance.voices; voice++) {
@@ -2944,14 +2863,12 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2944
2863
  }
2945
2864
  // Public API
2946
2865
  compute(input, output) {
2947
- if (this.fDestroyed)
2948
- return false;
2866
+ if (this.fDestroyed) return false;
2949
2867
  if (this.fFirstCall) {
2950
2868
  this.initMemory();
2951
2869
  this.fFirstCall = false;
2952
2870
  }
2953
- if (!this.fProcessing)
2954
- return true;
2871
+ if (!this.fProcessing) return true;
2955
2872
  if (this.getNumInputs() > 0 && (!input || !input[0] || input[0].length === 0)) {
2956
2873
  return true;
2957
2874
  }
@@ -2964,8 +2881,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2964
2881
  dspInput.set(input[chan]);
2965
2882
  }
2966
2883
  }
2967
- if (this.fComputeHandler)
2968
- this.fComputeHandler(this.fBufferSize);
2884
+ if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);
2969
2885
  this.fInstance.mixerAPI.clearOutput(this.fBufferSize, this.getNumOutputs(), this.fAudioOutputs);
2970
2886
  this.fVoiceTable.forEach((voice) => {
2971
2887
  if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {
@@ -2980,8 +2896,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
2980
2896
  }
2981
2897
  }
2982
2898
  });
2983
- if (this.fInstance.effectAPI)
2984
- this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);
2899
+ if (this.fInstance.effectAPI) this.fInstance.effectAPI.compute(this.fEffect, this.fBufferSize, this.fAudioOutputs, this.fAudioOutputs);
2985
2900
  this.updateOutputs();
2986
2901
  if (output !== void 0) {
2987
2902
  for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {
@@ -3008,15 +2923,13 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3008
2923
  return o.address === p;
3009
2924
  } else {
3010
2925
  for (const k in o) {
3011
- if (_FaustPolyWebAudioDsp.findPath(o[k], p))
3012
- return true;
2926
+ if (_FaustPolyWebAudioDsp.findPath(o[k], p)) return true;
3013
2927
  }
3014
2928
  return false;
3015
2929
  }
3016
2930
  }
3017
2931
  setParamValue(path, value) {
3018
- if (this.fPlotHandler)
3019
- this.fCachedEvents.push({ type: "param", data: { path, value } });
2932
+ if (this.fPlotHandler) this.fCachedEvents.push({ type: "param", data: { path, value } });
3020
2933
  if (this.fJSONEffect && _FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {
3021
2934
  this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);
3022
2935
  } else {
@@ -3068,12 +2981,9 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3068
2981
  const channel = data[0] & 15;
3069
2982
  const data1 = data[1];
3070
2983
  const data2 = data[2];
3071
- if (cmd === 8 || cmd === 9 && data2 === 0)
3072
- return this.keyOff(channel, data1, data2);
3073
- else if (cmd === 9)
3074
- return this.keyOn(channel, data1, data2);
3075
- else
3076
- super.midiMessage(data);
2984
+ if (cmd === 8 || cmd === 9 && data2 === 0) return this.keyOff(channel, data1, data2);
2985
+ else if (cmd === 9) return this.keyOn(channel, data1, data2);
2986
+ else super.midiMessage(data);
3077
2987
  }
3078
2988
  ctrlChange(channel, ctrl, value) {
3079
2989
  if (ctrl === 123 || ctrl === 120) {
@@ -3083,14 +2993,12 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3083
2993
  }
3084
2994
  }
3085
2995
  keyOn(channel, pitch, velocity) {
3086
- if (this.fPlotHandler)
3087
- this.fCachedEvents.push({ type: "keyOn", data: [channel, pitch, velocity] });
2996
+ if (this.fPlotHandler) this.fCachedEvents.push({ type: "keyOn", data: [channel, pitch, velocity] });
3088
2997
  const voice = this.getFreeVoice();
3089
2998
  this.fVoiceTable[voice].keyOn(pitch, velocity, this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice);
3090
2999
  }
3091
3000
  keyOff(channel, pitch, velocity) {
3092
- if (this.fPlotHandler)
3093
- this.fCachedEvents.push({ type: "keyOff", data: [channel, pitch, velocity] });
3001
+ if (this.fPlotHandler) this.fCachedEvents.push({ type: "keyOff", data: [channel, pitch, velocity] });
3094
3002
  const voice = this.getPlayingVoice(pitch);
3095
3003
  if (voice !== FaustWebAudioDspVoice.kNoVoice) {
3096
3004
  this.fVoiceTable[voice].keyOff();
@@ -3126,8 +3034,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3126
3034
  param = { name: item.address, defaultValue: item.init || 0, minValue: 0, maxValue: 1 };
3127
3035
  }
3128
3036
  }
3129
- if (param)
3130
- params.push(param);
3037
+ if (param) params.push(param);
3131
3038
  };
3132
3039
  FaustBaseWebAudioDsp.parseUI(this.fDSPCode.getUI(), callback);
3133
3040
  return params;
@@ -3298,8 +3205,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3298
3205
  } catch {
3299
3206
  }
3300
3207
  const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);
3301
- if (!success)
3302
- throw new Error(this.compiler.getErrorMessage());
3208
+ if (!success) throw new Error(this.compiler.getErrorMessage());
3303
3209
  const svgs = {};
3304
3210
  const files = fs.readdir(`/${name}-svg/`);
3305
3211
  files.filter((file) => file !== "." && file !== "..").forEach((file) => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: "utf8" }));
@@ -3802,8 +3708,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3802
3708
  static async fetchSoundfile(url, audioCtx) {
3803
3709
  console.log(`Loading sound file from ${url}`);
3804
3710
  const response = await fetch(url);
3805
- if (!response.ok)
3806
- throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);
3711
+ if (!response.ok) throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);
3807
3712
  const arrayBuffer = await response.arrayBuffer();
3808
3713
  const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);
3809
3714
  return this.toAudioData(audioBuffer);
@@ -3817,13 +3722,11 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3817
3722
  * @param audioCtx : the audio context
3818
3723
  */
3819
3724
  static async loadSoundfile(filename, metaUrls, soundfiles, audioCtx) {
3820
- if (soundfiles[filename])
3821
- return;
3725
+ if (soundfiles == null ? void 0 : soundfiles[filename]) return;
3822
3726
  const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map((path) => new URL(filename, path.endsWith("/") ? path : `${path}/`).href)];
3823
3727
  const checkResults = await Promise.all(urlsToCheck.map((url) => this.checkFileExists(url)));
3824
3728
  const successIndex = checkResults.findIndex((r) => !!r);
3825
- if (successIndex === -1)
3826
- throw new Error(`Failed to load sound file ${filename}, all check failed.`);
3729
+ if (successIndex === -1) throw new Error(`Failed to load sound file ${filename}, all check failed.`);
3827
3730
  soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);
3828
3731
  }
3829
3732
  /**
@@ -3838,7 +3741,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3838
3741
  const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);
3839
3742
  const soundfiles = this.findSoundfilesFromMeta(dspMeta);
3840
3743
  for (const id in soundfiles) {
3841
- if (soundfilesIn[id]) {
3744
+ if (soundfilesIn == null ? void 0 : soundfilesIn[id]) {
3842
3745
  soundfiles[id] = soundfilesIn[id];
3843
3746
  continue;
3844
3747
  }
@@ -3876,8 +3779,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3876
3779
  ptr += 3 * Float32Array.BYTES_PER_ELEMENT;
3877
3780
  }
3878
3781
  setNewAccDataAvailable(value) {
3879
- if (!this.uin8NewAccData)
3880
- return;
3782
+ if (!this.uin8NewAccData) return;
3881
3783
  this.uin8NewAccData[0] = +value;
3882
3784
  }
3883
3785
  getNewAccDataAvailable() {
@@ -3885,8 +3787,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3885
3787
  return !!((_a = this.uin8NewAccData) == null ? void 0 : _a[0]);
3886
3788
  }
3887
3789
  setNewGyrDataAvailable(value) {
3888
- if (!this.uin8NewGyrData)
3889
- return;
3790
+ if (!this.uin8NewGyrData) return;
3890
3791
  this.uin8NewGyrData[0] = +value;
3891
3792
  }
3892
3793
  getNewGyrDataAvailable() {
@@ -3898,8 +3799,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3898
3799
  const e = { type: "acc", data: { x, y, z }, invert };
3899
3800
  this.port.postMessage(e);
3900
3801
  }
3901
- if (!this.uin8NewAccData)
3902
- return;
3802
+ if (!this.uin8NewAccData) return;
3903
3803
  this.uin8Invert[0] = +invert;
3904
3804
  this.f32Acc[0] = x;
3905
3805
  this.f32Acc[1] = y;
@@ -3907,8 +3807,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3907
3807
  this.uin8NewAccData[0] = 1;
3908
3808
  }
3909
3809
  getAcc() {
3910
- if (!this.uin8NewAccData)
3911
- return;
3810
+ if (!this.uin8NewAccData) return;
3912
3811
  const invert = !!this.uin8Invert[0];
3913
3812
  const [x, y, z] = this.f32Acc;
3914
3813
  return { x, y, z, invert };
@@ -3918,16 +3817,14 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3918
3817
  const e = { type: "gyr", data: { alpha, beta, gamma } };
3919
3818
  this.port.postMessage(e);
3920
3819
  }
3921
- if (!this.uin8NewGyrData)
3922
- return;
3820
+ if (!this.uin8NewGyrData) return;
3923
3821
  this.f32Gyr[0] = alpha;
3924
3822
  this.f32Gyr[1] = beta;
3925
3823
  this.f32Gyr[2] = gamma;
3926
3824
  this.uin8NewGyrData[0] = 1;
3927
3825
  }
3928
3826
  getGyr() {
3929
- if (!this.uin8NewGyrData)
3930
- return;
3827
+ if (!this.uin8NewGyrData) return;
3931
3828
  const [alpha, beta, gamma] = this.f32Gyr;
3932
3829
  return { alpha, beta, gamma };
3933
3830
  }
@@ -3961,6 +3858,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
3961
3858
  this.port.addEventListener("message", (event) => {
3962
3859
  const msg = event.data;
3963
3860
  switch (msg.type) {
3861
+ // Sensors messages
3964
3862
  case "acc": {
3965
3863
  this.setAcc(msg.data, msg.invert);
3966
3864
  break;
@@ -4004,8 +3902,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4004
3902
  // Accelerometer and gyroscope handlers
4005
3903
  this.handleDeviceMotion = ({ accelerationIncludingGravity }) => {
4006
3904
  const isAndroid = /Android/i.test(navigator.userAgent);
4007
- if (!accelerationIncludingGravity)
4008
- return;
3905
+ if (!accelerationIncludingGravity) return;
4009
3906
  const { x, y, z } = accelerationIncludingGravity;
4010
3907
  this.propagateAcc({ x, y, z }, isAndroid);
4011
3908
  };
@@ -4023,14 +3920,11 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4023
3920
  if (item.type === "vslider" || item.type === "hslider" || item.type === "button" || item.type === "checkbox" || item.type === "nentry") {
4024
3921
  this.fInputsItems.push(item.address);
4025
3922
  this.fDescriptor.push(item);
4026
- if (!item.meta)
4027
- return;
3923
+ if (!item.meta) return;
4028
3924
  item.meta.forEach((meta) => {
4029
3925
  const { midi, acc, gyr } = meta;
4030
- if (acc)
4031
- __privateSet(this, _hasAccInput, true);
4032
- if (gyr)
4033
- __privateSet(this, _hasGyrInput, true);
3926
+ if (acc) __privateSet(this, _hasAccInput, true);
3927
+ if (gyr) __privateSet(this, _hasGyrInput, true);
4034
3928
  });
4035
3929
  }
4036
3930
  };
@@ -4118,16 +4012,11 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4118
4012
  const channel = data[0] & 15;
4119
4013
  const data1 = data[1];
4120
4014
  const data2 = data[2];
4121
- if (cmd === 11)
4122
- this.ctrlChange(channel, data1, data2);
4123
- else if (cmd === 14)
4124
- this.pitchWheel(channel, data2 * 128 + data1);
4125
- if (cmd === 8 || cmd === 9 && data2 === 0)
4126
- this.keyOff(channel, data1, data2);
4127
- else if (cmd === 9)
4128
- this.keyOn(channel, data1, data2);
4129
- else
4130
- this.port.postMessage({ type: "midi", data });
4015
+ if (cmd === 11) this.ctrlChange(channel, data1, data2);
4016
+ else if (cmd === 14) this.pitchWheel(channel, data2 * 128 + data1);
4017
+ if (cmd === 8 || cmd === 9 && data2 === 0) this.keyOff(channel, data1, data2);
4018
+ else if (cmd === 9) this.keyOn(channel, data1, data2);
4019
+ else this.port.postMessage({ type: "midi", data });
4131
4020
  }
4132
4021
  ctrlChange(channel, ctrl, value) {
4133
4022
  const e = { type: "ctrlChange", data: [channel, ctrl, value] };
@@ -4149,8 +4038,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4149
4038
  return __privateGet(this, _hasAccInput);
4150
4039
  }
4151
4040
  propagateAcc(accelerationIncludingGravity, invert = false) {
4152
- if (!accelerationIncludingGravity)
4153
- return;
4041
+ if (!accelerationIncludingGravity) return;
4154
4042
  const { x, y, z } = accelerationIncludingGravity;
4155
4043
  this.fCommunicator.setAcc({ x, y, z }, invert);
4156
4044
  }
@@ -4158,8 +4046,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4158
4046
  return __privateGet(this, _hasGyrInput);
4159
4047
  }
4160
4048
  propagateGyr(event) {
4161
- if (!event)
4162
- return;
4049
+ if (!event) return;
4163
4050
  const { alpha, beta, gamma } = event;
4164
4051
  this.fCommunicator.setGyr({ alpha, beta, gamma });
4165
4052
  }
@@ -4167,8 +4054,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4167
4054
  const e = { type: "param", data: { path, value } };
4168
4055
  this.port.postMessage(e);
4169
4056
  const param = this.parameters.get(path);
4170
- if (param)
4171
- param.setValueAtTime(value, this.context.currentTime);
4057
+ if (param) param.setValueAtTime(value, this.context.currentTime);
4172
4058
  }
4173
4059
  getParamValue(path) {
4174
4060
  const param = this.parameters.get(path);
@@ -4284,8 +4170,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4284
4170
  this.fOutputs = new Array(this.fDSPCode.getNumOutputs());
4285
4171
  this.handleDeviceMotion = ({ accelerationIncludingGravity }) => {
4286
4172
  const isAndroid = /Android/i.test(navigator.userAgent);
4287
- if (!accelerationIncludingGravity)
4288
- return;
4173
+ if (!accelerationIncludingGravity) return;
4289
4174
  const { x, y, z } = accelerationIncludingGravity;
4290
4175
  this.propagateAcc({ x, y, z }, isAndroid);
4291
4176
  };
@@ -4449,23 +4334,21 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4449
4334
  }
4450
4335
  }
4451
4336
  addSoundfiles(soundfileMap) {
4452
- if (!this.factory)
4453
- throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4337
+ if (!this.factory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4454
4338
  for (const id in soundfileMap) {
4455
4339
  this.factory.soundfiles[id] = soundfileMap[id];
4456
4340
  }
4457
4341
  }
4458
4342
  getSoundfileList() {
4459
- if (!this.factory)
4460
- throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4343
+ if (!this.factory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4461
4344
  const meta = JSON.parse(this.factory.json);
4462
4345
  const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
4346
+ if (!map) return [];
4463
4347
  return Object.keys(map);
4464
4348
  }
4465
4349
  async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name, processorOptions = {}) {
4466
4350
  var _a, _b;
4467
- if (!factory)
4468
- throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4351
+ if (!factory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4469
4352
  const meta = JSON.parse(factory.json);
4470
4353
  const sampleSize = meta.compile_options.match("-double") ? 8 : 4;
4471
4354
  factory.soundfiles = await SoundfileReader_default.loadSoundfiles(meta, factory.soundfiles || {}, context);
@@ -4477,8 +4360,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
4477
4360
  sp2.init(monoDsp);
4478
4361
  return sp2;
4479
4362
  } else {
4480
- if (!_FaustMonoDspGenerator.gWorkletProcessors.has(context))
4481
- _FaustMonoDspGenerator.gWorkletProcessors.set(context, /* @__PURE__ */ new Set());
4363
+ if (!_FaustMonoDspGenerator.gWorkletProcessors.has(context)) _FaustMonoDspGenerator.gWorkletProcessors.set(context, /* @__PURE__ */ new Set());
4482
4364
  if (!((_a = _FaustMonoDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _a.has(processorName))) {
4483
4365
  try {
4484
4366
  const processorCode = `
@@ -4531,13 +4413,11 @@ const dependencies = {
4531
4413
  }
4532
4414
  async createFFTNode(context, fftUtils, name = this.name, factory = this.factory, fftOptions = {}, processorName = (factory == null ? void 0 : factory.shaKey) ? `${factory.shaKey}_fft` : name, processorOptions = {}) {
4533
4415
  var _a, _b;
4534
- if (!factory)
4535
- throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4416
+ if (!factory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4536
4417
  const meta = JSON.parse(factory.json);
4537
4418
  const sampleSize = meta.compile_options.match("-double") ? 8 : 4;
4538
4419
  factory.soundfiles = await SoundfileReader_default.loadSoundfiles(meta, factory.soundfiles || {}, context);
4539
- if (!_FaustMonoDspGenerator.gWorkletProcessors.has(context))
4540
- _FaustMonoDspGenerator.gWorkletProcessors.set(context, /* @__PURE__ */ new Set());
4420
+ if (!_FaustMonoDspGenerator.gWorkletProcessors.has(context)) _FaustMonoDspGenerator.gWorkletProcessors.set(context, /* @__PURE__ */ new Set());
4541
4421
  if (!((_a = _FaustMonoDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _a.has(processorName))) {
4542
4422
  try {
4543
4423
  const processorCode = `
@@ -4589,29 +4469,24 @@ const dependencies = {
4589
4469
  const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });
4590
4470
  if (fftOptions.fftSize) {
4591
4471
  const param = node.parameters.get("fftSize");
4592
- if (param)
4593
- param.value = fftOptions.fftSize;
4472
+ if (param) param.value = fftOptions.fftSize;
4594
4473
  }
4595
4474
  if (fftOptions.fftOverlap) {
4596
4475
  const param = node.parameters.get("fftOverlap");
4597
- if (param)
4598
- param.value = fftOptions.fftOverlap;
4476
+ if (param) param.value = fftOptions.fftOverlap;
4599
4477
  }
4600
4478
  if (typeof fftOptions.defaultWindowFunction === "number") {
4601
4479
  const param = node.parameters.get("windowFunction");
4602
- if (param)
4603
- param.value = fftOptions.defaultWindowFunction + 1;
4480
+ if (param) param.value = fftOptions.defaultWindowFunction + 1;
4604
4481
  }
4605
4482
  if (typeof fftOptions.noIFFT === "boolean") {
4606
4483
  const param = node.parameters.get("noIFFT");
4607
- if (param)
4608
- param.value = +fftOptions.noIFFT;
4484
+ if (param) param.value = +fftOptions.noIFFT;
4609
4485
  }
4610
4486
  return node;
4611
4487
  }
4612
4488
  async createAudioWorkletProcessor(name = this.name, factory = this.factory, processorName = (factory == null ? void 0 : factory.shaKey) || name) {
4613
- if (!factory)
4614
- throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4489
+ if (!factory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4615
4490
  const meta = JSON.parse(factory.json);
4616
4491
  const dependencies = {
4617
4492
  FaustBaseWebAudioDsp,
@@ -4635,13 +4510,11 @@ const dependencies = {
4635
4510
  }
4636
4511
  }
4637
4512
  async createOfflineProcessor(sampleRate, bufferSize, factory = this.factory, context) {
4638
- if (!factory)
4639
- throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4513
+ if (!factory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4640
4514
  const meta = JSON.parse(factory.json);
4641
4515
  const instance = await FaustWasmInstantiator_default.createAsyncMonoDSPInstance(factory);
4642
4516
  const sampleSize = meta.compile_options.match("-double") ? 8 : 4;
4643
- if (context)
4644
- factory.soundfiles = await SoundfileReader_default.loadSoundfiles(meta, factory.soundfiles || {}, context);
4517
+ if (context) factory.soundfiles = await SoundfileReader_default.loadSoundfiles(meta, factory.soundfiles || {}, context);
4645
4518
  const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);
4646
4519
  return new FaustMonoOfflineProcessor(monoDsp, bufferSize);
4647
4520
  }
@@ -4732,33 +4605,29 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
4732
4605
  }
4733
4606
  }
4734
4607
  addSoundfiles(soundfileMap) {
4735
- if (!this.voiceFactory)
4736
- throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4608
+ if (!this.voiceFactory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4737
4609
  for (const id in soundfileMap) {
4738
4610
  this.voiceFactory.soundfiles[id] = soundfileMap[id];
4739
4611
  }
4740
4612
  }
4741
4613
  getSoundfileList() {
4742
- if (!this.voiceFactory)
4743
- throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4614
+ if (!this.voiceFactory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4744
4615
  const meta = JSON.parse(this.voiceFactory.json);
4745
4616
  const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
4746
- if (!this.effectFactory)
4747
- return Object.keys(map);
4617
+ if (!map) return [];
4618
+ if (!this.effectFactory) return Object.keys(map);
4748
4619
  const effectMeta = JSON.parse(this.effectFactory.json);
4749
4620
  const effectMap = SoundfileReader_default.findSoundfilesFromMeta(effectMeta);
4750
4621
  return Object.keys({ ...effectMap, ...map });
4751
4622
  }
4752
4623
  async createNode(context, voices, name = this.name, voiceFactory = this.voiceFactory, mixerModule = this.mixerModule, effectFactory = this.effectFactory, sp = false, bufferSize = 1024, processorName = ((voiceFactory == null ? void 0 : voiceFactory.shaKey) || "") + ((effectFactory == null ? void 0 : effectFactory.shaKey) || "") || `${name}_poly`, processorOptions = {}) {
4753
4624
  var _a, _b;
4754
- if (!voiceFactory)
4755
- throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4625
+ if (!voiceFactory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4756
4626
  const voiceMeta = JSON.parse(voiceFactory.json);
4757
4627
  const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : void 0;
4758
4628
  const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4;
4759
4629
  voiceFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);
4760
- if (effectFactory)
4761
- effectFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);
4630
+ if (effectFactory) effectFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);
4762
4631
  if (sp) {
4763
4632
  const instance = await FaustWasmInstantiator_default.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || void 0);
4764
4633
  const soundfiles = { ...effectFactory == null ? void 0 : effectFactory.soundfiles, ...voiceFactory.soundfiles };
@@ -4768,8 +4637,7 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
4768
4637
  sp2.init(polyDsp);
4769
4638
  return sp2;
4770
4639
  } else {
4771
- if (!_FaustPolyDspGenerator.gWorkletProcessors.has(context))
4772
- _FaustPolyDspGenerator.gWorkletProcessors.set(context, /* @__PURE__ */ new Set());
4640
+ if (!_FaustPolyDspGenerator.gWorkletProcessors.has(context)) _FaustPolyDspGenerator.gWorkletProcessors.set(context, /* @__PURE__ */ new Set());
4773
4641
  if (!((_a = _FaustPolyDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _a.has(processorName))) {
4774
4642
  try {
4775
4643
  const processorCode = `
@@ -4824,8 +4692,7 @@ const dependencies = {
4824
4692
  }
4825
4693
  }
4826
4694
  async createAudioWorkletProcessor(name = this.name, voiceFactory = this.voiceFactory, effectFactory = this.effectFactory, processorName = ((voiceFactory == null ? void 0 : voiceFactory.shaKey) || "") + ((effectFactory == null ? void 0 : effectFactory.shaKey) || "") || `${name}_poly`) {
4827
- if (!voiceFactory)
4828
- throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4695
+ if (!voiceFactory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4829
4696
  const voiceMeta = JSON.parse(voiceFactory.json);
4830
4697
  const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : void 0;
4831
4698
  const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4;
@@ -4852,16 +4719,14 @@ const dependencies = {
4852
4719
  }
4853
4720
  }
4854
4721
  async createOfflineProcessor(sampleRate, bufferSize, voices, voiceFactory = this.voiceFactory, mixerModule = this.mixerModule, effectFactory = this.effectFactory, context) {
4855
- if (!voiceFactory)
4856
- throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4722
+ if (!voiceFactory) throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
4857
4723
  const voiceMeta = JSON.parse(voiceFactory.json);
4858
4724
  const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : void 0;
4859
4725
  const instance = await FaustWasmInstantiator_default.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || void 0);
4860
4726
  const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4;
4861
4727
  if (context) {
4862
4728
  voiceFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);
4863
- if (effectFactory)
4864
- effectFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);
4729
+ if (effectFactory) effectFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);
4865
4730
  }
4866
4731
  const soundfiles = { ...effectFactory == null ? void 0 : effectFactory.soundfiles, ...voiceFactory.soundfiles };
4867
4732
  const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);