@grame/faustwasm 0.0.57 → 0.0.59

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 (50) hide show
  1. package/0001-Rework-polyphonic-effect-mode.patch +122 -0
  2. package/assets/standalone/faustwasm/index.d.ts +1 -1
  3. package/assets/standalone/faustwasm/index.js +63 -21
  4. package/assets/standalone/faustwasm/index.js.map +2 -2
  5. package/assets/standalone/index-poly.js +2 -1
  6. package/assets/standalone/index.js +2 -1
  7. package/dist/cjs/index.d.ts +1 -1
  8. package/dist/cjs/index.js +63 -21
  9. package/dist/cjs/index.js.map +2 -2
  10. package/dist/cjs-bundle/index.d.ts +1 -1
  11. package/dist/cjs-bundle/index.js +63 -21
  12. package/dist/cjs-bundle/index.js.map +2 -2
  13. package/dist/esm/index.d.ts +1 -1
  14. package/dist/esm/index.js +63 -21
  15. package/dist/esm/index.js.map +2 -2
  16. package/dist/esm-bundle/index.d.ts +1 -1
  17. package/dist/esm-bundle/index.js +63 -21
  18. package/dist/esm-bundle/index.js.map +2 -2
  19. package/package.json +1 -1
  20. package/src/FaustDspGenerator.ts +70 -23
  21. package/src/faust2wasmFiles.js +1 -1
  22. package/test/bug/bug.html +84 -0
  23. package/test/bug/bug.js +216 -0
  24. package/test/bug/bug.json +124 -0
  25. package/test/bug/bug.wasm +0 -0
  26. package/test/bug/bug_effect.json +95 -0
  27. package/test/bug/bug_effect.wasm +0 -0
  28. package/test/bug/faust-ui/index.css +416 -0
  29. package/test/bug/faust-ui/index.css.map +1 -0
  30. package/test/bug/faust-ui/index.d.ts +1 -0
  31. package/test/bug/faust-ui/index.js +3476 -0
  32. package/test/bug/faust-ui/index.js.map +1 -0
  33. package/test/bug/faustwasm/index.d.ts +1294 -0
  34. package/test/bug/faustwasm/index.js +3874 -0
  35. package/test/bug/faustwasm/index.js.map +7 -0
  36. package/test/bug/mixerModule.wasm +0 -0
  37. package/test/bug.dsp +22 -0
  38. package/test/clarinet.dsp +2 -1
  39. package/test/{p-dj.dsp → djembe.dsp} +0 -2
  40. package/test/faustlive-wasm/faustwasm/index.d.ts +1 -1
  41. package/test/faustlive-wasm/faustwasm/index.js +63 -21
  42. package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
  43. package/test/gain.dsp +2 -0
  44. package/test/guitar.dsp +2 -1
  45. package/test/guitar1.dsp +2 -1
  46. package/test/libfaust-in-worklet/index.js +33 -33
  47. package/test/midi.dsp +0 -1
  48. package/test/web/index.js +217 -217
  49. package/test/Sinusoide.dsp +0 -60
  50. package/test/t1.dsp +0 -1
@@ -22,7 +22,8 @@ const $divFaustUI = document.getElementById("div-faust-ui");
22
22
 
23
23
  /** @type {typeof AudioContext} */
24
24
  const AudioCtx = window.AudioContext || window.webkitAudioContext;
25
- const audioContext = new AudioCtx();
25
+ const audioContext = new AudioCtx({ latencyHint: 0.00001 });
26
+ audioContext.destination.channelInterpretation = "discrete";
26
27
  audioContext.suspend();
27
28
 
28
29
  /**
@@ -22,7 +22,8 @@ const $divFaustUI = document.getElementById("div-faust-ui");
22
22
 
23
23
  /** @type {typeof AudioContext} */
24
24
  const AudioCtx = window.AudioContext || window.webkitAudioContext;
25
- const audioContext = new AudioCtx();
25
+ const audioContext = new AudioCtx({ latencyHint: 0.00001 });
26
+ audioContext.destination.channelInterpretation = "discrete";
26
27
  audioContext.suspend();
27
28
 
28
29
  /**
@@ -1278,7 +1278,7 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
1278
1278
  mixerBuffer: Uint8Array;
1279
1279
  mixerModule: WebAssembly.Module;
1280
1280
  constructor();
1281
- compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<this | null>;
1281
+ compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCodeAux?: string): Promise<this | null>;
1282
1282
  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>;
1283
1283
  createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
1284
1284
  new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
package/dist/cjs/index.js CHANGED
@@ -3644,31 +3644,73 @@ const dependencies = {
3644
3644
  this.voiceFactory = null;
3645
3645
  this.effectFactory = null;
3646
3646
  }
3647
- async compile(compiler, name, dspCode, args, effectCode = `
3648
- adapt(1,1) = _;
3649
- adapt(2,2) = _,_;
3650
- adapt(1,2) = _ <: _,_;
3651
- adapt(2,1) = _,_ :> _;
3652
- adaptor(F,G) = adapt(outputs(F),inputs(G));
3653
- dsp_code = environment{
3654
- ${dspCode}
3647
+ async compile(compiler, name, dspCodeAux, args, effectCodeAux = `dsp_code = environment{
3648
+ ${dspCodeAux}
3655
3649
  };
3656
- process = adaptor(dsp_code.process, dsp_code.effect) : dsp_code.effect;`) {
3657
- this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
3658
- if (!this.voiceFactory)
3659
- return null;
3650
+ process = dsp_code.effect;`) {
3660
3651
  try {
3661
- this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args);
3652
+ this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);
3653
+ if (this.effectFactory) {
3654
+ const effectJSON = JSON.parse(this.effectFactory.json);
3655
+ const dspCode = `
3656
+ // Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,
3657
+ // so that the effect can process the 2 channels of the voice
3658
+ adaptOut(1,1,1) = _;
3659
+ adaptOut(1,1,2) = _ <: _,_;
3660
+ adaptOut(1,2,1) = _ <: _,_;
3661
+ adaptOut(1,2,2) = _ <: _,_;
3662
+ adaptOut(2,1,1) = _,_;
3663
+ adaptOut(2,1,2) = _,_;
3664
+ adaptOut(2,2,1) = _,_;
3665
+ adaptOut(2,2,2) = _,_;
3666
+ adaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
3667
+ dsp_code = environment{
3668
+ ${dspCodeAux}
3669
+ };
3670
+ process = dsp_code.process : adaptor(dsp_code.process);`;
3671
+ const effectCode = `
3672
+ // Inputs
3673
+ adaptIn(1,1,1) = _;
3674
+ adaptIn(1,1,2) = _,*(0) :> _; // The voice output was duplicated, so only one channel has to be kept
3675
+ adaptIn(1,2,1) = _,_;
3676
+ adaptIn(1,2,2) = _,_;
3677
+ adaptIn(2,1,1) = _,_ :> _;
3678
+ adaptIn(2,1,2) = _,_ :> _;
3679
+ adaptIn(2,2,1) = _,_;
3680
+ adaptIn(2,2,2) = _,_;
3681
+ // Outputs
3682
+ adaptOut(1,1) = _ <: _,*(0); // The left channel is kept, but the right one has to be cleared
3683
+ adaptOut(1,2) = _,_;
3684
+ adaptOut(2,1) = _ <: _,*(0); // The left channel is kept, but the right one has to be cleared
3685
+ adaptOut(2,2) = _,_;
3686
+ adaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
3687
+ adaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});
3688
+ dsp_code = environment{
3689
+ ${dspCodeAux}
3690
+ };
3691
+ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;`;
3692
+ this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
3693
+ try {
3694
+ this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + " -inpl");
3695
+ } catch (e) {
3696
+ console.log(e);
3697
+ }
3698
+ }
3662
3699
  } catch (e) {
3663
- console.warn(e);
3700
+ console.log(e);
3701
+ this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);
3702
+ }
3703
+ if (this.voiceFactory) {
3704
+ this.name = name;
3705
+ const voiceMeta = JSON.parse(this.voiceFactory.json);
3706
+ const isDouble = voiceMeta.compile_options.match("-double");
3707
+ const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);
3708
+ this.mixerBuffer = mixerBuffer;
3709
+ this.mixerModule = mixerModule;
3710
+ return this;
3711
+ } else {
3712
+ return null;
3664
3713
  }
3665
- this.name = name;
3666
- const voiceMeta = JSON.parse(this.voiceFactory.json);
3667
- const isDouble = voiceMeta.compile_options.match("-double");
3668
- const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);
3669
- this.mixerBuffer = mixerBuffer;
3670
- this.mixerModule = mixerModule;
3671
- return this;
3672
3714
  }
3673
3715
  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`) {
3674
3716
  var _a, _b;