@grame/faustwasm 0.4.5 → 0.4.8

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 (52) hide show
  1. package/COPYING.txt +520 -0
  2. package/README.md +4 -4
  3. package/assets/standalone/create-node.js +78 -0
  4. package/assets/standalone/faust-ui/index.css +8 -0
  5. package/assets/standalone/faust-ui/index.css.map +1 -1
  6. package/assets/standalone/faust-ui/index.js +56 -30
  7. package/assets/standalone/faust-ui/index.js.map +1 -1
  8. package/assets/standalone/faustwasm/index.d.ts +18 -10
  9. package/assets/standalone/faustwasm/index.js +81 -56
  10. package/assets/standalone/faustwasm/index.js.map +2 -2
  11. package/assets/standalone/index-template.html +17 -0
  12. package/assets/standalone/index-template.js +48 -0
  13. package/assets/standalone/index.html +4 -3
  14. package/assets/standalone/index.js +14 -71
  15. package/assets/standalone/manifest.json +5 -6
  16. package/assets/standalone/service-worker.js +51 -27
  17. package/dist/cjs/index.d.ts +18 -10
  18. package/dist/cjs/index.js +81 -56
  19. package/dist/cjs/index.js.map +2 -2
  20. package/dist/cjs-bundle/index.d.ts +18 -10
  21. package/dist/cjs-bundle/index.js +81 -56
  22. package/dist/cjs-bundle/index.js.map +2 -2
  23. package/dist/esm/index.d.ts +18 -10
  24. package/dist/esm/index.js +81 -56
  25. package/dist/esm/index.js.map +2 -2
  26. package/dist/esm-bundle/index.d.ts +18 -10
  27. package/dist/esm-bundle/index.js +81 -56
  28. package/dist/esm-bundle/index.js.map +2 -2
  29. package/fileutils.js +19 -21
  30. package/package.json +4 -2
  31. package/scripts/faust2wasm.js +10 -5
  32. package/src/FaustAudioWorkletNode.ts +18 -38
  33. package/src/FaustAudioWorkletProcessor.ts +28 -1
  34. package/src/FaustDspGenerator.ts +18 -9
  35. package/src/FaustFFTAudioWorkletProcessor.ts +27 -0
  36. package/src/FaustScriptProcessorNode.ts +5 -14
  37. package/src/copyWebStandaloneAssets.d.ts +2 -2
  38. package/src/copyWebStandaloneAssets.js +30 -19
  39. package/src/faust2wasmFiles.js +5 -5
  40. package/test/faustlive-wasm/faust-ui/index.css +8 -0
  41. package/test/faustlive-wasm/faust-ui/index.css.map +1 -1
  42. package/test/faustlive-wasm/faust-ui/index.js +56 -30
  43. package/test/faustlive-wasm/faust-ui/index.js.map +1 -1
  44. package/test/faustlive-wasm/faustwasm/index.d.ts +18 -10
  45. package/test/faustlive-wasm/faustwasm/index.js +81 -56
  46. package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
  47. package/assets/standalone/index-poly.js +0 -234
  48. package/assets/standalone/service-worker-poly.js +0 -98
  49. package/assets/standalone/template-poly.html +0 -60
  50. package/assets/standalone/template.html +0 -50
  51. package/assets/standalone/template.js +0 -63
  52. package/assets/standalone/types.d.ts +0 -9
@@ -894,6 +894,8 @@ export interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOption
894
894
  export interface FaustAudioWorkletProcessorOptions {
895
895
  name: string;
896
896
  sampleSize: number;
897
+ moduleId?: string;
898
+ instanceId?: string;
897
899
  }
898
900
  export interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
899
901
  factory: LooseFaustDspFactory;
@@ -938,6 +940,8 @@ export interface FaustFFTAudioWorkletProcessorOptions {
938
940
  name: string;
939
941
  sampleSize: number;
940
942
  factory: LooseFaustDspFactory;
943
+ moduleId?: string;
944
+ instanceId?: string;
941
945
  }
942
946
  export declare const getFaustFFTAudioWorkletProcessor: (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register?: boolean) => {
943
947
  new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
@@ -1273,7 +1277,7 @@ export declare class SoundfileReader {
1273
1277
  static loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory["soundfiles"], audioCtx: BaseAudioContext): Promise<LooseFaustDspFactory["soundfiles"]>;
1274
1278
  }
1275
1279
  declare const FaustAudioWorkletNode_base: {
1276
- new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions | undefined): AudioWorkletNode;
1280
+ new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode;
1277
1281
  prototype: AudioWorkletNode;
1278
1282
  };
1279
1283
  /**
@@ -1289,7 +1293,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
1289
1293
  protected fPlotHandler: PlotHandler | null;
1290
1294
  protected fUICallback: UIHandler;
1291
1295
  protected fDescriptor: FaustUIInputItem[];
1292
- constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: FaustAudioWorkletNodeOptions<Poly>["processorOptions"], nodeOptions?: Partial<FaustAudioWorkletNodeOptions>);
1296
+ constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial<FaustAudioWorkletNodeOptions<Poly>>);
1293
1297
  /** Setup accelerometer and gyroscope handlers */
1294
1298
  listenSensors(): Promise<void>;
1295
1299
  setOutputParamHandler(handler: OutputParamHandler | null): void;
@@ -1298,6 +1302,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
1298
1302
  getComputeHandler(): ComputeHandler | null;
1299
1303
  setPlotHandler(handler: PlotHandler | null): void;
1300
1304
  getPlotHandler(): PlotHandler | null;
1305
+ setupWamEventHandler(): void;
1301
1306
  getNumInputs(): number;
1302
1307
  getNumOutputs(): number;
1303
1308
  compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
@@ -1325,7 +1330,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
1325
1330
  */
1326
1331
  export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<false> implements IFaustMonoWebAudioDsp {
1327
1332
  onprocessorerror: (e: Event) => never;
1328
- constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, sampleSize: number, nodeOptions?: Partial<FaustAudioWorkletNodeOptions>);
1333
+ constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<false>> & Pick<FaustAudioWorkletNodeOptions<false>, "processorOptions">);
1329
1334
  }
1330
1335
  /**
1331
1336
  * Polyphonic AudioWorkletNode
@@ -1333,7 +1338,7 @@ export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<fal
1333
1338
  export declare class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode<true> implements IFaustPolyWebAudioDsp {
1334
1339
  private fJSONEffect;
1335
1340
  onprocessorerror: (e: Event) => never;
1336
- constructor(context: BaseAudioContext, name: string, voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, sampleSize: number, effectFactory?: LooseFaustDspFactory, nodeOptions?: Partial<FaustAudioWorkletNodeOptions>);
1341
+ constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<true>> & Pick<FaustAudioWorkletNodeOptions<true>, "processorOptions">);
1337
1342
  keyOn(channel: number, pitch: number, velocity: number): void;
1338
1343
  keyOff(channel: number, pitch: number, velocity: number): void;
1339
1344
  allNotesOff(hard: boolean): void;
@@ -1426,9 +1431,10 @@ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
1426
1431
  * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
1427
1432
  * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
1428
1433
  * @param processorName - AudioWorklet Processor name
1434
+ * @param processorOptions - Additional AudioWorklet Processor options
1429
1435
  * @returns the compiled WebAudio node or 'null' if failure
1430
1436
  */
1431
- createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string): Promise<IFaustMonoWebAudioNode | null>;
1437
+ createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<IFaustMonoWebAudioNode | null>;
1432
1438
  /**
1433
1439
  * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1434
1440
  *
@@ -1438,9 +1444,10 @@ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
1438
1444
  * @param factory - default is the compiled factory
1439
1445
  * @param fftOptions - initial FFT options
1440
1446
  * @param processorName - AudioWorklet Processor name
1447
+ * @param processorOptions - Additional AudioWorklet Processor options
1441
1448
  * @returns the compiled WebAudio node or 'null' if failure
1442
1449
  */
1443
- createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
1450
+ createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
1444
1451
  /**
1445
1452
  * Create a monophonic Offline processor.
1446
1453
  *
@@ -1496,9 +1503,10 @@ export interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {
1496
1503
  * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1497
1504
  * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
1498
1505
  * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
1506
+ * @param processorOptions - Additional AudioWorklet Processor options
1499
1507
  * @returns the compiled WebAudio node or 'null' if failure
1500
1508
  */
1501
- createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: boolean, bufferSize?: number, processorName?: string): Promise<IFaustPolyWebAudioNode | null>;
1509
+ createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<IFaustPolyWebAudioNode | null>;
1502
1510
  /**
1503
1511
  * Create a monophonic Offline processor.
1504
1512
  *
@@ -1538,8 +1546,8 @@ export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
1538
1546
  compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<this | null>;
1539
1547
  addSoundfiles(soundfileMap: Record<string, AudioData>): void;
1540
1548
  getSoundfileList(): string[];
1541
- createNode<SP extends boolean = false>(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: SP, bufferSize?: number, processorName?: string): Promise<SP extends true ? FaustMonoScriptProcessorNode | null : FaustMonoAudioWorkletNode | null>;
1542
- createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
1549
+ createNode<SP extends boolean = false>(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: SP, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<SP extends true ? FaustMonoScriptProcessorNode | null : FaustMonoAudioWorkletNode | null>;
1550
+ createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
1543
1551
  createAudioWorkletProcessor(name?: string, factory?: LooseFaustDspFactory, processorName?: string): Promise<{
1544
1552
  new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1545
1553
  prototype: AudioWorkletProcessor;
@@ -1561,7 +1569,7 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
1561
1569
  compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCodeAux?: string): Promise<this | null>;
1562
1570
  addSoundfiles(soundfileMap: Record<string, AudioData>): void;
1563
1571
  getSoundfileList(): string[];
1564
- createNode<SP extends boolean = false>(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: SP, bufferSize?: number, processorName?: string): Promise<SP extends true ? FaustPolyScriptProcessorNode | null : FaustPolyAudioWorkletNode | null>;
1572
+ createNode<SP extends boolean = false>(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: SP, bufferSize?: number, processorName?: string, processorOptions?: {}): Promise<SP extends true ? FaustPolyScriptProcessorNode | null : FaustPolyAudioWorkletNode | null>;
1565
1573
  createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
1566
1574
  new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1567
1575
  prototype: AudioWorkletProcessor;
@@ -6158,6 +6158,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
6158
6158
  parameterDescriptors.forEach((pd) => {
6159
6159
  this.paramValuesCache[pd.name] = pd.defaultValue || 0;
6160
6160
  });
6161
+ const { moduleId, instanceId } = options.processorOptions;
6162
+ if (!moduleId || !instanceId)
6163
+ return;
6164
+ this.wamInfo = { moduleId, instanceId };
6161
6165
  }
6162
6166
  static get parameterDescriptors() {
6163
6167
  const params = [];
@@ -6171,6 +6175,23 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
6171
6175
  FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, callback);
6172
6176
  return params;
6173
6177
  }
6178
+ setupWamEventHandler() {
6179
+ var _a;
6180
+ if (!this.wamInfo)
6181
+ return;
6182
+ const { moduleId, instanceId } = this.wamInfo;
6183
+ const { webAudioModules } = globalThis;
6184
+ const ModuleScope = webAudioModules.getModuleScope(moduleId);
6185
+ const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId];
6186
+ if (!paramMgrProcessor)
6187
+ return;
6188
+ if (paramMgrProcessor.handleEvent)
6189
+ return;
6190
+ paramMgrProcessor.handleEvent = (event) => {
6191
+ if (event.type === "wam-midi")
6192
+ this.midiMessage(event.data.bytes);
6193
+ };
6194
+ }
6174
6195
  process(inputs, outputs, parameters) {
6175
6196
  for (const path in parameters) {
6176
6197
  const [paramValue] = parameters[path];
@@ -6216,6 +6237,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
6216
6237
  }
6217
6238
  break;
6218
6239
  }
6240
+ case "setupWamEventHandler": {
6241
+ this.setupWamEventHandler();
6242
+ break;
6243
+ }
6219
6244
  case "start": {
6220
6245
  this.fDSPCode.start();
6221
6246
  break;
@@ -6425,6 +6450,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
6425
6450
  this.sampleSize = sampleSize;
6426
6451
  this.soundfiles = factory.soundfiles;
6427
6452
  this.initFFT();
6453
+ const { moduleId, instanceId } = options.processorOptions;
6454
+ if (!moduleId || !instanceId)
6455
+ return;
6456
+ this.wamInfo = { moduleId, instanceId };
6428
6457
  }
6429
6458
  get fftProcessorBufferSize() {
6430
6459
  return this.fftSize / 2 + 1;
@@ -6470,6 +6499,23 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
6470
6499
  }
6471
6500
  ];
6472
6501
  }
6502
+ setupWamEventHandler() {
6503
+ var _a;
6504
+ if (!this.wamInfo)
6505
+ return;
6506
+ const { moduleId, instanceId } = this.wamInfo;
6507
+ const { webAudioModules } = globalThis;
6508
+ const ModuleScope = webAudioModules.getModuleScope(moduleId);
6509
+ const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId];
6510
+ if (!paramMgrProcessor)
6511
+ return;
6512
+ if (paramMgrProcessor.handleEvent)
6513
+ return;
6514
+ paramMgrProcessor.handleEvent = (event) => {
6515
+ if (event.type === "wam-midi")
6516
+ this.midiMessage(event.data.bytes);
6517
+ };
6518
+ }
6473
6519
  processFFT() {
6474
6520
  let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;
6475
6521
  while (samplesForFFT >= this.fftSize) {
@@ -6607,6 +6653,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
6607
6653
  (_a = this.fDSPCode) == null ? void 0 : _a.setPlotHandler(this.fPlotHandler);
6608
6654
  break;
6609
6655
  }
6656
+ case "setupWamEventHandler": {
6657
+ this.setupWamEventHandler();
6658
+ break;
6659
+ }
6610
6660
  case "start": {
6611
6661
  (_b = this.fDSPCode) == null ? void 0 : _b.start();
6612
6662
  break;
@@ -9666,7 +9716,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
9666
9716
  // src/FaustAudioWorkletNode.ts
9667
9717
  var _hasAccInput, _hasGyrInput;
9668
9718
  var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) {
9669
- constructor(context, name, factory, options, nodeOptions = {}) {
9719
+ constructor(context, name, factory, options = {}) {
9670
9720
  const JSONObj = JSON.parse(factory.json);
9671
9721
  super(context, name, {
9672
9722
  numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,
@@ -9675,8 +9725,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
9675
9725
  outputChannelCount: [JSONObj.outputs],
9676
9726
  channelCountMode: "explicit",
9677
9727
  channelInterpretation: "speakers",
9678
- processorOptions: options,
9679
- ...nodeOptions
9728
+ processorOptions: options.processorOptions,
9729
+ ...options
9680
9730
  });
9681
9731
  __privateAdd(this, _hasAccInput, false);
9682
9732
  __privateAdd(this, _hasGyrInput, false);
@@ -9716,22 +9766,12 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
9716
9766
  async listenSensors() {
9717
9767
  if (this.hasAccInput) {
9718
9768
  const isAndroid = /Android/i.test(navigator.userAgent);
9719
- let handleDeviceMotion = null;
9720
- if (isAndroid) {
9721
- handleDeviceMotion = ({ accelerationIncludingGravity }) => {
9722
- if (!accelerationIncludingGravity)
9723
- return;
9724
- const { x, y, z } = accelerationIncludingGravity;
9725
- this.propagateAcc({ x, y, z }, true);
9726
- };
9727
- } else {
9728
- handleDeviceMotion = ({ accelerationIncludingGravity }) => {
9729
- if (!accelerationIncludingGravity)
9730
- return;
9731
- const { x, y, z } = accelerationIncludingGravity;
9732
- this.propagateAcc({ x, y, z });
9733
- };
9734
- }
9769
+ const handleDeviceMotion = ({ accelerationIncludingGravity }) => {
9770
+ if (!accelerationIncludingGravity)
9771
+ return;
9772
+ const { x, y, z } = accelerationIncludingGravity;
9773
+ this.propagateAcc({ x, y, z }, isAndroid);
9774
+ };
9735
9775
  if (window.DeviceMotionEvent) {
9736
9776
  if (typeof window.DeviceMotionEvent.requestPermission === "function") {
9737
9777
  try {
@@ -9794,6 +9834,9 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
9794
9834
  getPlotHandler() {
9795
9835
  return this.fPlotHandler;
9796
9836
  }
9837
+ setupWamEventHandler() {
9838
+ this.port.postMessage({ type: "setupWamEventHandler" });
9839
+ }
9797
9840
  getNumInputs() {
9798
9841
  return this.fJSONDsp.inputs;
9799
9842
  }
@@ -9887,33 +9930,25 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
9887
9930
  _hasAccInput = new WeakMap();
9888
9931
  _hasGyrInput = new WeakMap();
9889
9932
  var FaustMonoAudioWorkletNode = class extends FaustAudioWorkletNode {
9890
- constructor(context, name, factory, sampleSize, nodeOptions = {}) {
9891
- super(context, name, factory, { name, factory, sampleSize }, nodeOptions);
9933
+ constructor(context, options) {
9934
+ super(context, options.processorOptions.name, options.processorOptions.factory, options);
9892
9935
  this.onprocessorerror = (e) => {
9893
9936
  throw e;
9894
9937
  };
9895
9938
  }
9896
9939
  };
9897
9940
  var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode {
9898
- constructor(context, name, voiceFactory, mixerModule, voices, sampleSize, effectFactory, nodeOptions = {}) {
9941
+ constructor(context, options) {
9899
9942
  super(
9900
9943
  context,
9901
- name,
9902
- voiceFactory,
9903
- {
9904
- name,
9905
- voiceFactory,
9906
- mixerModule,
9907
- voices,
9908
- sampleSize,
9909
- effectFactory
9910
- },
9911
- nodeOptions
9944
+ options.processorOptions.name,
9945
+ options.processorOptions.voiceFactory,
9946
+ options
9912
9947
  );
9913
9948
  this.onprocessorerror = (e) => {
9914
9949
  throw e;
9915
9950
  };
9916
- this.fJSONEffect = effectFactory ? JSON.parse(effectFactory.json) : null;
9951
+ this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;
9917
9952
  if (this.fJSONEffect) {
9918
9953
  FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);
9919
9954
  }
@@ -9985,22 +10020,12 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
9985
10020
  async listenSensors() {
9986
10021
  if (this.hasAccInput) {
9987
10022
  const isAndroid = /Android/i.test(navigator.userAgent);
9988
- let handleDeviceMotion = null;
9989
- if (isAndroid) {
9990
- handleDeviceMotion = ({ accelerationIncludingGravity }) => {
9991
- if (!accelerationIncludingGravity)
9992
- return;
9993
- const { x, y, z } = accelerationIncludingGravity;
9994
- this.propagateAcc({ x, y, z }, true);
9995
- };
9996
- } else {
9997
- handleDeviceMotion = ({ accelerationIncludingGravity }) => {
9998
- if (!accelerationIncludingGravity)
9999
- return;
10000
- const { x, y, z } = accelerationIncludingGravity;
10001
- this.propagateAcc({ x, y, z });
10002
- };
10003
- }
10023
+ const handleDeviceMotion = ({ accelerationIncludingGravity }) => {
10024
+ if (!accelerationIncludingGravity)
10025
+ return;
10026
+ const { x, y, z } = accelerationIncludingGravity;
10027
+ this.propagateAcc({ x, y, z }, isAndroid);
10028
+ };
10004
10029
  if (window.DeviceMotionEvent) {
10005
10030
  if (typeof window.DeviceMotionEvent.requestPermission === "function") {
10006
10031
  try {
@@ -10163,7 +10188,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
10163
10188
  const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
10164
10189
  return Object.keys(map);
10165
10190
  }
10166
- async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name) {
10191
+ async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name, processorOptions = {}) {
10167
10192
  var _a, _b;
10168
10193
  if (!factory)
10169
10194
  throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
@@ -10221,11 +10246,11 @@ const dependencies = {
10221
10246
  throw e;
10222
10247
  }
10223
10248
  }
10224
- const node = new FaustMonoAudioWorkletNode(context, processorName, factory, sampleSize);
10249
+ const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });
10225
10250
  return node;
10226
10251
  }
10227
10252
  }
10228
- async createFFTNode(context, fftUtils, name = this.name, factory = this.factory, fftOptions = {}, processorName = (factory == null ? void 0 : factory.shaKey) ? `${factory.shaKey}_fft` : name) {
10253
+ async createFFTNode(context, fftUtils, name = this.name, factory = this.factory, fftOptions = {}, processorName = (factory == null ? void 0 : factory.shaKey) ? `${factory.shaKey}_fft` : name, processorOptions = {}) {
10229
10254
  var _a, _b;
10230
10255
  if (!factory)
10231
10256
  throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
@@ -10277,7 +10302,7 @@ const dependencies = {
10277
10302
  throw e;
10278
10303
  }
10279
10304
  }
10280
- const node = new FaustMonoAudioWorkletNode(context, processorName, factory, sampleSize, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)] });
10305
+ 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 } });
10281
10306
  if (fftOptions.fftSize) {
10282
10307
  const param = node.parameters.get("fftSize");
10283
10308
  if (param)
@@ -10439,7 +10464,7 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
10439
10464
  const effectMap = SoundfileReader_default.findSoundfilesFromMeta(effectMeta);
10440
10465
  return Object.keys({ ...effectMap, ...map });
10441
10466
  }
10442
- 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`) {
10467
+ 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 = {}) {
10443
10468
  var _a, _b;
10444
10469
  if (!voiceFactory)
10445
10470
  throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
@@ -10504,7 +10529,7 @@ const dependencies = {
10504
10529
  throw e;
10505
10530
  }
10506
10531
  }
10507
- const node = new FaustPolyAudioWorkletNode(context, processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory || void 0);
10532
+ const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || void 0, ...processorOptions } });
10508
10533
  return node;
10509
10534
  }
10510
10535
  }