@grame/faustwasm 0.12.2 → 0.13.0

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 (81) hide show
  1. package/.prettierrc +5 -0
  2. package/README.md +21 -3
  3. package/assets/standalone/faustwasm/index.d.ts +38 -16
  4. package/assets/standalone/faustwasm/index.js +1574 -404
  5. package/assets/standalone/faustwasm/index.js.map +2 -2
  6. package/dist/cjs/index.d.ts +38 -16
  7. package/dist/cjs/index.js +1573 -404
  8. package/dist/cjs/index.js.map +2 -2
  9. package/dist/cjs-bundle/index.d.ts +38 -16
  10. package/dist/cjs-bundle/index.js +1576 -406
  11. package/dist/cjs-bundle/index.js.map +2 -2
  12. package/dist/esm/index.d.ts +38 -16
  13. package/dist/esm/index.js +1574 -404
  14. package/dist/esm/index.js.map +2 -2
  15. package/dist/esm-bundle/index.d.ts +38 -16
  16. package/dist/esm-bundle/index.js +1576 -406
  17. package/dist/esm-bundle/index.js.map +2 -2
  18. package/eslint.config.js +11 -0
  19. package/package.json +57 -51
  20. package/sound.cpp +163 -0
  21. package/sound.dsp +4 -0
  22. package/sound.json +1 -0
  23. package/sound.wasm +0 -0
  24. package/src/FaustAudioWorkletCommunicator.ts +150 -143
  25. package/src/FaustAudioWorkletNode.ts +173 -75
  26. package/src/FaustAudioWorkletProcessor.ts +218 -90
  27. package/src/FaustCmajor.ts +9 -3
  28. package/src/FaustCompiler.ts +112 -35
  29. package/src/FaustDspGenerator.ts +561 -117
  30. package/src/FaustDspInstance.ts +58 -24
  31. package/src/FaustFFTAudioWorkletProcessor.ts +822 -612
  32. package/src/FaustOfflineProcessor.ts +187 -56
  33. package/src/FaustScriptProcessorNode.ts +156 -49
  34. package/src/FaustSensors.ts +426 -96
  35. package/src/FaustSvgDiagrams.ts +18 -5
  36. package/src/FaustWasmInstantiator.ts +224 -70
  37. package/src/FaustWebAudioDsp.ts +1060 -349
  38. package/src/LibFaust.ts +13 -4
  39. package/src/SoundfileReader.ts +175 -131
  40. package/src/WavDecoder.ts +42 -20
  41. package/src/WavEncoder.ts +35 -21
  42. package/src/copyWebStandaloneAssets.d.ts +20 -5
  43. package/src/copyWebStandaloneAssets.js +203 -75
  44. package/src/exports-bundle.ts +5 -5
  45. package/src/exports.ts +24 -24
  46. package/src/faust2CmajorFiles.d.ts +7 -3
  47. package/src/faust2cmajorFiles.js +10 -8
  48. package/src/faust2svgFiles.d.ts +7 -3
  49. package/src/faust2svgFiles.js +9 -7
  50. package/src/faust2wasmFiles.d.ts +10 -5
  51. package/src/faust2wasmFiles.js +34 -17
  52. package/src/faust2wavFiles.d.ts +12 -3
  53. package/src/faust2wavFiles.js +25 -12
  54. package/src/index-bundle-iife.ts +2 -2
  55. package/src/index-bundle.ts +1 -1
  56. package/src/index.ts +1 -1
  57. package/src/instantiateFaustModule.ts +43 -36
  58. package/src/instantiateFaustModuleFromFile.ts +30 -14
  59. package/src/types.ts +101 -25
  60. package/test/faustlive-wasm/faustwasm/index.d.ts +38 -16
  61. package/test/faustlive-wasm/faustwasm/index.js +1574 -404
  62. package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
  63. package/test/web/create-faust-node.html +53 -0
  64. package/test/web/create-faust-node.js +186 -0
  65. package/test/organ/create-node.js +0 -252
  66. package/test/organ/dsp-meta.json +0 -131
  67. package/test/organ/dsp-module.wasm +0 -0
  68. package/test/organ/faust-pwa.js +0 -344
  69. package/test/organ/faust-ui/index.css +0 -442
  70. package/test/organ/faust-ui/index.css.map +0 -1
  71. package/test/organ/faust-ui/index.d.ts +0 -1
  72. package/test/organ/faust-ui/index.js +0 -3756
  73. package/test/organ/faust-ui/index.js.map +0 -1
  74. package/test/organ/faustwasm/index.d.ts +0 -1705
  75. package/test/organ/faustwasm/index.js +0 -4773
  76. package/test/organ/faustwasm/index.js.map +0 -7
  77. package/test/organ/icon.png +0 -0
  78. package/test/organ/index.html +0 -76
  79. package/test/organ/index.js +0 -69
  80. package/test/organ/manifest.json +0 -17
  81. package/test/organ/service-worker.js +0 -165
@@ -1,4 +1,4 @@
1
- import type FaustCompiler from "./FaustCompiler";
1
+ import type FaustCompiler from './FaustCompiler';
2
2
 
3
3
  interface IFaustSvgDiagrams {
4
4
  /**
@@ -23,13 +23,26 @@ class FaustSvgDiagrams implements IFaustSvgDiagrams {
23
23
  const fs = this.compiler.fs();
24
24
  try {
25
25
  const files: string[] = fs.readdir(`/${name}-svg/`);
26
- files.filter(file => file !== "." && file !== "..").forEach(file => fs.unlink(`/${name}-svg/${file}`));
27
- } catch { }
28
- const success = this.compiler.generateAuxFiles(name, code, `-lang wasm -o binary -svg ${args}`);
26
+ files
27
+ .filter((file) => file !== '.' && file !== '..')
28
+ .forEach((file) => fs.unlink(`/${name}-svg/${file}`));
29
+ } catch {}
30
+ const success = this.compiler.generateAuxFiles(
31
+ name,
32
+ code,
33
+ `-lang wasm -o binary -svg ${args}`
34
+ );
29
35
  if (!success) throw new Error(this.compiler.getErrorMessage());
30
36
  const svgs: Record<string, string> = {};
31
37
  const files: string[] = fs.readdir(`/${name}-svg/`);
32
- files.filter(file => file !== "." && file !== "..").forEach(file => svgs[file] = fs.readFile(`/${name}-svg/${file}`, { encoding: "utf8" }) as string);
38
+ files
39
+ .filter((file) => file !== '.' && file !== '..')
40
+ .forEach(
41
+ (file) =>
42
+ (svgs[file] = fs.readFile(`/${name}-svg/${file}`, {
43
+ encoding: 'utf8'
44
+ }) as string)
45
+ );
33
46
  return svgs;
34
47
  }
35
48
  }
@@ -1,5 +1,15 @@
1
- import { FaustDspInstance, FaustMonoDspInstance, FaustPolyDspInstance, IFaustDspInstance, IFaustMixerInstance } from "./FaustDspInstance";
2
- import type { FaustDspFactory, FaustDspMeta, LooseFaustDspFactory } from "./types";
1
+ import {
2
+ FaustDspInstance,
3
+ FaustMonoDspInstance,
4
+ FaustPolyDspInstance,
5
+ IFaustDspInstance,
6
+ IFaustMixerInstance
7
+ } from './FaustDspInstance';
8
+ import type {
9
+ FaustDspFactory,
10
+ FaustDspMeta,
11
+ LooseFaustDspFactory
12
+ } from './types';
3
13
 
4
14
  class FaustWasmInstantiator {
5
15
  private static createWasmImport(memory?: WebAssembly.Memory) {
@@ -11,92 +21,172 @@ class FaustWasmInstantiator {
11
21
  // Integer version
12
22
  _abs: Math.abs,
13
23
  // Float version
14
- _acosf: Math.acos, _asinf: Math.asin, _atanf: Math.atan, _atan2f: Math.atan2,
15
- _ceilf: Math.ceil, _cosf: Math.cos, _expf: Math.exp, _floorf: Math.floor,
24
+ _acosf: Math.acos,
25
+ _asinf: Math.asin,
26
+ _atanf: Math.atan,
27
+ _atan2f: Math.atan2,
28
+ _ceilf: Math.ceil,
29
+ _cosf: Math.cos,
30
+ _expf: Math.exp,
31
+ _floorf: Math.floor,
16
32
  _fmodf: (x: number, y: number) => x % y,
17
- _logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,
18
- _remainderf: (x: number, y: number) => x - Math.round(x / y) * y,
19
- _powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,
20
- _acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,
21
- _coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,
22
- _isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),
23
- _copysignf: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),
33
+ _logf: Math.log,
34
+ _log10f: Math.log10,
35
+ _max_f: Math.max,
36
+ _min_f: Math.min,
37
+ _remainderf: (x: number, y: number) =>
38
+ x - Math.round(x / y) * y,
39
+ _powf: Math.pow,
40
+ _roundf: Math.round,
41
+ _sinf: Math.sin,
42
+ _sqrtf: Math.sqrt,
43
+ _tanf: Math.tan,
44
+ _acoshf: Math.acosh,
45
+ _asinhf: Math.asinh,
46
+ _atanhf: Math.atanh,
47
+ _coshf: Math.cosh,
48
+ _sinhf: Math.sinh,
49
+ _tanhf: Math.tanh,
50
+ _isnanf: Number.isNaN,
51
+ _isinff: (x: number) => !isFinite(x),
52
+ _copysignf: (x: number, y: number) =>
53
+ Math.sign(x) === Math.sign(y) ? x : -x,
24
54
 
25
55
  // Double version
26
- _acos: Math.acos, _asin: Math.asin, _atan: Math.atan, _atan2: Math.atan2,
27
- _ceil: Math.ceil, _cos: Math.cos, _exp: Math.exp, _floor: Math.floor,
56
+ _acos: Math.acos,
57
+ _asin: Math.asin,
58
+ _atan: Math.atan,
59
+ _atan2: Math.atan2,
60
+ _ceil: Math.ceil,
61
+ _cos: Math.cos,
62
+ _exp: Math.exp,
63
+ _floor: Math.floor,
28
64
  _fmod: (x: number, y: number) => x % y,
29
- _log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,
65
+ _log: Math.log,
66
+ _log10: Math.log10,
67
+ _max_: Math.max,
68
+ _min_: Math.min,
30
69
  _remainder: (x: number, y: number) => x - Math.round(x / y) * y,
31
- _pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,
32
- _acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,
33
- _cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,
34
- _isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),
35
- _copysign: (x: number, y: number) => (Math.sign(x) === Math.sign(y) ? x : -x),
70
+ _pow: Math.pow,
71
+ _round: Math.round,
72
+ _sin: Math.sin,
73
+ _sqrt: Math.sqrt,
74
+ _tan: Math.tan,
75
+ _acosh: Math.acosh,
76
+ _asinh: Math.asinh,
77
+ _atanh: Math.atanh,
78
+ _cosh: Math.cosh,
79
+ _sinh: Math.sinh,
80
+ _tanh: Math.tanh,
81
+ _isnan: Number.isNaN,
82
+ _isinf: (x: number) => !isFinite(x),
83
+ _copysign: (x: number, y: number) =>
84
+ Math.sign(x) === Math.sign(y) ? x : -x,
36
85
 
37
- table: new WebAssembly.Table({ initial: 0, element: "anyfunc" })
86
+ table: new WebAssembly.Table({ initial: 0, element: 'anyfunc' })
38
87
  }
39
88
  };
40
89
  }
41
- private static createWasmMemoryPoly(voicesIn: number, sampleSize: number, dspMeta: FaustDspMeta, effectMeta: FaustDspMeta, bufferSize: number) {
90
+ private static createWasmMemoryPoly(
91
+ voicesIn: number,
92
+ sampleSize: number,
93
+ dspMeta: FaustDspMeta,
94
+ effectMeta: FaustDspMeta,
95
+ bufferSize: number
96
+ ) {
42
97
  // Hack : at least 4 voices (to avoid weird wasm memory bug?)
43
98
  const voices = Math.max(4, voicesIn);
44
99
  // Memory allocator
45
100
  const ptrSize = sampleSize; // Done on wast/wasm backend side
46
101
  const pow2limit = (x: number) => {
47
102
  let n = 65536; // Minimum = 64 kB
48
- while (n < x) { n *= 2; }
103
+ while (n < x) {
104
+ n *= 2;
105
+ }
49
106
  return n;
50
107
  };
51
108
  const effectSize = effectMeta ? effectMeta.size : 0;
52
- let memorySize = pow2limit(
53
- effectSize
54
- + dspMeta.size * voices
55
- + (dspMeta.inputs + dspMeta.outputs * 2) // + 2 for effect
56
- * (ptrSize + bufferSize * sampleSize)
57
- ) / 65536;
109
+ let memorySize =
110
+ pow2limit(
111
+ effectSize +
112
+ dspMeta.size * voices +
113
+ (dspMeta.inputs + dspMeta.outputs * 2) * // + 2 for effect
114
+ (ptrSize + bufferSize * sampleSize)
115
+ ) / 65536;
58
116
  memorySize = Math.max(2, memorySize); // At least 2
59
117
  return new WebAssembly.Memory({ initial: memorySize });
60
- };
118
+ }
61
119
 
62
- private static createWasmMemoryMono(sampleSize: number, dspMeta: FaustDspMeta, bufferSize: number) {
120
+ private static createWasmMemoryMono(
121
+ sampleSize: number,
122
+ dspMeta: FaustDspMeta,
123
+ bufferSize: number
124
+ ) {
63
125
  // Memory allocator
64
126
  const ptrSize = sampleSize; // Done on wast/wasm backend side
65
- const memorySize = (dspMeta.size + (dspMeta.inputs + dspMeta.outputs) * (ptrSize + bufferSize * sampleSize)) / 65536;
127
+ const memorySize =
128
+ (dspMeta.size +
129
+ (dspMeta.inputs + dspMeta.outputs) *
130
+ (ptrSize + bufferSize * sampleSize)) /
131
+ 65536;
66
132
  return new WebAssembly.Memory({ initial: memorySize * 2 }); // Safer to have a bit more memory
67
133
  }
68
134
 
69
- private static createMonoDSPInstanceAux(instance: WebAssembly.Instance, json: string, mem: WebAssembly.Memory | null = null) {
70
- const functions = instance.exports as IFaustDspInstance & WebAssembly.Exports;
135
+ private static createMonoDSPInstanceAux(
136
+ instance: WebAssembly.Instance,
137
+ json: string,
138
+ mem: WebAssembly.Memory | null = null
139
+ ) {
140
+ const functions = instance.exports as IFaustDspInstance &
141
+ WebAssembly.Exports;
71
142
  const api = new FaustDspInstance(functions);
72
- const memory: any = (mem) ? mem : instance.exports.memory;
143
+ const memory: any = mem ? mem : instance.exports.memory;
73
144
  return { memory, api, json } as FaustMonoDspInstance;
74
145
  }
75
146
 
76
147
  private static createMemoryMono(monoFactory: LooseFaustDspFactory) {
77
148
  // Parse JSON to get 'size' and 'inputs/outputs' infos
78
149
  const monoMeta: FaustDspMeta = JSON.parse(monoFactory.json);
79
- const sampleSize = monoMeta.compile_options.match("-double") ? 8 : 4;
150
+ const sampleSize = monoMeta.compile_options.match('-double') ? 8 : 4;
80
151
  return this.createWasmMemoryMono(sampleSize, monoMeta, 8192);
81
-
82
152
  }
83
- private static createMemoryPoly(voices: number, voiceFactory: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory) {
153
+ private static createMemoryPoly(
154
+ voices: number,
155
+ voiceFactory: LooseFaustDspFactory,
156
+ effectFactory?: LooseFaustDspFactory
157
+ ) {
84
158
  // Parse JSON to get 'size' and 'inputs/outputs' infos
85
159
  const voiceMeta: FaustDspMeta = JSON.parse(voiceFactory.json);
86
- const effectMeta: FaustDspMeta = (effectFactory && effectFactory.json) ? JSON.parse(effectFactory.json) : null;
87
- const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4;
160
+ const effectMeta: FaustDspMeta =
161
+ effectFactory && effectFactory.json
162
+ ? JSON.parse(effectFactory.json)
163
+ : null;
164
+ const sampleSize = voiceMeta.compile_options.match('-double') ? 8 : 4;
88
165
  // Memory will be shared by voice, mixer and (possibly) effect instances
89
- return this.createWasmMemoryPoly(voices, sampleSize, voiceMeta, effectMeta, 8192);
166
+ return this.createWasmMemoryPoly(
167
+ voices,
168
+ sampleSize,
169
+ voiceMeta,
170
+ effectMeta,
171
+ 8192
172
+ );
90
173
  }
91
174
 
92
- private static createMixerAux(mixerModule: WebAssembly.Module, memory: WebAssembly.Memory) {
175
+ private static createMixerAux(
176
+ mixerModule: WebAssembly.Module,
177
+ memory: WebAssembly.Memory
178
+ ) {
93
179
  // Create mixer instance
94
180
  const mixerImport = {
95
181
  imports: { print: console.log },
96
182
  memory: { memory }
97
183
  };
98
- const mixerInstance = new WebAssembly.Instance(mixerModule, mixerImport);
99
- const mixerFunctions = mixerInstance.exports as IFaustMixerInstance & WebAssembly.Exports;
184
+ const mixerInstance = new WebAssembly.Instance(
185
+ mixerModule,
186
+ mixerImport
187
+ );
188
+ const mixerFunctions = mixerInstance.exports as IFaustMixerInstance &
189
+ WebAssembly.Exports;
100
190
  return mixerFunctions;
101
191
  }
102
192
 
@@ -104,7 +194,9 @@ class FaustWasmInstantiator {
104
194
  static async loadDSPFactory(wasmPath: string, jsonPath: string) {
105
195
  const wasmFile = await fetch(wasmPath);
106
196
  if (!wasmFile.ok) {
107
- throw new Error(`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`);
197
+ throw new Error(
198
+ `=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`
199
+ );
108
200
  }
109
201
  try {
110
202
  const wasmBuffer = await wasmFile.arrayBuffer();
@@ -114,7 +206,13 @@ class FaustWasmInstantiator {
114
206
  const meta: FaustDspMeta = JSON.parse(json);
115
207
  const cOptions = meta.compile_options;
116
208
  const poly = cOptions.indexOf('wasm-e') !== -1;
117
- return { cfactory: 0, code: new Uint8Array(wasmBuffer), module, json, poly } as FaustDspFactory;
209
+ return {
210
+ cfactory: 0,
211
+ code: new Uint8Array(wasmBuffer),
212
+ module,
213
+ json,
214
+ poly
215
+ } as FaustDspFactory;
118
216
  } catch (e) {
119
217
  // console.error(`=> exception raised while running loadDSPFactory: ${e}`);
120
218
  throw e;
@@ -125,7 +223,9 @@ class FaustWasmInstantiator {
125
223
  try {
126
224
  let mixerBuffer: BufferSource | null = null;
127
225
  if (fs) {
128
- mixerBuffer = new Uint8Array(fs.readFile(mixerPath, { encoding: "binary" }));
226
+ mixerBuffer = new Uint8Array(
227
+ fs.readFile(mixerPath, { encoding: 'binary' })
228
+ );
129
229
  } else {
130
230
  const mixerFile = await fetch(mixerPath);
131
231
  mixerBuffer = await mixerFile.arrayBuffer();
@@ -139,7 +239,6 @@ class FaustWasmInstantiator {
139
239
  }
140
240
 
141
241
  static async createAsyncMonoDSPInstance(factory: LooseFaustDspFactory) {
142
-
143
242
  // Regular expression to match the 'type: soundfile' pattern
144
243
  const pattern = /"type":\s*"soundfile"/;
145
244
  // Check if the pattern exists in the JSON string
@@ -147,17 +246,26 @@ class FaustWasmInstantiator {
147
246
 
148
247
  if (isDetected) {
149
248
  const memory = this.createMemoryMono(factory);
150
- const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport(memory));
151
- return this.createMonoDSPInstanceAux(instance, factory.json, memory);
249
+ const instance = await WebAssembly.instantiate(
250
+ factory.module,
251
+ this.createWasmImport(memory)
252
+ );
253
+ return this.createMonoDSPInstanceAux(
254
+ instance,
255
+ factory.json,
256
+ memory
257
+ );
152
258
  } else {
153
259
  // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module
154
- const instance = await WebAssembly.instantiate(factory.module, this.createWasmImport());
260
+ const instance = await WebAssembly.instantiate(
261
+ factory.module,
262
+ this.createWasmImport()
263
+ );
155
264
  return this.createMonoDSPInstanceAux(instance, factory.json);
156
265
  }
157
266
  }
158
267
 
159
268
  static createSyncMonoDSPInstance(factory: LooseFaustDspFactory) {
160
-
161
269
  // Regular expression to match the 'type: soundfile' pattern
162
270
  const pattern = /"type":\s*"soundfile"/;
163
271
  // Check if the pattern exists in the JSON string
@@ -166,28 +274,56 @@ class FaustWasmInstantiator {
166
274
  // If the JSON contains a soundfile UI element, we need to create a memory object
167
275
  if (isDetected) {
168
276
  const memory = this.createMemoryMono(factory);
169
- const instance = new WebAssembly.Instance(factory.module, this.createWasmImport(memory));
170
- return this.createMonoDSPInstanceAux(instance, factory.json, memory);
277
+ const instance = new WebAssembly.Instance(
278
+ factory.module,
279
+ this.createWasmImport(memory)
280
+ );
281
+ return this.createMonoDSPInstanceAux(
282
+ instance,
283
+ factory.json,
284
+ memory
285
+ );
171
286
  } else {
172
287
  // Otherwise, we can create the instance using the wasm internal memory allocated by the wasm module
173
- const instance = new WebAssembly.Instance(factory.module, this.createWasmImport());
288
+ const instance = new WebAssembly.Instance(
289
+ factory.module,
290
+ this.createWasmImport()
291
+ );
174
292
  return this.createMonoDSPInstanceAux(instance, factory.json);
175
293
  }
176
294
  }
177
295
 
178
- static async createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise<FaustPolyDspInstance> {
179
- const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);
180
- // Create voice
181
- const voiceInstance = await WebAssembly.instantiate(voiceFactory.module, this.createWasmImport(memory));
182
- const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;
296
+ static async createAsyncPolyDSPInstance(
297
+ voiceFactory: LooseFaustDspFactory,
298
+ mixerModule: WebAssembly.Module,
299
+ voices: number,
300
+ effectFactory?: LooseFaustDspFactory
301
+ ): Promise<FaustPolyDspInstance> {
302
+ const memory = this.createMemoryPoly(
303
+ voices,
304
+ voiceFactory,
305
+ effectFactory
306
+ );
307
+ // Create voice
308
+ const voiceInstance = await WebAssembly.instantiate(
309
+ voiceFactory.module,
310
+ this.createWasmImport(memory)
311
+ );
312
+ const voiceFunctions = voiceInstance.exports as IFaustDspInstance &
313
+ WebAssembly.Exports;
183
314
  const voiceAPI = new FaustDspInstance(voiceFunctions);
184
315
  // Create mixer
185
316
  const mixerAPI = this.createMixerAux(mixerModule, memory);
186
317
 
187
- // Possibly create effect instance
318
+ // Possibly create effect instance
188
319
  if (effectFactory) {
189
- const effectInstance = await WebAssembly.instantiate(effectFactory.module, this.createWasmImport(memory));
190
- const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;
320
+ const effectInstance = await WebAssembly.instantiate(
321
+ effectFactory.module,
322
+ this.createWasmImport(memory)
323
+ );
324
+ const effectFunctions =
325
+ effectInstance.exports as IFaustDspInstance &
326
+ WebAssembly.Exports;
191
327
  const effectAPI = new FaustDspInstance(effectFunctions);
192
328
  return {
193
329
  memory,
@@ -209,19 +345,37 @@ class FaustWasmInstantiator {
209
345
  }
210
346
  }
211
347
 
212
- static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance {
213
- const memory = this.createMemoryPoly(voices, voiceFactory, effectFactory);
214
- // Create voice
215
- const voiceInstance = new WebAssembly.Instance(voiceFactory.module, this.createWasmImport(memory));
216
- const voiceFunctions = voiceInstance.exports as IFaustDspInstance & WebAssembly.Exports;
348
+ static createSyncPolyDSPInstance(
349
+ voiceFactory: LooseFaustDspFactory,
350
+ mixerModule: WebAssembly.Module,
351
+ voices: number,
352
+ effectFactory?: LooseFaustDspFactory
353
+ ): FaustPolyDspInstance {
354
+ const memory = this.createMemoryPoly(
355
+ voices,
356
+ voiceFactory,
357
+ effectFactory
358
+ );
359
+ // Create voice
360
+ const voiceInstance = new WebAssembly.Instance(
361
+ voiceFactory.module,
362
+ this.createWasmImport(memory)
363
+ );
364
+ const voiceFunctions = voiceInstance.exports as IFaustDspInstance &
365
+ WebAssembly.Exports;
217
366
  const voiceAPI = new FaustDspInstance(voiceFunctions);
218
367
  // Create mixer
219
368
  const mixerAPI = this.createMixerAux(mixerModule, memory);
220
369
 
221
- // Possibly create effect instance
370
+ // Possibly create effect instance
222
371
  if (effectFactory) {
223
- const effectInstance = new WebAssembly.Instance(effectFactory.module, this.createWasmImport(memory));
224
- const effectFunctions = effectInstance.exports as IFaustDspInstance & WebAssembly.Exports;
372
+ const effectInstance = new WebAssembly.Instance(
373
+ effectFactory.module,
374
+ this.createWasmImport(memory)
375
+ );
376
+ const effectFunctions =
377
+ effectInstance.exports as IFaustDspInstance &
378
+ WebAssembly.Exports;
225
379
  const effectAPI = new FaustDspInstance(effectFunctions);
226
380
  return {
227
381
  memory,