@grame/faustwasm 0.1.6 → 0.1.7

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.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "WebAssembly version of Faust Compiler",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -37,10 +37,12 @@
37
37
  "url": "https://github.com/grame-cncm/faustwasm/issues"
38
38
  },
39
39
  "homepage": "https://github.com/grame-cncm/faustwasm#readme",
40
+ "dependencies": {
41
+ "@types/emscripten": "^1.39.5"
42
+ },
40
43
  "devDependencies": {
41
44
  "@aws-crypto/sha256-js": "^2.0.1",
42
45
  "@shren/faust-ui": "^1.1.9",
43
- "@types/emscripten": "^1.39.5",
44
46
  "@types/node": "^16.11.7",
45
47
  "@types/webmidi": "^2.0.6",
46
48
  "dts-bundle-generator": "^6.13.0",
@@ -1,50 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
-
4
- <head>
5
- <title>Faust DSP</title>
6
- </head>
7
-
8
- <body>
9
- <main>
10
- <span id="dsp-switch">
11
- <center><button id="button-dsp">Activate DSP</button></center>
12
- </span>
13
- </main>
14
- <script src="./clarinetMIDI.js"></script>
15
- <script>
16
- (async () => {
17
-
18
- // Create audio context
19
- const AudioCtx = window.AudioContext || window.webkitAudioContext;
20
- const audioContext = new AudioCtx();
21
- audioContext.suspend();
22
-
23
- // Create audio context activation button
24
- const $buttonDsp = document.getElementById("button-dsp");
25
-
26
- // Function to activate audio context
27
- $buttonDsp.disabled = true;
28
- $buttonDsp.onclick = () => {
29
- if (audioContext.state === "running") {
30
- $buttonDsp.textContent = "Suspended";
31
- audioContext.suspend();
32
- } else if (audioContext.state === "suspended") {
33
- $buttonDsp.textContent = "Running";
34
- audioContext.resume();
35
- }
36
- }
37
-
38
- // Create Faust node
39
- const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "clarinetMIDI");
40
-
41
- // Connect Faust node to audio context
42
- faustNode.connect(audioContext.destination);
43
-
44
- // Create Faust node activation button
45
- $buttonDsp.disabled = false;
46
- })();
47
- </script>
48
- </body>
49
-
50
- </html>
@@ -1,63 +0,0 @@
1
- /**
2
- * @typedef {import("./types").FaustDspDistribution} FaustDspDistribution
3
- * @typedef {import("./faustwasm").FaustAudioWorkletNode} FaustAudioWorkletNode
4
- * @typedef {import("./faustwasm").FaustDspMeta} FaustDspMeta
5
- */
6
-
7
- /**
8
- * Creates a Faust audio node for use in the Web Audio API.
9
- *
10
- * @param {AudioContext} audioContext - The Web Audio API AudioContext to which the Faust audio node will be connected.
11
- * @param {string} dspName - The name of the DSP to be loaded.
12
- * @param {number} voices - The number of voices to be used for polyphonic DSPs.
13
- * @returns {Object} - An object containing the Faust audio node and the DSP metadata.
14
- */
15
- const createFaustNode = async (audioContext, dspName = "template", voices = 0) => {
16
- // Import necessary Faust modules and data
17
- const { FaustMonoDspGenerator, FaustPolyDspGenerator } = await import("./faustwasm/index.js");
18
-
19
- // Load DSP metadata from JSON
20
- /** @type {FaustDspMeta} */
21
- const dspMeta = await (await fetch(`./${dspName}.json`)).json();
22
-
23
- // Compile the DSP module from WebAssembly binary data
24
- const dspModule = await WebAssembly.compileStreaming(await fetch(`./${dspName}.wasm`));
25
-
26
- // Create an object representing Faust DSP with metadata and module
27
- /** @type {FaustDspDistribution} */
28
- const faustDsp = { dspMeta, dspModule };
29
-
30
- /** @type {FaustAudioWorkletNode} */
31
- let faustNode;
32
-
33
- // Create either a polyphonic or monophonic Faust audio node based on the number of voices
34
- if (voices > 0) {
35
-
36
- // Try to load optional mixer and effect modules
37
- try {
38
- faustDsp.mixerModule = await WebAssembly.compileStreaming(await fetch("./mixerModule.wasm"));
39
- faustDsp.effectMeta = await (await fetch(`./${dspName}_effect.json`)).json();
40
- faustDsp.effectModule = await WebAssembly.compileStreaming(await fetch(`./${dspName}_effect.wasm`));
41
- } catch (e) { }
42
-
43
- const generator = new FaustPolyDspGenerator();
44
- faustNode = await generator.createNode(
45
- audioContext,
46
- voices,
47
- "FaustPolyDSP",
48
- { module: faustDsp.dspModule, json: JSON.stringify(faustDsp.dspMeta) },
49
- faustDsp.mixerModule,
50
- faustDsp.effectModule ? { module: faustDsp.effectModule, json: JSON.stringify(faustDsp.effectMeta) } : undefined
51
- );
52
- } else {
53
- const generator = new FaustMonoDspGenerator();
54
- faustNode = await generator.createNode(
55
- audioContext,
56
- "FaustMonoDSP",
57
- { module: faustDsp.dspModule, json: JSON.stringify(faustDsp.dspMeta) }
58
- );
59
- }
60
-
61
- // Return an object with the Faust audio node and the DSP metadata
62
- return { faustNode, dspMeta };
63
- }
@@ -1,431 +0,0 @@
1
- {
2
- "name": "ClarinetMIDI",
3
- "filename": "clarinetMIDI",
4
- "version": "2.73.0",
5
- "compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2",
6
- "library_list": [
7
- "/usr/share/faust/stdfaust.lib",
8
- "/usr/share/faust/physmodels.lib",
9
- "/usr/share/faust/signals.lib",
10
- "/usr/share/faust/basics.lib",
11
- "/usr/share/faust/maths.lib",
12
- "/usr/share/faust/platform.lib",
13
- "/usr/share/faust/oscillators.lib",
14
- "/usr/share/faust/noises.lib",
15
- "/usr/share/faust/filters.lib",
16
- "/usr/share/faust/routes.lib",
17
- "/usr/share/faust/delays.lib"
18
- ],
19
- "include_pathnames": [
20
- "/share/faust",
21
- "/usr/local/share/faust",
22
- "/usr/share/faust",
23
- "."
24
- ],
25
- "size": 278748,
26
- "code": "MAKIAbTGHg==",
27
- "inputs": 0,
28
- "outputs": 2,
29
- "meta": [
30
- {
31
- "basics.lib/name": "Faust Basic Element Library"
32
- },
33
- {
34
- "basics.lib/tabulateNd": "Copyright (C) 2023 Bart Brouns <bart@magnetophon.nl>"
35
- },
36
- {
37
- "basics.lib/version": "1.15.0"
38
- },
39
- {
40
- "compile_options": "-lang wasm-i -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2"
41
- },
42
- {
43
- "copyright": "(c)Romain Michon, CCRMA (Stanford University), GRAME"
44
- },
45
- {
46
- "delays.lib/fdelay4:author": "Julius O. Smith III"
47
- },
48
- {
49
- "delays.lib/fdelayltv:author": "Julius O. Smith III"
50
- },
51
- {
52
- "delays.lib/name": "Faust Delay Library"
53
- },
54
- {
55
- "delays.lib/version": "1.1.0"
56
- },
57
- {
58
- "description": "Simple MIDI-controllable clarinet physical model with physical parameters."
59
- },
60
- {
61
- "filename": "clarinetMIDI"
62
- },
63
- {
64
- "filters.lib/fir:author": "Julius O. Smith III"
65
- },
66
- {
67
- "filters.lib/fir:copyright": "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>"
68
- },
69
- {
70
- "filters.lib/fir:license": "MIT-style STK-4.3 license"
71
- },
72
- {
73
- "filters.lib/iir:author": "Julius O. Smith III"
74
- },
75
- {
76
- "filters.lib/iir:copyright": "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>"
77
- },
78
- {
79
- "filters.lib/iir:license": "MIT-style STK-4.3 license"
80
- },
81
- {
82
- "filters.lib/lowpass0_highpass1": "MIT-style STK-4.3 license"
83
- },
84
- {
85
- "filters.lib/lowpass0_highpass1:author": "Julius O. Smith III"
86
- },
87
- {
88
- "filters.lib/lowpass:author": "Julius O. Smith III"
89
- },
90
- {
91
- "filters.lib/lowpass:copyright": "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>"
92
- },
93
- {
94
- "filters.lib/lowpass:license": "MIT-style STK-4.3 license"
95
- },
96
- {
97
- "filters.lib/name": "Faust Filters Library"
98
- },
99
- {
100
- "filters.lib/tf2:author": "Julius O. Smith III"
101
- },
102
- {
103
- "filters.lib/tf2:copyright": "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>"
104
- },
105
- {
106
- "filters.lib/tf2:license": "MIT-style STK-4.3 license"
107
- },
108
- {
109
- "filters.lib/tf2s:author": "Julius O. Smith III"
110
- },
111
- {
112
- "filters.lib/tf2s:copyright": "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>"
113
- },
114
- {
115
- "filters.lib/tf2s:license": "MIT-style STK-4.3 license"
116
- },
117
- {
118
- "filters.lib/version": "1.3.0"
119
- },
120
- {
121
- "license": "MIT"
122
- },
123
- {
124
- "maths.lib/author": "GRAME"
125
- },
126
- {
127
- "maths.lib/copyright": "GRAME"
128
- },
129
- {
130
- "maths.lib/license": "LGPL with exception"
131
- },
132
- {
133
- "maths.lib/name": "Faust Math Library"
134
- },
135
- {
136
- "maths.lib/version": "2.8.0"
137
- },
138
- {
139
- "name": "ClarinetMIDI"
140
- },
141
- {
142
- "noises.lib/name": "Faust Noise Generator Library"
143
- },
144
- {
145
- "noises.lib/version": "1.4.1"
146
- },
147
- {
148
- "options": "[midi:on][nvoices:2]"
149
- },
150
- {
151
- "oscillators.lib/name": "Faust Oscillator Library"
152
- },
153
- {
154
- "oscillators.lib/version": "1.5.1"
155
- },
156
- {
157
- "physmodels.lib/name": "Faust Physical Models Library"
158
- },
159
- {
160
- "physmodels.lib/version": "1.1.0"
161
- },
162
- {
163
- "platform.lib/name": "Generic Platform Library"
164
- },
165
- {
166
- "platform.lib/version": "1.3.0"
167
- },
168
- {
169
- "routes.lib/name": "Faust Signal Routing Library"
170
- },
171
- {
172
- "routes.lib/version": "1.2.0"
173
- },
174
- {
175
- "signals.lib/name": "Faust Signal Routing Library"
176
- },
177
- {
178
- "signals.lib/version": "1.5.0"
179
- }
180
- ],
181
- "ui": [
182
- {
183
- "type": "vgroup",
184
- "label": "clarinet",
185
- "items": [
186
- {
187
- "type": "hgroup",
188
- "label": "midi",
189
- "meta": [
190
- {
191
- "0": ""
192
- }
193
- ],
194
- "items": [
195
- {
196
- "type": "hslider",
197
- "label": "freq",
198
- "shortname": "freq",
199
- "address": "/clarinet/midi/freq",
200
- "index": 262188,
201
- "meta": [
202
- {
203
- "0": ""
204
- },
205
- {
206
- "style": "knob"
207
- }
208
- ],
209
- "init": 440,
210
- "min": 50,
211
- "max": 1000,
212
- "step": 0.01
213
- },
214
- {
215
- "type": "hslider",
216
- "label": "bend",
217
- "shortname": "bend",
218
- "address": "/clarinet/midi/bend",
219
- "index": 262192,
220
- "meta": [
221
- {
222
- "1": ""
223
- },
224
- {
225
- "hidden": "1"
226
- },
227
- {
228
- "midi": "pitchwheel"
229
- },
230
- {
231
- "style": "knob"
232
- }
233
- ],
234
- "init": 0,
235
- "min": -2,
236
- "max": 2,
237
- "step": 0.01
238
- },
239
- {
240
- "type": "hslider",
241
- "label": "gain",
242
- "shortname": "gain",
243
- "address": "/clarinet/midi/gain",
244
- "index": 262224,
245
- "meta": [
246
- {
247
- "2": ""
248
- },
249
- {
250
- "style": "knob"
251
- }
252
- ],
253
- "init": 0.6,
254
- "min": 0,
255
- "max": 1,
256
- "step": 0.01
257
- },
258
- {
259
- "type": "hslider",
260
- "label": "envAttack",
261
- "shortname": "envAttack",
262
- "address": "/clarinet/midi/envAttack",
263
- "index": 262228,
264
- "meta": [
265
- {
266
- "3": ""
267
- },
268
- {
269
- "style": "knob"
270
- }
271
- ],
272
- "init": 1,
273
- "min": 0,
274
- "max": 30,
275
- "step": 0.01
276
- },
277
- {
278
- "type": "hslider",
279
- "label": "sustain",
280
- "shortname": "sustain",
281
- "address": "/clarinet/midi/sustain",
282
- "index": 262200,
283
- "meta": [
284
- {
285
- "4": ""
286
- },
287
- {
288
- "hidden": "1"
289
- },
290
- {
291
- "midi": "ctrl 64"
292
- },
293
- {
294
- "style": "knob"
295
- }
296
- ],
297
- "init": 0,
298
- "min": 0,
299
- "max": 1,
300
- "step": 1
301
- }
302
- ]
303
- },
304
- {
305
- "type": "hgroup",
306
- "label": "otherParams",
307
- "meta": [
308
- {
309
- "1": ""
310
- }
311
- ],
312
- "items": [
313
- {
314
- "type": "hslider",
315
- "label": "reedStiffness",
316
- "shortname": "reedStiffness",
317
- "address": "/clarinet/otherParams/reedStiffness",
318
- "index": 262312,
319
- "meta": [
320
- {
321
- "0": ""
322
- },
323
- {
324
- "midi": "ctrl 1"
325
- },
326
- {
327
- "style": "knob"
328
- }
329
- ],
330
- "init": 0.5,
331
- "min": 0,
332
- "max": 1,
333
- "step": 0.01
334
- },
335
- {
336
- "type": "hslider",
337
- "label": "bellOpening",
338
- "shortname": "bellOpening",
339
- "address": "/clarinet/otherParams/bellOpening",
340
- "index": 262156,
341
- "meta": [
342
- {
343
- "1": ""
344
- },
345
- {
346
- "midi": "ctrl 3"
347
- },
348
- {
349
- "style": "knob"
350
- }
351
- ],
352
- "init": 0.5,
353
- "min": 0,
354
- "max": 1,
355
- "step": 0.01
356
- },
357
- {
358
- "type": "hslider",
359
- "label": "vibratoFreq",
360
- "shortname": "vibratoFreq",
361
- "address": "/clarinet/otherParams/vibratoFreq",
362
- "index": 262244,
363
- "meta": [
364
- {
365
- "2": ""
366
- },
367
- {
368
- "style": "knob"
369
- }
370
- ],
371
- "init": 5,
372
- "min": 1,
373
- "max": 10,
374
- "step": 0.01
375
- },
376
- {
377
- "type": "hslider",
378
- "label": "vibratoGain",
379
- "shortname": "vibratoGain",
380
- "address": "/clarinet/otherParams/vibratoGain",
381
- "index": 262220,
382
- "meta": [
383
- {
384
- "3": ""
385
- },
386
- {
387
- "style": "knob"
388
- }
389
- ],
390
- "init": 0.25,
391
- "min": 0,
392
- "max": 1,
393
- "step": 0.01
394
- },
395
- {
396
- "type": "hslider",
397
- "label": "outGain",
398
- "shortname": "outGain",
399
- "address": "/clarinet/otherParams/outGain",
400
- "index": 262144,
401
- "meta": [
402
- {
403
- "4": ""
404
- },
405
- {
406
- "style": "knob"
407
- }
408
- ],
409
- "init": 0.5,
410
- "min": 0,
411
- "max": 1,
412
- "step": 0.01
413
- }
414
- ]
415
- },
416
- {
417
- "type": "button",
418
- "label": "gate",
419
- "shortname": "gate",
420
- "address": "/clarinet/gate",
421
- "index": 262196,
422
- "meta": [
423
- {
424
- "2": ""
425
- }
426
- ]
427
- }
428
- ]
429
- }
430
- ]
431
- }
Binary file