@grame/faustwasm 0.0.61 → 0.0.63

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 (49) hide show
  1. package/README.md +5 -4
  2. package/assets/standalone/faustwasm/index.js +1 -1
  3. package/assets/standalone/faustwasm/index.js.map +2 -2
  4. package/dist/cjs/index.js +1 -1
  5. package/dist/cjs/index.js.map +2 -2
  6. package/dist/cjs-bundle/index.js +5 -5
  7. package/dist/cjs-bundle/index.js.map +2 -2
  8. package/dist/esm/index.js +1 -1
  9. package/dist/esm/index.js.map +2 -2
  10. package/dist/esm-bundle/index.js +5 -5
  11. package/dist/esm-bundle/index.js.map +2 -2
  12. package/libfaust-wasm/libfaust-wasm.data +0 -0
  13. package/libfaust-wasm/libfaust-wasm.js +1 -1
  14. package/libfaust-wasm/libfaust-wasm.wasm +0 -0
  15. package/package.json +1 -1
  16. package/test/faustlive-wasm/faustwasm/index.js +1 -1
  17. package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
  18. package/test/{bug → organ}/faustwasm/index.js +1 -1
  19. package/test/{bug → organ}/faustwasm/index.js.map +2 -2
  20. package/test/{guitar → organ}/index.html +1 -1
  21. package/test/{guitar → organ}/manifest.json +2 -2
  22. package/test/{guitar/guitar.js → organ/organ.js} +1 -1
  23. package/test/{bug/bug.json → organ/organ.json} +31 -29
  24. package/test/organ/organ.wasm +0 -0
  25. package/test/{guitar → organ}/service-worker.js +4 -4
  26. package/0001-Rework-polyphonic-effect-mode.patch +0 -122
  27. package/test/bug/bug.html +0 -84
  28. package/test/bug/bug.js +0 -216
  29. package/test/bug/bug.wasm +0 -0
  30. package/test/bug/bug_effect.json +0 -95
  31. package/test/bug/bug_effect.wasm +0 -0
  32. package/test/bug/mixerModule.wasm +0 -0
  33. package/test/guitar/faust-ui/index.css +0 -416
  34. package/test/guitar/faust-ui/index.css.map +0 -1
  35. package/test/guitar/faust-ui/index.d.ts +0 -1
  36. package/test/guitar/faust-ui/index.js +0 -3476
  37. package/test/guitar/faust-ui/index.js.map +0 -1
  38. package/test/guitar/faustwasm/index.d.ts +0 -1294
  39. package/test/guitar/faustwasm/index.js +0 -3874
  40. package/test/guitar/faustwasm/index.js.map +0 -7
  41. package/test/guitar/guitar.json +0 -327
  42. package/test/guitar/guitar.wasm +0 -0
  43. /package/test/{bug → organ}/faust-ui/index.css +0 -0
  44. /package/test/{bug → organ}/faust-ui/index.css.map +0 -0
  45. /package/test/{bug → organ}/faust-ui/index.d.ts +0 -0
  46. /package/test/{bug → organ}/faust-ui/index.js +0 -0
  47. /package/test/{bug → organ}/faust-ui/index.js.map +0 -0
  48. /package/test/{bug → organ}/faustwasm/index.d.ts +0 -0
  49. /package/test/{guitar → organ}/icon.png +0 -0
@@ -80,7 +80,7 @@
80
80
  <div id="div-faust-ui">
81
81
  </div>
82
82
  </main>
83
- <script src="./guitar.js"></script>
83
+ <script src="./organ.js"></script>
84
84
  </body>
85
85
 
86
86
  </html>
@@ -1,6 +1,6 @@
1
1
  {
2
- "name": "Faust guitar",
3
- "short_name": "guitar",
2
+ "name": "Faust organ",
3
+ "short_name": "organ",
4
4
  "start_url": "/",
5
5
  "display": "standalone",
6
6
  "background_color": "#ffffff",
@@ -215,7 +215,7 @@ const createFaustUI = async (faustNode) => {
215
215
  };
216
216
 
217
217
  (async () => {
218
- const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "guitar");
218
+ const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "organ");
219
219
  await createFaustUI(faustNode);
220
220
  faustNode.connect(audioContext.destination);
221
221
  if (faustNode.numberOfInputs) await buildAudioDeviceMenu(faustNode);
@@ -1,13 +1,14 @@
1
1
  {
2
- "name": "bug",
3
- "filename": "bug",
2
+ "name": "organ",
3
+ "filename": "organ",
4
4
  "version": "2.72.4",
5
- "compile_options": "-lang wasm-e -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2",
5
+ "compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2",
6
6
  "library_list": [
7
7
  "/usr/share/faust/stdfaust.lib",
8
8
  "/usr/share/faust/oscillators.lib",
9
- "/usr/share/faust/maths.lib",
10
9
  "/usr/share/faust/platform.lib",
10
+ "/usr/share/faust/maths.lib",
11
+ "/usr/share/faust/basics.lib",
11
12
  "/usr/share/faust/envelopes.lib"
12
13
  ],
13
14
  "include_pathnames": [
@@ -16,12 +17,22 @@
16
17
  "/usr/share/faust",
17
18
  "."
18
19
  ],
19
- "size": 68,
20
+ "size": 262256,
21
+ "code": "IMic",
20
22
  "inputs": 0,
21
23
  "outputs": 1,
22
24
  "meta": [
23
25
  {
24
- "compile_options": "-lang wasm-e -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2"
26
+ "basics.lib/name": "Faust Basic Element Library"
27
+ },
28
+ {
29
+ "basics.lib/tabulateNd": "Copyright (C) 2023 Bart Brouns <bart@magnetophon.nl>"
30
+ },
31
+ {
32
+ "basics.lib/version": "1.12.0"
33
+ },
34
+ {
35
+ "compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2"
25
36
  },
26
37
  {
27
38
  "envelopes.lib/adsr:author": "Yann Orlarey and Andrey Bundin"
@@ -42,7 +53,7 @@
42
53
  "envelopes.lib/version": "1.3.0"
43
54
  },
44
55
  {
45
- "filename": "bug"
56
+ "filename": "organ"
46
57
  },
47
58
  {
48
59
  "maths.lib/author": "GRAME"
@@ -60,20 +71,11 @@
60
71
  "maths.lib/version": "2.7.0"
61
72
  },
62
73
  {
63
- "name": "bug"
64
- },
65
- {
66
- "options": "[midi:on][nvoices:12]"
74
+ "name": "organ"
67
75
  },
68
76
  {
69
77
  "oscillators.lib/name": "Faust Oscillator Library"
70
78
  },
71
- {
72
- "oscillators.lib/saw2ptr:author": "Julius O. Smith III"
73
- },
74
- {
75
- "oscillators.lib/saw2ptr:license": "STK-4.3"
76
- },
77
79
  {
78
80
  "oscillators.lib/version": "1.5.0"
79
81
  },
@@ -87,26 +89,26 @@
87
89
  "ui": [
88
90
  {
89
91
  "type": "vgroup",
90
- "label": "bug",
92
+ "label": "organ",
91
93
  "items": [
92
94
  {
93
95
  "type": "hslider",
94
96
  "label": "freq",
95
97
  "shortname": "freq",
96
- "address": "/bug/freq",
97
- "index": 16,
98
- "init": 200,
99
- "min": 50,
100
- "max": 1000,
101
- "step": 0.01
98
+ "address": "/organ/freq",
99
+ "index": 262164,
100
+ "init": 440,
101
+ "min": 20,
102
+ "max": 10000,
103
+ "step": 1
102
104
  },
103
105
  {
104
106
  "type": "hslider",
105
107
  "label": "gain",
106
108
  "shortname": "gain",
107
- "address": "/bug/gain",
108
- "index": 0,
109
- "init": 0.5,
109
+ "address": "/organ/gain",
110
+ "index": 262144,
111
+ "init": 0,
110
112
  "min": 0,
111
113
  "max": 1,
112
114
  "step": 0.01
@@ -115,8 +117,8 @@
115
117
  "type": "button",
116
118
  "label": "gate",
117
119
  "shortname": "gate",
118
- "address": "/bug/gate",
119
- "index": 32
120
+ "address": "/organ/gate",
121
+ "index": 262204
120
122
  }
121
123
  ]
122
124
  }
Binary file
@@ -1,14 +1,14 @@
1
1
  self.addEventListener('install', event => {
2
2
  event.waitUntil(
3
- caches.open('guitar-static-v1').then(cache => {
3
+ caches.open('organ-static-v1').then(cache => {
4
4
  return cache.addAll([
5
5
  '/faust-ui/index.js',
6
6
  '/faustwasm/index.js',
7
7
  '/faustwasm/styles.css',
8
8
  '/index.html',
9
- '/guitar.js',
10
- '/guitar.wasm',
11
- '/guitar.json',
9
+ '/organ.js',
10
+ '/organ.wasm',
11
+ '/organ.json',
12
12
  ]).catch(error => {
13
13
  // Catch and log any errors during the caching process
14
14
  console.error('Failed to cache resources during install:', error);
@@ -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/bug/bug.html DELETED
@@ -1,84 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8">
6
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
7
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
- <title>Faust DSP</title>
9
- <style>
10
- body {
11
- color: #b0b0b0;
12
- background-color: #1f1f1f;
13
- display: flex;
14
- top: 0;
15
- left: 0;
16
- width: 100%;
17
- height: 100%;
18
- margin: 0;
19
- position: absolute;
20
- }
21
-
22
- main {
23
- margin: 20px;
24
- display: flex;
25
- flex-direction: column;
26
- flex: 1 1 100%;
27
- }
28
-
29
- main span {
30
- position: relative;
31
- display: flex;
32
- }
33
-
34
- main span[hidden] {
35
- display: none;
36
- }
37
-
38
- main span span {
39
- margin: 0px 10px;
40
- flex: 1;
41
- }
42
-
43
- main span select {
44
- flex: 2;
45
- }
46
-
47
- #dsp-switch {
48
- margin: 20px auto;
49
- }
50
-
51
- #button-dsp {
52
- padding: 10px;
53
- }
54
-
55
- #div-faust-ui {
56
- flex: 1 1 auto;
57
- display: flex;
58
- position: relative;
59
- flex-direction: column;
60
- }
61
- </style>
62
- <link rel="stylesheet" href="./faust-ui/index.css">
63
- </head>
64
-
65
- <body>
66
- <main>
67
- <span id="audio-input">
68
- <span>Select Audio Input Device</span>
69
- <select id="select-audio-input"></select>
70
- </span>
71
- <span id="midi-input">
72
- <span>Select MIDI Input Device</span>
73
- <select id="select-midi-input"></select>
74
- </span>
75
- <span id="dsp-switch">
76
- <button id="button-dsp">Activate DSP</button>
77
- </span>
78
- <div id="div-faust-ui">
79
- </div>
80
- </main>
81
- <script src="./bug.js"></script>
82
- </body>
83
-
84
- </html>
package/test/bug/bug.js DELETED
@@ -1,216 +0,0 @@
1
- /**
2
- * @typedef {import("./types").FaustDspDistribution} FaustDspDistribution
3
- * @typedef {import("./faustwasm").FaustAudioWorkletNode} FaustAudioWorkletNode
4
- * @typedef {import("./faustwasm").FaustDspMeta} FaustDspMeta
5
- * @typedef {import("./faustwasm").FaustUIDescriptor} FaustUIDescriptor
6
- * @typedef {import("./faustwasm").FaustUIGroup} FaustUIGroup
7
- * @typedef {import("./faustwasm").FaustUIItem} FaustUIItem
8
- */
9
-
10
- /** @type {HTMLSpanElement} */
11
- const $spanAudioInput = document.getElementById("audio-input");
12
- /** @type {HTMLSpanElement} */
13
- const $spanMidiInput = document.getElementById("midi-input");
14
- /** @type {HTMLSelectElement} */
15
- const $selectAudioInput = document.getElementById("select-audio-input");
16
- /** @type {HTMLSelectElement} */
17
- const $selectMidiInput = document.getElementById("select-midi-input");
18
- /** @type {HTMLSelectElement} */
19
- const $buttonDsp = document.getElementById("button-dsp");
20
- /** @type {HTMLDivElement} */
21
- const $divFaustUI = document.getElementById("div-faust-ui");
22
-
23
- /** @type {typeof AudioContext} */
24
- const AudioCtx = window.AudioContext || window.webkitAudioContext;
25
- const audioContext = new AudioCtx({ latencyHint: 0.00001 });
26
- audioContext.destination.channelInterpretation = "discrete";
27
- audioContext.suspend();
28
-
29
- /**
30
- * @param {FaustAudioWorkletNode} faustNode
31
- */
32
- const buildAudioDeviceMenu = async (faustNode) => {
33
- /** @type {MediaStreamAudioSourceNode} */
34
- let inputStreamNode;
35
- const handleDeviceChange = async () => {
36
- const devicesInfo = await navigator.mediaDevices.enumerateDevices();
37
- $selectAudioInput.innerHTML = '';
38
- devicesInfo.forEach((deviceInfo, i) => {
39
- const { kind, deviceId, label } = deviceInfo;
40
- if (kind === "audioinput") {
41
- const option = new Option(label || `microphone ${i + 1}`, deviceId);
42
- $selectAudioInput.add(option);
43
- }
44
- });
45
- }
46
- await handleDeviceChange();
47
- navigator.mediaDevices.addEventListener("devicechange", handleDeviceChange)
48
- $selectAudioInput.onchange = async () => {
49
- const id = $selectAudioInput.value;
50
- const constraints = {
51
- audio: {
52
- echoCancellation: false,
53
- mozNoiseSuppression: false,
54
- mozAutoGainControl: false,
55
- deviceId: id ? { exact: id } : undefined,
56
- },
57
- };
58
- const stream = await navigator.mediaDevices.getUserMedia(constraints);
59
- if (inputStreamNode) inputStreamNode.disconnect();
60
- inputStreamNode = audioContext.createMediaStreamSource(stream);
61
- inputStreamNode.connect(faustNode);
62
- };
63
-
64
- const defaultConstraints = {
65
- audio: {
66
- echoCancellation: false,
67
- mozNoiseSuppression: false,
68
- mozAutoGainControl: false
69
- }
70
- };
71
- const defaultStream = await navigator.mediaDevices.getUserMedia(defaultConstraints);
72
- if (defaultStream) {
73
- inputStreamNode = audioContext.createMediaStreamSource(defaultStream);
74
- inputStreamNode.connect(faustNode);
75
- }
76
- };
77
-
78
- /**
79
- * @param {FaustAudioWorkletNode} faustNode
80
- */
81
- const buildMidiDeviceMenu = async (faustNode) => {
82
- const midiAccess = await navigator.requestMIDIAccess();
83
- /** @type {WebMidi.MIDIInput} */
84
- let currentInput;
85
- /**
86
- * @param {WebMidi.MIDIMessageEvent} e
87
- */
88
- const handleMidiMessage = e => faustNode.midiMessage(e.data);
89
- const handleStateChange = () => {
90
- const { inputs } = midiAccess;
91
- if ($selectMidiInput.options.length === inputs.size + 1) return;
92
- if (currentInput) currentInput.removeEventListener("midimessage", handleMidiMessage);
93
- $selectMidiInput.innerHTML = '<option value="-1" disabled selected>Select...</option>';
94
- inputs.forEach((midiInput) => {
95
- const { name, id } = midiInput;
96
- const option = new Option(name, id);
97
- $selectMidiInput.add(option);
98
- });
99
- };
100
- handleStateChange();
101
- midiAccess.addEventListener("statechange", handleStateChange);
102
- $selectMidiInput.onchange = () => {
103
- if (currentInput) currentInput.removeEventListener("midimessage", handleMidiMessage);
104
- const id = $selectMidiInput.value;
105
- currentInput = midiAccess.inputs.get(id);
106
- currentInput.addEventListener("midimessage", handleMidiMessage);
107
- };
108
- };
109
-
110
- $buttonDsp.disabled = true;
111
- $buttonDsp.onclick = () => {
112
- if (audioContext.state === "running") {
113
- $buttonDsp.textContent = "Suspended";
114
- audioContext.suspend();
115
- } else if (audioContext.state === "suspended") {
116
- $buttonDsp.textContent = "Running";
117
- audioContext.resume();
118
- }
119
- }
120
-
121
- /**
122
- * Creates a Faust audio node for use in the Web Audio API.
123
- *
124
- * @param {AudioContext} audioContext - The Web Audio API AudioContext to which the Faust audio node will be connected.
125
- * @param {string} dspName - The name of the DSP to be loaded.
126
- * @param {number} voices - The number of voices to be used for polyphonic DSPs.
127
- * @returns {Object} - An object containing the Faust audio node and the DSP metadata.
128
- */
129
- const createFaustNode = async (audioContext, dspName = "template", voices = 0) => {
130
- // Import necessary Faust modules and data
131
- const { FaustMonoDspGenerator, FaustPolyDspGenerator } = await import("./faustwasm/index.js");
132
-
133
- // Load DSP metadata from JSON
134
- /** @type {FaustDspMeta} */
135
- const dspMeta = await (await fetch(`./${dspName}.json`)).json();
136
-
137
- // Compile the DSP module from WebAssembly binary data
138
- const dspModule = await WebAssembly.compileStreaming(await fetch(`./${dspName}.wasm`));
139
-
140
- // Create an object representing Faust DSP with metadata and module
141
- /** @type {FaustDspDistribution} */
142
- const faustDsp = { dspMeta, dspModule };
143
-
144
- /** @type {FaustAudioWorkletNode} */
145
- let faustNode;
146
-
147
- // Create either a polyphonic or monophonic Faust audio node based on the number of voices
148
- if (voices > 0) {
149
-
150
- // Try to load optional mixer and effect modules
151
- try {
152
- faustDsp.mixerModule = await WebAssembly.compileStreaming(await fetch("./mixerModule.wasm"));
153
- faustDsp.effectMeta = await (await fetch(`./${dspName}_effect.json`)).json();
154
- faustDsp.effectModule = await WebAssembly.compileStreaming(await fetch(`./${dspName}_effect.wasm`));
155
- } catch (e) { }
156
-
157
- const generator = new FaustPolyDspGenerator();
158
- faustNode = await generator.createNode(
159
- audioContext,
160
- voices,
161
- "FaustPolyDSP",
162
- { module: faustDsp.dspModule, json: JSON.stringify(faustDsp.dspMeta) },
163
- faustDsp.mixerModule,
164
- faustDsp.effectModule ? { module: faustDsp.effectModule, json: JSON.stringify(faustDsp.effectMeta) } : undefined
165
- );
166
- } else {
167
- const generator = new FaustMonoDspGenerator();
168
- faustNode = await generator.createNode(
169
- audioContext,
170
- "FaustMonoDSP",
171
- { module: faustDsp.dspModule, json: JSON.stringify(faustDsp.dspMeta) }
172
- );
173
- }
174
-
175
- // Return an object with the Faust audio node and the DSP metadata
176
- return { faustNode, dspMeta };
177
- }
178
-
179
- /**
180
- * @param {FaustAudioWorkletNode} faustNode
181
- */
182
- const createFaustUI = async (faustNode) => {
183
- const { FaustUI } = await import("./faust-ui/index.js");
184
- const $container = document.createElement("div");
185
- $container.style.margin = "0";
186
- $container.style.position = "absolute";
187
- $container.style.overflow = "auto";
188
- $container.style.display = "flex";
189
- $container.style.flexDirection = "column";
190
- $container.style.width = "100%";
191
- $container.style.height = "100%";
192
- $divFaustUI.appendChild($container);
193
- const faustUI = new FaustUI({
194
- ui: faustNode.getUI(),
195
- root: $container,
196
- listenWindowMessage: false,
197
- listenWindowResize: true,
198
- });
199
- faustUI.paramChangeByUI = (path, value) => faustNode.setParamValue(path, value);
200
- faustNode.setOutputParamHandler((path, value) => faustUI.paramChangeByDSP(path, value));
201
- $container.style.minWidth = `${faustUI.minWidth}px`;
202
- $container.style.minHeight = `${faustUI.minHeight}px`;
203
- faustUI.resize();
204
- };
205
-
206
- (async () => {
207
- const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "bug", 16);
208
- await createFaustUI(faustNode);
209
- faustNode.connect(audioContext.destination);
210
- if (faustNode.numberOfInputs) await buildAudioDeviceMenu(faustNode);
211
- else $spanAudioInput.hidden = true;
212
- if (navigator.requestMIDIAccess) await buildMidiDeviceMenu(faustNode);
213
- else $spanMidiInput.hidden = true;
214
- $buttonDsp.disabled = false;
215
- document.title = name;
216
- })();
package/test/bug/bug.wasm DELETED
Binary file