@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
@@ -1285,7 +1285,7 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
1285
1285
  mixerBuffer: Uint8Array;
1286
1286
  mixerModule: WebAssembly.Module;
1287
1287
  constructor();
1288
- compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<this | null>;
1288
+ compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCodeAux?: string): Promise<this | null>;
1289
1289
  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>;
1290
1290
  createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
1291
1291
  new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
@@ -9661,31 +9661,73 @@ const dependencies = {
9661
9661
  this.voiceFactory = null;
9662
9662
  this.effectFactory = null;
9663
9663
  }
9664
- async compile(compiler, name, dspCode, args, effectCode = `
9665
- adapt(1,1) = _;
9666
- adapt(2,2) = _,_;
9667
- adapt(1,2) = _ <: _,_;
9668
- adapt(2,1) = _,_ :> _;
9669
- adaptor(F,G) = adapt(outputs(F),inputs(G));
9670
- dsp_code = environment{
9671
- ${dspCode}
9664
+ async compile(compiler, name, dspCodeAux, args, effectCodeAux = `dsp_code = environment{
9665
+ ${dspCodeAux}
9672
9666
  };
9673
- process = adaptor(dsp_code.process, dsp_code.effect) : dsp_code.effect;`) {
9674
- this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
9675
- if (!this.voiceFactory)
9676
- return null;
9667
+ process = dsp_code.effect;`) {
9677
9668
  try {
9678
- this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args);
9669
+ this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);
9670
+ if (this.effectFactory) {
9671
+ const effectJSON = JSON.parse(this.effectFactory.json);
9672
+ const dspCode = `
9673
+ // Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,
9674
+ // so that the effect can process the 2 channels of the voice
9675
+ adaptOut(1,1,1) = _;
9676
+ adaptOut(1,1,2) = _ <: _,_;
9677
+ adaptOut(1,2,1) = _ <: _,_;
9678
+ adaptOut(1,2,2) = _ <: _,_;
9679
+ adaptOut(2,1,1) = _,_;
9680
+ adaptOut(2,1,2) = _,_;
9681
+ adaptOut(2,2,1) = _,_;
9682
+ adaptOut(2,2,2) = _,_;
9683
+ adaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
9684
+ dsp_code = environment{
9685
+ ${dspCodeAux}
9686
+ };
9687
+ process = dsp_code.process : adaptor(dsp_code.process);`;
9688
+ const effectCode = `
9689
+ // Inputs
9690
+ adaptIn(1,1,1) = _;
9691
+ adaptIn(1,1,2) = _,*(0) :> _; // The voice output was duplicated, so only one channel has to be kept
9692
+ adaptIn(1,2,1) = _,_;
9693
+ adaptIn(1,2,2) = _,_;
9694
+ adaptIn(2,1,1) = _,_ :> _;
9695
+ adaptIn(2,1,2) = _,_ :> _;
9696
+ adaptIn(2,2,1) = _,_;
9697
+ adaptIn(2,2,2) = _,_;
9698
+ // Outputs
9699
+ adaptOut(1,1) = _ <: _,*(0); // The left channel is kept, but the right one has to be cleared
9700
+ adaptOut(1,2) = _,_;
9701
+ adaptOut(2,1) = _ <: _,*(0); // The left channel is kept, but the right one has to be cleared
9702
+ adaptOut(2,2) = _,_;
9703
+ adaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
9704
+ adaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});
9705
+ dsp_code = environment{
9706
+ ${dspCodeAux}
9707
+ };
9708
+ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;`;
9709
+ this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
9710
+ try {
9711
+ this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + " -inpl");
9712
+ } catch (e) {
9713
+ console.log(e);
9714
+ }
9715
+ }
9679
9716
  } catch (e) {
9680
- console.warn(e);
9717
+ console.log(e);
9718
+ this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);
9719
+ }
9720
+ if (this.voiceFactory) {
9721
+ this.name = name;
9722
+ const voiceMeta = JSON.parse(this.voiceFactory.json);
9723
+ const isDouble = voiceMeta.compile_options.match("-double");
9724
+ const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);
9725
+ this.mixerBuffer = mixerBuffer;
9726
+ this.mixerModule = mixerModule;
9727
+ return this;
9728
+ } else {
9729
+ return null;
9681
9730
  }
9682
- this.name = name;
9683
- const voiceMeta = JSON.parse(this.voiceFactory.json);
9684
- const isDouble = voiceMeta.compile_options.match("-double");
9685
- const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);
9686
- this.mixerBuffer = mixerBuffer;
9687
- this.mixerModule = mixerModule;
9688
- return this;
9689
9731
  }
9690
9732
  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`) {
9691
9733
  var _a, _b;