@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.
@@ -120,13 +120,27 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
120
120
  }
121
121
  static get parameterDescriptors() {
122
122
  const params = [];
123
- const callback = (item) => {
123
+ const origin = /* @__PURE__ */ new Map();
124
+ const collect = (side) => (item) => {
124
125
  const param = analysePolyParameters(item);
125
- if (param) params.push(param);
126
+ if (!param) return;
127
+ const previous = origin.get(param.name);
128
+ if (previous === side) {
129
+ throw new Error(
130
+ `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.`
131
+ );
132
+ }
133
+ if (previous !== void 0) {
134
+ throw new Error(
135
+ `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.`
136
+ );
137
+ }
138
+ origin.set(param.name, side);
139
+ params.push(param);
126
140
  };
127
- FaustBaseWebAudioDsp2.parseUI(dspMeta.ui, callback);
141
+ FaustBaseWebAudioDsp2.parseUI(dspMeta.ui, collect("voice"));
128
142
  if (effectMeta)
129
- FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, callback);
143
+ FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, collect("effect"));
130
144
  return params;
131
145
  }
132
146
  setupWamEventHandler() {
@@ -384,13 +398,14 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
384
398
  }
385
399
  const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;
386
400
  if (register) {
387
- try {
388
- registerProcessor(
389
- processorName || dspName || (poly ? "mydsp_poly" : "mydsp"),
390
- Processor
391
- );
392
- } catch (error) {
393
- console.warn(error);
401
+ const name = processorName || dspName || (poly ? "mydsp_poly" : "mydsp");
402
+ const scope = globalThis;
403
+ if (!scope.__faustRegisteredProcessors) {
404
+ scope.__faustRegisteredProcessors = /* @__PURE__ */ new Set();
405
+ }
406
+ if (!scope.__faustRegisteredProcessors.has(name)) {
407
+ registerProcessor(name, Processor);
408
+ scope.__faustRegisteredProcessors.add(name);
394
409
  }
395
410
  }
396
411
  return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;
@@ -931,13 +946,14 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
931
946
  }
932
947
  const Processor = FaustFFTAudioWorkletProcessor;
933
948
  if (register) {
934
- try {
935
- registerProcessor(
936
- processorName || dspName || "myfftdsp",
937
- Processor
938
- );
939
- } catch (error) {
940
- console.warn(error);
949
+ const name = processorName || dspName || "myfftdsp";
950
+ const scope = globalThis;
951
+ if (!scope.__faustRegisteredProcessors) {
952
+ scope.__faustRegisteredProcessors = /* @__PURE__ */ new Set();
953
+ }
954
+ if (!scope.__faustRegisteredProcessors.has(name)) {
955
+ registerProcessor(name, Processor);
956
+ scope.__faustRegisteredProcessors.add(name);
941
957
  }
942
958
  }
943
959
  return FaustFFTAudioWorkletProcessor;
@@ -5927,17 +5943,24 @@ const dependencies = {
5927
5943
  throw e;
5928
5944
  }
5929
5945
  }
5930
- const node = new FaustPolyAudioWorkletNode(context, {
5931
- processorOptions: {
5932
- name: processorName,
5933
- voiceFactory,
5934
- mixerModule,
5935
- voices,
5936
- sampleSize,
5937
- effectFactory: effectFactory || void 0,
5938
- ...processorOptions
5939
- }
5940
- });
5946
+ let node;
5947
+ try {
5948
+ node = new FaustPolyAudioWorkletNode(context, {
5949
+ processorOptions: {
5950
+ name: processorName,
5951
+ voiceFactory,
5952
+ mixerModule,
5953
+ voices,
5954
+ sampleSize,
5955
+ effectFactory: effectFactory || void 0,
5956
+ ...processorOptions
5957
+ }
5958
+ });
5959
+ } catch (error) {
5960
+ throw new Error(
5961
+ `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)}`
5962
+ );
5963
+ }
5941
5964
  return node;
5942
5965
  }
5943
5966
  }