@grame/faustwasm 0.12.2 → 0.13.1
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/.prettierrc +5 -0
- package/README.md +21 -3
- package/assets/standalone/faustwasm/index.d.ts +38 -16
- package/assets/standalone/faustwasm/index.js +1593 -404
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.d.ts +38 -16
- package/dist/cjs/index.js +1592 -404
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +38 -16
- package/dist/cjs-bundle/index.js +1595 -406
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +38 -16
- package/dist/esm/index.js +1593 -404
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +38 -16
- package/dist/esm-bundle/index.js +1595 -406
- package/dist/esm-bundle/index.js.map +2 -2
- package/eslint.config.js +11 -0
- package/package.json +57 -51
- package/sound.cpp +163 -0
- package/sound.dsp +4 -0
- package/sound.json +1 -0
- package/sound.wasm +0 -0
- package/src/FaustAudioWorkletCommunicator.ts +150 -143
- package/src/FaustAudioWorkletNode.ts +173 -75
- package/src/FaustAudioWorkletProcessor.ts +218 -90
- package/src/FaustCmajor.ts +9 -3
- package/src/FaustCompiler.ts +112 -35
- package/src/FaustDspGenerator.ts +589 -117
- package/src/FaustDspInstance.ts +58 -24
- package/src/FaustFFTAudioWorkletProcessor.ts +822 -612
- package/src/FaustOfflineProcessor.ts +187 -56
- package/src/FaustScriptProcessorNode.ts +156 -49
- package/src/FaustSensors.ts +426 -96
- package/src/FaustSvgDiagrams.ts +18 -5
- package/src/FaustWasmInstantiator.ts +224 -70
- package/src/FaustWebAudioDsp.ts +1060 -349
- package/src/LibFaust.ts +13 -4
- package/src/SoundfileReader.ts +175 -131
- package/src/WavDecoder.ts +42 -20
- package/src/WavEncoder.ts +35 -21
- package/src/copyWebStandaloneAssets.d.ts +20 -5
- package/src/copyWebStandaloneAssets.js +203 -75
- package/src/exports-bundle.ts +5 -5
- package/src/exports.ts +24 -24
- package/src/faust2CmajorFiles.d.ts +7 -3
- package/src/faust2cmajorFiles.js +10 -8
- package/src/faust2svgFiles.d.ts +7 -3
- package/src/faust2svgFiles.js +9 -7
- package/src/faust2wasmFiles.d.ts +10 -5
- package/src/faust2wasmFiles.js +34 -17
- package/src/faust2wavFiles.d.ts +12 -3
- package/src/faust2wavFiles.js +25 -12
- package/src/index-bundle-iife.ts +2 -2
- package/src/index-bundle.ts +1 -1
- package/src/index.ts +1 -1
- package/src/instantiateFaustModule.ts +43 -36
- package/src/instantiateFaustModuleFromFile.ts +30 -14
- package/src/types.ts +101 -25
- package/test/faustlive-wasm/faustwasm/index.d.ts +38 -16
- package/test/faustlive-wasm/faustwasm/index.js +1593 -404
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/web/create-faust-node.html +53 -0
- package/test/web/create-faust-node.js +181 -0
- package/test/organ/create-node.js +0 -252
- package/test/organ/dsp-meta.json +0 -131
- package/test/organ/dsp-module.wasm +0 -0
- package/test/organ/faust-pwa.js +0 -344
- package/test/organ/faust-ui/index.css +0 -442
- package/test/organ/faust-ui/index.css.map +0 -1
- package/test/organ/faust-ui/index.d.ts +0 -1
- package/test/organ/faust-ui/index.js +0 -3756
- package/test/organ/faust-ui/index.js.map +0 -1
- package/test/organ/faustwasm/index.d.ts +0 -1705
- package/test/organ/faustwasm/index.js +0 -4773
- package/test/organ/faustwasm/index.js.map +0 -7
- package/test/organ/icon.png +0 -0
- package/test/organ/index.html +0 -76
- package/test/organ/index.js +0 -69
- package/test/organ/manifest.json +0 -17
- package/test/organ/service-worker.js +0 -165
package/src/faust2wavFiles.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//@ts-check
|
|
2
|
-
import * as fs from
|
|
3
|
-
import * as path from
|
|
4
|
-
import * as process from
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import * as process from 'process';
|
|
5
5
|
import {
|
|
6
6
|
instantiateFaustModuleFromFile,
|
|
7
7
|
LibFaust,
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
FaustMonoDspGenerator,
|
|
10
10
|
WavDecoder,
|
|
11
11
|
WavEncoder
|
|
12
|
-
} from
|
|
13
|
-
import { fileURLToPath } from
|
|
12
|
+
} from '../dist/esm/index.js';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
14
|
|
|
15
15
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
16
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -25,18 +25,29 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
25
25
|
* @param {number} bitDepth
|
|
26
26
|
* @param {string[]} [argv]
|
|
27
27
|
*/
|
|
28
|
-
const faust2wavFiles = async (
|
|
29
|
-
|
|
28
|
+
const faust2wavFiles = async (
|
|
29
|
+
inputFile,
|
|
30
|
+
inputWav,
|
|
31
|
+
outputWav,
|
|
32
|
+
bufferSize = 64,
|
|
33
|
+
sampleRate = 44100,
|
|
34
|
+
samples = 5 * sampleRate,
|
|
35
|
+
bitDepth = 16,
|
|
36
|
+
argv = []
|
|
37
|
+
) => {
|
|
38
|
+
const faustModule = await instantiateFaustModuleFromFile(
|
|
39
|
+
path.join(__dirname, '../libfaust-wasm/libfaust-wasm.js')
|
|
40
|
+
);
|
|
30
41
|
const libFaust = new LibFaust(faustModule);
|
|
31
42
|
const compiler = new FaustCompiler(libFaust);
|
|
32
43
|
console.log(`Faust Compiler version: ${compiler.version()}`);
|
|
33
44
|
console.log(`Reading file ${inputFile}`);
|
|
34
|
-
const code = fs.readFileSync(inputFile, { encoding:
|
|
45
|
+
const code = fs.readFileSync(inputFile, { encoding: 'utf8' });
|
|
35
46
|
const { name } = path.parse(inputFile);
|
|
36
47
|
const gen = new FaustMonoDspGenerator();
|
|
37
|
-
await gen.compile(compiler, name, code, argv.join(
|
|
48
|
+
await gen.compile(compiler, name, code, argv.join(' '));
|
|
38
49
|
const processor = await gen.createOfflineProcessor(sampleRate, bufferSize);
|
|
39
|
-
if (!processor) throw Error(
|
|
50
|
+
if (!processor) throw Error('Processor not generated');
|
|
40
51
|
/** @type {Float32Array[] | undefined} */
|
|
41
52
|
let input = undefined;
|
|
42
53
|
if (inputWav) {
|
|
@@ -46,8 +57,10 @@ const faust2wavFiles = async (inputFile, inputWav, outputWav, bufferSize = 64, s
|
|
|
46
57
|
input = WavDecoder.decode(inputBuffer).channelData;
|
|
47
58
|
}
|
|
48
59
|
console.log(`Processing...`);
|
|
49
|
-
const output = processor.render(input, samples, sample =>
|
|
50
|
-
|
|
60
|
+
const output = processor.render(input, samples, (sample) =>
|
|
61
|
+
process.stdout.write(`\r${sample} / ${samples}`)
|
|
62
|
+
);
|
|
63
|
+
console.log('');
|
|
51
64
|
console.log(`Encoding...`);
|
|
52
65
|
const outputBuffer = WavEncoder.encode(output, { bitDepth, sampleRate });
|
|
53
66
|
console.log(`Writing output wav file ${outputWav}.`);
|
package/src/index-bundle-iife.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as faustwasm from
|
|
1
|
+
import * as faustwasm from './exports-bundle';
|
|
2
2
|
// export default faustwasm;
|
|
3
3
|
// Bug with dts-bundle-generator
|
|
4
4
|
|
|
5
|
-
export * from
|
|
5
|
+
export * from './exports-bundle';
|
|
6
6
|
|
|
7
7
|
(globalThis as any).faustwasm = faustwasm;
|
package/src/index-bundle.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,36 +1,43 @@
|
|
|
1
|
-
import factoryFn from
|
|
2
|
-
import wasmBinary from
|
|
3
|
-
import dataBinary from
|
|
4
|
-
|
|
5
|
-
export const FaustModuleFactoryFn = factoryFn;
|
|
6
|
-
export const FaustModuleFactoryWasm = wasmBinary;
|
|
7
|
-
export const FaustModuleFactoryData = dataBinary;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Instantiate `FaustModule` using bundled binaries. Module constructor and files can be overriden.
|
|
11
|
-
*/
|
|
12
|
-
const instantiateFaustModule = async (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import factoryFn from '../libfaust-wasm/libfaust-wasm.cjs';
|
|
2
|
+
import wasmBinary from '../libfaust-wasm/libfaust-wasm.wasm';
|
|
3
|
+
import dataBinary from '../libfaust-wasm/libfaust-wasm.data';
|
|
4
|
+
|
|
5
|
+
export const FaustModuleFactoryFn = factoryFn;
|
|
6
|
+
export const FaustModuleFactoryWasm = wasmBinary;
|
|
7
|
+
export const FaustModuleFactoryData = dataBinary;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Instantiate `FaustModule` using bundled binaries. Module constructor and files can be overriden.
|
|
11
|
+
*/
|
|
12
|
+
const instantiateFaustModule = async (
|
|
13
|
+
FaustModuleFactoryIn = factoryFn,
|
|
14
|
+
dataBinaryIn = dataBinary,
|
|
15
|
+
wasmBinaryIn = wasmBinary
|
|
16
|
+
) => {
|
|
17
|
+
const g = globalThis as any;
|
|
18
|
+
if (g.AudioWorkletGlobalScope) {
|
|
19
|
+
g.importScripts = () => {};
|
|
20
|
+
g.self = { location: { href: '' } };
|
|
21
|
+
}
|
|
22
|
+
const faustModule = await FaustModuleFactoryIn({
|
|
23
|
+
// Create a copy to guarantee a standard ArrayBuffer
|
|
24
|
+
wasmBinary: new Uint8Array(wasmBinaryIn).buffer,
|
|
25
|
+
getPreloadedPackage: (
|
|
26
|
+
remotePackageName: string,
|
|
27
|
+
remotePackageSize: number
|
|
28
|
+
) => {
|
|
29
|
+
if (remotePackageName === 'libfaust-wasm.data') {
|
|
30
|
+
// Create a copy to guarantee a standard ArrayBuffer
|
|
31
|
+
return new Uint8Array(dataBinaryIn).buffer;
|
|
32
|
+
}
|
|
33
|
+
return new ArrayBuffer(0);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
if (g.AudioWorkletGlobalScope) {
|
|
37
|
+
delete g.importScripts;
|
|
38
|
+
delete g.self;
|
|
39
|
+
}
|
|
40
|
+
return faustModule;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default instantiateFaustModule;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FaustModuleFactory } from
|
|
1
|
+
import type { FaustModuleFactory } from './types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Load libfaust-wasm files, than instantiate libFaust
|
|
@@ -6,24 +6,31 @@ import type { FaustModuleFactory } from "./types";
|
|
|
6
6
|
* @param dataFile path to `libfaust-wasm.data`
|
|
7
7
|
* @param wasmFile path to `libfaust-wasm.wasm`
|
|
8
8
|
*/
|
|
9
|
-
const instantiateFaustModuleFromFile = async (
|
|
9
|
+
const instantiateFaustModuleFromFile = async (
|
|
10
|
+
jsFile: string,
|
|
11
|
+
dataFile = jsFile.replace(/c?js$/, 'data'),
|
|
12
|
+
wasmFile = jsFile.replace(/c?js$/, 'wasm')
|
|
13
|
+
) => {
|
|
10
14
|
let FaustModule: FaustModuleFactory;
|
|
11
15
|
let dataBinary: ArrayBuffer;
|
|
12
16
|
let wasmBinary: ArrayBuffer;
|
|
13
17
|
const jsCodeHead = /var (.+) = \(/;
|
|
14
|
-
if (typeof window ===
|
|
18
|
+
if (typeof window === 'object') {
|
|
15
19
|
let jsCode = await (await fetch(jsFile)).text();
|
|
16
20
|
jsCode = `${jsCode}
|
|
17
21
|
export default ${jsCode.match(jsCodeHead)?.[1]};
|
|
18
22
|
`;
|
|
19
|
-
const jsFileMod = URL.createObjectURL(
|
|
20
|
-
|
|
23
|
+
const jsFileMod = URL.createObjectURL(
|
|
24
|
+
new Blob([jsCode], { type: 'text/javascript' })
|
|
25
|
+
);
|
|
26
|
+
FaustModule = (await import(/* webpackIgnore: true */ jsFileMod))
|
|
27
|
+
.default;
|
|
21
28
|
dataBinary = await (await fetch(dataFile)).arrayBuffer();
|
|
22
29
|
wasmBinary = await (await fetch(wasmFile)).arrayBuffer();
|
|
23
30
|
} else {
|
|
24
|
-
const { promises: fs } = await import(
|
|
25
|
-
const { pathToFileURL } = await import(
|
|
26
|
-
let jsCode =
|
|
31
|
+
const { promises: fs } = await import('fs');
|
|
32
|
+
const { pathToFileURL } = await import('url');
|
|
33
|
+
let jsCode = await fs.readFile(jsFile, { encoding: 'utf-8' });
|
|
27
34
|
jsCode = `
|
|
28
35
|
import process from "process";
|
|
29
36
|
import * as path from "path";
|
|
@@ -38,18 +45,27 @@ ${jsCode}
|
|
|
38
45
|
|
|
39
46
|
export default ${jsCode.match(jsCodeHead)?.[1]};
|
|
40
47
|
`;
|
|
41
|
-
const jsFileMod = jsFile.replace(/c?js$/,
|
|
48
|
+
const jsFileMod = jsFile.replace(/c?js$/, 'mjs');
|
|
42
49
|
await fs.writeFile(jsFileMod, jsCode);
|
|
43
|
-
FaustModule = (
|
|
50
|
+
FaustModule = (
|
|
51
|
+
await import(
|
|
52
|
+
/* webpackIgnore: true */ pathToFileURL(jsFileMod).href
|
|
53
|
+
)
|
|
54
|
+
).default;
|
|
44
55
|
await fs.unlink(jsFileMod);
|
|
45
56
|
// Using a type assertion `as ArrayBuffer` to satisfy the strict type checking.
|
|
46
|
-
dataBinary =
|
|
47
|
-
|
|
57
|
+
dataBinary = new Uint8Array(await fs.readFile(dataFile))
|
|
58
|
+
.buffer as ArrayBuffer;
|
|
59
|
+
wasmBinary = new Uint8Array(await fs.readFile(wasmFile))
|
|
60
|
+
.buffer as ArrayBuffer;
|
|
48
61
|
}
|
|
49
62
|
const faustModule = await FaustModule({
|
|
50
63
|
wasmBinary,
|
|
51
|
-
getPreloadedPackage: (
|
|
52
|
-
|
|
64
|
+
getPreloadedPackage: (
|
|
65
|
+
remotePackageName: string,
|
|
66
|
+
remotePackageSize: number
|
|
67
|
+
) => {
|
|
68
|
+
if (remotePackageName === 'libfaust-wasm.data') return dataBinary;
|
|
53
69
|
return new ArrayBuffer(0);
|
|
54
70
|
}
|
|
55
71
|
});
|
package/src/types.ts
CHANGED
|
@@ -3,8 +3,17 @@ export type FaustModuleFactory = EmscriptenModuleFactory<FaustModule>;
|
|
|
3
3
|
export interface FaustModule extends EmscriptenModule {
|
|
4
4
|
ccall: typeof ccall;
|
|
5
5
|
cwrap: typeof cwrap;
|
|
6
|
-
UTF8ArrayToString(
|
|
7
|
-
|
|
6
|
+
UTF8ArrayToString(
|
|
7
|
+
u8Array: number[],
|
|
8
|
+
ptr: number,
|
|
9
|
+
maxBytesToRead?: number
|
|
10
|
+
): string;
|
|
11
|
+
stringToUTF8Array(
|
|
12
|
+
str: string,
|
|
13
|
+
outU8Array: number[],
|
|
14
|
+
outIdx: number,
|
|
15
|
+
maxBytesToWrite: number
|
|
16
|
+
): number;
|
|
8
17
|
UTF8ToString: typeof UTF8ToString;
|
|
9
18
|
UTF16ToString: typeof UTF16ToString;
|
|
10
19
|
UTF32ToString: typeof UTF32ToString;
|
|
@@ -19,7 +28,14 @@ export interface FaustModule extends EmscriptenModule {
|
|
|
19
28
|
libFaustWasm: new () => LibFaustWasm;
|
|
20
29
|
}
|
|
21
30
|
|
|
22
|
-
export type FaustInfoType =
|
|
31
|
+
export type FaustInfoType =
|
|
32
|
+
| 'help'
|
|
33
|
+
| 'version'
|
|
34
|
+
| 'libdir'
|
|
35
|
+
| 'includedir'
|
|
36
|
+
| 'archdir'
|
|
37
|
+
| 'dspdir'
|
|
38
|
+
| 'pathslist';
|
|
23
39
|
|
|
24
40
|
export interface IntVector {
|
|
25
41
|
size(): number;
|
|
@@ -39,7 +55,7 @@ export interface FaustDspWasm {
|
|
|
39
55
|
export interface LibFaustWasm {
|
|
40
56
|
/**
|
|
41
57
|
* Return the Faust compiler version.
|
|
42
|
-
*
|
|
58
|
+
*
|
|
43
59
|
* @returns the version
|
|
44
60
|
*/
|
|
45
61
|
version(): string;
|
|
@@ -53,7 +69,12 @@ export interface LibFaustWasm {
|
|
|
53
69
|
* @param useInternalMemory - tell the compiler to generate static embedded memory or not
|
|
54
70
|
* @returns an opaque reference to the factory
|
|
55
71
|
*/
|
|
56
|
-
createDSPFactory(
|
|
72
|
+
createDSPFactory(
|
|
73
|
+
name: string,
|
|
74
|
+
code: string,
|
|
75
|
+
args: string,
|
|
76
|
+
useInternalMemory: boolean
|
|
77
|
+
): FaustDspWasm;
|
|
57
78
|
|
|
58
79
|
/**
|
|
59
80
|
* Delete a dsp factory.
|
|
@@ -104,7 +125,7 @@ export interface LibFaustWasm {
|
|
|
104
125
|
getInfos(what: FaustInfoType): string;
|
|
105
126
|
}
|
|
106
127
|
|
|
107
|
-
export
|
|
128
|
+
export type FaustDspFactory = Required<LooseFaustDspFactory>;
|
|
108
129
|
|
|
109
130
|
/**
|
|
110
131
|
* The Factory structure.
|
|
@@ -167,20 +188,29 @@ export interface FaustUIMeta {
|
|
|
167
188
|
[order: number]: string;
|
|
168
189
|
style?: string; // "knob" | "menu{'Name0':value0;'Name1':value1}" | "radio{'Name0':value0;'Name1':value1}" | "led";
|
|
169
190
|
unit?: string;
|
|
170
|
-
scale?:
|
|
191
|
+
scale?: 'linear' | 'exp' | 'log';
|
|
171
192
|
tooltip?: string;
|
|
172
193
|
hidden?: string;
|
|
173
194
|
[key: string]: string | undefined;
|
|
174
195
|
}
|
|
175
|
-
export type FaustUIGroupType =
|
|
176
|
-
export type FaustUIOutputType =
|
|
177
|
-
export type FaustUIInputType =
|
|
196
|
+
export type FaustUIGroupType = 'vgroup' | 'hgroup' | 'tgroup';
|
|
197
|
+
export type FaustUIOutputType = 'hbargraph' | 'vbargraph';
|
|
198
|
+
export type FaustUIInputType =
|
|
199
|
+
| 'vslider'
|
|
200
|
+
| 'hslider'
|
|
201
|
+
| 'button'
|
|
202
|
+
| 'checkbox'
|
|
203
|
+
| 'nentry'
|
|
204
|
+
| 'soundfile';
|
|
178
205
|
export interface FaustUIGroup {
|
|
179
206
|
type: FaustUIGroupType;
|
|
180
207
|
label: string;
|
|
181
208
|
items: FaustUIItem[];
|
|
182
209
|
}
|
|
183
|
-
export type FaustUIType =
|
|
210
|
+
export type FaustUIType =
|
|
211
|
+
| FaustUIGroupType
|
|
212
|
+
| FaustUIOutputType
|
|
213
|
+
| FaustUIInputType;
|
|
184
214
|
|
|
185
215
|
export interface AudioParamDescriptor {
|
|
186
216
|
automationRate?: AutomationRate;
|
|
@@ -192,18 +222,25 @@ export interface AudioParamDescriptor {
|
|
|
192
222
|
|
|
193
223
|
export interface AudioWorkletProcessor {
|
|
194
224
|
port: MessagePort;
|
|
195
|
-
process(
|
|
225
|
+
process(
|
|
226
|
+
inputs: Float32Array[][],
|
|
227
|
+
outputs: Float32Array[][],
|
|
228
|
+
parameters: Record<string, Float32Array>
|
|
229
|
+
): boolean;
|
|
196
230
|
}
|
|
197
231
|
export declare const AudioWorkletProcessor: {
|
|
198
232
|
prototype: AudioWorkletProcessor;
|
|
199
233
|
parameterDescriptors: AudioParamDescriptor[];
|
|
200
|
-
new(options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
234
|
+
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
201
235
|
};
|
|
202
236
|
|
|
203
237
|
export interface AudioWorkletGlobalScope {
|
|
204
238
|
AudioWorkletGlobalScope: any;
|
|
205
239
|
globalThis: AudioWorkletGlobalScope;
|
|
206
|
-
registerProcessor: (
|
|
240
|
+
registerProcessor: (
|
|
241
|
+
name: string,
|
|
242
|
+
constructor: new (options: any) => AudioWorkletProcessor
|
|
243
|
+
) => void;
|
|
207
244
|
currentFrame: number;
|
|
208
245
|
currentTime: number;
|
|
209
246
|
sampleRate: number;
|
|
@@ -211,18 +248,44 @@ export interface AudioWorkletGlobalScope {
|
|
|
211
248
|
}
|
|
212
249
|
|
|
213
250
|
export interface InterfaceFFT {
|
|
214
|
-
forward(
|
|
215
|
-
|
|
251
|
+
forward(
|
|
252
|
+
arr: ArrayLike<number> | ((arr: Float32Array) => any)
|
|
253
|
+
): Float32Array;
|
|
254
|
+
inverse(
|
|
255
|
+
arr: ArrayLike<number> | ((arr: Float32Array) => any)
|
|
256
|
+
): Float32Array;
|
|
216
257
|
dispose(): void;
|
|
217
258
|
}
|
|
218
259
|
export declare const InterfaceFFT: {
|
|
219
|
-
new(size: number): InterfaceFFT;
|
|
220
|
-
}
|
|
260
|
+
new (size: number): InterfaceFFT;
|
|
261
|
+
};
|
|
221
262
|
|
|
222
|
-
export type TWindowFunction = (
|
|
263
|
+
export type TWindowFunction = (
|
|
264
|
+
index: number,
|
|
265
|
+
length: number,
|
|
266
|
+
...args: any[]
|
|
267
|
+
) => number;
|
|
223
268
|
export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
|
|
224
|
-
export type TypedArray =
|
|
225
|
-
|
|
269
|
+
export type TypedArray =
|
|
270
|
+
| Int8Array
|
|
271
|
+
| Uint8Array
|
|
272
|
+
| Int16Array
|
|
273
|
+
| Uint16Array
|
|
274
|
+
| Int32Array
|
|
275
|
+
| Uint32Array
|
|
276
|
+
| Uint8ClampedArray
|
|
277
|
+
| Float32Array
|
|
278
|
+
| Float64Array;
|
|
279
|
+
export type TypedArrayConstructor =
|
|
280
|
+
| typeof Int8Array
|
|
281
|
+
| typeof Uint8Array
|
|
282
|
+
| typeof Int16Array
|
|
283
|
+
| typeof Uint16Array
|
|
284
|
+
| typeof Int32Array
|
|
285
|
+
| typeof Uint32Array
|
|
286
|
+
| typeof Uint8ClampedArray
|
|
287
|
+
| typeof Float32Array
|
|
288
|
+
| typeof Float64Array;
|
|
226
289
|
|
|
227
290
|
export declare const FFTUtils: {
|
|
228
291
|
/** Inject window functions as array, no need to add rectangular (no windowing) */
|
|
@@ -230,12 +293,25 @@ export declare const FFTUtils: {
|
|
|
230
293
|
/** Get a FFT interface constructor */
|
|
231
294
|
getFFT: () => Promise<typeof InterfaceFFT>;
|
|
232
295
|
/** Convert from FFTed (spectral) signal to three arrays for Faust processor's input, fft is readonly, real/imag/index length = *fftSize* / 2 + 1; fft length depends on the FFT implementation */
|
|
233
|
-
fftToSignal: (
|
|
296
|
+
fftToSignal: (
|
|
297
|
+
fft: Float32Array | Float64Array,
|
|
298
|
+
real: Float32Array | Float64Array,
|
|
299
|
+
imag?: Float32Array | Float64Array,
|
|
300
|
+
index?: Float32Array | Float64Array
|
|
301
|
+
) => any;
|
|
234
302
|
/** Convert from Faust processor's output to spectral data for Inversed FFT, real/imag are readonly, real/imag length = *fftSize* / 2 + 1; fft length depends on the FFT implementation */
|
|
235
|
-
signalToFFT: (
|
|
303
|
+
signalToFFT: (
|
|
304
|
+
real: Float32Array | Float64Array,
|
|
305
|
+
imag: Float32Array | Float64Array,
|
|
306
|
+
fft: Float32Array | Float64Array
|
|
307
|
+
) => any;
|
|
236
308
|
/** Convert from Faust processor's output to direct audio output, real/imag are readonly, fft length = fftSize = (real/imag length - 1) * 2 */
|
|
237
|
-
signalToNoFFT: (
|
|
238
|
-
|
|
309
|
+
signalToNoFFT: (
|
|
310
|
+
real: Float32Array | Float64Array,
|
|
311
|
+
imag: Float32Array | Float64Array,
|
|
312
|
+
fft: Float32Array | Float64Array
|
|
313
|
+
) => any;
|
|
314
|
+
};
|
|
239
315
|
|
|
240
316
|
export interface AudioData {
|
|
241
317
|
sampleRate: number;
|
|
@@ -91,8 +91,7 @@ export interface LibFaustWasm {
|
|
|
91
91
|
*/
|
|
92
92
|
getInfos(what: FaustInfoType): string;
|
|
93
93
|
}
|
|
94
|
-
export
|
|
95
|
-
}
|
|
94
|
+
export type FaustDspFactory = Required<LooseFaustDspFactory>;
|
|
96
95
|
/**
|
|
97
96
|
* The Factory structure.
|
|
98
97
|
*/
|
|
@@ -404,7 +403,7 @@ export declare class FaustWasmInstantiator {
|
|
|
404
403
|
private static createMemoryMono;
|
|
405
404
|
private static createMemoryPoly;
|
|
406
405
|
private static createMixerAux;
|
|
407
|
-
static loadDSPFactory(wasmPath: string, jsonPath: string): Promise<
|
|
406
|
+
static loadDSPFactory(wasmPath: string, jsonPath: string): Promise<Required<LooseFaustDspFactory>>;
|
|
408
407
|
static loadDSPMixer(mixerPath: string, fs?: typeof FS): Promise<WebAssembly.Module>;
|
|
409
408
|
static createAsyncMonoDSPInstance(factory: LooseFaustDspFactory): Promise<FaustMonoDspInstance>;
|
|
410
409
|
static createSyncMonoDSPInstance(factory: LooseFaustDspFactory): FaustMonoDspInstance;
|
|
@@ -673,10 +672,10 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
673
672
|
*/
|
|
674
673
|
getUI(): FaustUIDescriptor;
|
|
675
674
|
/**
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
675
|
+
* Get DSP UI items description.
|
|
676
|
+
*
|
|
677
|
+
* @return the DSP UI items description
|
|
678
|
+
*/
|
|
680
679
|
getDescriptors(): FaustUIInputItem[];
|
|
681
680
|
/**
|
|
682
681
|
* Get DSP JSON description with its UI and metadata.
|
|
@@ -685,8 +684,8 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
685
684
|
*/
|
|
686
685
|
getJSON(): string;
|
|
687
686
|
/**
|
|
688
|
-
|
|
689
|
-
|
|
687
|
+
* Start accelerometer and gyroscope handlers.
|
|
688
|
+
*/
|
|
690
689
|
startSensors(): void;
|
|
691
690
|
/**
|
|
692
691
|
* Stop accelerometer and gyroscope handlers.
|
|
@@ -720,8 +719,7 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
720
719
|
*/
|
|
721
720
|
destroy(): void;
|
|
722
721
|
}
|
|
723
|
-
export
|
|
724
|
-
}
|
|
722
|
+
export type IFaustMonoWebAudioDsp = IFaustBaseWebAudioDsp;
|
|
725
723
|
export interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode {
|
|
726
724
|
}
|
|
727
725
|
export interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {
|
|
@@ -849,7 +847,7 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
849
847
|
*
|
|
850
848
|
* @param allocator : the wasm memory allocator
|
|
851
849
|
* @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory
|
|
852
|
-
|
|
850
|
+
*/
|
|
853
851
|
protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number): void;
|
|
854
852
|
protected updateOutputs(): void;
|
|
855
853
|
metadata(handler: MetadataHandler): void;
|
|
@@ -1164,18 +1162,18 @@ export declare class FaustCompiler implements IFaustCompiler {
|
|
|
1164
1162
|
code: string;
|
|
1165
1163
|
json: any;
|
|
1166
1164
|
poly: boolean;
|
|
1167
|
-
}>): Promise<Map<string,
|
|
1165
|
+
}>): Promise<Map<string, Required<LooseFaustDspFactory>>[]>;
|
|
1168
1166
|
/**
|
|
1169
1167
|
* Import a stringified DSP factories table
|
|
1170
1168
|
*/
|
|
1171
|
-
static importDSPFactories(tableStr: string): Promise<Map<string,
|
|
1169
|
+
static importDSPFactories(tableStr: string): Promise<Map<string, Required<LooseFaustDspFactory>>[]>;
|
|
1172
1170
|
constructor(libFaust: ILibFaust);
|
|
1173
1171
|
private intVec2intArray;
|
|
1174
1172
|
private createDSPFactory;
|
|
1175
1173
|
version(): string;
|
|
1176
1174
|
getErrorMessage(): string;
|
|
1177
|
-
createMonoDSPFactory(name: string, code: string, args: string): Promise<
|
|
1178
|
-
createPolyDSPFactory(name: string, code: string, args: string): Promise<
|
|
1175
|
+
createMonoDSPFactory(name: string, code: string, args: string): Promise<Required<LooseFaustDspFactory> | null>;
|
|
1176
|
+
createPolyDSPFactory(name: string, code: string, args: string): Promise<Required<LooseFaustDspFactory> | null>;
|
|
1179
1177
|
deleteDSPFactory(factory: FaustDspFactory): void;
|
|
1180
1178
|
expandDSP(code: string, args: string): string;
|
|
1181
1179
|
generateAuxFiles(name: string, code: string, args: string): boolean;
|
|
@@ -1524,6 +1522,20 @@ export interface GeneratorSupportingSoundfiles {
|
|
|
1524
1522
|
*/
|
|
1525
1523
|
getSoundfileList(): string[];
|
|
1526
1524
|
}
|
|
1525
|
+
export interface IFaustDspGenerator {
|
|
1526
|
+
/**
|
|
1527
|
+
* Create a monophonic or polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
|
|
1528
|
+
* Analyze the code to decide whether to create a monophonic or polyphonic node.
|
|
1529
|
+
*
|
|
1530
|
+
* @param context - the WebAudio context
|
|
1531
|
+
* @param name - DSP name, can be used for processorName
|
|
1532
|
+
* @param code - the DSP code
|
|
1533
|
+
* @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
|
|
1534
|
+
* @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
|
|
1535
|
+
* @returns the compiled monophonic or polyphonic WebAudio node or 'null' if failure
|
|
1536
|
+
*/
|
|
1537
|
+
createFaustNode(context: BaseAudioContext, name: string, code: string, sp?: boolean, bufferSize?: number): Promise<IFaustMonoWebAudioNode | IFaustPolyWebAudioNode | null>;
|
|
1538
|
+
}
|
|
1527
1539
|
export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
|
|
1528
1540
|
/**
|
|
1529
1541
|
* Compile a monophonic DSP factory from given code.
|
|
@@ -1697,6 +1709,16 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
|
|
|
1697
1709
|
getJSON(): string;
|
|
1698
1710
|
getUI(): FaustUIDescriptor;
|
|
1699
1711
|
}
|
|
1712
|
+
export declare class FaustDspGenerator implements IFaustDspGenerator {
|
|
1713
|
+
private static compilerPromise;
|
|
1714
|
+
private extractMidiAndNvoices;
|
|
1715
|
+
/**
|
|
1716
|
+
* Compile DSP code, inspect metadata for [nvoices:] (and optionally [midi:on]), and build either a mono
|
|
1717
|
+
* or poly WebAudio node (ScriptProcessor or AudioWorklet depending on `sp`). Compilation uses a shared,
|
|
1718
|
+
* lazily-created libfaust instance to avoid repeatedly instantiating the WASM compiler.
|
|
1719
|
+
*/
|
|
1720
|
+
createFaustNode(context: BaseAudioContext, name: string, code: string, sp?: boolean, bufferSize?: number): Promise<IFaustMonoWebAudioNode | IFaustPolyWebAudioNode | null>;
|
|
1721
|
+
}
|
|
1700
1722
|
|
|
1701
1723
|
export {
|
|
1702
1724
|
AudioData$1 as AudioData,
|