@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,1259 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v6.13.0
|
|
2
|
+
|
|
3
|
+
/// <reference types="emscripten" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
|
|
6
|
+
export declare type FaustModuleFactory = EmscriptenModuleFactory<FaustModule>;
|
|
7
|
+
export interface FaustModule extends EmscriptenModule {
|
|
8
|
+
ccall: typeof ccall;
|
|
9
|
+
cwrap: typeof cwrap;
|
|
10
|
+
UTF8ArrayToString(u8Array: number[], ptr: number, maxBytesToRead?: number): string;
|
|
11
|
+
stringToUTF8Array(str: string, outU8Array: number[], outIdx: number, maxBytesToWrite: number): number;
|
|
12
|
+
UTF8ToString: typeof UTF8ToString;
|
|
13
|
+
UTF16ToString: typeof UTF16ToString;
|
|
14
|
+
UTF32ToString: typeof UTF32ToString;
|
|
15
|
+
stringToUTF8: typeof stringToUTF8;
|
|
16
|
+
stringToUTF16: typeof stringToUTF16;
|
|
17
|
+
stringToUTF32: typeof stringToUTF32;
|
|
18
|
+
allocateUTF8: typeof allocateUTF8;
|
|
19
|
+
lengthBytesUTF8: typeof lengthBytesUTF8;
|
|
20
|
+
lengthBytesUTF16: typeof lengthBytesUTF16;
|
|
21
|
+
lengthBytesUTF32: typeof lengthBytesUTF32;
|
|
22
|
+
FS: typeof FS;
|
|
23
|
+
libFaustWasm: new () => LibFaustWasm;
|
|
24
|
+
}
|
|
25
|
+
export declare type FaustInfoType = "help" | "version" | "libdir" | "includedir" | "archdir" | "dspdir" | "pathslist";
|
|
26
|
+
export interface IntVector {
|
|
27
|
+
size(): number;
|
|
28
|
+
get(i: number): number;
|
|
29
|
+
delete(): void;
|
|
30
|
+
}
|
|
31
|
+
export interface FaustDspWasm {
|
|
32
|
+
cfactory: number;
|
|
33
|
+
data: IntVector;
|
|
34
|
+
json: string;
|
|
35
|
+
}
|
|
36
|
+
export interface LibFaustWasm {
|
|
37
|
+
/**
|
|
38
|
+
* Return the Faust compiler version.
|
|
39
|
+
*
|
|
40
|
+
* @returns the version
|
|
41
|
+
*/
|
|
42
|
+
version(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Create a dsp factory from Faust code.
|
|
45
|
+
*
|
|
46
|
+
* @param name - an arbitrary name for the Faust module
|
|
47
|
+
* @param code - Faust dsp code
|
|
48
|
+
* @param args - the compiler options
|
|
49
|
+
* @param useInternalMemory - tell the compiler to generate static embedded memory or not
|
|
50
|
+
* @returns an opaque reference to the factory
|
|
51
|
+
*/
|
|
52
|
+
createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean): FaustDspWasm;
|
|
53
|
+
/**
|
|
54
|
+
* Delete a dsp factory.
|
|
55
|
+
*
|
|
56
|
+
* @param cFactory - the factory C++ internal pointer as a number
|
|
57
|
+
*/
|
|
58
|
+
deleteDSPFactory(cFactory: number): void;
|
|
59
|
+
/**
|
|
60
|
+
* Expand Faust code i.e. linearize included libraries.
|
|
61
|
+
*
|
|
62
|
+
* @param name - an arbitrary name for the Faust module
|
|
63
|
+
* @param code - Faust dsp code
|
|
64
|
+
* @param args - the compiler options
|
|
65
|
+
* @returns return the expanded dsp code
|
|
66
|
+
*/
|
|
67
|
+
expandDSP(name: string, code: string, args: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Generates auxiliary files from Faust code. The output depends on the compiler options.
|
|
70
|
+
*
|
|
71
|
+
* @param name - an arbitrary name for the faust module
|
|
72
|
+
* @param code - Faust dsp code
|
|
73
|
+
* @param args - the compiler options
|
|
74
|
+
*/
|
|
75
|
+
generateAuxFiles(name: string, code: string, args: string): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Delete all existing dsp factories.
|
|
78
|
+
*/
|
|
79
|
+
deleteAllDSPFactories(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Exception management: gives an error string
|
|
82
|
+
*/
|
|
83
|
+
getErrorAfterException(): string;
|
|
84
|
+
/**
|
|
85
|
+
* Exception management: cleanup
|
|
86
|
+
* Should be called after each exception generated by the LibFaust methods.
|
|
87
|
+
*/
|
|
88
|
+
cleanupAfterException(): void;
|
|
89
|
+
/**
|
|
90
|
+
* Get info about the embedded Faust engine
|
|
91
|
+
* @param what - the requested info
|
|
92
|
+
*/
|
|
93
|
+
getInfos(what: FaustInfoType): string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The Factory structure.
|
|
97
|
+
* cfactory: a "pointer" (as an integer) on the internal C++ factory
|
|
98
|
+
* code: the WASM code as a binary array
|
|
99
|
+
* module: the compule WASM module
|
|
100
|
+
* json: the compiled DSP JSON description
|
|
101
|
+
* poly: whether the factory is a polyphonic one or not
|
|
102
|
+
*/
|
|
103
|
+
export interface FaustDspFactory extends Required<LooseFaustDspFactory> {
|
|
104
|
+
}
|
|
105
|
+
export interface LooseFaustDspFactory {
|
|
106
|
+
cfactory?: number;
|
|
107
|
+
code?: Uint8Array;
|
|
108
|
+
module: WebAssembly.Module;
|
|
109
|
+
json: string;
|
|
110
|
+
poly?: boolean;
|
|
111
|
+
shaKey?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface FaustDspMeta {
|
|
114
|
+
name: string;
|
|
115
|
+
filename: string;
|
|
116
|
+
compile_options: string;
|
|
117
|
+
include_pathnames: string[];
|
|
118
|
+
inputs: number;
|
|
119
|
+
outputs: number;
|
|
120
|
+
size: number;
|
|
121
|
+
version: string;
|
|
122
|
+
library_list: string[];
|
|
123
|
+
meta: {
|
|
124
|
+
[key: string]: string;
|
|
125
|
+
}[];
|
|
126
|
+
ui: FaustUIDescriptor;
|
|
127
|
+
}
|
|
128
|
+
export declare type FaustUIDescriptor = FaustUIGroup[];
|
|
129
|
+
export declare type FaustUIItem = FaustUIInputItem | FaustUIOutputItem | FaustUIGroup;
|
|
130
|
+
export interface FaustUIInputItem {
|
|
131
|
+
type: FaustUIInputType;
|
|
132
|
+
label: string;
|
|
133
|
+
address: string;
|
|
134
|
+
index: number;
|
|
135
|
+
init?: number;
|
|
136
|
+
min?: number;
|
|
137
|
+
max?: number;
|
|
138
|
+
step?: number;
|
|
139
|
+
meta?: FaustUIMeta[];
|
|
140
|
+
}
|
|
141
|
+
export interface FaustUIOutputItem {
|
|
142
|
+
type: FaustUIOutputType;
|
|
143
|
+
label: string;
|
|
144
|
+
address: string;
|
|
145
|
+
index: number;
|
|
146
|
+
min?: number;
|
|
147
|
+
max?: number;
|
|
148
|
+
meta?: FaustUIMeta[];
|
|
149
|
+
}
|
|
150
|
+
export interface FaustUIMeta {
|
|
151
|
+
[order: number]: string;
|
|
152
|
+
style?: string;
|
|
153
|
+
unit?: string;
|
|
154
|
+
scale?: "linear" | "exp" | "log";
|
|
155
|
+
tooltip?: string;
|
|
156
|
+
hidden?: string;
|
|
157
|
+
[key: string]: string | undefined;
|
|
158
|
+
}
|
|
159
|
+
export declare type FaustUIGroupType = "vgroup" | "hgroup" | "tgroup";
|
|
160
|
+
export declare type FaustUIOutputType = "hbargraph" | "vbargraph";
|
|
161
|
+
export declare type FaustUIInputType = "vslider" | "hslider" | "button" | "checkbox" | "nentry";
|
|
162
|
+
export interface FaustUIGroup {
|
|
163
|
+
type: FaustUIGroupType;
|
|
164
|
+
label: string;
|
|
165
|
+
items: FaustUIItem[];
|
|
166
|
+
}
|
|
167
|
+
export declare type FaustUIType = FaustUIGroupType | FaustUIOutputType | FaustUIInputType;
|
|
168
|
+
export interface AudioParamDescriptor {
|
|
169
|
+
automationRate?: AutomationRate;
|
|
170
|
+
defaultValue?: number;
|
|
171
|
+
maxValue?: number;
|
|
172
|
+
minValue?: number;
|
|
173
|
+
name: string;
|
|
174
|
+
}
|
|
175
|
+
export interface AudioWorkletProcessor {
|
|
176
|
+
port: MessagePort;
|
|
177
|
+
process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: Record<string, Float32Array>): boolean;
|
|
178
|
+
}
|
|
179
|
+
export declare const AudioWorkletProcessor: {
|
|
180
|
+
prototype: AudioWorkletProcessor;
|
|
181
|
+
parameterDescriptors: AudioParamDescriptor[];
|
|
182
|
+
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
183
|
+
};
|
|
184
|
+
export interface AudioWorkletGlobalScope {
|
|
185
|
+
AudioWorkletGlobalScope: any;
|
|
186
|
+
globalThis: AudioWorkletGlobalScope;
|
|
187
|
+
registerProcessor: (name: string, constructor: new (options: any) => AudioWorkletProcessor) => void;
|
|
188
|
+
currentFrame: number;
|
|
189
|
+
currentTime: number;
|
|
190
|
+
sampleRate: number;
|
|
191
|
+
AudioWorkletProcessor: typeof AudioWorkletProcessor;
|
|
192
|
+
}
|
|
193
|
+
export interface InterfaceFFT {
|
|
194
|
+
forward(arr: ArrayLike<number> | ((arr: Float32Array) => any)): Float32Array;
|
|
195
|
+
inverse(arr: ArrayLike<number> | ((arr: Float32Array) => any)): Float32Array;
|
|
196
|
+
dispose(): void;
|
|
197
|
+
}
|
|
198
|
+
export declare const InterfaceFFT: {
|
|
199
|
+
new (size: number): InterfaceFFT;
|
|
200
|
+
};
|
|
201
|
+
export declare type TWindowFunction = (index: number, length: number, ...args: any[]) => number;
|
|
202
|
+
export declare type Writeable<T> = {
|
|
203
|
+
-readonly [P in keyof T]: T[P];
|
|
204
|
+
};
|
|
205
|
+
export declare type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
|
|
206
|
+
export declare type TypedArrayConstructor = typeof Int8Array | typeof Uint8Array | typeof Int16Array | typeof Uint16Array | typeof Int32Array | typeof Uint32Array | typeof Uint8ClampedArray | typeof Float32Array | typeof Float64Array;
|
|
207
|
+
export declare const FFTUtils: {
|
|
208
|
+
/** Inject window functions as array, no need to add rectangular (no windowing) */
|
|
209
|
+
windowFunctions?: TWindowFunction[];
|
|
210
|
+
/** Get a FFT interface constructor */
|
|
211
|
+
getFFT: () => Promise<typeof InterfaceFFT>;
|
|
212
|
+
/** 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 */
|
|
213
|
+
fftToSignal: (fft: Float32Array | Float64Array, real: Float32Array | Float64Array, imag?: Float32Array | Float64Array, index?: Float32Array | Float64Array) => any;
|
|
214
|
+
/** 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 */
|
|
215
|
+
signalToFFT: (real: Float32Array | Float64Array, imag: Float32Array | Float64Array, fft: Float32Array | Float64Array) => any;
|
|
216
|
+
/** Convert from Faust processor's output to direct audio output, real/imag are readonly, fft length = fftSize = (real/imag length - 1) * 2 */
|
|
217
|
+
signalToNoFFT: (real: Float32Array | Float64Array, imag: Float32Array | Float64Array, fft: Float32Array | Float64Array) => any;
|
|
218
|
+
};
|
|
219
|
+
export declare const FaustModuleFactoryFn: FaustModuleFactory;
|
|
220
|
+
export declare const FaustModuleFactoryWasm: Uint8Array;
|
|
221
|
+
export declare const FaustModuleFactoryData: Uint8Array;
|
|
222
|
+
/**
|
|
223
|
+
* Instantiate `FaustModule` using bundled binaries. Module constructor and files can be overriden.
|
|
224
|
+
*/
|
|
225
|
+
export declare const instantiateFaustModule: (FaustModuleFactoryIn?: FaustModuleFactory, dataBinaryIn?: Uint8Array, wasmBinaryIn?: Uint8Array) => Promise<FaustModule>;
|
|
226
|
+
/**
|
|
227
|
+
* Load libfaust-wasm files, than instantiate libFaust
|
|
228
|
+
* @param jsFile path to `libfaust-wasm.js`
|
|
229
|
+
* @param dataFile path to `libfaust-wasm.data`
|
|
230
|
+
* @param wasmFile path to `libfaust-wasm.wasm`
|
|
231
|
+
*/
|
|
232
|
+
export declare const instantiateFaustModuleFromFile: (jsFile: string, dataFile?: string, wasmFile?: string) => Promise<FaustModule>;
|
|
233
|
+
/**
|
|
234
|
+
* The Faust wasm instance interface.
|
|
235
|
+
*/
|
|
236
|
+
export interface IFaustDspInstance {
|
|
237
|
+
/**
|
|
238
|
+
* The dsp computation, to be called with successive input/output audio buffers.
|
|
239
|
+
*
|
|
240
|
+
* @param $dsp - the DSP pointer
|
|
241
|
+
* @param count - the audio buffer size in frames
|
|
242
|
+
* @param $inputs - the input audio buffer as in index in wasm memory
|
|
243
|
+
* @param $output - the output audio buffer as in index in wasm memory
|
|
244
|
+
*/
|
|
245
|
+
compute($dsp: number, count: number, $inputs: number, $output: number): void;
|
|
246
|
+
/**
|
|
247
|
+
* Give the number of inputs of a Faust wasm instance.
|
|
248
|
+
*
|
|
249
|
+
* @param $dsp - the DSP pointer
|
|
250
|
+
*/
|
|
251
|
+
getNumInputs($dsp: number): number;
|
|
252
|
+
/**
|
|
253
|
+
* Give the number of outputs of a Faust wasm instance.
|
|
254
|
+
*
|
|
255
|
+
* @param $dsp - the DSP pointer
|
|
256
|
+
*/
|
|
257
|
+
getNumOutputs($dsp: number): number;
|
|
258
|
+
/**
|
|
259
|
+
* Give a parameter current value.
|
|
260
|
+
*
|
|
261
|
+
* @param $dsp - the DSP pointer
|
|
262
|
+
* @param index - the parameter index
|
|
263
|
+
* @preturn the parameter value
|
|
264
|
+
*/
|
|
265
|
+
getParamValue($dsp: number, index: number): number;
|
|
266
|
+
/**
|
|
267
|
+
* Give the Faust wasm instance sample rate.
|
|
268
|
+
*
|
|
269
|
+
* @param $dsp - the DSP pointer
|
|
270
|
+
* @preturn the sample rate
|
|
271
|
+
*/
|
|
272
|
+
getSampleRate($dsp: number): number;
|
|
273
|
+
/**
|
|
274
|
+
* Global init, calls the following methods:
|
|
275
|
+
* - static class 'classInit': static tables initialization
|
|
276
|
+
* - 'instanceInit': constants and instance state initialization
|
|
277
|
+
*
|
|
278
|
+
* @param $dsp - the DSP pointer
|
|
279
|
+
* @param sampleRate - the sampling rate in Hertz
|
|
280
|
+
*/
|
|
281
|
+
init($dsp: number, sampleRate: number): void;
|
|
282
|
+
/** Init instance state (delay lines...).
|
|
283
|
+
*
|
|
284
|
+
* @param $dsp - the DSP pointer
|
|
285
|
+
*/
|
|
286
|
+
instanceClear($dsp: number): void;
|
|
287
|
+
/** Init instance constant state.
|
|
288
|
+
*
|
|
289
|
+
* @param $dsp - the DSP pointer
|
|
290
|
+
* @param sampleRate - the sampling rate in Hertz
|
|
291
|
+
*/
|
|
292
|
+
instanceConstants($dsp: number, sampleRate: number): void;
|
|
293
|
+
/** Init instance state.
|
|
294
|
+
*
|
|
295
|
+
* @param $dsp - the DSP pointer
|
|
296
|
+
* @param sampleRate - the sampling rate in Hertz
|
|
297
|
+
*/
|
|
298
|
+
instanceInit($dsp: number, sampleRate: number): void;
|
|
299
|
+
/** Init default control parameters values.
|
|
300
|
+
*
|
|
301
|
+
* @param $dsp - the DSP pointer
|
|
302
|
+
*/
|
|
303
|
+
instanceResetUserInterface($dsp: number): void;
|
|
304
|
+
/**
|
|
305
|
+
* Set a parameter current value.
|
|
306
|
+
*
|
|
307
|
+
* @param $dsp - the DSP pointer
|
|
308
|
+
* @param index - the parameter index
|
|
309
|
+
* @param value - the parameter value
|
|
310
|
+
*/
|
|
311
|
+
setParamValue($dsp: number, index: number, value: number): void;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Mixer used in polyphonic mode.
|
|
315
|
+
*/
|
|
316
|
+
export interface IFaustMixerInstance {
|
|
317
|
+
clearOutput(bufferSize: number, chans: number, $outputs: number): void;
|
|
318
|
+
mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;
|
|
319
|
+
fadeOut(bufferSize: number, chans: number, $outputs: number): void;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Monophonic instance.
|
|
323
|
+
*/
|
|
324
|
+
export interface FaustMonoDspInstance {
|
|
325
|
+
memory: WebAssembly.Memory;
|
|
326
|
+
api: IFaustDspInstance;
|
|
327
|
+
json: string;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Polyphonic instance.
|
|
331
|
+
*/
|
|
332
|
+
export interface FaustPolyDspInstance {
|
|
333
|
+
memory: WebAssembly.Memory;
|
|
334
|
+
voices: number;
|
|
335
|
+
voiceAPI: IFaustDspInstance;
|
|
336
|
+
effectAPI?: IFaustDspInstance;
|
|
337
|
+
mixerAPI: IFaustMixerInstance;
|
|
338
|
+
voiceJSON: string;
|
|
339
|
+
effectJSON?: string;
|
|
340
|
+
}
|
|
341
|
+
export declare class FaustDspInstance implements IFaustDspInstance {
|
|
342
|
+
private readonly fExports;
|
|
343
|
+
constructor(exports: IFaustDspInstance);
|
|
344
|
+
compute($dsp: number, count: number, $input: number, $output: number): void;
|
|
345
|
+
getNumInputs($dsp: number): number;
|
|
346
|
+
getNumOutputs($dsp: number): number;
|
|
347
|
+
getParamValue($dsp: number, index: number): number;
|
|
348
|
+
getSampleRate($dsp: number): number;
|
|
349
|
+
init($dsp: number, sampleRate: number): void;
|
|
350
|
+
instanceClear($dsp: number): void;
|
|
351
|
+
instanceConstants($dsp: number, sampleRate: number): void;
|
|
352
|
+
instanceInit($dsp: number, sampleRate: number): void;
|
|
353
|
+
instanceResetUserInterface($dsp: number): void;
|
|
354
|
+
setParamValue($dsp: number, index: number, value: number): void;
|
|
355
|
+
}
|
|
356
|
+
export declare class FaustWasmInstantiator {
|
|
357
|
+
private static createWasmImport;
|
|
358
|
+
private static createWasmMemory;
|
|
359
|
+
private static createMonoDSPInstanceAux;
|
|
360
|
+
private static createMemoryAux;
|
|
361
|
+
private static createMixerAux;
|
|
362
|
+
static loadDSPFactory(wasmPath: string, jsonPath: string): Promise<FaustDspFactory>;
|
|
363
|
+
static loadDSPMixer(mixerPath: string, fs?: typeof FS): Promise<WebAssembly.Module>;
|
|
364
|
+
static createAsyncMonoDSPInstance(factory: LooseFaustDspFactory): Promise<FaustMonoDspInstance>;
|
|
365
|
+
static createSyncMonoDSPInstance(factory: LooseFaustDspFactory): FaustMonoDspInstance;
|
|
366
|
+
static createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise<FaustPolyDspInstance>;
|
|
367
|
+
static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance;
|
|
368
|
+
}
|
|
369
|
+
export declare type OutputParamHandler = (path: string, value: number) => void;
|
|
370
|
+
export declare type ComputeHandler = (buffer_size: number) => void;
|
|
371
|
+
export declare type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: {
|
|
372
|
+
type: string;
|
|
373
|
+
data: any;
|
|
374
|
+
}[]) => void;
|
|
375
|
+
export declare type MetadataHandler = (key: string, value: string) => void;
|
|
376
|
+
export declare type UIHandler = (item: FaustUIItem) => void;
|
|
377
|
+
/**
|
|
378
|
+
* DSP implementation: mimic the C++ 'dsp' class:
|
|
379
|
+
* - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers
|
|
380
|
+
* - an output handler can be set to treat produced output controllers (like 'bargraph')
|
|
381
|
+
* - regular controllers are handled using setParamValue/getParamValue
|
|
382
|
+
*/
|
|
383
|
+
export interface IFaustBaseWebAudioDsp {
|
|
384
|
+
/**
|
|
385
|
+
* Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).
|
|
386
|
+
*
|
|
387
|
+
* @param handler - the output handler
|
|
388
|
+
*/
|
|
389
|
+
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
390
|
+
/**
|
|
391
|
+
* Get the parameter output handler.
|
|
392
|
+
*
|
|
393
|
+
* @return the current output handler
|
|
394
|
+
*/
|
|
395
|
+
getOutputParamHandler(): OutputParamHandler | null;
|
|
396
|
+
/**
|
|
397
|
+
* Set the compute handler, to be called in the 'compute' method with buffer size.
|
|
398
|
+
*
|
|
399
|
+
* @param handler - the compute handler
|
|
400
|
+
*/
|
|
401
|
+
setComputeHandler(handler: ComputeHandler | null): void;
|
|
402
|
+
/**
|
|
403
|
+
* Get the compute handler.
|
|
404
|
+
*
|
|
405
|
+
* @return the current output handler
|
|
406
|
+
*/
|
|
407
|
+
getComputeHandler(): ComputeHandler | null;
|
|
408
|
+
/**
|
|
409
|
+
* Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).
|
|
410
|
+
*
|
|
411
|
+
* @param handler - the plot handler
|
|
412
|
+
*/
|
|
413
|
+
setPlotHandler(handler: PlotHandler | null): void;
|
|
414
|
+
/**
|
|
415
|
+
* Get the plot handler.
|
|
416
|
+
*
|
|
417
|
+
* @return the current plot handler
|
|
418
|
+
*/
|
|
419
|
+
getPlotHandler(): PlotHandler | null;
|
|
420
|
+
/**
|
|
421
|
+
* Return instance number of audio inputs.
|
|
422
|
+
*
|
|
423
|
+
* @return the instance number of audio inputs
|
|
424
|
+
*/
|
|
425
|
+
getNumInputs(): number;
|
|
426
|
+
/**
|
|
427
|
+
* Return instance number of audio outputs.
|
|
428
|
+
*
|
|
429
|
+
* @return the instance number of audio outputs
|
|
430
|
+
*/
|
|
431
|
+
getNumOutputs(): number;
|
|
432
|
+
/**
|
|
433
|
+
* DSP instance computation, to be called with successive input/output audio buffers, using their size.
|
|
434
|
+
*
|
|
435
|
+
* @param inputs - the input audio buffers
|
|
436
|
+
* @param outputs - the output audio buffers
|
|
437
|
+
*/
|
|
438
|
+
compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
|
|
439
|
+
/**
|
|
440
|
+
* Give a handler to be called on 'declare key value' kind of metadata.
|
|
441
|
+
*
|
|
442
|
+
* @param handler - the handler to be used
|
|
443
|
+
*/
|
|
444
|
+
metadata(handler: MetadataHandler): void;
|
|
445
|
+
/**
|
|
446
|
+
* Handle untyped MIDI messages.
|
|
447
|
+
*
|
|
448
|
+
* @param data - and arry of MIDI bytes
|
|
449
|
+
*/
|
|
450
|
+
midiMessage(data: number[] | Uint8Array): void;
|
|
451
|
+
/**
|
|
452
|
+
* Handle MIDI ctrlChange messages.
|
|
453
|
+
*
|
|
454
|
+
* @param channel - the MIDI channel (0..15, not used for now)
|
|
455
|
+
* @param ctrl - the MIDI controller number (0..127)
|
|
456
|
+
* @param value - the MIDI controller value (0..127)
|
|
457
|
+
*/
|
|
458
|
+
ctrlChange(chan: number, ctrl: number, value: number): void;
|
|
459
|
+
/**
|
|
460
|
+
* Handle MIDI pitchWheel messages.
|
|
461
|
+
*
|
|
462
|
+
* @param channel - the MIDI channel (0..15, not used for now)
|
|
463
|
+
* @param value - the MIDI controller value (0..16383)
|
|
464
|
+
*/
|
|
465
|
+
pitchWheel(chan: number, value: number): void;
|
|
466
|
+
/**
|
|
467
|
+
* Set parameter value.
|
|
468
|
+
*
|
|
469
|
+
* @param path - the path to the wanted parameter (retrieved using 'getParams' method)
|
|
470
|
+
* @param val - the float value for the wanted control
|
|
471
|
+
*/
|
|
472
|
+
setParamValue(path: string, value: number): void;
|
|
473
|
+
/**
|
|
474
|
+
* Get parameter value.
|
|
475
|
+
*
|
|
476
|
+
* @param path - the path to the wanted parameter (retrieved using 'getParams' method)
|
|
477
|
+
*
|
|
478
|
+
* @return the float value
|
|
479
|
+
*/
|
|
480
|
+
getParamValue(path: string): number;
|
|
481
|
+
/**
|
|
482
|
+
* Get the table of all input parameters paths.
|
|
483
|
+
*
|
|
484
|
+
* @return the table of all input parameters paths
|
|
485
|
+
*/
|
|
486
|
+
getParams(): string[];
|
|
487
|
+
/**
|
|
488
|
+
* Get DSP JSON description with its UI and metadata as object.
|
|
489
|
+
*
|
|
490
|
+
* @return the DSP JSON description as object
|
|
491
|
+
*/
|
|
492
|
+
getMeta(): FaustDspMeta;
|
|
493
|
+
/**
|
|
494
|
+
* Get DSP JSON description with its UI and metadata.
|
|
495
|
+
*
|
|
496
|
+
* @return the DSP JSON description
|
|
497
|
+
*/
|
|
498
|
+
getJSON(): string;
|
|
499
|
+
/**
|
|
500
|
+
* Get DSP UI description.
|
|
501
|
+
*
|
|
502
|
+
* @return the DSP UI description
|
|
503
|
+
*/
|
|
504
|
+
getUI(): FaustUIDescriptor;
|
|
505
|
+
/**
|
|
506
|
+
* Get DSP UI items description.
|
|
507
|
+
*
|
|
508
|
+
* @return the DSP UI items description
|
|
509
|
+
*/
|
|
510
|
+
getDescriptors(): FaustUIInputItem[];
|
|
511
|
+
/**
|
|
512
|
+
* Start the DSP.
|
|
513
|
+
*/
|
|
514
|
+
start(): void;
|
|
515
|
+
/**
|
|
516
|
+
* Stop the DSP.
|
|
517
|
+
*/
|
|
518
|
+
stop(): void;
|
|
519
|
+
/**
|
|
520
|
+
* Destroy the DSP.
|
|
521
|
+
*/
|
|
522
|
+
destroy(): void;
|
|
523
|
+
}
|
|
524
|
+
export interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp {
|
|
525
|
+
}
|
|
526
|
+
export interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode {
|
|
527
|
+
}
|
|
528
|
+
export interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {
|
|
529
|
+
/**
|
|
530
|
+
* Handle MIDI keyOn messages.
|
|
531
|
+
*
|
|
532
|
+
* @param channel - the MIDI channel (0..15, not used for now)
|
|
533
|
+
* @param pitch - the MIDI pitch value (0..127)
|
|
534
|
+
* @param velocity - the MIDI velocity value (0..127)
|
|
535
|
+
*/
|
|
536
|
+
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
537
|
+
/**
|
|
538
|
+
* Handle MIDI keyOff messages.
|
|
539
|
+
*
|
|
540
|
+
* @param channel - the MIDI channel (0..15, not used for now)
|
|
541
|
+
* @param pitch - the MIDI pitch value (0..127)
|
|
542
|
+
* @param velocity - the MIDI velocity value (0..127)
|
|
543
|
+
*/
|
|
544
|
+
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
545
|
+
/**
|
|
546
|
+
* Stop all playing notes.
|
|
547
|
+
*
|
|
548
|
+
* @param hard - whether to immediately stop notes or put them in release mode
|
|
549
|
+
*/
|
|
550
|
+
allNotesOff(hard: boolean): void;
|
|
551
|
+
}
|
|
552
|
+
export interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode {
|
|
553
|
+
}
|
|
554
|
+
export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
555
|
+
protected fOutputHandler: OutputParamHandler | null;
|
|
556
|
+
protected fComputeHandler: ComputeHandler | null;
|
|
557
|
+
protected fPlotHandler: PlotHandler | null;
|
|
558
|
+
protected fCachedEvents: {
|
|
559
|
+
type: string;
|
|
560
|
+
data: any;
|
|
561
|
+
}[];
|
|
562
|
+
protected fBufferNum: number;
|
|
563
|
+
protected fInChannels: Float32Array[] | Float64Array[];
|
|
564
|
+
protected fOutChannels: Float32Array[] | Float64Array[];
|
|
565
|
+
protected fOutputsTimer: number;
|
|
566
|
+
protected fInputsItems: string[];
|
|
567
|
+
protected fOutputsItems: string[];
|
|
568
|
+
protected fDescriptor: FaustUIInputItem[];
|
|
569
|
+
protected fAudioInputs: number;
|
|
570
|
+
protected fAudioOutputs: number;
|
|
571
|
+
protected fBufferSize: number;
|
|
572
|
+
protected gPtrSize: number;
|
|
573
|
+
protected gSampleSize: number;
|
|
574
|
+
protected fPitchwheelLabel: {
|
|
575
|
+
path: string;
|
|
576
|
+
min: number;
|
|
577
|
+
max: number;
|
|
578
|
+
}[];
|
|
579
|
+
protected fCtrlLabel: {
|
|
580
|
+
path: string;
|
|
581
|
+
min: number;
|
|
582
|
+
max: number;
|
|
583
|
+
}[][];
|
|
584
|
+
protected fPathTable: {
|
|
585
|
+
[address: string]: number;
|
|
586
|
+
};
|
|
587
|
+
protected fUICallback: UIHandler;
|
|
588
|
+
protected fProcessing: boolean;
|
|
589
|
+
protected fDestroyed: boolean;
|
|
590
|
+
protected fJSONDsp: FaustDspMeta;
|
|
591
|
+
constructor(sampleSize: number, bufferSize: number);
|
|
592
|
+
static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number): number;
|
|
593
|
+
static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any): void;
|
|
594
|
+
static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any): void;
|
|
595
|
+
static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any): void;
|
|
596
|
+
static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any): void;
|
|
597
|
+
protected updateOutputs(): void;
|
|
598
|
+
metadata(handler: MetadataHandler): void;
|
|
599
|
+
compute(input: Float32Array[], output: Float32Array[]): boolean;
|
|
600
|
+
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
601
|
+
getOutputParamHandler(): OutputParamHandler | null;
|
|
602
|
+
setComputeHandler(handler: ComputeHandler | null): void;
|
|
603
|
+
getComputeHandler(): ComputeHandler | null;
|
|
604
|
+
setPlotHandler(handler: PlotHandler | null): void;
|
|
605
|
+
getPlotHandler(): PlotHandler | null;
|
|
606
|
+
getNumInputs(): number;
|
|
607
|
+
getNumOutputs(): number;
|
|
608
|
+
midiMessage(data: number[] | Uint8Array): void;
|
|
609
|
+
ctrlChange(channel: number, ctrl: number, value: number): void;
|
|
610
|
+
pitchWheel(channel: number, wheel: number): void;
|
|
611
|
+
setParamValue(path: string, value: number): void;
|
|
612
|
+
getParamValue(path: string): number;
|
|
613
|
+
getParams(): string[];
|
|
614
|
+
getMeta(): FaustDspMeta;
|
|
615
|
+
getJSON(): string;
|
|
616
|
+
getUI(): FaustUIDescriptor;
|
|
617
|
+
getDescriptors(): FaustUIInputItem[];
|
|
618
|
+
start(): void;
|
|
619
|
+
stop(): void;
|
|
620
|
+
destroy(): void;
|
|
621
|
+
}
|
|
622
|
+
export declare class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {
|
|
623
|
+
private fInstance;
|
|
624
|
+
private fDSP;
|
|
625
|
+
constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number);
|
|
626
|
+
private initMemory;
|
|
627
|
+
toString(): string;
|
|
628
|
+
compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)): boolean;
|
|
629
|
+
metadata(handler: MetadataHandler): void;
|
|
630
|
+
getNumInputs(): number;
|
|
631
|
+
getNumOutputs(): number;
|
|
632
|
+
setParamValue(path: string, value: number): void;
|
|
633
|
+
getParamValue(path: string): number;
|
|
634
|
+
getMeta(): FaustDspMeta;
|
|
635
|
+
getJSON(): string;
|
|
636
|
+
getDescriptors(): FaustUIInputItem[];
|
|
637
|
+
getUI(): FaustUIDescriptor;
|
|
638
|
+
}
|
|
639
|
+
export declare class FaustWebAudioDspVoice {
|
|
640
|
+
static kActiveVoice: number;
|
|
641
|
+
static kFreeVoice: number;
|
|
642
|
+
static kReleaseVoice: number;
|
|
643
|
+
static kLegatoVoice: number;
|
|
644
|
+
static kNoVoice: number;
|
|
645
|
+
static VOICE_STOP_LEVEL: number;
|
|
646
|
+
private fFreqLabel;
|
|
647
|
+
private fGateLabel;
|
|
648
|
+
private fGainLabel;
|
|
649
|
+
private fKeyLabel;
|
|
650
|
+
private fVelLabel;
|
|
651
|
+
private fDSP;
|
|
652
|
+
private fAPI;
|
|
653
|
+
fCurNote: number;
|
|
654
|
+
fNextNote: number;
|
|
655
|
+
fNextVel: number;
|
|
656
|
+
fDate: number;
|
|
657
|
+
fLevel: number;
|
|
658
|
+
fRelease: number;
|
|
659
|
+
constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: {
|
|
660
|
+
[address: string]: number;
|
|
661
|
+
}, sampleRate: number);
|
|
662
|
+
static midiToFreq(note: number): number;
|
|
663
|
+
static normalizeVelocity(velocity: number): number;
|
|
664
|
+
private extractPaths;
|
|
665
|
+
keyOn(pitch: number, velocity: number, legato?: boolean): void;
|
|
666
|
+
keyOff(hard?: boolean): void;
|
|
667
|
+
computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number): void;
|
|
668
|
+
compute(bufferSize: number, $inputs: number, $outputs: number): void;
|
|
669
|
+
setParamValue(index: number, value: number): void;
|
|
670
|
+
getParamValue(index: number): number;
|
|
671
|
+
}
|
|
672
|
+
export declare class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {
|
|
673
|
+
private fInstance;
|
|
674
|
+
private fEffect;
|
|
675
|
+
private fJSONEffect;
|
|
676
|
+
private fAudioMixing;
|
|
677
|
+
private fAudioMixingHalf;
|
|
678
|
+
private fVoiceTable;
|
|
679
|
+
constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number);
|
|
680
|
+
private initMemory;
|
|
681
|
+
toString(): string;
|
|
682
|
+
private allocVoice;
|
|
683
|
+
private getPlayingVoice;
|
|
684
|
+
private getFreeVoice;
|
|
685
|
+
compute(input: Float32Array[], output: Float32Array[]): boolean;
|
|
686
|
+
getNumInputs(): number;
|
|
687
|
+
getNumOutputs(): number;
|
|
688
|
+
private static findPath;
|
|
689
|
+
setParamValue(path: string, value: number): void;
|
|
690
|
+
getParamValue(path: string): number;
|
|
691
|
+
getMeta(): FaustDspMeta;
|
|
692
|
+
getJSON(): string;
|
|
693
|
+
getUI(): FaustUIDescriptor;
|
|
694
|
+
getDescriptors(): FaustUIInputItem[];
|
|
695
|
+
midiMessage(data: number[] | Uint8Array): void;
|
|
696
|
+
ctrlChange(channel: number, ctrl: number, value: number): void;
|
|
697
|
+
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
698
|
+
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
699
|
+
allNotesOff(hard?: boolean): void;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Injected in the string to be compiled on AudioWorkletProcessor side
|
|
703
|
+
*/
|
|
704
|
+
export interface FaustData {
|
|
705
|
+
processorName: string;
|
|
706
|
+
dspName: string;
|
|
707
|
+
dspMeta: FaustDspMeta;
|
|
708
|
+
poly: boolean;
|
|
709
|
+
effectMeta?: FaustDspMeta;
|
|
710
|
+
}
|
|
711
|
+
export interface FaustAudioWorkletProcessorDependencies<Poly extends boolean = false> {
|
|
712
|
+
FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;
|
|
713
|
+
FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;
|
|
714
|
+
FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;
|
|
715
|
+
FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;
|
|
716
|
+
FaustWasmInstantiator: typeof FaustWasmInstantiator;
|
|
717
|
+
}
|
|
718
|
+
export interface FaustAudioWorkletNodeOptions<Poly extends boolean = false> extends AudioWorkletNodeOptions {
|
|
719
|
+
processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;
|
|
720
|
+
}
|
|
721
|
+
export interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
|
|
722
|
+
processorOptions: FaustMonoAudioWorkletProcessorOptions;
|
|
723
|
+
}
|
|
724
|
+
export interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
|
|
725
|
+
processorOptions: FaustPolyAudioWorkletProcessorOptions;
|
|
726
|
+
}
|
|
727
|
+
export interface FaustAudioWorkletProcessorOptions {
|
|
728
|
+
name: string;
|
|
729
|
+
sampleSize: number;
|
|
730
|
+
}
|
|
731
|
+
export interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
|
|
732
|
+
factory: LooseFaustDspFactory;
|
|
733
|
+
}
|
|
734
|
+
export interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
|
|
735
|
+
voiceFactory: LooseFaustDspFactory;
|
|
736
|
+
mixerModule: WebAssembly.Module;
|
|
737
|
+
voices: number;
|
|
738
|
+
effectFactory?: LooseFaustDspFactory;
|
|
739
|
+
}
|
|
740
|
+
export declare const getFaustAudioWorkletProcessor: <Poly extends boolean = false>(dependencies: FaustAudioWorkletProcessorDependencies<Poly>, faustData: FaustData, register?: boolean) => {
|
|
741
|
+
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
742
|
+
prototype: AudioWorkletProcessor;
|
|
743
|
+
parameterDescriptors: AudioParamDescriptor[];
|
|
744
|
+
};
|
|
745
|
+
export interface FaustFFTOptionsData {
|
|
746
|
+
fftSize: number;
|
|
747
|
+
fftOverlap: number;
|
|
748
|
+
noIFFT: boolean;
|
|
749
|
+
/** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */
|
|
750
|
+
defaultWindowFunction: number;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Injected in the string to be compiled on AudioWorkletProcessor side
|
|
754
|
+
*/
|
|
755
|
+
export interface FaustFFTData {
|
|
756
|
+
processorName: string;
|
|
757
|
+
dspName: string;
|
|
758
|
+
dspMeta: FaustDspMeta;
|
|
759
|
+
fftOptions?: Partial<FaustFFTOptionsData>;
|
|
760
|
+
}
|
|
761
|
+
export interface FaustFFTAudioWorkletProcessorDependencies {
|
|
762
|
+
FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;
|
|
763
|
+
FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;
|
|
764
|
+
FaustWasmInstantiator: typeof FaustWasmInstantiator;
|
|
765
|
+
FFTUtils: typeof FFTUtils;
|
|
766
|
+
}
|
|
767
|
+
export interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
|
|
768
|
+
processorOptions: FaustFFTAudioWorkletProcessorOptions;
|
|
769
|
+
}
|
|
770
|
+
export interface FaustFFTAudioWorkletProcessorOptions {
|
|
771
|
+
name: string;
|
|
772
|
+
sampleSize: number;
|
|
773
|
+
factory: LooseFaustDspFactory;
|
|
774
|
+
}
|
|
775
|
+
export declare const getFaustFFTAudioWorkletProcessor: (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register?: boolean) => {
|
|
776
|
+
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
777
|
+
prototype: AudioWorkletProcessor; /** Generated from the current window function */
|
|
778
|
+
parameterDescriptors: AudioParamDescriptor[];
|
|
779
|
+
};
|
|
780
|
+
export interface ILibFaust extends LibFaustWasm {
|
|
781
|
+
module(): FaustModule;
|
|
782
|
+
fs(): typeof FS;
|
|
783
|
+
}
|
|
784
|
+
export declare class LibFaust implements ILibFaust {
|
|
785
|
+
private fModule;
|
|
786
|
+
private fCompiler;
|
|
787
|
+
private fFileSystem;
|
|
788
|
+
constructor(module: FaustModule);
|
|
789
|
+
module(): FaustModule;
|
|
790
|
+
fs(): typeof FS;
|
|
791
|
+
version(): string;
|
|
792
|
+
createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean): FaustDspWasm;
|
|
793
|
+
deleteDSPFactory(cFactory: number): void;
|
|
794
|
+
expandDSP(name: string, code: string, args: string): string;
|
|
795
|
+
generateAuxFiles(name: string, code: string, args: string): boolean;
|
|
796
|
+
deleteAllDSPFactories(): void;
|
|
797
|
+
getErrorAfterException(): string;
|
|
798
|
+
cleanupAfterException(): void;
|
|
799
|
+
getInfos(what: FaustInfoType): string;
|
|
800
|
+
toString(): string;
|
|
801
|
+
}
|
|
802
|
+
export declare const ab2str: (buf: Uint8Array) => any;
|
|
803
|
+
export declare const str2ab: (str: string) => Uint8Array;
|
|
804
|
+
export interface IFaustCompiler {
|
|
805
|
+
/**
|
|
806
|
+
* Gives the Faust compiler version.
|
|
807
|
+
* @return a version string
|
|
808
|
+
*/
|
|
809
|
+
version(): string;
|
|
810
|
+
/**
|
|
811
|
+
* Gives the last compilation error.
|
|
812
|
+
* @return an error string
|
|
813
|
+
*/
|
|
814
|
+
getErrorMessage(): string;
|
|
815
|
+
/**
|
|
816
|
+
* Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances.
|
|
817
|
+
* This function is running asynchronously.
|
|
818
|
+
*
|
|
819
|
+
* @param name - an arbitrary name for the Faust factory
|
|
820
|
+
* @param code - Faust dsp code
|
|
821
|
+
* @param args - the compiler options
|
|
822
|
+
* @returns returns the wasm factory
|
|
823
|
+
*/
|
|
824
|
+
createMonoDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
|
|
825
|
+
/**
|
|
826
|
+
* Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances.
|
|
827
|
+
* This function is running asynchronously.
|
|
828
|
+
*
|
|
829
|
+
* @param name - an arbitrary name for the Faust factory
|
|
830
|
+
* @param code - Faust dsp code
|
|
831
|
+
* @param args - the compiler options
|
|
832
|
+
* @returns returns the wasm factory
|
|
833
|
+
*/
|
|
834
|
+
createPolyDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
|
|
835
|
+
/**
|
|
836
|
+
* Delete a dsp factory.
|
|
837
|
+
*
|
|
838
|
+
* @param factory - the factory to be deleted
|
|
839
|
+
*/
|
|
840
|
+
deleteDSPFactory(factory: FaustDspFactory): void;
|
|
841
|
+
/**
|
|
842
|
+
* Expand Faust code i.e. linearize included libraries.
|
|
843
|
+
*
|
|
844
|
+
* @param code - Faust dsp code
|
|
845
|
+
* @param args - the compiler options
|
|
846
|
+
* @returns returns the expanded dsp code
|
|
847
|
+
*/
|
|
848
|
+
expandDSP(code: string, args: string): string | null;
|
|
849
|
+
/**
|
|
850
|
+
* Generates auxiliary files from Faust code. The output depends on the compiler options.
|
|
851
|
+
*
|
|
852
|
+
* @param name - an arbitrary name for the Faust module
|
|
853
|
+
* @param code - Faust dsp code
|
|
854
|
+
* @param args - the compiler options
|
|
855
|
+
* @returns whether the generation actually succeded
|
|
856
|
+
*/
|
|
857
|
+
generateAuxFiles(name: string, code: string, args: string): boolean;
|
|
858
|
+
/**
|
|
859
|
+
* Delete all factories.
|
|
860
|
+
*/
|
|
861
|
+
deleteAllDSPFactories(): void;
|
|
862
|
+
fs(): typeof FS;
|
|
863
|
+
getAsyncInternalMixerModule(isDouble?: boolean): Promise<{
|
|
864
|
+
mixerBuffer: Uint8Array;
|
|
865
|
+
mixerModule: WebAssembly.Module;
|
|
866
|
+
}>;
|
|
867
|
+
getSyncInternalMixerModule(isDouble?: boolean): {
|
|
868
|
+
mixerBuffer: Uint8Array;
|
|
869
|
+
mixerModule: WebAssembly.Module;
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
export declare class FaustCompiler implements IFaustCompiler {
|
|
873
|
+
private fLibFaust;
|
|
874
|
+
private fErrorMessage;
|
|
875
|
+
private static gFactories;
|
|
876
|
+
private mixer32Buffer;
|
|
877
|
+
private mixer64Buffer;
|
|
878
|
+
private mixer32Module;
|
|
879
|
+
private mixer64Module;
|
|
880
|
+
/**
|
|
881
|
+
* Get a stringified DSP factories table
|
|
882
|
+
*/
|
|
883
|
+
static serializeDSPFactories(): Record<string, {
|
|
884
|
+
code: string;
|
|
885
|
+
json: any;
|
|
886
|
+
poly: boolean;
|
|
887
|
+
}>;
|
|
888
|
+
/**
|
|
889
|
+
* Get a stringified DSP factories table as string
|
|
890
|
+
*/
|
|
891
|
+
static stringifyDSPFactories(): string;
|
|
892
|
+
/**
|
|
893
|
+
* Import a DSP factories table
|
|
894
|
+
*/
|
|
895
|
+
static deserializeDSPFactories(table: Record<string, {
|
|
896
|
+
code: string;
|
|
897
|
+
json: any;
|
|
898
|
+
poly: boolean;
|
|
899
|
+
}>): Promise<Map<string, FaustDspFactory>[]>;
|
|
900
|
+
/**
|
|
901
|
+
* Import a stringified DSP factories table
|
|
902
|
+
*/
|
|
903
|
+
static importDSPFactories(tableStr: string): Promise<Map<string, FaustDspFactory>[]>;
|
|
904
|
+
constructor(libFaust: ILibFaust);
|
|
905
|
+
private intVec2intArray;
|
|
906
|
+
private createDSPFactory;
|
|
907
|
+
version(): string;
|
|
908
|
+
getErrorMessage(): string;
|
|
909
|
+
createMonoDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
|
|
910
|
+
createPolyDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
|
|
911
|
+
deleteDSPFactory(factory: FaustDspFactory): void;
|
|
912
|
+
expandDSP(code: string, args: string): string;
|
|
913
|
+
generateAuxFiles(name: string, code: string, args: string): boolean;
|
|
914
|
+
deleteAllDSPFactories(): void;
|
|
915
|
+
fs(): typeof FS;
|
|
916
|
+
getAsyncInternalMixerModule(isDouble?: boolean): Promise<{
|
|
917
|
+
mixerBuffer: Uint8Array;
|
|
918
|
+
mixerModule: WebAssembly.Module;
|
|
919
|
+
}>;
|
|
920
|
+
getSyncInternalMixerModule(isDouble?: boolean): {
|
|
921
|
+
mixerBuffer: Uint8Array;
|
|
922
|
+
mixerModule: WebAssembly.Module;
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* For offline rendering.
|
|
927
|
+
*/
|
|
928
|
+
export interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {
|
|
929
|
+
render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];
|
|
930
|
+
}
|
|
931
|
+
export interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp {
|
|
932
|
+
}
|
|
933
|
+
export interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp {
|
|
934
|
+
}
|
|
935
|
+
export declare class FaustOfflineProcessor<Poly extends boolean = false> {
|
|
936
|
+
protected fDSPCode: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;
|
|
937
|
+
protected fBufferSize: number;
|
|
938
|
+
protected fInputs: Float32Array[];
|
|
939
|
+
protected fOutputs: Float32Array[];
|
|
940
|
+
constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number);
|
|
941
|
+
getParameterDescriptors(): AudioParamDescriptor[];
|
|
942
|
+
compute(input: Float32Array[], output: Float32Array[]): boolean;
|
|
943
|
+
setOutputParamHandler(handler: OutputParamHandler): void;
|
|
944
|
+
getOutputParamHandler(): OutputParamHandler | null;
|
|
945
|
+
setComputeHandler(handler: ComputeHandler): void;
|
|
946
|
+
getComputeHandler(): ComputeHandler | null;
|
|
947
|
+
setPlotHandler(handler: PlotHandler): void;
|
|
948
|
+
getPlotHandler(): PlotHandler | null;
|
|
949
|
+
getNumInputs(): number;
|
|
950
|
+
getNumOutputs(): number;
|
|
951
|
+
metadata(handler: MetadataHandler): void;
|
|
952
|
+
midiMessage(data: number[] | Uint8Array): void;
|
|
953
|
+
ctrlChange(chan: number, ctrl: number, value: number): void;
|
|
954
|
+
pitchWheel(chan: number, value: number): void;
|
|
955
|
+
setParamValue(path: string, value: number): void;
|
|
956
|
+
getParamValue(path: string): number;
|
|
957
|
+
getParams(): string[];
|
|
958
|
+
getMeta(): FaustDspMeta;
|
|
959
|
+
getJSON(): string;
|
|
960
|
+
getDescriptors(): FaustUIInputItem[];
|
|
961
|
+
getUI(): FaustUIDescriptor;
|
|
962
|
+
start(): void;
|
|
963
|
+
stop(): void;
|
|
964
|
+
destroy(): void;
|
|
965
|
+
/**
|
|
966
|
+
* Render frames in an array.
|
|
967
|
+
*
|
|
968
|
+
* @param inputs - input signal
|
|
969
|
+
* @param length - the number of frames to render (default: bufferSize)
|
|
970
|
+
* @param onUpdate - a callback after each buffer calculated, with an argument "current sample"
|
|
971
|
+
* @return an array of Float32Array with the rendered frames
|
|
972
|
+
*/
|
|
973
|
+
render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];
|
|
974
|
+
}
|
|
975
|
+
export declare class FaustMonoOfflineProcessor extends FaustOfflineProcessor<false> implements IFaustMonoWebAudioDsp {
|
|
976
|
+
}
|
|
977
|
+
export declare class FaustPolyOfflineProcessor extends FaustOfflineProcessor<true> implements IFaustPolyWebAudioDsp {
|
|
978
|
+
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
979
|
+
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
980
|
+
allNotesOff(hard: boolean): void;
|
|
981
|
+
}
|
|
982
|
+
export interface IFaustSvgDiagrams {
|
|
983
|
+
/**
|
|
984
|
+
* Generates auxiliary files from Faust code. The output depends on the compiler options.
|
|
985
|
+
*
|
|
986
|
+
* @param name - the DSP's name
|
|
987
|
+
* @param code - Faust code
|
|
988
|
+
* @param args - compilation args
|
|
989
|
+
* @returns the svg diagrams as a filename - svg string map
|
|
990
|
+
*/
|
|
991
|
+
from(name: string, code: string, args: string): Record<string, string>;
|
|
992
|
+
}
|
|
993
|
+
export declare class FaustSvgDiagrams implements IFaustSvgDiagrams {
|
|
994
|
+
private compiler;
|
|
995
|
+
constructor(compiler: FaustCompiler);
|
|
996
|
+
from(name: string, code: string, args: string): Record<string, string>;
|
|
997
|
+
}
|
|
998
|
+
export interface WavEncoderOptions {
|
|
999
|
+
bitDepth: number;
|
|
1000
|
+
float?: boolean;
|
|
1001
|
+
symmetric?: boolean;
|
|
1002
|
+
shared?: boolean;
|
|
1003
|
+
sampleRate: number;
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Code from https://github.com/mohayonao/wav-encoder
|
|
1007
|
+
*/
|
|
1008
|
+
export declare class WavEncoder {
|
|
1009
|
+
static encode(audioBuffer: Float32Array[], options: WavEncoderOptions): ArrayBuffer;
|
|
1010
|
+
private static writeHeader;
|
|
1011
|
+
private static writeData;
|
|
1012
|
+
}
|
|
1013
|
+
export interface WavDecoderOptions {
|
|
1014
|
+
symmetric?: boolean;
|
|
1015
|
+
shared?: boolean;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Code from https://github.com/mohayonao/wav-decoder
|
|
1019
|
+
*/
|
|
1020
|
+
export declare class WavDecoder {
|
|
1021
|
+
static decode(buffer: ArrayBuffer, options?: WavDecoderOptions): {
|
|
1022
|
+
numberOfChannels: number;
|
|
1023
|
+
length: number;
|
|
1024
|
+
sampleRate: number;
|
|
1025
|
+
channelData: Float32Array[];
|
|
1026
|
+
};
|
|
1027
|
+
private static decodeFormat;
|
|
1028
|
+
private static decodeData;
|
|
1029
|
+
private static readPCM;
|
|
1030
|
+
}
|
|
1031
|
+
declare const FaustAudioWorkletNode_base: {
|
|
1032
|
+
new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions | undefined): AudioWorkletNode;
|
|
1033
|
+
prototype: AudioWorkletNode;
|
|
1034
|
+
};
|
|
1035
|
+
/**
|
|
1036
|
+
* Base class for Monophonic and Polyphonic AudioWorkletNode
|
|
1037
|
+
*/
|
|
1038
|
+
export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends FaustAudioWorkletNode_base {
|
|
1039
|
+
protected fJSONDsp: FaustDspMeta;
|
|
1040
|
+
protected fJSON: string;
|
|
1041
|
+
protected fInputsItems: string[];
|
|
1042
|
+
protected fOutputHandler: OutputParamHandler | null;
|
|
1043
|
+
protected fComputeHandler: ComputeHandler | null;
|
|
1044
|
+
protected fPlotHandler: PlotHandler | null;
|
|
1045
|
+
protected fUICallback: UIHandler;
|
|
1046
|
+
protected fDescriptor: FaustUIInputItem[];
|
|
1047
|
+
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: FaustAudioWorkletNodeOptions<Poly>["processorOptions"], nodeOptions?: Partial<FaustAudioWorkletNodeOptions>);
|
|
1048
|
+
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
1049
|
+
getOutputParamHandler(): OutputParamHandler | null;
|
|
1050
|
+
setComputeHandler(handler: ComputeHandler | null): void;
|
|
1051
|
+
getComputeHandler(): ComputeHandler | null;
|
|
1052
|
+
setPlotHandler(handler: PlotHandler | null): void;
|
|
1053
|
+
getPlotHandler(): PlotHandler | null;
|
|
1054
|
+
getNumInputs(): number;
|
|
1055
|
+
getNumOutputs(): number;
|
|
1056
|
+
compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
|
|
1057
|
+
metadata(handler: MetadataHandler): void;
|
|
1058
|
+
midiMessage(data: number[] | Uint8Array): void;
|
|
1059
|
+
ctrlChange(channel: number, ctrl: number, value: number): void;
|
|
1060
|
+
pitchWheel(channel: number, wheel: number): void;
|
|
1061
|
+
setParamValue(path: string, value: number): void;
|
|
1062
|
+
getParamValue(path: string): number;
|
|
1063
|
+
getParams(): string[];
|
|
1064
|
+
getMeta(): FaustDspMeta;
|
|
1065
|
+
getJSON(): string;
|
|
1066
|
+
getUI(): FaustUIDescriptor;
|
|
1067
|
+
getDescriptors(): FaustUIInputItem[];
|
|
1068
|
+
start(): void;
|
|
1069
|
+
stop(): void;
|
|
1070
|
+
destroy(): void;
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Monophonic AudioWorkletNode
|
|
1074
|
+
*/
|
|
1075
|
+
export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<false> implements IFaustMonoWebAudioDsp {
|
|
1076
|
+
onprocessorerror: (e: Event) => never;
|
|
1077
|
+
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, sampleSize: number, nodeOptions?: Partial<FaustAudioWorkletNodeOptions>);
|
|
1078
|
+
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Polyphonic AudioWorkletNode
|
|
1081
|
+
*/
|
|
1082
|
+
export declare class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode<true> implements IFaustPolyWebAudioDsp {
|
|
1083
|
+
private fJSONEffect;
|
|
1084
|
+
onprocessorerror: (e: Event) => never;
|
|
1085
|
+
constructor(context: BaseAudioContext, name: string, voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, sampleSize: number, effectFactory?: LooseFaustDspFactory, nodeOptions?: Partial<FaustAudioWorkletNodeOptions>);
|
|
1086
|
+
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
1087
|
+
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
1088
|
+
allNotesOff(hard: boolean): void;
|
|
1089
|
+
getMeta(): FaustDspMeta;
|
|
1090
|
+
getJSON(): string;
|
|
1091
|
+
getUI(): FaustUIDescriptor;
|
|
1092
|
+
}
|
|
1093
|
+
declare const FaustScriptProcessorNode_base: {
|
|
1094
|
+
new (): ScriptProcessorNode;
|
|
1095
|
+
prototype: ScriptProcessorNode;
|
|
1096
|
+
};
|
|
1097
|
+
/**
|
|
1098
|
+
* Base class for Monophonic and Polyphonic ScriptProcessorNode
|
|
1099
|
+
*/
|
|
1100
|
+
export declare class FaustScriptProcessorNode<Poly extends boolean = false> extends FaustScriptProcessorNode_base {
|
|
1101
|
+
protected fDSPCode: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;
|
|
1102
|
+
protected fInputs: Float32Array[];
|
|
1103
|
+
protected fOutputs: Float32Array[];
|
|
1104
|
+
init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void;
|
|
1105
|
+
compute(input: Float32Array[], output: Float32Array[]): boolean;
|
|
1106
|
+
setOutputParamHandler(handler: OutputParamHandler): void;
|
|
1107
|
+
getOutputParamHandler(): OutputParamHandler | null;
|
|
1108
|
+
setComputeHandler(handler: ComputeHandler): void;
|
|
1109
|
+
getComputeHandler(): ComputeHandler | null;
|
|
1110
|
+
setPlotHandler(handler: PlotHandler): void;
|
|
1111
|
+
getPlotHandler(): PlotHandler | null;
|
|
1112
|
+
getNumInputs(): number;
|
|
1113
|
+
getNumOutputs(): number;
|
|
1114
|
+
metadata(handler: MetadataHandler): void;
|
|
1115
|
+
midiMessage(data: number[] | Uint8Array): void;
|
|
1116
|
+
ctrlChange(chan: number, ctrl: number, value: number): void;
|
|
1117
|
+
pitchWheel(chan: number, value: number): void;
|
|
1118
|
+
setParamValue(path: string, value: number): void;
|
|
1119
|
+
getParamValue(path: string): number;
|
|
1120
|
+
getParams(): string[];
|
|
1121
|
+
getMeta(): FaustDspMeta;
|
|
1122
|
+
getJSON(): string;
|
|
1123
|
+
getDescriptors(): FaustUIInputItem[];
|
|
1124
|
+
getUI(): FaustUIDescriptor;
|
|
1125
|
+
start(): void;
|
|
1126
|
+
stop(): void;
|
|
1127
|
+
destroy(): void;
|
|
1128
|
+
}
|
|
1129
|
+
export declare class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode<false> implements IFaustMonoWebAudioDsp {
|
|
1130
|
+
}
|
|
1131
|
+
export declare class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode<true> implements IFaustPolyWebAudioDsp {
|
|
1132
|
+
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
1133
|
+
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
1134
|
+
allNotesOff(hard: boolean): void;
|
|
1135
|
+
}
|
|
1136
|
+
export interface IFaustMonoDspGenerator {
|
|
1137
|
+
/**
|
|
1138
|
+
* Compile a monophonic DSP factory from given code.
|
|
1139
|
+
*
|
|
1140
|
+
* @param compiler - the Faust compiler
|
|
1141
|
+
* @param name - the DSP name
|
|
1142
|
+
* @param code - the DSP code
|
|
1143
|
+
* @param args - the compilation parameters
|
|
1144
|
+
* @returns the compiled factory or 'null' if failure
|
|
1145
|
+
*/
|
|
1146
|
+
compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{
|
|
1147
|
+
factory: FaustDspFactory | null;
|
|
1148
|
+
name?: string;
|
|
1149
|
+
meta?: FaustDspMeta;
|
|
1150
|
+
} | null>;
|
|
1151
|
+
/**
|
|
1152
|
+
* Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
|
|
1153
|
+
*
|
|
1154
|
+
* @param context - the WebAudio context
|
|
1155
|
+
* @param name - DSP name, can be used for processorName
|
|
1156
|
+
* @param factory - default is the compiled factory
|
|
1157
|
+
* @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
|
|
1158
|
+
* @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
|
|
1159
|
+
* @param processorName - AudioWorklet Processor name
|
|
1160
|
+
* @returns the compiled WebAudio node or 'null' if failure
|
|
1161
|
+
*/
|
|
1162
|
+
createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string): Promise<IFaustMonoWebAudioNode | null>;
|
|
1163
|
+
/**
|
|
1164
|
+
* Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
|
|
1165
|
+
*
|
|
1166
|
+
* @param context - the WebAudio context
|
|
1167
|
+
* @param fftUtils - should be an anonymous class with static methods, without any import from outside
|
|
1168
|
+
* @param name - DSP name, can be used for processorName
|
|
1169
|
+
* @param factory - default is the compiled factory
|
|
1170
|
+
* @param fftOptions - initial FFT options
|
|
1171
|
+
* @param processorName - AudioWorklet Processor name
|
|
1172
|
+
* @returns the compiled WebAudio node or 'null' if failure
|
|
1173
|
+
*/
|
|
1174
|
+
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1175
|
+
/**
|
|
1176
|
+
* Create a monophonic Offline processor.
|
|
1177
|
+
*
|
|
1178
|
+
* @param sampleRate - the sample rate in Hz
|
|
1179
|
+
* @param bufferSize - the buffer size in frames
|
|
1180
|
+
* @param factory - default is the compiled factory
|
|
1181
|
+
* @returns the compiled processor or 'null' if failure
|
|
1182
|
+
*/
|
|
1183
|
+
createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, meta?: FaustDspMeta): Promise<IFaustMonoOfflineProcessor | null>;
|
|
1184
|
+
}
|
|
1185
|
+
export interface IFaustPolyDspGenerator {
|
|
1186
|
+
/**
|
|
1187
|
+
* Compile a monophonic DSP factory from given code.
|
|
1188
|
+
*
|
|
1189
|
+
* @param compiler - the Faust compiler
|
|
1190
|
+
* @param name - the DSP name
|
|
1191
|
+
* @param dspCode - the DSP code ('dsp_code' can possibly contain an integrated effect)
|
|
1192
|
+
* @param args - the compilation parameters
|
|
1193
|
+
* @param effectCode - optional effect DSP code
|
|
1194
|
+
* @returns the compiled factory or 'null' if failure
|
|
1195
|
+
*/
|
|
1196
|
+
compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{
|
|
1197
|
+
voiceFactory: FaustDspFactory | null;
|
|
1198
|
+
effectFactory?: FaustDspFactory | null;
|
|
1199
|
+
} | null>;
|
|
1200
|
+
/**
|
|
1201
|
+
* Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
|
|
1202
|
+
*
|
|
1203
|
+
* @param context the WebAudio context
|
|
1204
|
+
* @param voices - the number of voices
|
|
1205
|
+
* @param name - AudioWorklet Processor name
|
|
1206
|
+
* @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
|
|
1207
|
+
* @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)
|
|
1208
|
+
* @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
|
|
1209
|
+
* @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
|
|
1210
|
+
* @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
|
|
1211
|
+
* @returns the compiled WebAudio node or 'null' if failure
|
|
1212
|
+
*/
|
|
1213
|
+
createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: boolean, bufferSize?: number): Promise<IFaustPolyWebAudioNode | null>;
|
|
1214
|
+
/**
|
|
1215
|
+
* Create a monophonic Offline processor.
|
|
1216
|
+
*
|
|
1217
|
+
* @param sampleRate - the sample rate in Hz
|
|
1218
|
+
* @param bufferSize - the buffer size in frames
|
|
1219
|
+
* @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
|
|
1220
|
+
* @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)
|
|
1221
|
+
* @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
|
|
1222
|
+
* @returns the compiled processor or 'null' if failure
|
|
1223
|
+
*/
|
|
1224
|
+
createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null): Promise<IFaustPolyOfflineProcessor | null>;
|
|
1225
|
+
}
|
|
1226
|
+
export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
|
|
1227
|
+
private static gWorkletProcessors;
|
|
1228
|
+
name: string;
|
|
1229
|
+
factory: FaustDspFactory | null;
|
|
1230
|
+
constructor();
|
|
1231
|
+
compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<this | null>;
|
|
1232
|
+
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>;
|
|
1233
|
+
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1234
|
+
createAudioWorkletProcessor(name?: string, factory?: LooseFaustDspFactory, processorName?: string): Promise<{
|
|
1235
|
+
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
1236
|
+
prototype: AudioWorkletProcessor;
|
|
1237
|
+
parameterDescriptors: AudioParamDescriptor[];
|
|
1238
|
+
}>;
|
|
1239
|
+
createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory): Promise<FaustMonoOfflineProcessor>;
|
|
1240
|
+
}
|
|
1241
|
+
export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
|
|
1242
|
+
private static gWorkletProcessors;
|
|
1243
|
+
name: string;
|
|
1244
|
+
voiceFactory: FaustDspFactory | null;
|
|
1245
|
+
effectFactory: FaustDspFactory | null;
|
|
1246
|
+
mixerBuffer: Uint8Array;
|
|
1247
|
+
mixerModule: WebAssembly.Module;
|
|
1248
|
+
constructor();
|
|
1249
|
+
compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<this | null>;
|
|
1250
|
+
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>;
|
|
1251
|
+
createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
|
|
1252
|
+
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
1253
|
+
prototype: AudioWorkletProcessor;
|
|
1254
|
+
parameterDescriptors: AudioParamDescriptor[];
|
|
1255
|
+
}>;
|
|
1256
|
+
createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null): Promise<FaustPolyOfflineProcessor>;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
export {};
|