@grame/faustwasm 0.0.57 → 0.0.59
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.
- package/0001-Rework-polyphonic-effect-mode.patch +122 -0
- package/assets/standalone/faustwasm/index.d.ts +1 -1
- package/assets/standalone/faustwasm/index.js +63 -21
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/assets/standalone/index-poly.js +2 -1
- package/assets/standalone/index.js +2 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +63 -21
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +1 -1
- package/dist/cjs-bundle/index.js +63 -21
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +63 -21
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +1 -1
- package/dist/esm-bundle/index.js +63 -21
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +1 -1
- package/src/FaustDspGenerator.ts +70 -23
- package/src/faust2wasmFiles.js +1 -1
- package/test/bug/bug.html +84 -0
- package/test/bug/bug.js +216 -0
- package/test/bug/bug.json +124 -0
- package/test/bug/bug.wasm +0 -0
- package/test/bug/bug_effect.json +95 -0
- package/test/bug/bug_effect.wasm +0 -0
- package/test/bug/faust-ui/index.css +416 -0
- package/test/bug/faust-ui/index.css.map +1 -0
- package/test/bug/faust-ui/index.d.ts +1 -0
- package/test/bug/faust-ui/index.js +3476 -0
- package/test/bug/faust-ui/index.js.map +1 -0
- package/test/bug/faustwasm/index.d.ts +1294 -0
- package/test/bug/faustwasm/index.js +3874 -0
- package/test/bug/faustwasm/index.js.map +7 -0
- package/test/bug/mixerModule.wasm +0 -0
- package/test/bug.dsp +22 -0
- package/test/clarinet.dsp +2 -1
- package/test/{p-dj.dsp → djembe.dsp} +0 -2
- package/test/faustlive-wasm/faustwasm/index.d.ts +1 -1
- package/test/faustlive-wasm/faustwasm/index.js +63 -21
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/gain.dsp +2 -0
- package/test/guitar.dsp +2 -1
- package/test/guitar1.dsp +2 -1
- package/test/libfaust-in-worklet/index.js +33 -33
- package/test/midi.dsp +0 -1
- package/test/web/index.js +217 -217
- package/test/Sinusoide.dsp +0 -60
- package/test/t1.dsp +0 -1
package/package.json
CHANGED
package/src/FaustDspGenerator.ts
CHANGED
|
@@ -395,35 +395,82 @@ export class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
|
|
|
395
395
|
async compile(
|
|
396
396
|
compiler: IFaustCompiler,
|
|
397
397
|
name: string,
|
|
398
|
-
|
|
398
|
+
dspCodeAux: string,
|
|
399
399
|
args: string,
|
|
400
|
-
// The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
adapt(2,2) = _,_;
|
|
404
|
-
adapt(1,2) = _ <: _,_;
|
|
405
|
-
adapt(2,1) = _,_ :> _;
|
|
406
|
-
adaptor(F,G) = adapt(outputs(F),inputs(G));
|
|
407
|
-
dsp_code = environment{
|
|
408
|
-
${dspCode}
|
|
400
|
+
// The ${dspCode} has to be added with wrapping new lines to make it properly formatted and ready to compile
|
|
401
|
+
effectCodeAux = `dsp_code = environment{
|
|
402
|
+
${dspCodeAux}
|
|
409
403
|
};
|
|
410
|
-
process =
|
|
404
|
+
process = dsp_code.effect;`
|
|
411
405
|
) {
|
|
412
|
-
|
|
413
|
-
if (!this.voiceFactory) return null;
|
|
414
|
-
// Compile effect, possibly failing
|
|
406
|
+
// Try to compile effect, possibly failing
|
|
415
407
|
try {
|
|
416
|
-
this.effectFactory = await compiler.createPolyDSPFactory(name,
|
|
408
|
+
this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);
|
|
409
|
+
// Since the effect is processing the same buffers for inputs and outputs (in place processing),
|
|
410
|
+
// the voice and effect are adapted, possibly clearing buffers
|
|
411
|
+
if (this.effectFactory) {
|
|
412
|
+
const effectJSON = JSON.parse(this.effectFactory.json);
|
|
413
|
+
const dspCode = `
|
|
414
|
+
// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,
|
|
415
|
+
// so that the effect can process the 2 channels of the voice
|
|
416
|
+
adaptOut(1,1,1) = _;
|
|
417
|
+
adaptOut(1,1,2) = _ <: _,_;
|
|
418
|
+
adaptOut(1,2,1) = _ <: _,_;
|
|
419
|
+
adaptOut(1,2,2) = _ <: _,_;
|
|
420
|
+
adaptOut(2,1,1) = _,_;
|
|
421
|
+
adaptOut(2,1,2) = _,_;
|
|
422
|
+
adaptOut(2,2,1) = _,_;
|
|
423
|
+
adaptOut(2,2,2) = _,_;
|
|
424
|
+
adaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
|
|
425
|
+
dsp_code = environment{
|
|
426
|
+
${dspCodeAux}
|
|
427
|
+
};
|
|
428
|
+
process = dsp_code.process : adaptor(dsp_code.process);`
|
|
429
|
+
const effectCode = `
|
|
430
|
+
// Inputs
|
|
431
|
+
adaptIn(1,1,1) = _;
|
|
432
|
+
adaptIn(1,1,2) = _,*(0) :> _; // The voice output was duplicated, so only one channel has to be kept
|
|
433
|
+
adaptIn(1,2,1) = _,_;
|
|
434
|
+
adaptIn(1,2,2) = _,_;
|
|
435
|
+
adaptIn(2,1,1) = _,_ :> _;
|
|
436
|
+
adaptIn(2,1,2) = _,_ :> _;
|
|
437
|
+
adaptIn(2,2,1) = _,_;
|
|
438
|
+
adaptIn(2,2,2) = _,_;
|
|
439
|
+
// Outputs
|
|
440
|
+
adaptOut(1,1) = _ <: _,*(0); // The left channel is kept, but the right one has to be cleared
|
|
441
|
+
adaptOut(1,2) = _,_;
|
|
442
|
+
adaptOut(2,1) = _ <: _,*(0); // The left channel is kept, but the right one has to be cleared
|
|
443
|
+
adaptOut(2,2) = _,_;
|
|
444
|
+
adaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
|
|
445
|
+
adaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});
|
|
446
|
+
dsp_code = environment{
|
|
447
|
+
${dspCodeAux}
|
|
448
|
+
};
|
|
449
|
+
process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;`
|
|
450
|
+
this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
|
|
451
|
+
try {
|
|
452
|
+
// Effect is processing same buffers for inputs and outputs, so has to use -inpl option
|
|
453
|
+
this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + " -inpl");
|
|
454
|
+
} catch (e) {
|
|
455
|
+
console.log(e);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
417
458
|
} catch (e) {
|
|
418
|
-
console.
|
|
459
|
+
console.log(e);
|
|
460
|
+
this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCodeAux, args);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
if (this.voiceFactory) {
|
|
464
|
+
this.name = name;
|
|
465
|
+
const voiceMeta = JSON.parse(this.voiceFactory.json);
|
|
466
|
+
const isDouble = voiceMeta.compile_options.match("-double");
|
|
467
|
+
const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);
|
|
468
|
+
this.mixerBuffer = mixerBuffer;
|
|
469
|
+
this.mixerModule = mixerModule;
|
|
470
|
+
return this;
|
|
471
|
+
} else {
|
|
472
|
+
return null;
|
|
419
473
|
}
|
|
420
|
-
this.name = name;
|
|
421
|
-
const voiceMeta = JSON.parse(this.voiceFactory.json);
|
|
422
|
-
const isDouble = voiceMeta.compile_options.match("-double");
|
|
423
|
-
const { mixerBuffer, mixerModule } = await compiler.getAsyncInternalMixerModule(!!isDouble);
|
|
424
|
-
this.mixerBuffer = mixerBuffer;
|
|
425
|
-
this.mixerModule = mixerModule;
|
|
426
|
-
return this;
|
|
427
474
|
}
|
|
428
475
|
|
|
429
476
|
async createNode<SP extends boolean = false>(
|
package/src/faust2wasmFiles.js
CHANGED
|
@@ -31,6 +31,7 @@ const faust2wasmFiles = async (inputFile, outputDir, argv = [], poly = false) =>
|
|
|
31
31
|
const dspName = fileName.replace(/\.dsp$/, '');
|
|
32
32
|
|
|
33
33
|
if (!argv.find(a => a === "-I")) argv.push("-I", "libraries/");
|
|
34
|
+
argv.push("-ftz", "2");
|
|
34
35
|
const dspModulePath = path.join(outputDir, `${dspName}.wasm`);
|
|
35
36
|
const dspMetaPath = path.join(outputDir, `${dspName}.json`);
|
|
36
37
|
const effectModulePath = path.join(outputDir, `${dspName}_effect.wasm`);
|
|
@@ -58,7 +59,6 @@ const faust2wasmFiles = async (inputFile, outputDir, argv = [], poly = false) =>
|
|
|
58
59
|
dspModule = voiceFactory.code;
|
|
59
60
|
dspMeta = JSON.parse(voiceFactory.json);
|
|
60
61
|
mixerModule = mixerBuffer;
|
|
61
|
-
|
|
62
62
|
if (effectFactory) {
|
|
63
63
|
effectModule = effectFactory.code;
|
|
64
64
|
effectMeta = JSON.parse(effectFactory.json);
|
|
@@ -0,0 +1,84 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
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
|
+
})();
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bug",
|
|
3
|
+
"filename": "bug",
|
|
4
|
+
"version": "2.72.4",
|
|
5
|
+
"compile_options": "-lang wasm-e -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/oscillators.lib",
|
|
9
|
+
"/usr/share/faust/maths.lib",
|
|
10
|
+
"/usr/share/faust/platform.lib",
|
|
11
|
+
"/usr/share/faust/envelopes.lib"
|
|
12
|
+
],
|
|
13
|
+
"include_pathnames": [
|
|
14
|
+
"/share/faust",
|
|
15
|
+
"/usr/local/share/faust",
|
|
16
|
+
"/usr/share/faust",
|
|
17
|
+
"."
|
|
18
|
+
],
|
|
19
|
+
"size": 76,
|
|
20
|
+
"inputs": 0,
|
|
21
|
+
"outputs": 2,
|
|
22
|
+
"meta": [
|
|
23
|
+
{
|
|
24
|
+
"compile_options": "-lang wasm-e -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"envelopes.lib/adsr:author": "Yann Orlarey and Andrey Bundin"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"envelopes.lib/author": "GRAME"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"envelopes.lib/copyright": "GRAME"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"envelopes.lib/license": "LGPL with exception"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"envelopes.lib/name": "Faust Envelope Library"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"envelopes.lib/version": "1.3.0"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"filename": "bug"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"maths.lib/author": "GRAME"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"maths.lib/copyright": "GRAME"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"maths.lib/license": "LGPL with exception"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"maths.lib/name": "Faust Math Library"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"maths.lib/version": "2.7.0"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "bug"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"options": "[midi:on][nvoices:12]"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"oscillators.lib/name": "Faust Oscillator Library"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"oscillators.lib/saw2ptr:author": "Julius O. Smith III"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"oscillators.lib/saw2ptr:license": "STK-4.3"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"oscillators.lib/version": "1.5.0"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"platform.lib/name": "Generic Platform Library"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"platform.lib/version": "1.3.0"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"ui": [
|
|
88
|
+
{
|
|
89
|
+
"type": "vgroup",
|
|
90
|
+
"label": "bug",
|
|
91
|
+
"items": [
|
|
92
|
+
{
|
|
93
|
+
"type": "hslider",
|
|
94
|
+
"label": "freq",
|
|
95
|
+
"shortname": "freq",
|
|
96
|
+
"address": "/bug/freq",
|
|
97
|
+
"index": 16,
|
|
98
|
+
"init": 200,
|
|
99
|
+
"min": 50,
|
|
100
|
+
"max": 1000,
|
|
101
|
+
"step": 0.01
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"type": "hslider",
|
|
105
|
+
"label": "gain",
|
|
106
|
+
"shortname": "gain",
|
|
107
|
+
"address": "/bug/gain",
|
|
108
|
+
"index": 0,
|
|
109
|
+
"init": 0.5,
|
|
110
|
+
"min": 0,
|
|
111
|
+
"max": 1,
|
|
112
|
+
"step": 0.01
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"type": "button",
|
|
116
|
+
"label": "gate",
|
|
117
|
+
"shortname": "gate",
|
|
118
|
+
"address": "/bug/gate",
|
|
119
|
+
"index": 32
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bug",
|
|
3
|
+
"filename": "bug",
|
|
4
|
+
"version": "2.72.4",
|
|
5
|
+
"compile_options": "-lang wasm-e -inpl -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/oscillators.lib",
|
|
9
|
+
"/usr/share/faust/maths.lib",
|
|
10
|
+
"/usr/share/faust/platform.lib",
|
|
11
|
+
"/usr/share/faust/envelopes.lib"
|
|
12
|
+
],
|
|
13
|
+
"include_pathnames": [
|
|
14
|
+
"/share/faust",
|
|
15
|
+
"/usr/local/share/faust",
|
|
16
|
+
"/usr/share/faust",
|
|
17
|
+
"."
|
|
18
|
+
],
|
|
19
|
+
"size": 4,
|
|
20
|
+
"code": "xI8e",
|
|
21
|
+
"inputs": 2,
|
|
22
|
+
"outputs": 2,
|
|
23
|
+
"meta": [
|
|
24
|
+
{
|
|
25
|
+
"compile_options": "-lang wasm-e -inpl -ct 1 -es 1 -mcd 16 -mdd 1024 -mdy 33 -single -ftz 2"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"envelopes.lib/adsr:author": "Yann Orlarey and Andrey Bundin"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"envelopes.lib/author": "GRAME"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"envelopes.lib/copyright": "GRAME"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"envelopes.lib/license": "LGPL with exception"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"envelopes.lib/name": "Faust Envelope Library"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"envelopes.lib/version": "1.3.0"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"filename": "bug"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"maths.lib/author": "GRAME"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"maths.lib/copyright": "GRAME"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"maths.lib/license": "LGPL with exception"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"maths.lib/name": "Faust Math Library"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"maths.lib/version": "2.7.0"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "bug"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"options": "[midi:on][nvoices:12]"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"oscillators.lib/name": "Faust Oscillator Library"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"oscillators.lib/saw2ptr:author": "Julius O. Smith III"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"oscillators.lib/saw2ptr:license": "STK-4.3"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"oscillators.lib/version": "1.5.0"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"platform.lib/name": "Generic Platform Library"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"platform.lib/version": "1.3.0"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"ui": [
|
|
89
|
+
{
|
|
90
|
+
"type": "vgroup",
|
|
91
|
+
"label": "bug",
|
|
92
|
+
"items": []
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
Binary file
|