@grame/faustwasm 0.16.6 → 0.16.7

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.
@@ -5923,13 +5923,27 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
5923
5923
  }
5924
5924
  static get parameterDescriptors() {
5925
5925
  const params = [];
5926
- const callback = (item) => {
5926
+ const origin = /* @__PURE__ */ new Map();
5927
+ const collect = (side) => (item) => {
5927
5928
  const param = analysePolyParameters(item);
5928
- if (param) params.push(param);
5929
+ if (!param) return;
5930
+ const previous = origin.get(param.name);
5931
+ if (previous === side) {
5932
+ throw new Error(
5933
+ `Faust: control "${param.name}" is declared twice in the ${side}. Two widgets resolved to the same path, so one of them would be unreachable. Give them distinct labels or groups.`
5934
+ );
5935
+ }
5936
+ if (previous !== void 0) {
5937
+ throw new Error(
5938
+ `Faust: control "${param.name}" is declared both in the ${previous} and in the ${side}. A polyphonic DSP cannot share a control path between \`process\` and \`effect\`: setParamValue routes a path to one side only, so the other would keep its default. Declare it under a distinct path on each side and have the host write both.`
5939
+ );
5940
+ }
5941
+ origin.set(param.name, side);
5942
+ params.push(param);
5929
5943
  };
5930
- FaustBaseWebAudioDsp2.parseUI(dspMeta.ui, callback);
5944
+ FaustBaseWebAudioDsp2.parseUI(dspMeta.ui, collect("voice"));
5931
5945
  if (effectMeta)
5932
- FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, callback);
5946
+ FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, collect("effect"));
5933
5947
  return params;
5934
5948
  }
5935
5949
  setupWamEventHandler() {
@@ -6187,13 +6201,14 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
6187
6201
  }
6188
6202
  const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;
6189
6203
  if (register) {
6190
- try {
6191
- registerProcessor(
6192
- processorName || dspName || (poly ? "mydsp_poly" : "mydsp"),
6193
- Processor
6194
- );
6195
- } catch (error) {
6196
- console.warn(error);
6204
+ const name = processorName || dspName || (poly ? "mydsp_poly" : "mydsp");
6205
+ const scope = globalThis;
6206
+ if (!scope.__faustRegisteredProcessors) {
6207
+ scope.__faustRegisteredProcessors = /* @__PURE__ */ new Set();
6208
+ }
6209
+ if (!scope.__faustRegisteredProcessors.has(name)) {
6210
+ registerProcessor(name, Processor);
6211
+ scope.__faustRegisteredProcessors.add(name);
6197
6212
  }
6198
6213
  }
6199
6214
  return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;
@@ -6734,13 +6749,14 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
6734
6749
  }
6735
6750
  const Processor = FaustFFTAudioWorkletProcessor;
6736
6751
  if (register) {
6737
- try {
6738
- registerProcessor(
6739
- processorName || dspName || "myfftdsp",
6740
- Processor
6741
- );
6742
- } catch (error) {
6743
- console.warn(error);
6752
+ const name = processorName || dspName || "myfftdsp";
6753
+ const scope = globalThis;
6754
+ if (!scope.__faustRegisteredProcessors) {
6755
+ scope.__faustRegisteredProcessors = /* @__PURE__ */ new Set();
6756
+ }
6757
+ if (!scope.__faustRegisteredProcessors.has(name)) {
6758
+ registerProcessor(name, Processor);
6759
+ scope.__faustRegisteredProcessors.add(name);
6744
6760
  }
6745
6761
  }
6746
6762
  return FaustFFTAudioWorkletProcessor;
@@ -11730,17 +11746,24 @@ const dependencies = {
11730
11746
  throw e;
11731
11747
  }
11732
11748
  }
11733
- const node = new FaustPolyAudioWorkletNode(context, {
11734
- processorOptions: {
11735
- name: processorName,
11736
- voiceFactory,
11737
- mixerModule,
11738
- voices,
11739
- sampleSize,
11740
- effectFactory: effectFactory || void 0,
11741
- ...processorOptions
11742
- }
11743
- });
11749
+ let node;
11750
+ try {
11751
+ node = new FaustPolyAudioWorkletNode(context, {
11752
+ processorOptions: {
11753
+ name: processorName,
11754
+ voiceFactory,
11755
+ mixerModule,
11756
+ voices,
11757
+ sampleSize,
11758
+ effectFactory: effectFactory || void 0,
11759
+ ...processorOptions
11760
+ }
11761
+ });
11762
+ } catch (error) {
11763
+ throw new Error(
11764
+ `Faust: the AudioWorkletProcessor "${processorName}" did not register. The module loaded, so the failure happened inside registerProcessor \u2014 its error is reported in the AudioWorklet scope and appears in the browser console above this one. A duplicate control path shared between \`process\` and \`effect\` is the usual cause. Original error: ${error instanceof Error ? error.message : String(error)}`
11765
+ );
11766
+ }
11744
11767
  return node;
11745
11768
  }
11746
11769
  }