@grame/faustwasm 0.4.5 → 0.4.8
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/COPYING.txt +520 -0
- package/README.md +4 -4
- package/assets/standalone/create-node.js +78 -0
- package/assets/standalone/faust-ui/index.css +8 -0
- package/assets/standalone/faust-ui/index.css.map +1 -1
- package/assets/standalone/faust-ui/index.js +56 -30
- package/assets/standalone/faust-ui/index.js.map +1 -1
- package/assets/standalone/faustwasm/index.d.ts +18 -10
- package/assets/standalone/faustwasm/index.js +81 -56
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/assets/standalone/index-template.html +17 -0
- package/assets/standalone/index-template.js +48 -0
- package/assets/standalone/index.html +4 -3
- package/assets/standalone/index.js +14 -71
- package/assets/standalone/manifest.json +5 -6
- package/assets/standalone/service-worker.js +51 -27
- package/dist/cjs/index.d.ts +18 -10
- package/dist/cjs/index.js +81 -56
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +18 -10
- package/dist/cjs-bundle/index.js +81 -56
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +18 -10
- package/dist/esm/index.js +81 -56
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +18 -10
- package/dist/esm-bundle/index.js +81 -56
- package/dist/esm-bundle/index.js.map +2 -2
- package/fileutils.js +19 -21
- package/package.json +4 -2
- package/scripts/faust2wasm.js +10 -5
- package/src/FaustAudioWorkletNode.ts +18 -38
- package/src/FaustAudioWorkletProcessor.ts +28 -1
- package/src/FaustDspGenerator.ts +18 -9
- package/src/FaustFFTAudioWorkletProcessor.ts +27 -0
- package/src/FaustScriptProcessorNode.ts +5 -14
- package/src/copyWebStandaloneAssets.d.ts +2 -2
- package/src/copyWebStandaloneAssets.js +30 -19
- package/src/faust2wasmFiles.js +5 -5
- package/test/faustlive-wasm/faust-ui/index.css +8 -0
- package/test/faustlive-wasm/faust-ui/index.css.map +1 -1
- package/test/faustlive-wasm/faust-ui/index.js +56 -30
- package/test/faustlive-wasm/faust-ui/index.js.map +1 -1
- package/test/faustlive-wasm/faustwasm/index.d.ts +18 -10
- package/test/faustlive-wasm/faustwasm/index.js +81 -56
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/assets/standalone/index-poly.js +0 -234
- package/assets/standalone/service-worker-poly.js +0 -98
- package/assets/standalone/template-poly.html +0 -60
- package/assets/standalone/template.html +0 -50
- package/assets/standalone/template.js +0 -63
- package/assets/standalone/types.d.ts +0 -9
|
@@ -0,0 +1,17 @@
|
|
|
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="./index-template.js"></script>
|
|
15
|
+
</body>
|
|
16
|
+
|
|
17
|
+
</html>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Set to > 0 if the DSP is polyphonic
|
|
2
|
+
const FAUST_DSP_VOICES = 0;
|
|
3
|
+
|
|
4
|
+
(async () => {
|
|
5
|
+
const { default: createFaustNode } = await import("./create-node.js");
|
|
6
|
+
|
|
7
|
+
// Create audio context
|
|
8
|
+
const AudioCtx = window.AudioContext || window.webkitAudioContext;
|
|
9
|
+
const audioContext = new AudioCtx({ latencyHint: 0.00001 });
|
|
10
|
+
audioContext.suspend();
|
|
11
|
+
|
|
12
|
+
// Create audio context activation button
|
|
13
|
+
/** @type {HTMLButtonElement} */
|
|
14
|
+
const $buttonDsp = document.getElementById("button-dsp");
|
|
15
|
+
|
|
16
|
+
const play = (node) => {
|
|
17
|
+
node.keyOn(0, 60, 100);
|
|
18
|
+
setTimeout(() => node.keyOn(0, 64, 100), 1000);
|
|
19
|
+
setTimeout(() => node.keyOn(0, 67, 100), 2000);
|
|
20
|
+
setTimeout(() => node.allNotesOff(), 5000);
|
|
21
|
+
setTimeout(() => play(node), 7000);
|
|
22
|
+
}
|
|
23
|
+
// Function to activate audio context
|
|
24
|
+
$buttonDsp.disabled = true;
|
|
25
|
+
$buttonDsp.onclick = () => {
|
|
26
|
+
if (audioContext.state === "running") {
|
|
27
|
+
$buttonDsp.textContent = "Suspended";
|
|
28
|
+
audioContext.suspend();
|
|
29
|
+
} else if (audioContext.state === "suspended") {
|
|
30
|
+
$buttonDsp.textContent = "Running";
|
|
31
|
+
audioContext.resume();
|
|
32
|
+
if (FAUST_DSP_VOICES) play(faustNode);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Create Faust node
|
|
37
|
+
const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "FAUST_DSP_NAME", FAUST_DSP_VOICES);
|
|
38
|
+
if (!faustNode) throw new Error("Faust DSP not compiled");
|
|
39
|
+
|
|
40
|
+
// Connect Faust node to audio context
|
|
41
|
+
faustNode.connect(audioContext.destination);
|
|
42
|
+
|
|
43
|
+
// Create Faust node activation button
|
|
44
|
+
$buttonDsp.disabled = false;
|
|
45
|
+
|
|
46
|
+
// Set page title to the DSP name
|
|
47
|
+
document.title = name;
|
|
48
|
+
})();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
|
|
4
|
-
<link rel="manifest" href="
|
|
4
|
+
<link rel="manifest" href="./manifest.json">
|
|
5
5
|
|
|
6
6
|
<head>
|
|
7
7
|
<meta charset="UTF-8">
|
|
@@ -59,9 +59,10 @@
|
|
|
59
59
|
display: flex;
|
|
60
60
|
position: relative;
|
|
61
61
|
flex-direction: column;
|
|
62
|
+
color: black;
|
|
62
63
|
}
|
|
63
64
|
</style>
|
|
64
|
-
<link rel="stylesheet" href="
|
|
65
|
+
<link rel="stylesheet" href="./faust-ui/index.css">
|
|
65
66
|
</head>
|
|
66
67
|
|
|
67
68
|
<body>
|
|
@@ -80,7 +81,7 @@
|
|
|
80
81
|
<div id="div-faust-ui">
|
|
81
82
|
</div>
|
|
82
83
|
</main>
|
|
83
|
-
<script src="
|
|
84
|
+
<script src="./index.js"></script>
|
|
84
85
|
</body>
|
|
85
86
|
|
|
86
87
|
</html>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
// Set to > 0 if the DSP is polyphonic
|
|
2
|
+
const FAUST_DSP_VOICES = 0;
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
* @typedef {import("./types").FaustDspDistribution} FaustDspDistribution
|
|
3
5
|
* @typedef {import("./faustwasm").FaustAudioWorkletNode} FaustAudioWorkletNode
|
|
4
6
|
* @typedef {import("./faustwasm").FaustDspMeta} FaustDspMeta
|
|
5
7
|
* @typedef {import("./faustwasm").FaustUIDescriptor} FaustUIDescriptor
|
|
@@ -10,11 +12,11 @@
|
|
|
10
12
|
/**
|
|
11
13
|
* Registers the service worker.
|
|
12
14
|
*/
|
|
13
|
-
if (
|
|
14
|
-
window.addEventListener(
|
|
15
|
-
navigator.serviceWorker.register(
|
|
16
|
-
.then(reg => console.log(
|
|
17
|
-
.catch(err => console.log(
|
|
15
|
+
if ("serviceWorker" in navigator) {
|
|
16
|
+
window.addEventListener("load", () => {
|
|
17
|
+
navigator.serviceWorker.register("./service-worker.js")
|
|
18
|
+
.then(reg => console.log("Service Worker registered", reg))
|
|
19
|
+
.catch(err => console.log("Service Worker registration failed", err));
|
|
18
20
|
});
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -33,7 +35,7 @@ const $divFaustUI = document.getElementById("div-faust-ui");
|
|
|
33
35
|
|
|
34
36
|
/** @type {typeof AudioContext} */
|
|
35
37
|
const AudioCtx = window.AudioContext || window.webkitAudioContext;
|
|
36
|
-
const audioContext = new AudioCtx({ latencyHint: 0.00001
|
|
38
|
+
const audioContext = new AudioCtx({ latencyHint: 0.00001 });
|
|
37
39
|
audioContext.destination.channelInterpretation = "discrete";
|
|
38
40
|
audioContext.suspend();
|
|
39
41
|
$buttonDsp.disabled = true;
|
|
@@ -46,7 +48,7 @@ const buildAudioDeviceMenu = async (faustNode) => {
|
|
|
46
48
|
let inputStreamNode;
|
|
47
49
|
const handleDeviceChange = async () => {
|
|
48
50
|
const devicesInfo = await navigator.mediaDevices.enumerateDevices();
|
|
49
|
-
$selectAudioInput.innerHTML =
|
|
51
|
+
$selectAudioInput.innerHTML = "";
|
|
50
52
|
devicesInfo.forEach((deviceInfo, i) => {
|
|
51
53
|
const { kind, deviceId, label } = deviceInfo;
|
|
52
54
|
if (kind === "audioinput") {
|
|
@@ -119,67 +121,6 @@ const buildMidiDeviceMenu = async (faustNode) => {
|
|
|
119
121
|
};
|
|
120
122
|
};
|
|
121
123
|
|
|
122
|
-
/**
|
|
123
|
-
* Creates a Faust audio node for use in the Web Audio API.
|
|
124
|
-
*
|
|
125
|
-
* @param {AudioContext} audioContext - The Web Audio API AudioContext to which the Faust audio node will be connected.
|
|
126
|
-
* @param {string} dspName - The name of the DSP to be loaded.
|
|
127
|
-
* @param {number} voices - The number of voices to be used for polyphonic DSPs.
|
|
128
|
-
* @param {boolean} sp - Whether to create a ScriptProcessorNode instead of an AudioWorkletNode.
|
|
129
|
-
* @returns {Object} - An object containing the Faust audio node and the DSP metadata.
|
|
130
|
-
*/
|
|
131
|
-
const createFaustNode = async (audioContext, dspName = "template", voices = 0, sp = false) => {
|
|
132
|
-
// Import necessary Faust modules and data
|
|
133
|
-
const { FaustMonoDspGenerator, FaustPolyDspGenerator } = await import("./faustwasm/index.js");
|
|
134
|
-
|
|
135
|
-
// Load DSP metadata from JSON
|
|
136
|
-
/** @type {FaustDspMeta} */
|
|
137
|
-
const dspMeta = await (await fetch(`./${dspName}.json`)).json();
|
|
138
|
-
|
|
139
|
-
// Compile the DSP module from WebAssembly binary data
|
|
140
|
-
const dspModule = await WebAssembly.compileStreaming(await fetch(`./${dspName}.wasm`));
|
|
141
|
-
|
|
142
|
-
// Create an object representing Faust DSP with metadata and module
|
|
143
|
-
/** @type {FaustDspDistribution} */
|
|
144
|
-
const faustDsp = { dspMeta, dspModule };
|
|
145
|
-
|
|
146
|
-
/** @type {FaustAudioWorkletNode} */
|
|
147
|
-
let faustNode;
|
|
148
|
-
|
|
149
|
-
// Create either a polyphonic or monophonic Faust audio node based on the number of voices
|
|
150
|
-
if (voices > 0) {
|
|
151
|
-
|
|
152
|
-
// Try to load optional mixer and effect modules
|
|
153
|
-
try {
|
|
154
|
-
faustDsp.mixerModule = await WebAssembly.compileStreaming(await fetch("./mixerModule.wasm"));
|
|
155
|
-
faustDsp.effectMeta = await (await fetch(`./${dspName}_effect.json`)).json();
|
|
156
|
-
faustDsp.effectModule = await WebAssembly.compileStreaming(await fetch(`./${dspName}_effect.wasm`));
|
|
157
|
-
} catch (e) { }
|
|
158
|
-
|
|
159
|
-
const generator = new FaustPolyDspGenerator();
|
|
160
|
-
faustNode = await generator.createNode(
|
|
161
|
-
audioContext,
|
|
162
|
-
voices,
|
|
163
|
-
"FaustPolyDSP",
|
|
164
|
-
{ module: faustDsp.dspModule, json: JSON.stringify(faustDsp.dspMeta) },
|
|
165
|
-
faustDsp.mixerModule,
|
|
166
|
-
faustDsp.effectModule ? { module: faustDsp.effectModule, json: JSON.stringify(faustDsp.effectMeta) } : undefined,
|
|
167
|
-
sp
|
|
168
|
-
);
|
|
169
|
-
} else {
|
|
170
|
-
const generator = new FaustMonoDspGenerator();
|
|
171
|
-
faustNode = await generator.createNode(
|
|
172
|
-
audioContext,
|
|
173
|
-
"FaustMonoDSP",
|
|
174
|
-
{ module: faustDsp.dspModule, json: JSON.stringify(faustDsp.dspMeta) },
|
|
175
|
-
sp
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Return an object with the Faust audio node and the DSP metadata
|
|
180
|
-
return { faustNode, dspMeta };
|
|
181
|
-
}
|
|
182
|
-
|
|
183
124
|
/**
|
|
184
125
|
* @param {FaustAudioWorkletNode} faustNode
|
|
185
126
|
*/
|
|
@@ -208,9 +149,11 @@ const createFaustUI = async (faustNode) => {
|
|
|
208
149
|
};
|
|
209
150
|
|
|
210
151
|
(async () => {
|
|
152
|
+
const { default: createFaustNode } = await import("./create-node.js");
|
|
211
153
|
// To test the ScriptProcessorNode mode
|
|
212
|
-
//const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "
|
|
213
|
-
const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "
|
|
154
|
+
// const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "FAUST_DSP_NAME", FAUST_DSP_VOICES, true);
|
|
155
|
+
const { faustNode, dspMeta: { name } } = await createFaustNode(audioContext, "FAUST_DSP_NAME", FAUST_DSP_VOICES);
|
|
156
|
+
if (!faustNode) throw new Error("Faust DSP not compiled");
|
|
214
157
|
await createFaustUI(faustNode);
|
|
215
158
|
faustNode.connect(audioContext.destination);
|
|
216
159
|
if (faustNode.numberOfInputs) await buildAudioDeviceMenu(faustNode);
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "Faust
|
|
3
|
-
"short_name": "
|
|
4
|
-
"start_url": "
|
|
5
|
-
"description": "Progressive Web App for
|
|
2
|
+
"name": "Faust FAUST_DSP_NAME",
|
|
3
|
+
"short_name": "FAUST_DSP_NAME",
|
|
4
|
+
"start_url": "./index.html",
|
|
5
|
+
"description": "Progressive Web App for FAUST_DSP_NAME",
|
|
6
6
|
"display": "standalone",
|
|
7
7
|
"background_color": "#ffffff",
|
|
8
8
|
"theme_color": "#000000",
|
|
9
|
-
"scope": "/FAUST_DSP/",
|
|
10
9
|
"orientation": "portrait",
|
|
11
10
|
"icons": [
|
|
12
11
|
{
|
|
13
|
-
"src": "icon.png",
|
|
12
|
+
"src": "./icon.png",
|
|
14
13
|
"sizes": "390x390",
|
|
15
14
|
"type": "image/png"
|
|
16
15
|
}
|
|
@@ -1,31 +1,55 @@
|
|
|
1
|
+
/// <reference lib="webworker" />
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
// Set to > 0 if the DSP is polyphonic
|
|
4
|
+
const FAUST_DSP_VOICES = 0;
|
|
5
|
+
// Set to true if the DSP has an effect
|
|
6
|
+
const FAUST_DSP_HAS_EFFECT = false;
|
|
7
|
+
|
|
8
|
+
const CACHE_NAME = "FAUST_DSP_NAME-static"; // Cache name without versioning
|
|
9
|
+
|
|
10
|
+
const MONO_RESOURCES = [
|
|
11
|
+
"./index.html",
|
|
12
|
+
"./faust-ui/index.js",
|
|
13
|
+
"./faust-ui/index.css",
|
|
14
|
+
"./faustwasm/index.js",
|
|
15
|
+
"./index.js",
|
|
16
|
+
"./dsp-module.wasm",
|
|
17
|
+
"./dsp-meta.json"
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const POLY_RESOURCES = [
|
|
21
|
+
...MONO_RESOURCES,
|
|
22
|
+
"./mixer-module.wasm",
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const POLY_EFFECT_RESOURCES = [
|
|
26
|
+
...POLY_RESOURCES,
|
|
27
|
+
"./effect-module.wasm",
|
|
28
|
+
"./effect-meta.json",
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
/**@type {ServiceWorkerGlobalScope} */
|
|
32
|
+
const serviceWorkerGlobalScope = self;
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Install the service worker and cache the resources
|
|
36
|
+
*/
|
|
37
|
+
serviceWorkerGlobalScope.addEventListener("install", (event) => {
|
|
38
|
+
console.log("Service worker installed");
|
|
39
|
+
event.waitUntil((async () => {
|
|
40
|
+
const cache = await caches.open(CACHE_NAME);
|
|
41
|
+
const resources = (FAUST_DSP_VOICES && FAUST_DSP_HAS_EFFECT) ? POLY_EFFECT_RESOURCES : FAUST_DSP_VOICES ? POLY_RESOURCES : MONO_RESOURCES;
|
|
42
|
+
try {
|
|
43
|
+
return cache.addAll(resources);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error("Failed to cache resources during install:", error);
|
|
46
|
+
}
|
|
47
|
+
})());
|
|
26
48
|
});
|
|
27
49
|
|
|
28
|
-
|
|
50
|
+
serviceWorkerGlobalScope.addEventListener("activate", () => console.log("Service worker activated"));
|
|
51
|
+
|
|
52
|
+
serviceWorkerGlobalScope.addEventListener("fetch", (event) => {
|
|
29
53
|
event.respondWith((async () => {
|
|
30
54
|
const cache = await caches.open(CACHE_NAME);
|
|
31
55
|
const cachedResponse = await cache.match(event.request);
|
|
@@ -35,14 +59,14 @@ self.addEventListener('fetch', event => {
|
|
|
35
59
|
try {
|
|
36
60
|
const fetchResponse = await fetch(event.request);
|
|
37
61
|
// Ensure the response is valid before caching it
|
|
38
|
-
if (event.request.method ===
|
|
62
|
+
if (event.request.method === "GET" && fetchResponse && fetchResponse.status === 200 && fetchResponse.type === "basic") {
|
|
39
63
|
cache.put(event.request, fetchResponse.clone());
|
|
40
64
|
}
|
|
41
65
|
return fetchResponse;
|
|
42
66
|
} catch (e) {
|
|
43
67
|
// Network access failure
|
|
44
|
-
console.log(
|
|
68
|
+
console.log("Network access error", e);
|
|
45
69
|
}
|
|
46
70
|
}
|
|
47
71
|
})());
|
|
48
|
-
});
|
|
72
|
+
});
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -887,6 +887,8 @@ export interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOption
|
|
|
887
887
|
export interface FaustAudioWorkletProcessorOptions {
|
|
888
888
|
name: string;
|
|
889
889
|
sampleSize: number;
|
|
890
|
+
moduleId?: string;
|
|
891
|
+
instanceId?: string;
|
|
890
892
|
}
|
|
891
893
|
export interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
|
|
892
894
|
factory: LooseFaustDspFactory;
|
|
@@ -931,6 +933,8 @@ export interface FaustFFTAudioWorkletProcessorOptions {
|
|
|
931
933
|
name: string;
|
|
932
934
|
sampleSize: number;
|
|
933
935
|
factory: LooseFaustDspFactory;
|
|
936
|
+
moduleId?: string;
|
|
937
|
+
instanceId?: string;
|
|
934
938
|
}
|
|
935
939
|
export declare const getFaustFFTAudioWorkletProcessor: (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register?: boolean) => {
|
|
936
940
|
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
@@ -1266,7 +1270,7 @@ export declare class SoundfileReader {
|
|
|
1266
1270
|
static loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory["soundfiles"], audioCtx: BaseAudioContext): Promise<LooseFaustDspFactory["soundfiles"]>;
|
|
1267
1271
|
}
|
|
1268
1272
|
declare const FaustAudioWorkletNode_base: {
|
|
1269
|
-
new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions
|
|
1273
|
+
new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode;
|
|
1270
1274
|
prototype: AudioWorkletNode;
|
|
1271
1275
|
};
|
|
1272
1276
|
/**
|
|
@@ -1282,7 +1286,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1282
1286
|
protected fPlotHandler: PlotHandler | null;
|
|
1283
1287
|
protected fUICallback: UIHandler;
|
|
1284
1288
|
protected fDescriptor: FaustUIInputItem[];
|
|
1285
|
-
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options
|
|
1289
|
+
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial<FaustAudioWorkletNodeOptions<Poly>>);
|
|
1286
1290
|
/** Setup accelerometer and gyroscope handlers */
|
|
1287
1291
|
listenSensors(): Promise<void>;
|
|
1288
1292
|
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
@@ -1291,6 +1295,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1291
1295
|
getComputeHandler(): ComputeHandler | null;
|
|
1292
1296
|
setPlotHandler(handler: PlotHandler | null): void;
|
|
1293
1297
|
getPlotHandler(): PlotHandler | null;
|
|
1298
|
+
setupWamEventHandler(): void;
|
|
1294
1299
|
getNumInputs(): number;
|
|
1295
1300
|
getNumOutputs(): number;
|
|
1296
1301
|
compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
|
|
@@ -1318,7 +1323,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1318
1323
|
*/
|
|
1319
1324
|
export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<false> implements IFaustMonoWebAudioDsp {
|
|
1320
1325
|
onprocessorerror: (e: Event) => never;
|
|
1321
|
-
constructor(context: BaseAudioContext,
|
|
1326
|
+
constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<false>> & Pick<FaustAudioWorkletNodeOptions<false>, "processorOptions">);
|
|
1322
1327
|
}
|
|
1323
1328
|
/**
|
|
1324
1329
|
* Polyphonic AudioWorkletNode
|
|
@@ -1326,7 +1331,7 @@ export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<fal
|
|
|
1326
1331
|
export declare class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode<true> implements IFaustPolyWebAudioDsp {
|
|
1327
1332
|
private fJSONEffect;
|
|
1328
1333
|
onprocessorerror: (e: Event) => never;
|
|
1329
|
-
constructor(context: BaseAudioContext,
|
|
1334
|
+
constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<true>> & Pick<FaustAudioWorkletNodeOptions<true>, "processorOptions">);
|
|
1330
1335
|
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
1331
1336
|
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
1332
1337
|
allNotesOff(hard: boolean): void;
|
|
@@ -1419,9 +1424,10 @@ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
|
|
|
1419
1424
|
* @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
|
|
1420
1425
|
* @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
|
|
1421
1426
|
* @param processorName - AudioWorklet Processor name
|
|
1427
|
+
* @param processorOptions - Additional AudioWorklet Processor options
|
|
1422
1428
|
* @returns the compiled WebAudio node or 'null' if failure
|
|
1423
1429
|
*/
|
|
1424
|
-
createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string): Promise<IFaustMonoWebAudioNode | null>;
|
|
1430
|
+
createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<IFaustMonoWebAudioNode | null>;
|
|
1425
1431
|
/**
|
|
1426
1432
|
* Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
|
|
1427
1433
|
*
|
|
@@ -1431,9 +1437,10 @@ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
|
|
|
1431
1437
|
* @param factory - default is the compiled factory
|
|
1432
1438
|
* @param fftOptions - initial FFT options
|
|
1433
1439
|
* @param processorName - AudioWorklet Processor name
|
|
1440
|
+
* @param processorOptions - Additional AudioWorklet Processor options
|
|
1434
1441
|
* @returns the compiled WebAudio node or 'null' if failure
|
|
1435
1442
|
*/
|
|
1436
|
-
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1443
|
+
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1437
1444
|
/**
|
|
1438
1445
|
* Create a monophonic Offline processor.
|
|
1439
1446
|
*
|
|
@@ -1489,9 +1496,10 @@ export interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {
|
|
|
1489
1496
|
* @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
|
|
1490
1497
|
* @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
|
|
1491
1498
|
* @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
|
|
1499
|
+
* @param processorOptions - Additional AudioWorklet Processor options
|
|
1492
1500
|
* @returns the compiled WebAudio node or 'null' if failure
|
|
1493
1501
|
*/
|
|
1494
|
-
createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: boolean, bufferSize?: number, processorName?: string): Promise<IFaustPolyWebAudioNode | null>;
|
|
1502
|
+
createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<IFaustPolyWebAudioNode | null>;
|
|
1495
1503
|
/**
|
|
1496
1504
|
* Create a monophonic Offline processor.
|
|
1497
1505
|
*
|
|
@@ -1531,8 +1539,8 @@ export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
|
|
|
1531
1539
|
compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<this | null>;
|
|
1532
1540
|
addSoundfiles(soundfileMap: Record<string, AudioData>): void;
|
|
1533
1541
|
getSoundfileList(): string[];
|
|
1534
|
-
createNode<SP extends boolean = false>(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: SP, bufferSize?: number, processorName?: string): Promise<SP extends true ? FaustMonoScriptProcessorNode | null : FaustMonoAudioWorkletNode | null>;
|
|
1535
|
-
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1542
|
+
createNode<SP extends boolean = false>(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: SP, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<SP extends true ? FaustMonoScriptProcessorNode | null : FaustMonoAudioWorkletNode | null>;
|
|
1543
|
+
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1536
1544
|
createAudioWorkletProcessor(name?: string, factory?: LooseFaustDspFactory, processorName?: string): Promise<{
|
|
1537
1545
|
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
1538
1546
|
prototype: AudioWorkletProcessor;
|
|
@@ -1554,7 +1562,7 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
|
|
|
1554
1562
|
compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCodeAux?: string): Promise<this | null>;
|
|
1555
1563
|
addSoundfiles(soundfileMap: Record<string, AudioData>): void;
|
|
1556
1564
|
getSoundfileList(): string[];
|
|
1557
|
-
createNode<SP extends boolean = false>(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: SP, bufferSize?: number, processorName?: string): Promise<SP extends true ? FaustPolyScriptProcessorNode | null : FaustPolyAudioWorkletNode | null>;
|
|
1565
|
+
createNode<SP extends boolean = false>(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: SP, bufferSize?: number, processorName?: string, processorOptions?: {}): Promise<SP extends true ? FaustPolyScriptProcessorNode | null : FaustPolyAudioWorkletNode | null>;
|
|
1558
1566
|
createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
|
|
1559
1567
|
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
1560
1568
|
prototype: AudioWorkletProcessor;
|