@grame/faustwasm 0.0.62 → 0.0.64

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grame/faustwasm",
3
- "version": "0.0.62",
3
+ "version": "0.0.64",
4
4
  "description": "WebAssembly version of Faust Compiler",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -1,122 +0,0 @@
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
-
package/test/gain.dsp DELETED
@@ -1,2 +0,0 @@
1
- gain = hslider("Vol",0.5,0,1,0.01);
2
- process = *(gain),*(gain);