@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.
package/dist/cjs/index.js CHANGED
@@ -149,13 +149,27 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
149
149
  }
150
150
  static get parameterDescriptors() {
151
151
  const params = [];
152
- const callback = (item) => {
152
+ const origin = /* @__PURE__ */ new Map();
153
+ const collect = (side) => (item) => {
153
154
  const param = analysePolyParameters(item);
154
- if (param) params.push(param);
155
+ if (!param) return;
156
+ const previous = origin.get(param.name);
157
+ if (previous === side) {
158
+ throw new Error(
159
+ `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.`
160
+ );
161
+ }
162
+ if (previous !== void 0) {
163
+ throw new Error(
164
+ `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.`
165
+ );
166
+ }
167
+ origin.set(param.name, side);
168
+ params.push(param);
155
169
  };
156
- FaustBaseWebAudioDsp2.parseUI(dspMeta.ui, callback);
170
+ FaustBaseWebAudioDsp2.parseUI(dspMeta.ui, collect("voice"));
157
171
  if (effectMeta)
158
- FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, callback);
172
+ FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, collect("effect"));
159
173
  return params;
160
174
  }
161
175
  setupWamEventHandler() {
@@ -413,13 +427,14 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
413
427
  }
414
428
  const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;
415
429
  if (register) {
416
- try {
417
- registerProcessor(
418
- processorName || dspName || (poly ? "mydsp_poly" : "mydsp"),
419
- Processor
420
- );
421
- } catch (error) {
422
- console.warn(error);
430
+ const name = processorName || dspName || (poly ? "mydsp_poly" : "mydsp");
431
+ const scope = globalThis;
432
+ if (!scope.__faustRegisteredProcessors) {
433
+ scope.__faustRegisteredProcessors = /* @__PURE__ */ new Set();
434
+ }
435
+ if (!scope.__faustRegisteredProcessors.has(name)) {
436
+ registerProcessor(name, Processor);
437
+ scope.__faustRegisteredProcessors.add(name);
423
438
  }
424
439
  }
425
440
  return poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;
@@ -960,13 +975,14 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
960
975
  }
961
976
  const Processor = FaustFFTAudioWorkletProcessor;
962
977
  if (register) {
963
- try {
964
- registerProcessor(
965
- processorName || dspName || "myfftdsp",
966
- Processor
967
- );
968
- } catch (error) {
969
- console.warn(error);
978
+ const name = processorName || dspName || "myfftdsp";
979
+ const scope = globalThis;
980
+ if (!scope.__faustRegisteredProcessors) {
981
+ scope.__faustRegisteredProcessors = /* @__PURE__ */ new Set();
982
+ }
983
+ if (!scope.__faustRegisteredProcessors.has(name)) {
984
+ registerProcessor(name, Processor);
985
+ scope.__faustRegisteredProcessors.add(name);
970
986
  }
971
987
  }
972
988
  return FaustFFTAudioWorkletProcessor;
@@ -5956,17 +5972,24 @@ const dependencies = {
5956
5972
  throw e;
5957
5973
  }
5958
5974
  }
5959
- const node = new FaustPolyAudioWorkletNode(context, {
5960
- processorOptions: {
5961
- name: processorName,
5962
- voiceFactory,
5963
- mixerModule,
5964
- voices,
5965
- sampleSize,
5966
- effectFactory: effectFactory || void 0,
5967
- ...processorOptions
5968
- }
5969
- });
5975
+ let node;
5976
+ try {
5977
+ node = new FaustPolyAudioWorkletNode(context, {
5978
+ processorOptions: {
5979
+ name: processorName,
5980
+ voiceFactory,
5981
+ mixerModule,
5982
+ voices,
5983
+ sampleSize,
5984
+ effectFactory: effectFactory || void 0,
5985
+ ...processorOptions
5986
+ }
5987
+ });
5988
+ } catch (error) {
5989
+ throw new Error(
5990
+ `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)}`
5991
+ );
5992
+ }
5970
5993
  return node;
5971
5994
  }
5972
5995
  }