@grame/faustwasm 0.13.7 → 0.14.1

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.
@@ -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;
@@ -1328,6 +1330,12 @@ export declare class WavDecoder {
1328
1330
  }
1329
1331
  /** Read metadata and fetch soundfiles */
1330
1332
  export declare class SoundfileReader {
1333
+ /**
1334
+ * Set fallback base URLs used to resolve soundfile paths.
1335
+ *
1336
+ * In Node or other non-browser runtimes, `location` may be undefined;
1337
+ * in that case this returns an empty list to avoid resolution errors.
1338
+ */
1331
1339
  static get fallbackPaths(): string[];
1332
1340
  /**
1333
1341
  * Extract the parent URL from an URL.
@@ -1401,6 +1409,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
1401
1409
  protected fUICallback: UIHandler;
1402
1410
  protected fDescriptor: FaustUIInputItem[];
1403
1411
  protected fCommunicator: FaustAudioWorkletNodeCommunicator;
1412
+ protected fParamAliases: Record<string, string>;
1404
1413
  constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial<FaustAudioWorkletNodeOptions<Poly>>);
1405
1414
  protected handleMessageAux: (e: MessageEvent) => void;
1406
1415
  private handleDeviceMotion;
@@ -8314,11 +8314,25 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
8314
8314
  this.fPathTable = {};
8315
8315
  this.fUICallback = (item) => {
8316
8316
  if (item.type === "hbargraph" || item.type === "vbargraph") {
8317
+ const registerPath = (alias) => {
8318
+ if (this.fPathTable[alias] === void 0) {
8319
+ this.fPathTable[alias] = item.index;
8320
+ }
8321
+ };
8317
8322
  this.fOutputsItems.push(item.address);
8318
- this.fPathTable[item.address] = item.index;
8323
+ registerPath(item.address);
8324
+ registerPath(item.shortname);
8325
+ registerPath(item.label);
8319
8326
  } else if (item.type === "vslider" || item.type === "hslider" || item.type === "button" || item.type === "checkbox" || item.type === "nentry") {
8327
+ const registerPath = (alias) => {
8328
+ if (this.fPathTable[alias] === void 0) {
8329
+ this.fPathTable[alias] = item.index;
8330
+ }
8331
+ };
8320
8332
  this.fInputsItems.push(item.address);
8321
- this.fPathTable[item.address] = item.index;
8333
+ registerPath(item.address);
8334
+ registerPath(item.shortname);
8335
+ registerPath(item.label);
8322
8336
  this.fDescriptor.push(item);
8323
8337
  if (!item.meta) return;
8324
8338
  item.meta.forEach((meta) => {
@@ -10218,13 +10232,20 @@ var WavDecoder_default = WavDecoder;
10218
10232
 
10219
10233
  // src/SoundfileReader.ts
10220
10234
  var SoundfileReader = class {
10221
- // Set the fallback paths
10235
+ /**
10236
+ * Set fallback base URLs used to resolve soundfile paths.
10237
+ *
10238
+ * In Node or other non-browser runtimes, `location` may be undefined;
10239
+ * in that case this returns an empty list to avoid resolution errors.
10240
+ */
10222
10241
  static get fallbackPaths() {
10223
- return [
10224
- location.href,
10225
- this.getParentUrl(location.href),
10226
- location.origin
10227
- ];
10242
+ const loc = typeof location !== "undefined" ? location : null;
10243
+ const href = loc == null ? void 0 : loc.href;
10244
+ const origin = loc == null ? void 0 : loc.origin;
10245
+ const parent = href ? this.getParentUrl(href) : null;
10246
+ return [href, parent, origin].filter(
10247
+ (value) => typeof value === "string" && value.length > 0
10248
+ );
10228
10249
  }
10229
10250
  /**
10230
10251
  * Extract the parent URL from an URL.
@@ -10523,11 +10544,19 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
10523
10544
  this.fComputeHandler = null;
10524
10545
  this.fPlotHandler = null;
10525
10546
  this.fDescriptor = [];
10547
+ this.fParamAliases = {};
10526
10548
  this.fInputsItems = [];
10527
10549
  this.fUICallback = (item) => {
10528
10550
  if (item.type === "vslider" || item.type === "hslider" || item.type === "button" || item.type === "checkbox" || item.type === "nentry") {
10529
10551
  this.fInputsItems.push(item.address);
10530
10552
  this.fDescriptor.push(item);
10553
+ const registerAlias = (alias) => {
10554
+ if (!this.fParamAliases[alias]) {
10555
+ this.fParamAliases[alias] = item.address;
10556
+ }
10557
+ };
10558
+ registerAlias(item.shortname);
10559
+ registerAlias(item.label);
10531
10560
  if (!item.meta) return;
10532
10561
  item.meta.forEach((meta) => {
10533
10562
  const { midi, acc, gyr } = meta;
@@ -10682,13 +10711,14 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
10682
10711
  });
10683
10712
  }
10684
10713
  setParamValue(path, value) {
10685
- const e = { type: "param", data: { path, value } };
10686
- this.port.postMessage(e);
10687
- const param = this.parameters.get(path);
10714
+ const resolved = this.fParamAliases[path] || path;
10715
+ this.port.postMessage({ type: "param", data: { path: resolved, value } });
10716
+ const param = this.parameters.get(resolved);
10688
10717
  if (param) param.setValueAtTime(value, this.context.currentTime);
10689
10718
  }
10690
10719
  getParamValue(path) {
10691
- const param = this.parameters.get(path);
10720
+ const resolved = this.fParamAliases[path] || path;
10721
+ const param = this.parameters.get(resolved);
10692
10722
  return param ? param.value : 0;
10693
10723
  }
10694
10724
  getParams() {