@grame/faustwasm 0.0.25
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/README.md +181 -0
- package/assets/standalone/faust-ui/index.css +414 -0
- package/assets/standalone/faust-ui/index.css.map +1 -0
- package/assets/standalone/faust-ui/index.d.ts +1 -0
- package/assets/standalone/faust-ui/index.js +3478 -0
- package/assets/standalone/faust-ui/index.js.map +1 -0
- package/assets/standalone/faustwasm/index.d.ts +1252 -0
- package/assets/standalone/faustwasm/index.js +3772 -0
- package/assets/standalone/faustwasm/index.js.map +7 -0
- package/assets/standalone/index.html +73 -0
- package/assets/standalone/index.js +198 -0
- package/assets/standalone/types.d.ts +9 -0
- package/dist/cjs/index.d.ts +1252 -0
- package/dist/cjs/index.js +3752 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs-bundle/index.d.ts +1259 -0
- package/dist/cjs-bundle/index.js +11507 -0
- package/dist/cjs-bundle/index.js.map +7 -0
- package/dist/esm/index.d.ts +1252 -0
- package/dist/esm/index.js +3772 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm-bundle/index.d.ts +1259 -0
- package/dist/esm-bundle/index.js +11495 -0
- package/dist/esm-bundle/index.js.map +7 -0
- package/fileutils.js +40 -0
- package/libfaust-wasm/libfaust-wasm.d.cts +3 -0
- package/libfaust-wasm/libfaust-wasm.d.ts +3 -0
- package/libfaust-wasm/libfaust-wasm.data +0 -0
- package/libfaust-wasm/libfaust-wasm.data.d.ts +2 -0
- package/libfaust-wasm/libfaust-wasm.js +21 -0
- package/libfaust-wasm/libfaust-wasm.wasm +0 -0
- package/libfaust-wasm/libfaust-wasm.wasm.d.ts +2 -0
- package/library.md +91 -0
- package/package.json +43 -0
- package/postbuild-bundled.js +11 -0
- package/postbuild.js +63 -0
- package/prebuild-bundled.js +11 -0
- package/rsrc/overview.png +0 -0
- package/rsrc/overview.xlsx +0 -0
- package/scripts/faust2sndfile.js +43 -0
- package/scripts/faust2svg.js +17 -0
- package/scripts/faust2wasm.js +29 -0
- package/src/FaustAudioWorkletNode.ts +264 -0
- package/src/FaustAudioWorkletProcessor.ts +273 -0
- package/src/FaustCompiler.ts +252 -0
- package/src/FaustDspGenerator.ts +498 -0
- package/src/FaustDspInstance.ts +141 -0
- package/src/FaustFFTAudioWorkletProcessor.ts +554 -0
- package/src/FaustOfflineProcessor.ts +141 -0
- package/src/FaustScriptProcessorNode.ts +80 -0
- package/src/FaustSvgDiagrams.ts +37 -0
- package/src/FaustWasmInstantiator.ts +202 -0
- package/src/FaustWebAudioDsp.ts +1060 -0
- package/src/LibFaust.ts +57 -0
- package/src/WavDecoder.ts +207 -0
- package/src/WavEncoder.ts +204 -0
- package/src/copyWebStandaloneAssets.d.ts +3 -0
- package/src/copyWebStandaloneAssets.js +20 -0
- package/src/exports-bundle.ts +5 -0
- package/src/exports.ts +24 -0
- package/src/faust2svgFiles.d.ts +3 -0
- package/src/faust2svgFiles.js +43 -0
- package/src/faust2wasmFiles.d.ts +5 -0
- package/src/faust2wasmFiles.js +93 -0
- package/src/faust2wavFiles.d.ts +3 -0
- package/src/faust2wavFiles.js +58 -0
- package/src/index-bundle-iife.ts +7 -0
- package/src/index-bundle.ts +5 -0
- package/src/index.ts +5 -0
- package/src/instantiateFaustModule.ts +32 -0
- package/src/instantiateFaustModuleFromFile.ts +57 -0
- package/src/types.ts +234 -0
- package/test/clarinet.dsp +1 -0
- package/test/faustlive-wasm/faust-ui/index.css +414 -0
- package/test/faustlive-wasm/faust-ui/index.css.map +1 -0
- package/test/faustlive-wasm/faust-ui/index.d.ts +1 -0
- package/test/faustlive-wasm/faust-ui/index.js +3478 -0
- package/test/faustlive-wasm/faust-ui/index.js.map +1 -0
- package/test/faustlive-wasm/faustwasm/index.d.ts +1252 -0
- package/test/faustlive-wasm/faustwasm/index.js +3772 -0
- package/test/faustlive-wasm/faustwasm/index.js.map +7 -0
- package/test/faustlive-wasm/index.css +97 -0
- package/test/faustlive-wasm/index.html +130 -0
- package/test/faustlive-wasm/index.js +638 -0
- package/test/guitar.dsp +1 -0
- package/test/guitar1.dsp +2 -0
- package/test/libfaust-in-worklet/index.html +13 -0
- package/test/libfaust-in-worklet/index.js +40 -0
- package/test/mono.dsp +8 -0
- package/test/node/test.js +17 -0
- package/test/noise.dsp +3 -0
- package/test/organ.dsp +5 -0
- package/test/organ1.dsp +6 -0
- package/test/osc.dsp +4 -0
- package/test/osc2.dsp +5 -0
- package/test/osc3.dsp +4 -0
- package/test/p-dj.dsp +4 -0
- package/test/poly.dsp +13 -0
- package/test/rev.dsp +2 -0
- package/test/t1.dsp +1 -0
- package/test/web/fft.html +87 -0
- package/test/web/fft1.html +88 -0
- package/test/web/fft2.html +114 -0
- package/test/web/fftw.js +1907 -0
- package/test/web/index.html +12 -0
- package/test/web/index.js +235 -0
- package/test/web/kissfft.js +904 -0
- package/test/web/mono.html +46 -0
- package/test/web/poly-key.html +62 -0
- package/test/web/poly.html +59 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import * as process from "process";
|
|
5
|
+
import {
|
|
6
|
+
instantiateFaustModuleFromFile,
|
|
7
|
+
LibFaust,
|
|
8
|
+
FaustCompiler,
|
|
9
|
+
FaustMonoDspGenerator,
|
|
10
|
+
WavDecoder,
|
|
11
|
+
WavEncoder
|
|
12
|
+
} from "../dist/esm/index.js";
|
|
13
|
+
import { fileURLToPath } from "url";
|
|
14
|
+
|
|
15
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} inputFile
|
|
20
|
+
* @param {string} inputWav
|
|
21
|
+
* @param {string} outputWav
|
|
22
|
+
* @param {number} bufferSize
|
|
23
|
+
* @param {number} sampleRate
|
|
24
|
+
* @param {number} samples
|
|
25
|
+
* @param {number} bitDepth
|
|
26
|
+
* @param {string[]} [argv]
|
|
27
|
+
*/
|
|
28
|
+
const faust2wavFiles = async (inputFile, inputWav, outputWav, bufferSize = 64, sampleRate = 44100, samples = 5 * sampleRate, bitDepth = 16, argv = []) => {
|
|
29
|
+
const faustModule = await instantiateFaustModuleFromFile(path.join(__dirname, "../libfaust-wasm/libfaust-wasm.js"));
|
|
30
|
+
const libFaust = new LibFaust(faustModule);
|
|
31
|
+
const compiler = new FaustCompiler(libFaust);
|
|
32
|
+
console.log(`Faust Compiler version: ${compiler.version()}`);
|
|
33
|
+
console.log(`Reading file ${inputFile}`);
|
|
34
|
+
const code = fs.readFileSync(inputFile, { encoding: "utf8" });
|
|
35
|
+
if (!argv.find(a => a === "-I")) argv.push("-I", "libraries/");
|
|
36
|
+
const { name } = path.parse(inputFile);
|
|
37
|
+
const gen = new FaustMonoDspGenerator();
|
|
38
|
+
await gen.compile(compiler, name, code, argv.join(" "));
|
|
39
|
+
const processor = await gen.createOfflineProcessor(sampleRate, bufferSize);
|
|
40
|
+
if (!processor) throw Error("Processor not generated");
|
|
41
|
+
/** @type {Float32Array[] | undefined} */
|
|
42
|
+
let input = undefined;
|
|
43
|
+
if (inputWav) {
|
|
44
|
+
console.log(`Reading input wav file ${inputWav}.`);
|
|
45
|
+
const inputBuffer = fs.readFileSync(inputWav).buffer;
|
|
46
|
+
console.log(`Decoding...`);
|
|
47
|
+
input = WavDecoder.decode(inputBuffer).channelData;
|
|
48
|
+
}
|
|
49
|
+
console.log(`Processing...`);
|
|
50
|
+
const output = processor.render(input, samples, sample => process.stdout.write(`\r${sample} / ${samples}`));
|
|
51
|
+
console.log("");
|
|
52
|
+
console.log(`Encoding...`);
|
|
53
|
+
const outputBuffer = WavEncoder.encode(output, { bitDepth, sampleRate });
|
|
54
|
+
console.log(`Writing output wav file ${outputWav}.`);
|
|
55
|
+
fs.writeFileSync(outputWav, new Uint8Array(outputBuffer));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default faust2wavFiles;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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 (FaustModuleFactoryIn = factoryFn, dataBinaryIn = dataBinary, wasmBinaryIn = wasmBinary) => {
|
|
13
|
+
const g = globalThis as any;
|
|
14
|
+
if (g.AudioWorkletGlobalScope) {
|
|
15
|
+
g.importScripts = () => {};
|
|
16
|
+
g.self = { location: { href: "" } };
|
|
17
|
+
}
|
|
18
|
+
const faustModule = await FaustModuleFactoryIn({
|
|
19
|
+
wasmBinary: wasmBinaryIn,
|
|
20
|
+
getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {
|
|
21
|
+
if (remotePackageName === "libfaust-wasm.data") return dataBinaryIn.buffer;
|
|
22
|
+
return new ArrayBuffer(0);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (g.AudioWorkletGlobalScope) {
|
|
26
|
+
delete g.importScripts;
|
|
27
|
+
delete g.self;
|
|
28
|
+
}
|
|
29
|
+
return faustModule;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default instantiateFaustModule;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { FaustModuleFactory } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Load libfaust-wasm files, than instantiate libFaust
|
|
5
|
+
* @param jsFile path to `libfaust-wasm.js`
|
|
6
|
+
* @param dataFile path to `libfaust-wasm.data`
|
|
7
|
+
* @param wasmFile path to `libfaust-wasm.wasm`
|
|
8
|
+
*/
|
|
9
|
+
const instantiateFaustModuleFromFile = async (jsFile: string, dataFile = jsFile.replace(/c?js$/, "data"), wasmFile = jsFile.replace(/c?js$/, "wasm")) => {
|
|
10
|
+
let FaustModule: FaustModuleFactory;
|
|
11
|
+
let dataBinary: ArrayBuffer;
|
|
12
|
+
let wasmBinary: Uint8Array | ArrayBuffer;
|
|
13
|
+
const jsCodeHead = /var (.+) = \(/;
|
|
14
|
+
if (typeof window === "object") {
|
|
15
|
+
let jsCode = await (await fetch(jsFile)).text();
|
|
16
|
+
jsCode = `${jsCode}
|
|
17
|
+
export default ${jsCode.match(jsCodeHead)?.[1]};
|
|
18
|
+
`;
|
|
19
|
+
const jsFileMod = URL.createObjectURL(new Blob([jsCode], { type: "text/javascript" }));
|
|
20
|
+
FaustModule = (await import(/* webpackIgnore: true */jsFileMod)).default;
|
|
21
|
+
dataBinary = await (await fetch(dataFile)).arrayBuffer();
|
|
22
|
+
wasmBinary = new Uint8Array(await (await fetch(wasmFile)).arrayBuffer());
|
|
23
|
+
} else {
|
|
24
|
+
const { promises: fs } = await import("fs");
|
|
25
|
+
const { pathToFileURL } = await import("url");
|
|
26
|
+
let jsCode = (await fs.readFile(jsFile, { encoding: "utf-8" }));
|
|
27
|
+
jsCode = `
|
|
28
|
+
import process from "process";
|
|
29
|
+
import * as path from "path";
|
|
30
|
+
import { createRequire } from "module";
|
|
31
|
+
import { fileURLToPath } from "url";
|
|
32
|
+
|
|
33
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
34
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
35
|
+
const require = createRequire(import.meta.url);
|
|
36
|
+
|
|
37
|
+
${jsCode}
|
|
38
|
+
|
|
39
|
+
export default ${jsCode.match(jsCodeHead)?.[1]};
|
|
40
|
+
`;
|
|
41
|
+
const jsFileMod = jsFile.replace(/c?js$/, "mjs");
|
|
42
|
+
await fs.writeFile(jsFileMod, jsCode);
|
|
43
|
+
FaustModule = (await import(/* webpackIgnore: true */pathToFileURL(jsFileMod).href)).default;
|
|
44
|
+
await fs.unlink(jsFileMod);
|
|
45
|
+
dataBinary = (await fs.readFile(dataFile)).buffer;
|
|
46
|
+
wasmBinary = (await fs.readFile(wasmFile)).buffer;
|
|
47
|
+
}
|
|
48
|
+
const faustModule = await FaustModule({
|
|
49
|
+
wasmBinary,
|
|
50
|
+
getPreloadedPackage: (remotePackageName: string, remotePackageSize: number) => {
|
|
51
|
+
if (remotePackageName === "libfaust-wasm.data") return dataBinary;
|
|
52
|
+
return new ArrayBuffer(0);
|
|
53
|
+
}});
|
|
54
|
+
return faustModule;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default instantiateFaustModuleFromFile;
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
export type FaustModuleFactory = EmscriptenModuleFactory<FaustModule>;
|
|
2
|
+
|
|
3
|
+
export interface FaustModule extends EmscriptenModule {
|
|
4
|
+
ccall: typeof ccall;
|
|
5
|
+
cwrap: typeof cwrap;
|
|
6
|
+
UTF8ArrayToString(u8Array: number[], ptr: number, maxBytesToRead?: number): string;
|
|
7
|
+
stringToUTF8Array(str: string, outU8Array: number[], outIdx: number, maxBytesToWrite: number): number;
|
|
8
|
+
UTF8ToString: typeof UTF8ToString;
|
|
9
|
+
UTF16ToString: typeof UTF16ToString;
|
|
10
|
+
UTF32ToString: typeof UTF32ToString;
|
|
11
|
+
stringToUTF8: typeof stringToUTF8;
|
|
12
|
+
stringToUTF16: typeof stringToUTF16;
|
|
13
|
+
stringToUTF32: typeof stringToUTF32;
|
|
14
|
+
allocateUTF8: typeof allocateUTF8;
|
|
15
|
+
lengthBytesUTF8: typeof lengthBytesUTF8;
|
|
16
|
+
lengthBytesUTF16: typeof lengthBytesUTF16;
|
|
17
|
+
lengthBytesUTF32: typeof lengthBytesUTF32;
|
|
18
|
+
FS: typeof FS;
|
|
19
|
+
libFaustWasm: new () => LibFaustWasm;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type FaustInfoType = "help" | "version" | "libdir" | "includedir" | "archdir" | "dspdir" | "pathslist";
|
|
23
|
+
|
|
24
|
+
export interface IntVector {
|
|
25
|
+
size(): number;
|
|
26
|
+
get(i: number): number;
|
|
27
|
+
delete(): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface FaustDspWasm {
|
|
31
|
+
/* The C++ factory pointer as in integer */
|
|
32
|
+
cfactory: number;
|
|
33
|
+
/* The compiled wasm binary code */
|
|
34
|
+
data: IntVector;
|
|
35
|
+
/* The DSP JSON description */
|
|
36
|
+
json: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface LibFaustWasm {
|
|
40
|
+
/**
|
|
41
|
+
* Return the Faust compiler version.
|
|
42
|
+
*
|
|
43
|
+
* @returns the version
|
|
44
|
+
*/
|
|
45
|
+
version(): string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Create a dsp factory from Faust code.
|
|
49
|
+
*
|
|
50
|
+
* @param name - an arbitrary name for the Faust module
|
|
51
|
+
* @param code - Faust dsp code
|
|
52
|
+
* @param args - the compiler options
|
|
53
|
+
* @param useInternalMemory - tell the compiler to generate static embedded memory or not
|
|
54
|
+
* @returns an opaque reference to the factory
|
|
55
|
+
*/
|
|
56
|
+
createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean): FaustDspWasm;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Delete a dsp factory.
|
|
60
|
+
*
|
|
61
|
+
* @param cFactory - the factory C++ internal pointer as a number
|
|
62
|
+
*/
|
|
63
|
+
deleteDSPFactory(cFactory: number): void;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Expand Faust code i.e. linearize included libraries.
|
|
67
|
+
*
|
|
68
|
+
* @param name - an arbitrary name for the Faust module
|
|
69
|
+
* @param code - Faust dsp code
|
|
70
|
+
* @param args - the compiler options
|
|
71
|
+
* @returns return the expanded dsp code
|
|
72
|
+
*/
|
|
73
|
+
expandDSP(name: string, code: string, args: string): string;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Generates auxiliary files from Faust code. The output depends on the compiler options.
|
|
77
|
+
*
|
|
78
|
+
* @param name - an arbitrary name for the faust module
|
|
79
|
+
* @param code - Faust dsp code
|
|
80
|
+
* @param args - the compiler options
|
|
81
|
+
*/
|
|
82
|
+
generateAuxFiles(name: string, code: string, args: string): boolean;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Delete all existing dsp factories.
|
|
86
|
+
*/
|
|
87
|
+
deleteAllDSPFactories(): void;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Exception management: gives an error string
|
|
91
|
+
*/
|
|
92
|
+
getErrorAfterException(): string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Exception management: cleanup
|
|
96
|
+
* Should be called after each exception generated by the LibFaust methods.
|
|
97
|
+
*/
|
|
98
|
+
cleanupAfterException(): void;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get info about the embedded Faust engine
|
|
102
|
+
* @param what - the requested info
|
|
103
|
+
*/
|
|
104
|
+
getInfos(what: FaustInfoType): string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The Factory structure.
|
|
109
|
+
* cfactory: a "pointer" (as an integer) on the internal C++ factory
|
|
110
|
+
* code: the WASM code as a binary array
|
|
111
|
+
* module: the compule WASM module
|
|
112
|
+
* json: the compiled DSP JSON description
|
|
113
|
+
* poly: whether the factory is a polyphonic one or not
|
|
114
|
+
*/
|
|
115
|
+
export interface FaustDspFactory extends Required<LooseFaustDspFactory> {}
|
|
116
|
+
|
|
117
|
+
export interface LooseFaustDspFactory {
|
|
118
|
+
cfactory?: number;
|
|
119
|
+
code?: Uint8Array;
|
|
120
|
+
module: WebAssembly.Module;
|
|
121
|
+
json: string;
|
|
122
|
+
poly?: boolean;
|
|
123
|
+
shaKey?: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface FaustDspMeta {
|
|
127
|
+
name: string;
|
|
128
|
+
filename: string;
|
|
129
|
+
compile_options: string;
|
|
130
|
+
include_pathnames: string[];
|
|
131
|
+
inputs: number;
|
|
132
|
+
outputs: number;
|
|
133
|
+
size: number;
|
|
134
|
+
version: string;
|
|
135
|
+
library_list: string[];
|
|
136
|
+
meta: { [key: string]: string }[];
|
|
137
|
+
ui: FaustUIDescriptor;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export type FaustUIDescriptor = FaustUIGroup[];
|
|
141
|
+
export type FaustUIItem = FaustUIInputItem | FaustUIOutputItem | FaustUIGroup;
|
|
142
|
+
export interface FaustUIInputItem {
|
|
143
|
+
type: FaustUIInputType;
|
|
144
|
+
label: string;
|
|
145
|
+
address: string;
|
|
146
|
+
index: number;
|
|
147
|
+
init?: number;
|
|
148
|
+
min?: number;
|
|
149
|
+
max?: number;
|
|
150
|
+
step?: number;
|
|
151
|
+
meta?: FaustUIMeta[];
|
|
152
|
+
}
|
|
153
|
+
export interface FaustUIOutputItem {
|
|
154
|
+
type: FaustUIOutputType;
|
|
155
|
+
label: string;
|
|
156
|
+
address: string;
|
|
157
|
+
index: number;
|
|
158
|
+
min?: number;
|
|
159
|
+
max?: number;
|
|
160
|
+
meta?: FaustUIMeta[];
|
|
161
|
+
}
|
|
162
|
+
export interface FaustUIMeta {
|
|
163
|
+
[order: number]: string;
|
|
164
|
+
style?: string; // "knob" | "menu{'Name0':value0;'Name1':value1}" | "radio{'Name0':value0;'Name1':value1}" | "led";
|
|
165
|
+
unit?: string;
|
|
166
|
+
scale?: "linear" | "exp" | "log";
|
|
167
|
+
tooltip?: string;
|
|
168
|
+
hidden?: string;
|
|
169
|
+
[key: string]: string | undefined;
|
|
170
|
+
}
|
|
171
|
+
export type FaustUIGroupType = "vgroup" | "hgroup" | "tgroup";
|
|
172
|
+
export type FaustUIOutputType = "hbargraph" | "vbargraph";
|
|
173
|
+
export type FaustUIInputType = "vslider" | "hslider" | "button" | "checkbox" | "nentry";
|
|
174
|
+
export interface FaustUIGroup {
|
|
175
|
+
type: FaustUIGroupType;
|
|
176
|
+
label: string;
|
|
177
|
+
items: FaustUIItem[];
|
|
178
|
+
}
|
|
179
|
+
export type FaustUIType = FaustUIGroupType | FaustUIOutputType | FaustUIInputType;
|
|
180
|
+
|
|
181
|
+
export interface AudioParamDescriptor {
|
|
182
|
+
automationRate?: AutomationRate;
|
|
183
|
+
defaultValue?: number;
|
|
184
|
+
maxValue?: number;
|
|
185
|
+
minValue?: number;
|
|
186
|
+
name: string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface AudioWorkletProcessor {
|
|
190
|
+
port: MessagePort;
|
|
191
|
+
process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: Record<string, Float32Array>): boolean;
|
|
192
|
+
}
|
|
193
|
+
export declare const AudioWorkletProcessor: {
|
|
194
|
+
prototype: AudioWorkletProcessor;
|
|
195
|
+
parameterDescriptors: AudioParamDescriptor[];
|
|
196
|
+
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export interface AudioWorkletGlobalScope {
|
|
200
|
+
AudioWorkletGlobalScope: any;
|
|
201
|
+
globalThis: AudioWorkletGlobalScope;
|
|
202
|
+
registerProcessor: (name: string, constructor: new (options: any) => AudioWorkletProcessor) => void;
|
|
203
|
+
currentFrame: number;
|
|
204
|
+
currentTime: number;
|
|
205
|
+
sampleRate: number;
|
|
206
|
+
AudioWorkletProcessor: typeof AudioWorkletProcessor;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface InterfaceFFT {
|
|
210
|
+
forward(arr: ArrayLike<number> | ((arr: Float32Array) => any)): Float32Array;
|
|
211
|
+
inverse(arr: ArrayLike<number> | ((arr: Float32Array) => any)): Float32Array;
|
|
212
|
+
dispose(): void;
|
|
213
|
+
}
|
|
214
|
+
export declare const InterfaceFFT: {
|
|
215
|
+
new (size: number): InterfaceFFT;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export type TWindowFunction = (index: number, length: number, ...args: any[]) => number;
|
|
219
|
+
export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
|
|
220
|
+
export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
|
|
221
|
+
export type TypedArrayConstructor = typeof Int8Array | typeof Uint8Array | typeof Int16Array | typeof Uint16Array | typeof Int32Array | typeof Uint32Array | typeof Uint8ClampedArray | typeof Float32Array | typeof Float64Array;
|
|
222
|
+
|
|
223
|
+
export declare const FFTUtils: {
|
|
224
|
+
/** Inject window functions as array, no need to add rectangular (no windowing) */
|
|
225
|
+
windowFunctions?: TWindowFunction[];
|
|
226
|
+
/** Get a FFT interface constructor */
|
|
227
|
+
getFFT: () => Promise<typeof InterfaceFFT>;
|
|
228
|
+
/** 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 */
|
|
229
|
+
fftToSignal: (fft: Float32Array | Float64Array, real: Float32Array | Float64Array, imag?: Float32Array | Float64Array, index?: Float32Array | Float64Array) => any;
|
|
230
|
+
/** 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 */
|
|
231
|
+
signalToFFT: (real: Float32Array | Float64Array, imag: Float32Array | Float64Array, fft: Float32Array | Float64Array) => any;
|
|
232
|
+
/** Convert from Faust processor's output to direct audio output, real/imag are readonly, fft length = fftSize = (real/imag length - 1) * 2 */
|
|
233
|
+
signalToNoFFT: (real: Float32Array | Float64Array, imag: Float32Array | Float64Array, fft: Float32Array | Float64Array) => any;
|
|
234
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import("stdfaust.lib"); process = pm.clarinet_ui_MIDI <: _,_;
|