@grame/faustwasm 0.0.56 → 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 +64 -22
  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 +64 -22
  18. package/dist/esm-bundle/index.js.map +2 -2
  19. package/libfaust-wasm/libfaust-wasm.wasm +0 -0
  20. package/package.json +1 -1
  21. package/src/FaustDspGenerator.ts +70 -23
  22. package/test/bug/bug.html +84 -0
  23. package/test/bug/bug.js +216 -0
  24. package/test/bug/bug.json +122 -0
  25. package/test/bug/bug.wasm +0 -0
  26. package/test/bug/bug_effect.json +92 -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 +3879 -0
  35. package/test/bug/faustwasm/index.js.map +7 -0
  36. package/test/bug/mixerModule.wasm +0 -0
  37. package/test/bug1 +0 -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/midi.dsp +0 -1
  47. package/test/t1.dsp +0 -1
@@ -0,0 +1,122 @@
1
+ From 5c99c8c6e3c97d8dcab29f7569c527c1b3ebc537 Mon Sep 17 00:00:00 2001
2
+ From: Stephane Letz <letz@grame.fr>
3
+ Date: Fri, 9 Feb 2024 18:05:34 +0100
4
+ Subject: [PATCH] Rework polyphonic + effect mode.
5
+
6
+ ---
7
+ src/FaustDspGenerator.ts | 93 ++++++++++++++++++++++++++++++----------
8
+ 1 file changed, 70 insertions(+), 23 deletions(-)
9
+
10
+ diff --git a/src/FaustDspGenerator.ts b/src/FaustDspGenerator.ts
11
+ index dd09044..f52c5a8 100644
12
+ --- a/src/FaustDspGenerator.ts
13
+ +++ b/src/FaustDspGenerator.ts
14
+ @@ -395,35 +395,82 @@ export class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
15
+ async compile(
16
+ compiler: IFaustCompiler,
17
+ name: string,
18
+ - dspCode: string,
19
+ + dspCodeAux: string,
20
+ args: string,
21
+ - // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile
22
+ - effectCode = `
23
+ - adapt(1,1) = _;
24
+ - adapt(2,2) = _,_;
25
+ - adapt(1,2) = _ <: _,_;
26
+ - adapt(2,1) = _,_ :> _;
27
+ - adaptor(F,G) = adapt(outputs(F),inputs(G));
28
+ - dsp_code = environment{
29
+ - ${dspCode}
30
+ + // The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile
31
+ + effectCodeAux = `dsp_code = environment{
32
+ + ${dspCodeAux}
33
+ };
34
+ - process = adaptor(dsp_code.process, dsp_code.effect) : dsp_code.effect;`
35
+ + process = dsp_code.effect;`
36
+ ) {
37
+ - this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
38
+ - if (!this.voiceFactory) return null;
39
+ - // Compile effect, possibly failing
40
+ + // Try to compile effect, possibly failing
41
+ try {
42
+ - this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args);
43
+ + this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);
44
+ + // Since the effect is processing the same buffers for inputs and outputs (in place processing),
45
+ + // the voice and effect are adapted, possibly clearing buffers
46
+ + if (this.effectFactory) {
47
+ + const effectJSON = JSON.parse(this.effectFactory.json);
48
+ + const dspCode = `
49
+ + // Voice output is forced to 2 as soon as effect has 2 ins or 2 outs,
50
+ + // so that the effect can process the 2 channels of the voice
51
+ + adaptOut(1,1,1) = _;
52
+ + adaptOut(1,1,2) = _ <: _,_;
53
+ + adaptOut(1,2,1) = _ <: _,_;
54
+ + adaptOut(1,2,2) = _ <: _,_;
55
+ + adaptOut(2,1,1) = _,_ :> _;
56
+ + adaptOut(2,1,2) = _,_;
57
+ + adaptOut(2,2,1) = _,_;
58
+ + adaptOut(2,2,2) = _,_;
59
+ + adaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
60
+ + dsp_code = environment{
61
+ + ${dspCodeAux}
62
+ + };
63
+ + process = dsp_code.process : adaptor(dsp_code.process);`
64
+ + const effectCode = `
65
+ + // Inputs
66
+ + adaptIn(1,1,1) = _;
67
+ + adaptIn(1,1,2) = _,*(0) :> _; // The voice output was duplicated, so only one channel has to be kept
68
+ + adaptIn(1,2,1) = _,_;
69
+ + adaptIn(1,2,2) = _,_;
70
+ + adaptIn(2,1,1) = _,_ :> _;
71
+ + adaptIn(2,1,2) = _,_ :> _;
72
+ + adaptIn(2,2,1) = _,_;
73
+ + adaptIn(2,2,2) = _,_;
74
+ + // Outputs
75
+ + adaptOut(1,1) = _;
76
+ + adaptOut(1,2) = _,_;
77
+ + adaptOut(2,1) = _ <: _,*(0); // The left channel is kept, and the right one has to be cleared
78
+ + adaptOut(2,2) = _,_;
79
+ + adaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
80
+ + adaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});
81
+ + dsp_code = environment{
82
+ + ${dspCodeAux}
83
+ + };
84
+ + process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;`
85
+ + this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
86
+ + try {
87
+ + // Effect is processing same buffers for inputs and outputs, so has to use -inpl option
88
+ + this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + " -inpl");
89
+ + } catch (e) {
90
+ + console.log(e);
91
+ + }
92
+ + }
93
+ } catch (e) {
94
+ - console.warn(e);
95
+ + console.log(e);
96
+ + this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);
97
+ + }
98
+ +
99
+ + if (this.voiceFactory) {
100
+ + this.name = name;
101
+ + const voiceMeta = JSON.parse(this.voiceFactory.json);
102
+ + const isDouble = voiceMeta.compile_options.match("-double");
103
+ + const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);
104
+ + this.mixerBuffer = mixerBuffer;
105
+ + this.mixerModule = mixerModule;
106
+ + return this;
107
+ + } else {
108
+ + return null;
109
+ }
110
+ - this.name = name;
111
+ - const voiceMeta = JSON.parse(this.voiceFactory.json);
112
+ - const isDouble = voiceMeta.compile_options.match("-double");
113
+ - const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);
114
+ - this.mixerBuffer = mixerBuffer;
115
+ - this.mixerModule = mixerModule;
116
+ - return this;
117
+ }
118
+
119
+ async createNode<SP extends boolean = false>(
120
+ --
121
+ 2.32.0 (Apple Git-132)
122
+
@@ -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;
@@ -3636,31 +3636,73 @@ var _FaustPolyDspGenerator = class {
3636
3636
  this.voiceFactory = null;
3637
3637
  this.effectFactory = null;
3638
3638
  }
3639
- async compile(compiler, name, dspCode, args, effectCode = `
3640
- adapt(1,1) = _;
3641
- adapt(2,2) = _,_;
3642
- adapt(1,2) = _ <: _,_;
3643
- adapt(2,1) = _,_ :> _;
3644
- adaptor(F,G) = adapt(outputs(F),inputs(G));
3645
- dsp_code = environment{
3646
- ${dspCode}
3639
+ async compile(compiler, name, dspCodeAux, args, effectCodeAux = `dsp_code = environment{
3640
+ ${dspCodeAux}
3647
3641
  };
3648
- process = adaptor(dsp_code.process, dsp_code.effect) : dsp_code.effect;`) {
3649
- this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
3650
- if (!this.voiceFactory)
3651
- return null;
3642
+ process = dsp_code.effect;`) {
3652
3643
  try {
3653
- this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args);
3644
+ this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);
3645
+ if (this.effectFactory) {
3646
+ const effectJSON = JSON.parse(this.effectFactory.json);
3647
+ const dspCode = `
3648
+ // Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,
3649
+ // so that the effect can process the 2 channels of the voice
3650
+ adaptOut(1,1,1) = _;
3651
+ adaptOut(1,1,2) = _ <: _,_;
3652
+ adaptOut(1,2,1) = _ <: _,_;
3653
+ adaptOut(1,2,2) = _ <: _,_;
3654
+ adaptOut(2,1,1) = _,_;
3655
+ adaptOut(2,1,2) = _,_;
3656
+ adaptOut(2,2,1) = _,_;
3657
+ adaptOut(2,2,2) = _,_;
3658
+ adaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
3659
+ dsp_code = environment{
3660
+ ${dspCodeAux}
3661
+ };
3662
+ process = dsp_code.process : adaptor(dsp_code.process);`;
3663
+ const effectCode = `
3664
+ // Inputs
3665
+ adaptIn(1,1,1) = _;
3666
+ adaptIn(1,1,2) = _,*(0) :> _; // The voice output was duplicated, so only one channel has to be kept
3667
+ adaptIn(1,2,1) = _,_;
3668
+ adaptIn(1,2,2) = _,_;
3669
+ adaptIn(2,1,1) = _,_ :> _;
3670
+ adaptIn(2,1,2) = _,_ :> _;
3671
+ adaptIn(2,2,1) = _,_;
3672
+ adaptIn(2,2,2) = _,_;
3673
+ // Outputs
3674
+ adaptOut(1,1) = _ <: _,*(0); // The left channel is kept, but the right one has to be cleared
3675
+ adaptOut(1,2) = _,_;
3676
+ adaptOut(2,1) = _ <: _,*(0); // The left channel is kept, but the right one has to be cleared
3677
+ adaptOut(2,2) = _,_;
3678
+ adaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
3679
+ adaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});
3680
+ dsp_code = environment{
3681
+ ${dspCodeAux}
3682
+ };
3683
+ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;`;
3684
+ this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
3685
+ try {
3686
+ this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + " -inpl");
3687
+ } catch (e) {
3688
+ console.log(e);
3689
+ }
3690
+ }
3654
3691
  } catch (e) {
3655
- console.warn(e);
3692
+ console.log(e);
3693
+ this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);
3694
+ }
3695
+ if (this.voiceFactory) {
3696
+ this.name = name;
3697
+ const voiceMeta = JSON.parse(this.voiceFactory.json);
3698
+ const isDouble = voiceMeta.compile_options.match("-double");
3699
+ const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);
3700
+ this.mixerBuffer = mixerBuffer;
3701
+ this.mixerModule = mixerModule;
3702
+ return this;
3703
+ } else {
3704
+ return null;
3656
3705
  }
3657
- this.name = name;
3658
- const voiceMeta = JSON.parse(this.voiceFactory.json);
3659
- const isDouble = voiceMeta.compile_options.match("-double");
3660
- const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);
3661
- this.mixerBuffer = mixerBuffer;
3662
- this.mixerModule = mixerModule;
3663
- return this;
3664
3706
  }
3665
3707
  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`) {
3666
3708
  var _a, _b;