@grame/faustwasm 0.8.2 → 0.9.0

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.
Files changed (61) hide show
  1. package/assets/standalone/create-node.js +15 -8
  2. package/assets/standalone/faustwasm/index.d.ts +40 -0
  3. package/assets/standalone/faustwasm/index.js +109 -30
  4. package/assets/standalone/faustwasm/index.js.map +2 -2
  5. package/assets/standalone/index-pwa.js +1 -1
  6. package/assets/standalone/service-worker.js +58 -5
  7. package/dist/cjs/index.d.ts +40 -0
  8. package/dist/cjs/index.js +109 -30
  9. package/dist/cjs/index.js.map +2 -2
  10. package/dist/cjs-bundle/index.d.ts +40 -0
  11. package/dist/cjs-bundle/index.js +109 -30
  12. package/dist/cjs-bundle/index.js.map +2 -2
  13. package/dist/esm/index.d.ts +40 -0
  14. package/dist/esm/index.js +109 -30
  15. package/dist/esm/index.js.map +2 -2
  16. package/dist/esm-bundle/index.d.ts +40 -0
  17. package/dist/esm-bundle/index.js +109 -30
  18. package/dist/esm-bundle/index.js.map +2 -2
  19. package/package.json +1 -1
  20. package/src/FaustAudioWorkletNode.ts +10 -0
  21. package/src/FaustAudioWorkletProcessor.ts +16 -0
  22. package/src/FaustOfflineProcessor.ts +2 -0
  23. package/src/FaustScriptProcessorNode.ts +2 -0
  24. package/src/FaustWebAudioDsp.ts +88 -0
  25. package/src/copyWebStandaloneAssets.js +14 -0
  26. package/test/faustlive-wasm/faustwasm/index.d.ts +40 -0
  27. package/test/faustlive-wasm/faustwasm/index.js +109 -30
  28. package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
  29. package/test/midi/create-node.js +177 -0
  30. package/test/midi/dsp-meta.json +133 -0
  31. package/test/midi/dsp-module.wasm +0 -0
  32. package/test/midi/faust-ui/index.css +442 -0
  33. package/test/midi/faust-ui/index.css.map +1 -0
  34. package/test/midi/faust-ui/index.d.ts +1 -0
  35. package/test/midi/faust-ui/index.js +3729 -0
  36. package/test/midi/faust-ui/index.js.map +1 -0
  37. package/test/midi/faustwasm/index.d.ts +1680 -0
  38. package/test/midi/faustwasm/index.js +4884 -0
  39. package/test/midi/faustwasm/index.js.map +7 -0
  40. package/test/midi/icon.png +0 -0
  41. package/test/midi/index.html +76 -0
  42. package/test/midi/index.js +183 -0
  43. package/test/midi/manifest.json +17 -0
  44. package/test/midi/service-worker.js +165 -0
  45. package/test/midi.dsp +8 -1
  46. package/test/organ1/create-node.js +177 -0
  47. package/test/organ1/dsp-meta.json +126 -0
  48. package/test/organ1/dsp-module.wasm +0 -0
  49. package/test/organ1/faust-ui/index.css +442 -0
  50. package/test/organ1/faust-ui/index.css.map +1 -0
  51. package/test/organ1/faust-ui/index.d.ts +1 -0
  52. package/test/organ1/faust-ui/index.js +3729 -0
  53. package/test/organ1/faust-ui/index.js.map +1 -0
  54. package/test/organ1/faustwasm/index.d.ts +1656 -0
  55. package/test/organ1/faustwasm/index.js +4783 -0
  56. package/test/organ1/faustwasm/index.js.map +7 -0
  57. package/test/organ1/icon.png +0 -0
  58. package/test/organ1/index.html +76 -0
  59. package/test/organ1/index.js +203 -0
  60. package/test/organ1/manifest.json +17 -0
  61. package/test/organ1/service-worker.js +181 -0
@@ -0,0 +1,1656 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ /// <reference types="emscripten" />
4
+
5
+ export type FaustModuleFactory = EmscriptenModuleFactory<FaustModule>;
6
+ export interface FaustModule extends EmscriptenModule {
7
+ ccall: typeof ccall;
8
+ cwrap: typeof cwrap;
9
+ UTF8ArrayToString(u8Array: number[], ptr: number, maxBytesToRead?: number): string;
10
+ stringToUTF8Array(str: string, outU8Array: number[], outIdx: number, maxBytesToWrite: number): number;
11
+ UTF8ToString: typeof UTF8ToString;
12
+ UTF16ToString: typeof UTF16ToString;
13
+ UTF32ToString: typeof UTF32ToString;
14
+ stringToUTF8: typeof stringToUTF8;
15
+ stringToUTF16: typeof stringToUTF16;
16
+ stringToUTF32: typeof stringToUTF32;
17
+ allocateUTF8: typeof allocateUTF8;
18
+ lengthBytesUTF8: typeof lengthBytesUTF8;
19
+ lengthBytesUTF16: typeof lengthBytesUTF16;
20
+ lengthBytesUTF32: typeof lengthBytesUTF32;
21
+ FS: typeof FS;
22
+ libFaustWasm: new () => LibFaustWasm;
23
+ }
24
+ export type FaustInfoType = "help" | "version" | "libdir" | "includedir" | "archdir" | "dspdir" | "pathslist";
25
+ export interface IntVector {
26
+ size(): number;
27
+ get(i: number): number;
28
+ delete(): void;
29
+ }
30
+ export interface FaustDspWasm {
31
+ cfactory: number;
32
+ data: IntVector;
33
+ json: string;
34
+ }
35
+ export interface LibFaustWasm {
36
+ /**
37
+ * Return the Faust compiler version.
38
+ *
39
+ * @returns the version
40
+ */
41
+ version(): string;
42
+ /**
43
+ * Create a dsp factory from Faust code.
44
+ *
45
+ * @param name - an arbitrary name for the Faust module
46
+ * @param code - Faust dsp code
47
+ * @param args - the compiler options
48
+ * @param useInternalMemory - tell the compiler to generate static embedded memory or not
49
+ * @returns an opaque reference to the factory
50
+ */
51
+ createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean): FaustDspWasm;
52
+ /**
53
+ * Delete a dsp factory.
54
+ *
55
+ * @param cFactory - the factory C++ internal pointer as a number
56
+ */
57
+ deleteDSPFactory(cFactory: number): void;
58
+ /**
59
+ * Expand Faust code i.e. linearize included libraries.
60
+ *
61
+ * @param name - an arbitrary name for the Faust module
62
+ * @param code - Faust dsp code
63
+ * @param args - the compiler options
64
+ * @returns return the expanded dsp code
65
+ */
66
+ expandDSP(name: string, code: string, args: string): string;
67
+ /**
68
+ * Generates auxiliary files from Faust code. The output depends on the compiler options.
69
+ *
70
+ * @param name - an arbitrary name for the faust module
71
+ * @param code - Faust dsp code
72
+ * @param args - the compiler options
73
+ */
74
+ generateAuxFiles(name: string, code: string, args: string): boolean;
75
+ /**
76
+ * Delete all existing dsp factories.
77
+ */
78
+ deleteAllDSPFactories(): void;
79
+ /**
80
+ * Exception management: gives an error string
81
+ */
82
+ getErrorAfterException(): string;
83
+ /**
84
+ * Exception management: cleanup
85
+ * Should be called after each exception generated by the LibFaust methods.
86
+ */
87
+ cleanupAfterException(): void;
88
+ /**
89
+ * Get info about the embedded Faust engine
90
+ * @param what - the requested info
91
+ */
92
+ getInfos(what: FaustInfoType): string;
93
+ }
94
+ export interface FaustDspFactory extends Required<LooseFaustDspFactory> {
95
+ }
96
+ /**
97
+ * The Factory structure.
98
+ */
99
+ export interface LooseFaustDspFactory {
100
+ /** a "pointer" (as an integer) on the internal C++ factory */
101
+ cfactory?: number;
102
+ /** the WASM code as a binary array */
103
+ code?: Uint8Array;
104
+ /** the compule WASM module */
105
+ module: WebAssembly.Module;
106
+ /** the compiled DSP JSON description */
107
+ json: string;
108
+ /** whether the factory is a polyphonic one or not */
109
+ poly?: boolean;
110
+ /** a unique identifier */
111
+ shaKey?: string;
112
+ /** a map of transferable audio buffers for the `soundfile` function */
113
+ soundfiles: Record<string, (AudioData$1 | null)>;
114
+ }
115
+ export interface FaustDspMeta {
116
+ name: string;
117
+ filename: string;
118
+ compile_options: string;
119
+ include_pathnames: string[];
120
+ inputs: number;
121
+ outputs: number;
122
+ size: number;
123
+ version: string;
124
+ library_list: string[];
125
+ meta: {
126
+ [key: string]: string;
127
+ }[];
128
+ ui: FaustUIDescriptor;
129
+ }
130
+ export type FaustUIDescriptor = FaustUIGroup[];
131
+ export type FaustUIItem = FaustUIInputItem | FaustUIOutputItem | FaustUIGroup;
132
+ export interface FaustUIInputItem {
133
+ type: FaustUIInputType;
134
+ label: string;
135
+ address: string;
136
+ url: string;
137
+ index: number;
138
+ init?: number;
139
+ min?: number;
140
+ max?: number;
141
+ step?: number;
142
+ meta?: FaustUIMeta[];
143
+ }
144
+ export interface FaustUIOutputItem {
145
+ type: FaustUIOutputType;
146
+ label: string;
147
+ address: string;
148
+ index: number;
149
+ min?: number;
150
+ max?: number;
151
+ meta?: FaustUIMeta[];
152
+ }
153
+ export interface FaustUIMeta {
154
+ [order: number]: string;
155
+ style?: string;
156
+ unit?: string;
157
+ scale?: "linear" | "exp" | "log";
158
+ tooltip?: string;
159
+ hidden?: string;
160
+ [key: string]: string | undefined;
161
+ }
162
+ export type FaustUIGroupType = "vgroup" | "hgroup" | "tgroup";
163
+ export type FaustUIOutputType = "hbargraph" | "vbargraph";
164
+ export type FaustUIInputType = "vslider" | "hslider" | "button" | "checkbox" | "nentry" | "soundfile";
165
+ export interface FaustUIGroup {
166
+ type: FaustUIGroupType;
167
+ label: string;
168
+ items: FaustUIItem[];
169
+ }
170
+ export type FaustUIType = FaustUIGroupType | FaustUIOutputType | FaustUIInputType;
171
+ export interface AudioParamDescriptor {
172
+ automationRate?: AutomationRate;
173
+ defaultValue?: number;
174
+ maxValue?: number;
175
+ minValue?: number;
176
+ name: string;
177
+ }
178
+ export interface AudioWorkletProcessor {
179
+ port: MessagePort;
180
+ process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: Record<string, Float32Array>): boolean;
181
+ }
182
+ export declare const AudioWorkletProcessor: {
183
+ prototype: AudioWorkletProcessor;
184
+ parameterDescriptors: AudioParamDescriptor[];
185
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
186
+ };
187
+ export interface AudioWorkletGlobalScope {
188
+ AudioWorkletGlobalScope: any;
189
+ globalThis: AudioWorkletGlobalScope;
190
+ registerProcessor: (name: string, constructor: new (options: any) => AudioWorkletProcessor) => void;
191
+ currentFrame: number;
192
+ currentTime: number;
193
+ sampleRate: number;
194
+ AudioWorkletProcessor: typeof AudioWorkletProcessor;
195
+ }
196
+ export interface InterfaceFFT {
197
+ forward(arr: ArrayLike<number> | ((arr: Float32Array) => any)): Float32Array;
198
+ inverse(arr: ArrayLike<number> | ((arr: Float32Array) => any)): Float32Array;
199
+ dispose(): void;
200
+ }
201
+ export declare const InterfaceFFT: {
202
+ new (size: number): InterfaceFFT;
203
+ };
204
+ export type TWindowFunction = (index: number, length: number, ...args: any[]) => number;
205
+ export type Writeable<T> = {
206
+ -readonly [P in keyof T]: T[P];
207
+ };
208
+ export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
209
+ export type TypedArrayConstructor = typeof Int8Array | typeof Uint8Array | typeof Int16Array | typeof Uint16Array | typeof Int32Array | typeof Uint32Array | typeof Uint8ClampedArray | typeof Float32Array | typeof Float64Array;
210
+ export declare const FFTUtils: {
211
+ /** Inject window functions as array, no need to add rectangular (no windowing) */
212
+ windowFunctions?: TWindowFunction[];
213
+ /** Get a FFT interface constructor */
214
+ getFFT: () => Promise<typeof InterfaceFFT>;
215
+ /** 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 */
216
+ fftToSignal: (fft: Float32Array | Float64Array, real: Float32Array | Float64Array, imag?: Float32Array | Float64Array, index?: Float32Array | Float64Array) => any;
217
+ /** 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 */
218
+ signalToFFT: (real: Float32Array | Float64Array, imag: Float32Array | Float64Array, fft: Float32Array | Float64Array) => any;
219
+ /** Convert from Faust processor's output to direct audio output, real/imag are readonly, fft length = fftSize = (real/imag length - 1) * 2 */
220
+ signalToNoFFT: (real: Float32Array | Float64Array, imag: Float32Array | Float64Array, fft: Float32Array | Float64Array) => any;
221
+ };
222
+ interface AudioData$1 {
223
+ sampleRate: number;
224
+ audioBuffer: Float32Array[];
225
+ }
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
+ declare class FaustAudioWorkletCommunicator {
234
+ protected readonly port: MessagePort;
235
+ protected readonly supportSharedArrayBuffer: boolean;
236
+ protected readonly byteLength: number;
237
+ protected uin8Invert: Uint8ClampedArray;
238
+ protected uin8NewAccData: Uint8ClampedArray;
239
+ protected uin8NewGyrData: Uint8ClampedArray;
240
+ protected f32Acc: Float32Array;
241
+ protected f32Gyr: Float32Array;
242
+ constructor(port: MessagePort);
243
+ initializeBuffer(ab: SharedArrayBuffer | ArrayBuffer): void;
244
+ setNewAccDataAvailable(value: boolean): void;
245
+ getNewAccDataAvailable(): boolean;
246
+ setNewGyrDataAvailable(value: boolean): void;
247
+ getNewGyrDataAvailable(): boolean;
248
+ setAcc({ x, y, z }: {
249
+ x: number;
250
+ y: number;
251
+ z: number;
252
+ }, invert?: boolean): void;
253
+ getAcc(): {
254
+ x: number;
255
+ y: number;
256
+ z: number;
257
+ invert: boolean;
258
+ } | undefined;
259
+ setGyr({ alpha, beta, gamma }: {
260
+ alpha: number;
261
+ beta: number;
262
+ gamma: number;
263
+ }): void;
264
+ getGyr(): {
265
+ alpha: number;
266
+ beta: number;
267
+ gamma: number;
268
+ } | undefined;
269
+ }
270
+ declare class FaustAudioWorkletNodeCommunicator extends FaustAudioWorkletCommunicator {
271
+ constructor(port: MessagePort);
272
+ }
273
+ declare class FaustAudioWorkletProcessorCommunicator extends FaustAudioWorkletCommunicator {
274
+ constructor(port: MessagePort);
275
+ }
276
+ /**
277
+ * The Faust wasm instance interface.
278
+ */
279
+ export interface IFaustDspInstance {
280
+ /**
281
+ * The dsp computation, to be called with successive input/output audio buffers.
282
+ *
283
+ * @param $dsp - the DSP pointer
284
+ * @param count - the audio buffer size in frames
285
+ * @param $inputs - the input audio buffer as in index in wasm memory
286
+ * @param $output - the output audio buffer as in index in wasm memory
287
+ */
288
+ compute($dsp: number, count: number, $inputs: number, $output: number): void;
289
+ /**
290
+ * Give the number of inputs of a Faust wasm instance.
291
+ *
292
+ * @param $dsp - the DSP pointer
293
+ */
294
+ getNumInputs($dsp: number): number;
295
+ /**
296
+ * Give the number of outputs of a Faust wasm instance.
297
+ *
298
+ * @param $dsp - the DSP pointer
299
+ */
300
+ getNumOutputs($dsp: number): number;
301
+ /**
302
+ * Give a parameter current value.
303
+ *
304
+ * @param $dsp - the DSP pointer
305
+ * @param index - the parameter index
306
+ * @return the parameter value
307
+ */
308
+ getParamValue($dsp: number, index: number): number;
309
+ /**
310
+ * Give the Faust wasm instance sample rate.
311
+ *
312
+ * @param $dsp - the DSP pointer
313
+ * @return the sample rate
314
+ */
315
+ getSampleRate($dsp: number): number;
316
+ /**
317
+ * Global init, calls the following methods:
318
+ * - static class 'classInit': static tables initialization
319
+ * - 'instanceInit': constants and instance state initialization
320
+ *
321
+ * @param $dsp - the DSP pointer
322
+ * @param sampleRate - the sampling rate in Hertz
323
+ */
324
+ init($dsp: number, sampleRate: number): void;
325
+ /** Init instance state (delay lines...).
326
+ *
327
+ * @param $dsp - the DSP pointer
328
+ */
329
+ instanceClear($dsp: number): void;
330
+ /** Init instance constant state.
331
+ *
332
+ * @param $dsp - the DSP pointer
333
+ * @param sampleRate - the sampling rate in Hertz
334
+ */
335
+ instanceConstants($dsp: number, sampleRate: number): void;
336
+ /** Init instance state.
337
+ *
338
+ * @param $dsp - the DSP pointer
339
+ * @param sampleRate - the sampling rate in Hertz
340
+ */
341
+ instanceInit($dsp: number, sampleRate: number): void;
342
+ /** Init default control parameters values.
343
+ *
344
+ * @param $dsp - the DSP pointer
345
+ */
346
+ instanceResetUserInterface($dsp: number): void;
347
+ /**
348
+ * Set a parameter current value.
349
+ *
350
+ * @param $dsp - the DSP pointer
351
+ * @param index - the parameter index
352
+ * @param value - the parameter value
353
+ */
354
+ setParamValue($dsp: number, index: number, value: number): void;
355
+ }
356
+ /**
357
+ * Mixer used in polyphonic mode.
358
+ */
359
+ export interface IFaustMixerInstance {
360
+ clearOutput(bufferSize: number, chans: number, $outputs: number): void;
361
+ mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;
362
+ fadeOut(bufferSize: number, chans: number, $outputs: number): void;
363
+ }
364
+ /**
365
+ * Monophonic instance.
366
+ */
367
+ export interface FaustMonoDspInstance {
368
+ memory: WebAssembly.Memory;
369
+ api: IFaustDspInstance;
370
+ json: string;
371
+ }
372
+ /**
373
+ * Polyphonic instance.
374
+ */
375
+ export interface FaustPolyDspInstance {
376
+ memory: WebAssembly.Memory;
377
+ voices: number;
378
+ voiceAPI: IFaustDspInstance;
379
+ effectAPI?: IFaustDspInstance;
380
+ mixerAPI: IFaustMixerInstance;
381
+ voiceJSON: string;
382
+ effectJSON?: string;
383
+ }
384
+ export declare class FaustDspInstance implements IFaustDspInstance {
385
+ private readonly fExports;
386
+ constructor(exports: IFaustDspInstance);
387
+ compute($dsp: number, count: number, $input: number, $output: number): void;
388
+ getNumInputs($dsp: number): number;
389
+ getNumOutputs($dsp: number): number;
390
+ getParamValue($dsp: number, index: number): number;
391
+ getSampleRate($dsp: number): number;
392
+ init($dsp: number, sampleRate: number): void;
393
+ instanceClear($dsp: number): void;
394
+ instanceConstants($dsp: number, sampleRate: number): void;
395
+ instanceInit($dsp: number, sampleRate: number): void;
396
+ instanceResetUserInterface($dsp: number): void;
397
+ setParamValue($dsp: number, index: number, value: number): void;
398
+ }
399
+ export declare class FaustWasmInstantiator {
400
+ private static createWasmImport;
401
+ private static createWasmMemoryPoly;
402
+ private static createWasmMemoryMono;
403
+ private static createMonoDSPInstanceAux;
404
+ private static createMemoryMono;
405
+ private static createMemoryPoly;
406
+ private static createMixerAux;
407
+ static loadDSPFactory(wasmPath: string, jsonPath: string): Promise<FaustDspFactory>;
408
+ static loadDSPMixer(mixerPath: string, fs?: typeof FS): Promise<WebAssembly.Module>;
409
+ static createAsyncMonoDSPInstance(factory: LooseFaustDspFactory): Promise<FaustMonoDspInstance>;
410
+ static createSyncMonoDSPInstance(factory: LooseFaustDspFactory): FaustMonoDspInstance;
411
+ static createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise<FaustPolyDspInstance>;
412
+ static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance;
413
+ }
414
+ export type OutputParamHandler = (path: string, value: number) => void;
415
+ export type ComputeHandler = (buffer_size: number) => void;
416
+ export type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: {
417
+ type: string;
418
+ data: any;
419
+ }[]) => void;
420
+ export type MetadataHandler = (key: string, value: string) => void;
421
+ export type UIHandler = (item: FaustUIItem) => void;
422
+ export type SensorEventHandler = (val: number) => void;
423
+ export type SensorEventHandlers = {
424
+ x: SensorEventHandler[];
425
+ y: SensorEventHandler[];
426
+ z: SensorEventHandler[];
427
+ };
428
+ /** Definition of the AudioBufferItem type */
429
+ export interface AudioBufferItem {
430
+ pathName: string;
431
+ audioBuffer: AudioBuffer;
432
+ }
433
+ /** Definition of the SoundfileItem type */
434
+ export interface SoundfileItem {
435
+ /** Name of the soundfile */
436
+ name: string;
437
+ /** URL of the soundfile */
438
+ url: string;
439
+ /** Index in the DSP struct */
440
+ index: number;
441
+ /** Base pointer in wasm memory */
442
+ basePtr: number;
443
+ }
444
+ /**
445
+ * WasmAllocator is a basic memory management class designed to allocate
446
+ * blocks of memory within a WebAssembly.Memory object. It provides a simple
447
+ * alloc method to allocate a contiguous block of memory of a specified size.
448
+ *
449
+ * The allocator operates by keeping a linear progression through the memory,
450
+ * always allocating the next block at the end of the last. This approach does not
451
+ * handle freeing of memory or reuse of memory spaces.
452
+ */
453
+ export declare class WasmAllocator {
454
+ private readonly memory;
455
+ private allocatedBytes;
456
+ constructor(memory: WebAssembly.Memory, offset: number);
457
+ /**
458
+ * Allocates a block of memory of the specified size, returning the pointer to the
459
+ * beginning of the block. The block is allocated at the current offset and the
460
+ * offset is incremented by the size of the block.
461
+ *
462
+ * @param sizeInBytes The size of the block to allocate in bytes.
463
+ * @returns The offset (pointer) to the beginning of the allocated block.
464
+ */
465
+ alloc(sizeInBytes: number): number;
466
+ /**
467
+ * Returns the underlying buffer object.
468
+ *
469
+ * @returns The buffer object.
470
+ */
471
+ getBuffer(): ArrayBuffer;
472
+ /**
473
+ * Returns the Int32 view of the underlying buffer object.
474
+ *
475
+ * @returns The view of the memory buffer as Int32Array.
476
+ */
477
+ getInt32Array(): Int32Array;
478
+ /**
479
+ * Returns the Int64 view of the underlying buffer object.
480
+ *
481
+ * @returns The view of the memory buffer as BigInt64Array.
482
+ */
483
+ getInt64Array(): BigInt64Array;
484
+ /**
485
+ * Returns the Float32 view of the underlying buffer object.
486
+ *
487
+ * @returns The view of the memory buffer as Float32Array.
488
+ */
489
+ getFloat32Array(): Float32Array;
490
+ /**
491
+ * Returns the Float64 view of the underlying buffer object..
492
+ *
493
+ * @returns The view of the memory buffer as Float64Array.
494
+ */
495
+ getFloat64Array(): Float64Array;
496
+ }
497
+ /**
498
+ * Soundfile class to handle soundfile data in wasm memory.
499
+ */
500
+ export declare class Soundfile {
501
+ /** Maximum number of soundfile parts. */
502
+ static get MAX_SOUNDFILE_PARTS(): number;
503
+ /** Maximum number of channels. */
504
+ static get MAX_CHAN(): number;
505
+ /** Maximum buffer size in frames. */
506
+ static get BUFFER_SIZE(): number;
507
+ /** Default sample rate. */
508
+ static get SAMPLE_RATE(): number;
509
+ /** Pointer to the soundfile structure in wasm memory */
510
+ private readonly fPtr;
511
+ private readonly fBuffers;
512
+ private readonly fLength;
513
+ private readonly fSR;
514
+ private readonly fOffset;
515
+ private readonly fSampleSize;
516
+ private readonly fPtrSize;
517
+ private readonly fIntSize;
518
+ private readonly fAllocator;
519
+ constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number);
520
+ private allocBuffers;
521
+ shareBuffers(curChan: number, maxChan: number): void;
522
+ copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData$1): void;
523
+ copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData$1): void;
524
+ copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData$1): void;
525
+ emptyFile(part: number, offset: number): number;
526
+ displayMemory(where?: string, mem?: boolean): void;
527
+ getPtr(): number;
528
+ getHEAP32(): Int32Array;
529
+ getHEAPFloat32(): Float32Array;
530
+ getHEAPFloat64(): Float64Array;
531
+ }
532
+ /**
533
+ * DSP implementation that mimic the C++ 'dsp' class:
534
+ * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers
535
+ * - an output handler can be set to treat produced output controllers (like 'bargraph')
536
+ * - regular controllers are handled using setParamValue/getParamValue and getParams methods
537
+ */
538
+ export interface IFaustBaseWebAudioDsp {
539
+ /**
540
+ * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).
541
+ *
542
+ * @param handler - the output handler
543
+ */
544
+ setOutputParamHandler(handler: OutputParamHandler | null): void;
545
+ /**
546
+ * Get the parameter output handler.
547
+ *
548
+ * @return the current output handler
549
+ */
550
+ getOutputParamHandler(): OutputParamHandler | null;
551
+ /**
552
+ * Set the compute handler, to be called in the 'compute' method with buffer size.
553
+ *
554
+ * @param handler - the compute handler
555
+ */
556
+ setComputeHandler(handler: ComputeHandler | null): void;
557
+ /**
558
+ * Get the compute handler.
559
+ *
560
+ * @return the current output handler
561
+ */
562
+ getComputeHandler(): ComputeHandler | null;
563
+ /**
564
+ * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).
565
+ *
566
+ * @param handler - the plot handler
567
+ */
568
+ setPlotHandler(handler: PlotHandler | null): void;
569
+ /**
570
+ * Get the plot handler.
571
+ *
572
+ * @return the current plot handler
573
+ */
574
+ getPlotHandler(): PlotHandler | null;
575
+ /**
576
+ * Return instance number of audio inputs.
577
+ *
578
+ * @return the instance number of audio inputs
579
+ */
580
+ getNumInputs(): number;
581
+ /**
582
+ * Return instance number of audio outputs.
583
+ *
584
+ * @return the instance number of audio outputs
585
+ */
586
+ getNumOutputs(): number;
587
+ /**
588
+ * DSP instance computation, to be called with successive input/output audio buffers, using their size.
589
+ *
590
+ * @param inputs - the input audio buffers
591
+ * @param outputs - the output audio buffers
592
+ */
593
+ compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
594
+ /**
595
+ * Give a handler to be called on 'declare key value' kind of metadata.
596
+ *
597
+ * @param handler - the handler to be used
598
+ */
599
+ metadata(handler: MetadataHandler): void;
600
+ /**
601
+ * Handle untyped MIDI messages.
602
+ *
603
+ * @param data - and arry of MIDI bytes
604
+ */
605
+ midiMessage(data: number[] | Uint8Array): void;
606
+ /**
607
+ * Handle MIDI ctrlChange messages.
608
+ *
609
+ * @param channel - the MIDI channel (0..15, not used for now)
610
+ * @param ctrl - the MIDI controller number (0..127)
611
+ * @param value - the MIDI controller value (0..127)
612
+ */
613
+ ctrlChange(chan: number, ctrl: number, value: number): void;
614
+ /**
615
+ * Handle MIDI pitchWheel messages.
616
+ *
617
+ * @param channel - the MIDI channel (0..15, not used for now)
618
+ * @param value - the MIDI controller value (0..16383)
619
+ */
620
+ pitchWheel(chan: number, value: number): void;
621
+ /**
622
+ * Set parameter value.
623
+ *
624
+ * @param path - the path to the wanted parameter (retrieved using 'getParams' method)
625
+ * @param val - the float value for the wanted control
626
+ */
627
+ setParamValue(path: string, value: number): void;
628
+ /**
629
+ * Get parameter value.
630
+ *
631
+ * @param path - the path to the wanted parameter (retrieved using 'getParams' method)
632
+ *
633
+ * @return the float value
634
+ */
635
+ getParamValue(path: string): number;
636
+ /**
637
+ * Get the table of all input parameters paths.
638
+ *
639
+ * @return the table of all input parameters paths
640
+ */
641
+ getParams(): string[];
642
+ /**
643
+ * Get DSP JSON description with its UI and metadata as object.
644
+ *
645
+ * @return the DSP JSON description as object
646
+ */
647
+ getMeta(): FaustDspMeta;
648
+ /**
649
+ * Get DSP UI description.
650
+ *
651
+ * @return the DSP UI description
652
+ */
653
+ getUI(): FaustUIDescriptor;
654
+ /**
655
+ * Get DSP UI items description.
656
+ *
657
+ * @return the DSP UI items description
658
+ */
659
+ getDescriptors(): FaustUIInputItem[];
660
+ /**
661
+ * Get DSP JSON description with its UI and metadata.
662
+ *
663
+ * @return the DSP JSON description
664
+ */
665
+ getJSON(): string;
666
+ /**
667
+ * Start accelerometer and gyroscope handlers.
668
+ */
669
+ startSensors(): void;
670
+ /**
671
+ * Stop accelerometer and gyroscope handlers.
672
+ */
673
+ stopSensors(): void;
674
+ /** Indicating if the DSP handles the accelerometer */
675
+ readonly hasAccInput: boolean;
676
+ /**
677
+ * Accelerometer handling.
678
+ * accelerationIncludingGravity: DeviceMotionEvent["accelerationIncludingGravity"]
679
+ * invert: boolean
680
+ */
681
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert: boolean): void;
682
+ /** Indicating if the DSP handles the gyroscope */
683
+ readonly hasGyrInput: boolean;
684
+ /**
685
+ * Gyroscope handling.
686
+ * event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">
687
+ */
688
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
689
+ /**
690
+ * Start the DSP audio processing.
691
+ */
692
+ start(): void;
693
+ /**
694
+ * Stop the DSP audio processing.
695
+ */
696
+ stop(): void;
697
+ /**
698
+ * Destroy the DSP.
699
+ */
700
+ destroy(): void;
701
+ }
702
+ export interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp {
703
+ }
704
+ export interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode {
705
+ }
706
+ export interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {
707
+ /**
708
+ * Handle MIDI keyOn messages.
709
+ *
710
+ * @param channel - the MIDI channel (0..15, not used for now)
711
+ * @param pitch - the MIDI pitch value (0..127)
712
+ * @param velocity - the MIDI velocity value (0..127)
713
+ */
714
+ keyOn(channel: number, pitch: number, velocity: number): void;
715
+ /**
716
+ * Handle MIDI keyOff messages.
717
+ *
718
+ * @param channel - the MIDI channel (0..15, not used for now)
719
+ * @param pitch - the MIDI pitch value (0..127)
720
+ * @param velocity - the MIDI velocity value (0..127)
721
+ */
722
+ keyOff(channel: number, pitch: number, velocity: number): void;
723
+ /**
724
+ * Stop all playing notes.
725
+ *
726
+ * @param hard - whether to immediately stop notes or put them in release mode
727
+ */
728
+ allNotesOff(hard: boolean): void;
729
+ }
730
+ export interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode {
731
+ }
732
+ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
733
+ protected fOutputHandler: OutputParamHandler | null;
734
+ protected fComputeHandler: ComputeHandler | null;
735
+ protected fPlotHandler: PlotHandler | null;
736
+ protected fCachedEvents: {
737
+ type: string;
738
+ data: any;
739
+ }[];
740
+ protected fBufferNum: number;
741
+ protected fInChannels: Float32Array[] | Float64Array[];
742
+ protected fOutChannels: Float32Array[] | Float64Array[];
743
+ protected fOutputsTimer: number;
744
+ protected fInputsItems: string[];
745
+ protected fOutputsItems: string[];
746
+ protected fDescriptor: FaustUIInputItem[];
747
+ protected fSoundfiles: SoundfileItem[];
748
+ protected fSoundfileBuffers: LooseFaustDspFactory["soundfiles"];
749
+ /** Keep the end of memory offset before soundfiles */
750
+ protected fEndMemory: number;
751
+ protected fAcc: SensorEventHandlers;
752
+ protected fGyr: SensorEventHandlers;
753
+ protected fAudioInputs: number;
754
+ protected fAudioOutputs: number;
755
+ protected fBufferSize: number;
756
+ protected fPtrSize: number;
757
+ protected fSampleSize: number;
758
+ protected fPitchwheelLabel: {
759
+ path: string;
760
+ chan: number;
761
+ min: number;
762
+ max: number;
763
+ }[];
764
+ protected fCtrlLabel: {
765
+ path: string;
766
+ chan: number;
767
+ min: number;
768
+ max: number;
769
+ }[][];
770
+ protected fPathTable: {
771
+ [address: string]: number;
772
+ };
773
+ protected fUICallback: UIHandler;
774
+ protected fProcessing: boolean;
775
+ protected fDestroyed: boolean;
776
+ protected fFirstCall: boolean;
777
+ protected fJSONDsp: FaustDspMeta;
778
+ constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory["soundfiles"]);
779
+ static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number): number;
780
+ static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any): void;
781
+ static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any): void;
782
+ static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any): void;
783
+ static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any): void;
784
+ /** Split the soundfile names and return an array of names */
785
+ static splitSoundfileNames(input: string): string[];
786
+ get hasAccInput(): boolean;
787
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
788
+ get hasGyrInput(): boolean;
789
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
790
+ /** Build the accelerometer handler */
791
+ private setupAccHandler;
792
+ /** Build the gyroscope handler */
793
+ private setupGyrHandler;
794
+ static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[];
795
+ /**
796
+ * Load a soundfile possibly containing several parts in the DSP struct.
797
+ * Soundfile pointers are located at 'index' offset, to be read in the JSON file.
798
+ * The DSP struct is located at baseDSP in the wasm memory,
799
+ * either a monophonic DSP, or a voice in a polyphonic context.
800
+ *
801
+ * @param allocator : the wasm memory allocator
802
+ * @param baseDSP : the base DSP in the wasm memory
803
+ * @param name : the name of the soundfile
804
+ * @param url : the url of the soundfile
805
+ */
806
+ private loadSoundfile;
807
+ createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory["soundfiles"], maxChan?: number): Soundfile;
808
+ /**
809
+ * Init soundfiles memory.
810
+ *
811
+ * @param allocator : the wasm memory allocator
812
+ * @param sfReader : the soundfile reader
813
+ * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory
814
+ */
815
+ protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number): void;
816
+ protected updateOutputs(): void;
817
+ metadata(handler: MetadataHandler): void;
818
+ compute(input: Float32Array[], output: Float32Array[]): boolean;
819
+ setOutputParamHandler(handler: OutputParamHandler | null): void;
820
+ getOutputParamHandler(): OutputParamHandler | null;
821
+ setComputeHandler(handler: ComputeHandler | null): void;
822
+ getComputeHandler(): ComputeHandler | null;
823
+ setPlotHandler(handler: PlotHandler | null): void;
824
+ getPlotHandler(): PlotHandler | null;
825
+ getNumInputs(): number;
826
+ getNumOutputs(): number;
827
+ midiMessage(data: number[] | Uint8Array): void;
828
+ ctrlChange(channel: number, ctrl: number, value: number): void;
829
+ pitchWheel(channel: number, wheel: number): void;
830
+ setParamValue(path: string, value: number): void;
831
+ getParamValue(path: string): number;
832
+ getParams(): string[];
833
+ getMeta(): FaustDspMeta;
834
+ getJSON(): string;
835
+ getUI(): FaustUIDescriptor;
836
+ getDescriptors(): FaustUIInputItem[];
837
+ hasSoundfiles(): boolean;
838
+ startSensors(): void;
839
+ stopSensors(): void;
840
+ start(): void;
841
+ stop(): void;
842
+ destroy(): void;
843
+ }
844
+ export declare class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {
845
+ private fInstance;
846
+ private fDSP;
847
+ constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory["soundfiles"]);
848
+ private initMemory;
849
+ toString(): string;
850
+ compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)): boolean;
851
+ metadata(handler: MetadataHandler): void;
852
+ getNumInputs(): number;
853
+ getNumOutputs(): number;
854
+ setParamValue(path: string, value: number): void;
855
+ getParamValue(path: string): number;
856
+ getMeta(): FaustDspMeta;
857
+ getJSON(): string;
858
+ getDescriptors(): FaustUIInputItem[];
859
+ getUI(): FaustUIDescriptor;
860
+ }
861
+ export declare class FaustWebAudioDspVoice {
862
+ static get kActiveVoice(): number;
863
+ static get kFreeVoice(): number;
864
+ static get kReleaseVoice(): number;
865
+ static get kLegatoVoice(): number;
866
+ static get kNoVoice(): number;
867
+ static get VOICE_STOP_LEVEL(): number;
868
+ private fFreqLabel;
869
+ private fGateLabel;
870
+ private fGainLabel;
871
+ private fKeyLabel;
872
+ private fVelLabel;
873
+ private fDSP;
874
+ private fAPI;
875
+ fCurNote: number;
876
+ fNextNote: number;
877
+ fNextVel: number;
878
+ fDate: number;
879
+ fLevel: number;
880
+ fRelease: number;
881
+ constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: {
882
+ [address: string]: number;
883
+ }, sampleRate: number);
884
+ static midiToFreq(note: number): number;
885
+ static normalizeVelocity(velocity: number): number;
886
+ private extractPaths;
887
+ keyOn(pitch: number, velocity: number, legato?: boolean): void;
888
+ keyOff(hard?: boolean): void;
889
+ computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number): void;
890
+ compute(bufferSize: number, $inputs: number, $outputs: number): void;
891
+ setParamValue(index: number, value: number): void;
892
+ getParamValue(index: number): number;
893
+ }
894
+ export declare class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {
895
+ private fInstance;
896
+ private fEffect;
897
+ private fJSONEffect;
898
+ private fAudioMixing;
899
+ private fAudioMixingHalf;
900
+ private fVoiceTable;
901
+ constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory["soundfiles"]);
902
+ private initMemory;
903
+ toString(): string;
904
+ private allocVoice;
905
+ private getPlayingVoice;
906
+ private getFreeVoice;
907
+ compute(input: Float32Array[], output: Float32Array[]): boolean;
908
+ getNumInputs(): number;
909
+ getNumOutputs(): number;
910
+ private static findPath;
911
+ setParamValue(path: string, value: number): void;
912
+ getParamValue(path: string): number;
913
+ getMeta(): FaustDspMeta;
914
+ getJSON(): string;
915
+ getUI(): FaustUIDescriptor;
916
+ getDescriptors(): FaustUIInputItem[];
917
+ midiMessage(data: number[] | Uint8Array): void;
918
+ ctrlChange(channel: number, ctrl: number, value: number): void;
919
+ keyOn(channel: number, pitch: number, velocity: number): void;
920
+ keyOff(channel: number, pitch: number, velocity: number): void;
921
+ allNotesOff(hard?: boolean): void;
922
+ }
923
+ /**
924
+ * Injected in the string to be compiled on AudioWorkletProcessor side
925
+ */
926
+ export interface FaustData {
927
+ processorName: string;
928
+ dspName: string;
929
+ dspMeta: FaustDspMeta;
930
+ poly: boolean;
931
+ effectMeta?: FaustDspMeta;
932
+ }
933
+ export interface FaustAudioWorkletProcessorDependencies<Poly extends boolean = false> {
934
+ FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;
935
+ FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;
936
+ FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;
937
+ FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;
938
+ FaustWasmInstantiator: typeof FaustWasmInstantiator;
939
+ FaustAudioWorkletProcessorCommunicator: typeof FaustAudioWorkletProcessorCommunicator;
940
+ }
941
+ export interface FaustAudioWorkletNodeOptions<Poly extends boolean = false> extends AudioWorkletNodeOptions {
942
+ processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;
943
+ }
944
+ export interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
945
+ processorOptions: FaustMonoAudioWorkletProcessorOptions;
946
+ }
947
+ export interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
948
+ processorOptions: FaustPolyAudioWorkletProcessorOptions;
949
+ }
950
+ export interface FaustAudioWorkletProcessorOptions {
951
+ name: string;
952
+ sampleSize: number;
953
+ moduleId?: string;
954
+ instanceId?: string;
955
+ }
956
+ export interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
957
+ factory: LooseFaustDspFactory;
958
+ }
959
+ export interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
960
+ voiceFactory: LooseFaustDspFactory;
961
+ mixerModule: WebAssembly.Module;
962
+ voices: number;
963
+ effectFactory?: LooseFaustDspFactory;
964
+ }
965
+ export declare const getFaustAudioWorkletProcessor: <Poly extends boolean = false>(dependencies: FaustAudioWorkletProcessorDependencies<Poly>, faustData: FaustData, register?: boolean) => {
966
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
967
+ prototype: AudioWorkletProcessor;
968
+ parameterDescriptors: AudioParamDescriptor[];
969
+ };
970
+ export interface FaustFFTOptionsData {
971
+ fftSize: number;
972
+ fftOverlap: number;
973
+ noIFFT: boolean;
974
+ /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */
975
+ defaultWindowFunction: number;
976
+ }
977
+ /**
978
+ * Injected in the string to be compiled on AudioWorkletProcessor side
979
+ */
980
+ export interface FaustFFTData {
981
+ processorName: string;
982
+ dspName: string;
983
+ dspMeta: FaustDspMeta;
984
+ fftOptions?: Partial<FaustFFTOptionsData>;
985
+ }
986
+ export interface FaustFFTAudioWorkletProcessorDependencies {
987
+ FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;
988
+ FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;
989
+ FaustWasmInstantiator: typeof FaustWasmInstantiator;
990
+ FaustAudioWorkletProcessorCommunicator: typeof FaustAudioWorkletProcessorCommunicator;
991
+ FFTUtils: typeof FFTUtils;
992
+ }
993
+ export interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
994
+ processorOptions: FaustFFTAudioWorkletProcessorOptions;
995
+ }
996
+ export interface FaustFFTAudioWorkletProcessorOptions {
997
+ name: string;
998
+ sampleSize: number;
999
+ factory: LooseFaustDspFactory;
1000
+ moduleId?: string;
1001
+ instanceId?: string;
1002
+ }
1003
+ export declare const getFaustFFTAudioWorkletProcessor: (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register?: boolean) => {
1004
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1005
+ prototype: AudioWorkletProcessor;
1006
+ parameterDescriptors: AudioParamDescriptor[];
1007
+ };
1008
+ export interface ILibFaust extends LibFaustWasm {
1009
+ module(): FaustModule;
1010
+ fs(): typeof FS;
1011
+ }
1012
+ export declare class LibFaust implements ILibFaust {
1013
+ private fModule;
1014
+ private fCompiler;
1015
+ private fFileSystem;
1016
+ constructor(module: FaustModule);
1017
+ module(): FaustModule;
1018
+ fs(): typeof FS;
1019
+ version(): string;
1020
+ createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean): FaustDspWasm;
1021
+ deleteDSPFactory(cFactory: number): void;
1022
+ expandDSP(name: string, code: string, args: string): string;
1023
+ generateAuxFiles(name: string, code: string, args: string): boolean;
1024
+ deleteAllDSPFactories(): void;
1025
+ getErrorAfterException(): string;
1026
+ cleanupAfterException(): void;
1027
+ getInfos(what: FaustInfoType): string;
1028
+ toString(): string;
1029
+ }
1030
+ export declare const ab2str: (buf: Uint8Array) => any;
1031
+ export declare const str2ab: (str: string) => Uint8Array<ArrayBuffer>;
1032
+ export interface IFaustCompiler {
1033
+ /**
1034
+ * Gives the Faust compiler version.
1035
+ * @return a version string
1036
+ */
1037
+ version(): string;
1038
+ /**
1039
+ * Gives the last compilation error.
1040
+ * @return an error string
1041
+ */
1042
+ getErrorMessage(): string;
1043
+ /**
1044
+ * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances.
1045
+ * This function is running asynchronously.
1046
+ *
1047
+ * @param name - an arbitrary name for the Faust factory
1048
+ * @param code - Faust dsp code
1049
+ * @param args - the compiler options
1050
+ * @returns returns the wasm factory
1051
+ */
1052
+ createMonoDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
1053
+ /**
1054
+ * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances.
1055
+ * This function is running asynchronously.
1056
+ *
1057
+ * @param name - an arbitrary name for the Faust factory
1058
+ * @param code - Faust dsp code
1059
+ * @param args - the compiler options
1060
+ * @returns returns the wasm factory
1061
+ */
1062
+ createPolyDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
1063
+ /**
1064
+ * Delete a dsp factory.
1065
+ *
1066
+ * @param factory - the factory to be deleted
1067
+ */
1068
+ deleteDSPFactory(factory: FaustDspFactory): void;
1069
+ /**
1070
+ * Expand Faust code i.e. linearize included libraries.
1071
+ *
1072
+ * @param code - Faust dsp code
1073
+ * @param args - the compiler options
1074
+ * @returns returns the expanded dsp code
1075
+ */
1076
+ expandDSP(code: string, args: string): string | null;
1077
+ /**
1078
+ * Generates auxiliary files from Faust code. The output depends on the compiler options.
1079
+ *
1080
+ * @param name - an arbitrary name for the Faust module
1081
+ * @param code - Faust dsp code
1082
+ * @param args - the compiler options
1083
+ * @returns whether the generation actually succeded
1084
+ */
1085
+ generateAuxFiles(name: string, code: string, args: string): boolean;
1086
+ /**
1087
+ * Delete all factories.
1088
+ */
1089
+ deleteAllDSPFactories(): void;
1090
+ fs(): typeof FS;
1091
+ getAsyncInternalMixerModule(isDouble?: boolean): Promise<{
1092
+ mixerBuffer: Uint8Array;
1093
+ mixerModule: WebAssembly.Module;
1094
+ }>;
1095
+ getSyncInternalMixerModule(isDouble?: boolean): {
1096
+ mixerBuffer: Uint8Array;
1097
+ mixerModule: WebAssembly.Module;
1098
+ };
1099
+ }
1100
+ export declare class FaustCompiler implements IFaustCompiler {
1101
+ private fLibFaust;
1102
+ private fErrorMessage;
1103
+ private static gFactories;
1104
+ private mixer32Buffer;
1105
+ private mixer64Buffer;
1106
+ private mixer32Module;
1107
+ private mixer64Module;
1108
+ /**
1109
+ * Get a stringified DSP factories table
1110
+ */
1111
+ static serializeDSPFactories(): Record<string, {
1112
+ code: string;
1113
+ json: any;
1114
+ poly: boolean;
1115
+ }>;
1116
+ /**
1117
+ * Get a stringified DSP factories table as string
1118
+ */
1119
+ static stringifyDSPFactories(): string;
1120
+ /**
1121
+ * Import a DSP factories table
1122
+ */
1123
+ static deserializeDSPFactories(table: Record<string, {
1124
+ code: string;
1125
+ json: any;
1126
+ poly: boolean;
1127
+ }>): Promise<Map<string, FaustDspFactory>[]>;
1128
+ /**
1129
+ * Import a stringified DSP factories table
1130
+ */
1131
+ static importDSPFactories(tableStr: string): Promise<Map<string, FaustDspFactory>[]>;
1132
+ constructor(libFaust: ILibFaust);
1133
+ private intVec2intArray;
1134
+ private createDSPFactory;
1135
+ version(): string;
1136
+ getErrorMessage(): string;
1137
+ createMonoDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
1138
+ createPolyDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
1139
+ deleteDSPFactory(factory: FaustDspFactory): void;
1140
+ expandDSP(code: string, args: string): string;
1141
+ generateAuxFiles(name: string, code: string, args: string): boolean;
1142
+ deleteAllDSPFactories(): void;
1143
+ fs(): typeof FS;
1144
+ getAsyncInternalMixerModule(isDouble?: boolean): Promise<{
1145
+ mixerBuffer: Uint8Array<ArrayBufferLike>;
1146
+ mixerModule: WebAssembly.Module;
1147
+ }>;
1148
+ getSyncInternalMixerModule(isDouble?: boolean): {
1149
+ mixerBuffer: Uint8Array<ArrayBufferLike>;
1150
+ mixerModule: WebAssembly.Module;
1151
+ };
1152
+ }
1153
+ /**
1154
+ * For offline rendering.
1155
+ */
1156
+ export interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {
1157
+ render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];
1158
+ }
1159
+ export interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp {
1160
+ }
1161
+ export interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp {
1162
+ }
1163
+ export declare class FaustOfflineProcessor<Poly extends boolean = false> {
1164
+ protected fDSPCode: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;
1165
+ protected fBufferSize: number;
1166
+ protected fInputs: Float32Array[];
1167
+ protected fOutputs: Float32Array[];
1168
+ constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number);
1169
+ getParameterDescriptors(): AudioParamDescriptor[];
1170
+ compute(input: Float32Array[], output: Float32Array[]): boolean;
1171
+ setOutputParamHandler(handler: OutputParamHandler): void;
1172
+ getOutputParamHandler(): OutputParamHandler | null;
1173
+ setComputeHandler(handler: ComputeHandler): void;
1174
+ getComputeHandler(): ComputeHandler | null;
1175
+ setPlotHandler(handler: PlotHandler): void;
1176
+ getPlotHandler(): PlotHandler | null;
1177
+ getNumInputs(): number;
1178
+ getNumOutputs(): number;
1179
+ metadata(handler: MetadataHandler): void;
1180
+ midiMessage(data: number[] | Uint8Array): void;
1181
+ ctrlChange(chan: number, ctrl: number, value: number): void;
1182
+ pitchWheel(chan: number, value: number): void;
1183
+ setParamValue(path: string, value: number): void;
1184
+ getParamValue(path: string): number;
1185
+ getParams(): string[];
1186
+ getMeta(): FaustDspMeta;
1187
+ getJSON(): string;
1188
+ getDescriptors(): FaustUIInputItem[];
1189
+ getUI(): FaustUIDescriptor;
1190
+ start(): void;
1191
+ stop(): void;
1192
+ destroy(): void;
1193
+ get hasAccInput(): boolean;
1194
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
1195
+ get hasGyrInput(): boolean;
1196
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
1197
+ startSensors(): void;
1198
+ stopSensors(): void;
1199
+ /**
1200
+ * Render frames in an array.
1201
+ *
1202
+ * @param inputs - input signal
1203
+ * @param length - the number of frames to render (default: bufferSize)
1204
+ * @param onUpdate - a callback after each buffer calculated, with an argument "current sample"
1205
+ * @return an array of Float32Array with the rendered frames
1206
+ */
1207
+ render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];
1208
+ }
1209
+ export declare class FaustMonoOfflineProcessor extends FaustOfflineProcessor<false> implements IFaustMonoWebAudioDsp {
1210
+ }
1211
+ export declare class FaustPolyOfflineProcessor extends FaustOfflineProcessor<true> implements IFaustPolyWebAudioDsp {
1212
+ keyOn(channel: number, pitch: number, velocity: number): void;
1213
+ keyOff(channel: number, pitch: number, velocity: number): void;
1214
+ allNotesOff(hard: boolean): void;
1215
+ }
1216
+ export interface IFaustSvgDiagrams {
1217
+ /**
1218
+ * Generates auxiliary files from Faust code. The output depends on the compiler options.
1219
+ *
1220
+ * @param name - the DSP's name
1221
+ * @param code - Faust code
1222
+ * @param args - compilation args
1223
+ * @returns the svg diagrams as a filename - svg string map
1224
+ */
1225
+ from(name: string, code: string, args: string): Record<string, string>;
1226
+ }
1227
+ export declare class FaustSvgDiagrams implements IFaustSvgDiagrams {
1228
+ private compiler;
1229
+ constructor(compiler: FaustCompiler);
1230
+ from(name: string, code: string, args: string): Record<string, string>;
1231
+ }
1232
+ export interface IFaustCmajor {
1233
+ /**
1234
+ * Generates auxiliary files from Faust code. The output depends on the compiler options.
1235
+ *
1236
+ * @param name - the DSP's name
1237
+ * @param code - Faust code
1238
+ * @param args - compilation args
1239
+ * @returns the Cmajor compiled string
1240
+ */
1241
+ compile(name: string, code: string, args: string): string;
1242
+ }
1243
+ export declare class FaustCmajor implements IFaustCmajor {
1244
+ private fCompiler;
1245
+ constructor(compiler: FaustCompiler);
1246
+ compile(name: string, code: string, args: string): string;
1247
+ }
1248
+ export interface WavEncoderOptions {
1249
+ bitDepth: number;
1250
+ float?: boolean;
1251
+ symmetric?: boolean;
1252
+ shared?: boolean;
1253
+ sampleRate: number;
1254
+ }
1255
+ /**
1256
+ * Code from https://github.com/mohayonao/wav-encoder
1257
+ */
1258
+ export declare class WavEncoder {
1259
+ static encode(audioBuffer: Float32Array[], options: WavEncoderOptions): ArrayBuffer;
1260
+ private static writeHeader;
1261
+ private static writeData;
1262
+ }
1263
+ export interface WavDecoderOptions {
1264
+ symmetric?: boolean;
1265
+ shared?: boolean;
1266
+ }
1267
+ /**
1268
+ * Code from https://github.com/mohayonao/wav-decoder
1269
+ */
1270
+ export declare class WavDecoder {
1271
+ static decode(buffer: ArrayBuffer, options?: WavDecoderOptions): {
1272
+ numberOfChannels: number;
1273
+ length: number;
1274
+ sampleRate: number;
1275
+ channelData: Float32Array[];
1276
+ };
1277
+ private static decodeFormat;
1278
+ private static decodeData;
1279
+ private static readPCM;
1280
+ }
1281
+ /** Read metadata and fetch soundfiles */
1282
+ export declare class SoundfileReader {
1283
+ static get fallbackPaths(): string[];
1284
+ /**
1285
+ * Extract the parent URL from an URL.
1286
+ * @param url : the URL
1287
+ * @returns : the parent URL
1288
+ */
1289
+ private static getParentUrl;
1290
+ /**
1291
+ * Convert an audio buffer to audio data.
1292
+ *
1293
+ * @param audioBuffer : the audio buffer to convert
1294
+ * @returns : the audio data
1295
+ */
1296
+ private static toAudioData;
1297
+ /**
1298
+ * Extract the URLs from the metadata.
1299
+ *
1300
+ * @param dspMeta : the metadata
1301
+ * @returns : the URLs
1302
+ */
1303
+ static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory["soundfiles"];
1304
+ /**
1305
+ * Check if the file exists.
1306
+ *
1307
+ * @param url : the url of the file to check
1308
+ * @returns : true if the file exists, otherwise false
1309
+ */
1310
+ private static checkFileExists;
1311
+ /**
1312
+ * Fetch the soundfile.
1313
+ *
1314
+ * @param url : the url of the soundfile
1315
+ * @param audioCtx : the audio context
1316
+ * @returns : the audio data
1317
+ */
1318
+ private static fetchSoundfile;
1319
+ /**
1320
+ * Load the soundfile.
1321
+ *
1322
+ * @param filename : the filename
1323
+ * @param metaUrls : the metadata URLs
1324
+ * @param soundfiles : the soundfiles
1325
+ * @param audioCtx : the audio context
1326
+ */
1327
+ private static loadSoundfile;
1328
+ /**
1329
+ * Load the soundfiles, public API.
1330
+ *
1331
+ * @param dspMeta : the metadata
1332
+ * @param soundfilesIn : the soundfiles
1333
+ * @param audioCtx : the audio context
1334
+ * @returns : the soundfiles
1335
+ */
1336
+ static loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory["soundfiles"], audioCtx: BaseAudioContext): Promise<LooseFaustDspFactory["soundfiles"]>;
1337
+ }
1338
+ declare const FaustAudioWorkletNode_base: {
1339
+ new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode;
1340
+ prototype: AudioWorkletNode;
1341
+ };
1342
+ /**
1343
+ * Base class for Monophonic and Polyphonic AudioWorkletNode
1344
+ */
1345
+ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends FaustAudioWorkletNode_base {
1346
+ #private;
1347
+ protected fJSONDsp: FaustDspMeta;
1348
+ protected fJSON: string;
1349
+ protected fInputsItems: string[];
1350
+ protected fOutputHandler: OutputParamHandler | null;
1351
+ protected fComputeHandler: ComputeHandler | null;
1352
+ protected fPlotHandler: PlotHandler | null;
1353
+ protected fUICallback: UIHandler;
1354
+ protected fDescriptor: FaustUIInputItem[];
1355
+ protected fCommunicator: FaustAudioWorkletNodeCommunicator;
1356
+ constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial<FaustAudioWorkletNodeOptions<Poly>>);
1357
+ protected handleMessageAux: (e: MessageEvent) => void;
1358
+ private handleDeviceMotion;
1359
+ private handleDeviceOrientation;
1360
+ /** Setup accelerometer and gyroscope handlers */
1361
+ startSensors(): Promise<void>;
1362
+ stopSensors(): void;
1363
+ setOutputParamHandler(handler: OutputParamHandler | null): void;
1364
+ getOutputParamHandler(): OutputParamHandler | null;
1365
+ setComputeHandler(handler: ComputeHandler | null): void;
1366
+ getComputeHandler(): ComputeHandler | null;
1367
+ setPlotHandler(handler: PlotHandler | null): void;
1368
+ getPlotHandler(): PlotHandler | null;
1369
+ setupWamEventHandler(): void;
1370
+ getNumInputs(): number;
1371
+ getNumOutputs(): number;
1372
+ compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
1373
+ metadata(handler: MetadataHandler): void;
1374
+ midiMessage(data: number[] | Uint8Array): void;
1375
+ ctrlChange(channel: number, ctrl: number, value: number): void;
1376
+ pitchWheel(channel: number, wheel: number): void;
1377
+ get hasAccInput(): boolean;
1378
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
1379
+ get hasGyrInput(): boolean;
1380
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
1381
+ setParamValue(path: string, value: number): void;
1382
+ getParamValue(path: string): number;
1383
+ getParams(): string[];
1384
+ getMeta(): FaustDspMeta;
1385
+ getJSON(): string;
1386
+ getUI(): FaustUIDescriptor;
1387
+ getDescriptors(): FaustUIInputItem[];
1388
+ start(): void;
1389
+ stop(): void;
1390
+ destroy(): void;
1391
+ }
1392
+ /**
1393
+ * Monophonic AudioWorkletNode
1394
+ */
1395
+ export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<false> implements IFaustMonoWebAudioDsp {
1396
+ onprocessorerror: (e: Event) => never;
1397
+ constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<false>> & Pick<FaustAudioWorkletNodeOptions<false>, "processorOptions">);
1398
+ }
1399
+ /**
1400
+ * Polyphonic AudioWorkletNode
1401
+ */
1402
+ export declare class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode<true> implements IFaustPolyWebAudioDsp {
1403
+ private fJSONEffect;
1404
+ onprocessorerror: (e: Event) => never;
1405
+ constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<true>> & Pick<FaustAudioWorkletNodeOptions<true>, "processorOptions">);
1406
+ keyOn(channel: number, pitch: number, velocity: number): void;
1407
+ keyOff(channel: number, pitch: number, velocity: number): void;
1408
+ allNotesOff(hard: boolean): void;
1409
+ getMeta(): FaustDspMeta;
1410
+ getJSON(): string;
1411
+ getUI(): FaustUIDescriptor;
1412
+ }
1413
+ declare const FaustScriptProcessorNode_base: {
1414
+ new (): ScriptProcessorNode;
1415
+ prototype: ScriptProcessorNode;
1416
+ };
1417
+ /**
1418
+ * Base class for Monophonic and Polyphonic ScriptProcessorNode
1419
+ */
1420
+ export declare class FaustScriptProcessorNode<Poly extends boolean = false> extends FaustScriptProcessorNode_base {
1421
+ protected fDSPCode: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;
1422
+ protected fInputs: Float32Array[];
1423
+ protected fOutputs: Float32Array[];
1424
+ protected handleDeviceMotion: any;
1425
+ protected handleDeviceOrientation: any;
1426
+ init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void;
1427
+ /** Start accelerometer and gyroscope handlers */
1428
+ startSensors(): Promise<void>;
1429
+ /** Stop accelerometer and gyroscope handlers */
1430
+ stopSensors(): void;
1431
+ compute(input: Float32Array[], output: Float32Array[]): boolean;
1432
+ setOutputParamHandler(handler: OutputParamHandler): void;
1433
+ getOutputParamHandler(): OutputParamHandler | null;
1434
+ setComputeHandler(handler: ComputeHandler): void;
1435
+ getComputeHandler(): ComputeHandler | null;
1436
+ setPlotHandler(handler: PlotHandler): void;
1437
+ getPlotHandler(): PlotHandler | null;
1438
+ getNumInputs(): number;
1439
+ getNumOutputs(): number;
1440
+ metadata(handler: MetadataHandler): void;
1441
+ midiMessage(data: number[] | Uint8Array): void;
1442
+ ctrlChange(chan: number, ctrl: number, value: number): void;
1443
+ pitchWheel(chan: number, value: number): void;
1444
+ setParamValue(path: string, value: number): void;
1445
+ getParamValue(path: string): number;
1446
+ getParams(): string[];
1447
+ getMeta(): FaustDspMeta;
1448
+ getJSON(): string;
1449
+ getDescriptors(): FaustUIInputItem[];
1450
+ getUI(): FaustUIDescriptor;
1451
+ start(): void;
1452
+ stop(): void;
1453
+ destroy(): void;
1454
+ get hasAccInput(): boolean;
1455
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
1456
+ get hasGyrInput(): boolean;
1457
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
1458
+ }
1459
+ export declare class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode<false> implements IFaustMonoWebAudioDsp {
1460
+ }
1461
+ export declare class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode<true> implements IFaustPolyWebAudioDsp {
1462
+ keyOn(channel: number, pitch: number, velocity: number): void;
1463
+ keyOff(channel: number, pitch: number, velocity: number): void;
1464
+ allNotesOff(hard: boolean): void;
1465
+ }
1466
+ export interface GeneratorSupportingSoundfiles {
1467
+ /**
1468
+ * Attach a map of id - audio data, call after `compile()` before `createNode()`
1469
+ *
1470
+ * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`
1471
+ */
1472
+ addSoundfiles(soundfileMap: Record<string, AudioData$1>): void;
1473
+ /**
1474
+ * Get a list of soundfiles needed, call after `compile()`
1475
+ */
1476
+ getSoundfileList(): string[];
1477
+ }
1478
+ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
1479
+ /**
1480
+ * Compile a monophonic DSP factory from given code.
1481
+ *
1482
+ * @param compiler - the Faust compiler
1483
+ * @param name - the DSP name
1484
+ * @param code - the DSP code
1485
+ * @param args - the compilation parameters
1486
+ * @returns the compiled factory or 'null' if failure
1487
+ */
1488
+ compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{
1489
+ factory: FaustDspFactory | null;
1490
+ name?: string;
1491
+ meta?: FaustDspMeta;
1492
+ } | null>;
1493
+ /**
1494
+ * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1495
+ *
1496
+ * @param context - the WebAudio context
1497
+ * @param name - DSP name, can be used for processorName
1498
+ * @param factory - default is the compiled factory
1499
+ * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
1500
+ * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
1501
+ * @param processorName - AudioWorklet Processor name
1502
+ * @param processorOptions - Additional AudioWorklet Processor options
1503
+ * @returns the compiled WebAudio node or 'null' if failure
1504
+ */
1505
+ createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<IFaustMonoWebAudioNode | null>;
1506
+ /**
1507
+ * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1508
+ *
1509
+ * @param context - the WebAudio context
1510
+ * @param fftUtils - should be an anonymous class with static methods, without any import from outside
1511
+ * @param name - DSP name, can be used for processorName
1512
+ * @param factory - default is the compiled factory
1513
+ * @param fftOptions - initial FFT options
1514
+ * @param processorName - AudioWorklet Processor name
1515
+ * @param processorOptions - Additional AudioWorklet Processor options
1516
+ * @returns the compiled WebAudio node or 'null' if failure
1517
+ */
1518
+ createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
1519
+ /**
1520
+ * Create a monophonic Offline processor.
1521
+ *
1522
+ * @param sampleRate - the sample rate in Hz
1523
+ * @param bufferSize - the buffer size in frames
1524
+ * @param factory - default is the compiled factory
1525
+ * @param context - if this exists, will be used to fetch soundfiles online
1526
+ * @returns the compiled processor or 'null' if failure
1527
+ */
1528
+ createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, context?: BaseAudioContext): Promise<IFaustMonoOfflineProcessor | null>;
1529
+ /**
1530
+ * Get DSP JSON description with its UI and metadata as object.
1531
+ *
1532
+ * @return the DSP JSON description as object
1533
+ */
1534
+ getMeta(): FaustDspMeta;
1535
+ /**
1536
+ * Get DSP JSON description with its UI and metadata.
1537
+ *
1538
+ * @return the DSP JSON description
1539
+ */
1540
+ getJSON(): string;
1541
+ /**
1542
+ * Get DSP UI description.
1543
+ *
1544
+ * @return the DSP UI description
1545
+ */
1546
+ getUI(): FaustUIDescriptor;
1547
+ }
1548
+ export interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {
1549
+ /**
1550
+ * Compile a monophonic DSP factory from given code.
1551
+ *
1552
+ * @param compiler - the Faust compiler
1553
+ * @param name - the DSP name
1554
+ * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)
1555
+ * @param args - the compilation parameters
1556
+ * @param effectCode - optional effect DSP code
1557
+ * @returns the compiled factory or 'null' if failure
1558
+ */
1559
+ compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{
1560
+ voiceFactory: FaustDspFactory | null;
1561
+ effectFactory?: FaustDspFactory | null;
1562
+ } | null>;
1563
+ /**
1564
+ * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1565
+ *
1566
+ * @param context the WebAudio context
1567
+ * @param voices - the number of voices
1568
+ * @param name - AudioWorklet Processor name
1569
+ * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1570
+ * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)
1571
+ * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1572
+ * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
1573
+ * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
1574
+ * @param processorOptions - Additional AudioWorklet Processor options
1575
+ * @returns the compiled WebAudio node or 'null' if failure
1576
+ */
1577
+ createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<IFaustPolyWebAudioNode | null>;
1578
+ /**
1579
+ * Create a monophonic Offline processor.
1580
+ *
1581
+ * @param sampleRate - the sample rate in Hz
1582
+ * @param bufferSize - the buffer size in frames
1583
+ * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1584
+ * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)
1585
+ * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1586
+ * @param context - if this exists, will be used to fetch soundfiles online
1587
+ * @returns the compiled processor or 'null' if failure
1588
+ */
1589
+ createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, context?: BaseAudioContext): Promise<IFaustPolyOfflineProcessor | null>;
1590
+ /**
1591
+ * Get DSP JSON description with its UI and metadata as object.
1592
+ *
1593
+ * @return the DSP JSON description as object
1594
+ */
1595
+ getMeta(): FaustDspMeta;
1596
+ /**
1597
+ * Get DSP JSON description with its UI and metadata.
1598
+ *
1599
+ * @return the DSP JSON description
1600
+ */
1601
+ getJSON(): string;
1602
+ /**
1603
+ * Get DSP UI description.
1604
+ *
1605
+ * @return the DSP UI description
1606
+ */
1607
+ getUI(): FaustUIDescriptor;
1608
+ }
1609
+ export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
1610
+ private static gWorkletProcessors;
1611
+ name: string;
1612
+ factory: FaustDspFactory | null;
1613
+ constructor();
1614
+ compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<this | null>;
1615
+ addSoundfiles(soundfileMap: Record<string, AudioData$1>): void;
1616
+ getSoundfileList(): string[];
1617
+ createNode<SP extends boolean = false>(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: SP, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<SP extends true ? FaustMonoScriptProcessorNode | null : FaustMonoAudioWorkletNode | null>;
1618
+ createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
1619
+ createAudioWorkletProcessor(name?: string, factory?: LooseFaustDspFactory, processorName?: string): Promise<{
1620
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1621
+ prototype: AudioWorkletProcessor;
1622
+ parameterDescriptors: AudioParamDescriptor[];
1623
+ }>;
1624
+ createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, context?: BaseAudioContext): Promise<FaustMonoOfflineProcessor>;
1625
+ getMeta(): any;
1626
+ getJSON(): string;
1627
+ getUI(): any;
1628
+ }
1629
+ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
1630
+ private static gWorkletProcessors;
1631
+ name: string;
1632
+ voiceFactory: FaustDspFactory | null;
1633
+ effectFactory: FaustDspFactory | null;
1634
+ mixerBuffer: Uint8Array;
1635
+ mixerModule: WebAssembly.Module;
1636
+ constructor();
1637
+ compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCodeAux?: string): Promise<this | null>;
1638
+ addSoundfiles(soundfileMap: Record<string, AudioData$1>): void;
1639
+ getSoundfileList(): string[];
1640
+ createNode<SP extends boolean = false>(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: SP, bufferSize?: number, processorName?: string, processorOptions?: {}): Promise<SP extends true ? FaustPolyScriptProcessorNode | null : FaustPolyAudioWorkletNode | null>;
1641
+ createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
1642
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1643
+ prototype: AudioWorkletProcessor;
1644
+ parameterDescriptors: AudioParamDescriptor[];
1645
+ }>;
1646
+ createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, context?: BaseAudioContext): Promise<FaustPolyOfflineProcessor>;
1647
+ getMeta(): FaustDspMeta;
1648
+ getJSON(): string;
1649
+ getUI(): FaustUIDescriptor;
1650
+ }
1651
+
1652
+ export {
1653
+ AudioData$1 as AudioData,
1654
+ };
1655
+
1656
+ export {};