@grame/faustwasm 0.0.57 → 0.0.58

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 (47) 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/test/bug/bug.html +84 -0
  22. package/test/bug/bug.js +216 -0
  23. package/test/bug/bug.json +122 -0
  24. package/test/bug/bug.wasm +0 -0
  25. package/test/bug/bug_effect.json +92 -0
  26. package/test/bug/bug_effect.wasm +0 -0
  27. package/test/bug/faust-ui/index.css +416 -0
  28. package/test/bug/faust-ui/index.css.map +1 -0
  29. package/test/bug/faust-ui/index.d.ts +1 -0
  30. package/test/bug/faust-ui/index.js +3476 -0
  31. package/test/bug/faust-ui/index.js.map +1 -0
  32. package/test/bug/faustwasm/index.d.ts +1294 -0
  33. package/test/bug/faustwasm/index.js +3879 -0
  34. package/test/bug/faustwasm/index.js.map +7 -0
  35. package/test/bug/mixerModule.wasm +0 -0
  36. package/test/bug1 +0 -0
  37. package/test/clarinet.dsp +2 -1
  38. package/test/{p-dj.dsp → djembe.dsp} +0 -2
  39. package/test/faustlive-wasm/faustwasm/index.d.ts +1 -1
  40. package/test/faustlive-wasm/faustwasm/index.js +63 -21
  41. package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
  42. package/test/gain.dsp +2 -0
  43. package/test/guitar.dsp +2 -1
  44. package/test/guitar1.dsp +2 -1
  45. package/test/midi.dsp +0 -1
  46. package/test/Sinusoide.dsp +0 -60
  47. 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;
@@ -9624,31 +9624,73 @@ var _FaustPolyDspGenerator = class {
9624
9624
  this.voiceFactory = null;
9625
9625
  this.effectFactory = null;
9626
9626
  }
9627
- async compile(compiler, name, dspCode, args, effectCode = `
9628
- adapt(1,1) = _;
9629
- adapt(2,2) = _,_;
9630
- adapt(1,2) = _ <: _,_;
9631
- adapt(2,1) = _,_ :> _;
9632
- adaptor(F,G) = adapt(outputs(F),inputs(G));
9633
- dsp_code = environment{
9634
- ${dspCode}
9627
+ async compile(compiler, name, dspCodeAux, args, effectCodeAux = `dsp_code = environment{
9628
+ ${dspCodeAux}
9635
9629
  };
9636
- process = adaptor(dsp_code.process, dsp_code.effect) : dsp_code.effect;`) {
9637
- this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
9638
- if (!this.voiceFactory)
9639
- return null;
9630
+ process = dsp_code.effect;`) {
9640
9631
  try {
9641
- this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args);
9632
+ this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);
9633
+ if (this.effectFactory) {
9634
+ const effectJSON = JSON.parse(this.effectFactory.json);
9635
+ const dspCode = `
9636
+ // Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,
9637
+ // so that the effect can process the 2 channels of the voice
9638
+ adaptOut(1,1,1) = _;
9639
+ adaptOut(1,1,2) = _ <: _,_;
9640
+ adaptOut(1,2,1) = _ <: _,_;
9641
+ adaptOut(1,2,2) = _ <: _,_;
9642
+ adaptOut(2,1,1) = _,_;
9643
+ adaptOut(2,1,2) = _,_;
9644
+ adaptOut(2,2,1) = _,_;
9645
+ adaptOut(2,2,2) = _,_;
9646
+ adaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
9647
+ dsp_code = environment{
9648
+ ${dspCodeAux}
9649
+ };
9650
+ process = dsp_code.process : adaptor(dsp_code.process);`;
9651
+ const effectCode = `
9652
+ // Inputs
9653
+ adaptIn(1,1,1) = _;
9654
+ adaptIn(1,1,2) = _,*(0) :> _; // The voice output was duplicated, so only one channel has to be kept
9655
+ adaptIn(1,2,1) = _,_;
9656
+ adaptIn(1,2,2) = _,_;
9657
+ adaptIn(2,1,1) = _,_ :> _;
9658
+ adaptIn(2,1,2) = _,_ :> _;
9659
+ adaptIn(2,2,1) = _,_;
9660
+ adaptIn(2,2,2) = _,_;
9661
+ // Outputs
9662
+ adaptOut(1,1) = _ <: _,*(0); // The left channel is kept, but the right one has to be cleared
9663
+ adaptOut(1,2) = _,_;
9664
+ adaptOut(2,1) = _ <: _,*(0); // The left channel is kept, but the right one has to be cleared
9665
+ adaptOut(2,2) = _,_;
9666
+ adaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
9667
+ adaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});
9668
+ dsp_code = environment{
9669
+ ${dspCodeAux}
9670
+ };
9671
+ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;`;
9672
+ this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
9673
+ try {
9674
+ this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + " -inpl");
9675
+ } catch (e) {
9676
+ console.log(e);
9677
+ }
9678
+ }
9642
9679
  } catch (e) {
9643
- console.warn(e);
9680
+ console.log(e);
9681
+ this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);
9682
+ }
9683
+ if (this.voiceFactory) {
9684
+ this.name = name;
9685
+ const voiceMeta = JSON.parse(this.voiceFactory.json);
9686
+ const isDouble = voiceMeta.compile_options.match("-double");
9687
+ const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);
9688
+ this.mixerBuffer = mixerBuffer;
9689
+ this.mixerModule = mixerModule;
9690
+ return this;
9691
+ } else {
9692
+ return null;
9644
9693
  }
9645
- this.name = name;
9646
- const voiceMeta = JSON.parse(this.voiceFactory.json);
9647
- const isDouble = voiceMeta.compile_options.match("-double");
9648
- const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);
9649
- this.mixerBuffer = mixerBuffer;
9650
- this.mixerModule = mixerModule;
9651
- return this;
9652
9694
  }
9653
9695
  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`) {
9654
9696
  var _a, _b;