@grame/faustwasm 0.9.6 → 0.10.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.
@@ -0,0 +1,1695 @@
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
+ * Handle MIDI keyOn messages.
623
+ * @param channel
624
+ * @param pitch
625
+ * @param velocity
626
+ */
627
+ keyOn(channel: number, pitch: number, velocity: number): void;
628
+ /**
629
+ * Handle MIDI keyOn messages.
630
+ * @param channel
631
+ * @param pitch
632
+ * @param velocity
633
+ */
634
+ keyOff(channel: number, pitch: number, velocity: number): void;
635
+ /**
636
+ * Set parameter value.
637
+ *
638
+ * @param path - the path to the wanted parameter (retrieved using 'getParams' method)
639
+ * @param val - the float value for the wanted control
640
+ */
641
+ setParamValue(path: string, value: number): void;
642
+ /**
643
+ * Get parameter value.
644
+ *
645
+ * @param path - the path to the wanted parameter (retrieved using 'getParams' method)
646
+ *
647
+ * @return the float value
648
+ */
649
+ getParamValue(path: string): number;
650
+ /**
651
+ * Get the table of all input parameters paths.
652
+ *
653
+ * @return the table of all input parameters paths
654
+ */
655
+ getParams(): string[];
656
+ /**
657
+ * Get DSP JSON description with its UI and metadata as object.
658
+ *
659
+ * @return the DSP JSON description as object
660
+ */
661
+ getMeta(): FaustDspMeta;
662
+ /**
663
+ * Get DSP UI description.
664
+ *
665
+ * @return the DSP UI description
666
+ */
667
+ getUI(): FaustUIDescriptor;
668
+ /**
669
+ * Get DSP UI items description.
670
+ *
671
+ * @return the DSP UI items description
672
+ */
673
+ getDescriptors(): FaustUIInputItem[];
674
+ /**
675
+ * Get DSP JSON description with its UI and metadata.
676
+ *
677
+ * @return the DSP JSON description
678
+ */
679
+ getJSON(): string;
680
+ /**
681
+ * Start accelerometer and gyroscope handlers.
682
+ */
683
+ startSensors(): void;
684
+ /**
685
+ * Stop accelerometer and gyroscope handlers.
686
+ */
687
+ stopSensors(): void;
688
+ /** Indicating if the DSP handles the accelerometer */
689
+ readonly hasAccInput: boolean;
690
+ /**
691
+ * Accelerometer handling.
692
+ * accelerationIncludingGravity: DeviceMotionEvent["accelerationIncludingGravity"]
693
+ * invert: boolean
694
+ */
695
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert: boolean): void;
696
+ /** Indicating if the DSP handles the gyroscope */
697
+ readonly hasGyrInput: boolean;
698
+ /**
699
+ * Gyroscope handling.
700
+ * event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">
701
+ */
702
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
703
+ /**
704
+ * Start the DSP audio processing.
705
+ */
706
+ start(): void;
707
+ /**
708
+ * Stop the DSP audio processing.
709
+ */
710
+ stop(): void;
711
+ /**
712
+ * Destroy the DSP.
713
+ */
714
+ destroy(): void;
715
+ }
716
+ export interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp {
717
+ }
718
+ export interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode {
719
+ }
720
+ export interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {
721
+ /**
722
+ * Handle MIDI keyOn messages.
723
+ *
724
+ * @param channel - the MIDI channel (0..15, not used for now)
725
+ * @param pitch - the MIDI pitch value (0..127)
726
+ * @param velocity - the MIDI velocity value (0..127)
727
+ */
728
+ keyOn(channel: number, pitch: number, velocity: number): void;
729
+ /**
730
+ * Handle MIDI keyOff messages.
731
+ *
732
+ * @param channel - the MIDI channel (0..15, not used for now)
733
+ * @param pitch - the MIDI pitch value (0..127)
734
+ * @param velocity - the MIDI velocity value (0..127)
735
+ */
736
+ keyOff(channel: number, pitch: number, velocity: number): void;
737
+ /**
738
+ * Stop all playing notes.
739
+ *
740
+ * @param hard - whether to immediately stop notes or put them in release mode
741
+ */
742
+ allNotesOff(hard: boolean): void;
743
+ }
744
+ export interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode {
745
+ }
746
+ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
747
+ protected fOutputHandler: OutputParamHandler | null;
748
+ protected fComputeHandler: ComputeHandler | null;
749
+ protected fPlotHandler: PlotHandler | null;
750
+ protected fCachedEvents: {
751
+ type: string;
752
+ data: any;
753
+ }[];
754
+ protected fBufferNum: number;
755
+ protected fInChannels: Float32Array[] | Float64Array[];
756
+ protected fOutChannels: Float32Array[] | Float64Array[];
757
+ protected fOutputsTimer: number;
758
+ protected fInputsItems: string[];
759
+ protected fOutputsItems: string[];
760
+ protected fDescriptor: FaustUIInputItem[];
761
+ protected fSoundfiles: SoundfileItem[];
762
+ protected fSoundfileBuffers: LooseFaustDspFactory["soundfiles"];
763
+ /** Keep the end of memory offset before soundfiles */
764
+ protected fEndMemory: number;
765
+ protected fAcc: SensorEventHandlers;
766
+ protected fGyr: SensorEventHandlers;
767
+ protected fAudioInputs: number;
768
+ protected fAudioOutputs: number;
769
+ protected fBufferSize: number;
770
+ protected fPtrSize: number;
771
+ protected fSampleSize: number;
772
+ protected fPitchwheelLabel: {
773
+ path: string;
774
+ chan: number;
775
+ min: number;
776
+ max: number;
777
+ }[];
778
+ protected fCtrlLabel: {
779
+ path: string;
780
+ chan: number;
781
+ min: number;
782
+ max: number;
783
+ }[][];
784
+ protected fMidiKeyLabel: {
785
+ path: string;
786
+ chan: number;
787
+ min: number;
788
+ max: number;
789
+ }[][];
790
+ protected fMidiKeyOnLabel: {
791
+ path: string;
792
+ chan: number;
793
+ min: number;
794
+ max: number;
795
+ }[][];
796
+ protected fMidiKeyOffLabel: {
797
+ path: string;
798
+ chan: number;
799
+ min: number;
800
+ max: number;
801
+ }[][];
802
+ protected fPathTable: {
803
+ [address: string]: number;
804
+ };
805
+ protected fUICallback: UIHandler;
806
+ protected fProcessing: boolean;
807
+ protected fDestroyed: boolean;
808
+ protected fFirstCall: boolean;
809
+ protected fJSONDsp: FaustDspMeta;
810
+ constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory["soundfiles"]);
811
+ static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number): number;
812
+ static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any): void;
813
+ static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any): void;
814
+ static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any): void;
815
+ static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any): void;
816
+ /** Split the soundfile names and return an array of names */
817
+ static splitSoundfileNames(input: string): string[];
818
+ get hasAccInput(): boolean;
819
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
820
+ get hasGyrInput(): boolean;
821
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
822
+ /** Build the accelerometer handler */
823
+ private setupAccHandler;
824
+ /** Build the gyroscope handler */
825
+ private setupGyrHandler;
826
+ static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[];
827
+ /**
828
+ * Load a soundfile possibly containing several parts in the DSP struct.
829
+ * Soundfile pointers are located at 'index' offset, to be read in the JSON file.
830
+ * The DSP struct is located at baseDSP in the wasm memory,
831
+ * either a monophonic DSP, or a voice in a polyphonic context.
832
+ *
833
+ * @param allocator : the wasm memory allocator
834
+ * @param baseDSP : the base DSP in the wasm memory
835
+ * @param name : the name of the soundfile
836
+ * @param url : the url of the soundfile
837
+ */
838
+ private loadSoundfile;
839
+ createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory["soundfiles"], maxChan?: number): Soundfile;
840
+ /**
841
+ * Init soundfiles memory.
842
+ *
843
+ * @param allocator : the wasm memory allocator
844
+ * @param sfReader : the soundfile reader
845
+ * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory
846
+ */
847
+ protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number): void;
848
+ protected updateOutputs(): void;
849
+ metadata(handler: MetadataHandler): void;
850
+ compute(input: Float32Array[], output: Float32Array[]): boolean;
851
+ setOutputParamHandler(handler: OutputParamHandler | null): void;
852
+ getOutputParamHandler(): OutputParamHandler | null;
853
+ setComputeHandler(handler: ComputeHandler | null): void;
854
+ getComputeHandler(): ComputeHandler | null;
855
+ setPlotHandler(handler: PlotHandler | null): void;
856
+ getPlotHandler(): PlotHandler | null;
857
+ getNumInputs(): number;
858
+ getNumOutputs(): number;
859
+ midiMessage(data: number[] | Uint8Array): void;
860
+ ctrlChange(channel: number, ctrl: number, value: number): void;
861
+ keyOn(channel: number, pitch: number, velocity: number): void;
862
+ keyOff(channel: number, pitch: number, velocity: number): void;
863
+ pitchWheel(channel: number, wheel: number): void;
864
+ setParamValue(path: string, value: number): void;
865
+ getParamValue(path: string): number;
866
+ getParams(): string[];
867
+ getMeta(): FaustDspMeta;
868
+ getJSON(): string;
869
+ getUI(): FaustUIDescriptor;
870
+ getDescriptors(): FaustUIInputItem[];
871
+ hasSoundfiles(): boolean;
872
+ startSensors(): void;
873
+ stopSensors(): void;
874
+ start(): void;
875
+ stop(): void;
876
+ destroy(): void;
877
+ }
878
+ export declare class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {
879
+ private fInstance;
880
+ private fDSP;
881
+ constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory["soundfiles"]);
882
+ private initMemory;
883
+ toString(): string;
884
+ compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)): boolean;
885
+ metadata(handler: MetadataHandler): void;
886
+ getNumInputs(): number;
887
+ getNumOutputs(): number;
888
+ setParamValue(path: string, value: number): void;
889
+ getParamValue(path: string): number;
890
+ getMeta(): FaustDspMeta;
891
+ getJSON(): string;
892
+ getDescriptors(): FaustUIInputItem[];
893
+ getUI(): FaustUIDescriptor;
894
+ }
895
+ export declare class FaustWebAudioDspVoice {
896
+ static get kActiveVoice(): number;
897
+ static get kFreeVoice(): number;
898
+ static get kReleaseVoice(): number;
899
+ static get kLegatoVoice(): number;
900
+ static get kNoVoice(): number;
901
+ static get VOICE_STOP_LEVEL(): number;
902
+ private fFreqLabel;
903
+ private fGateLabel;
904
+ private fGainLabel;
905
+ private fKeyLabel;
906
+ private fVelLabel;
907
+ private fDSP;
908
+ private fAPI;
909
+ fCurNote: number;
910
+ fNextNote: number;
911
+ fNextVel: number;
912
+ fDate: number;
913
+ fLevel: number;
914
+ constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: {
915
+ [address: string]: number;
916
+ }, sampleRate: number);
917
+ static midiToFreq(note: number): number;
918
+ static normalizeVelocity(velocity: number): number;
919
+ private extractPaths;
920
+ keyOn(pitch: number, velocity: number, legato?: boolean): void;
921
+ keyOff(hard?: boolean): void;
922
+ computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number): void;
923
+ compute(bufferSize: number, $inputs: number, $outputs: number): void;
924
+ setParamValue(index: number, value: number): void;
925
+ getParamValue(index: number): number;
926
+ }
927
+ export declare class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {
928
+ private fInstance;
929
+ private fEffect;
930
+ private fJSONEffect;
931
+ private fAudioMixing;
932
+ private fAudioMixingHalf;
933
+ private fVoiceTable;
934
+ constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory["soundfiles"]);
935
+ private initMemory;
936
+ toString(): string;
937
+ private allocVoice;
938
+ private getPlayingVoice;
939
+ private getFreeVoice;
940
+ compute(input: Float32Array[], output: Float32Array[]): boolean;
941
+ getNumInputs(): number;
942
+ getNumOutputs(): number;
943
+ private static findPath;
944
+ setParamValue(path: string, value: number): void;
945
+ getParamValue(path: string): number;
946
+ getMeta(): FaustDspMeta;
947
+ getJSON(): string;
948
+ getUI(): FaustUIDescriptor;
949
+ getDescriptors(): FaustUIInputItem[];
950
+ midiMessage(data: number[] | Uint8Array): void;
951
+ ctrlChange(channel: number, ctrl: number, value: number): void;
952
+ keyOn(channel: number, pitch: number, velocity: number): void;
953
+ keyOff(channel: number, pitch: number, velocity: number): void;
954
+ allNotesOff(hard?: boolean): void;
955
+ }
956
+ /**
957
+ * Injected in the string to be compiled on AudioWorkletProcessor side
958
+ */
959
+ export interface FaustData {
960
+ processorName: string;
961
+ dspName: string;
962
+ dspMeta: FaustDspMeta;
963
+ poly: boolean;
964
+ effectMeta?: FaustDspMeta;
965
+ }
966
+ export interface FaustAudioWorkletProcessorDependencies<Poly extends boolean = false> {
967
+ FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;
968
+ FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;
969
+ FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;
970
+ FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;
971
+ FaustWasmInstantiator: typeof FaustWasmInstantiator;
972
+ FaustAudioWorkletProcessorCommunicator: typeof FaustAudioWorkletProcessorCommunicator;
973
+ }
974
+ export interface FaustAudioWorkletNodeOptions<Poly extends boolean = false> extends AudioWorkletNodeOptions {
975
+ processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;
976
+ }
977
+ export interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
978
+ processorOptions: FaustMonoAudioWorkletProcessorOptions;
979
+ }
980
+ export interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
981
+ processorOptions: FaustPolyAudioWorkletProcessorOptions;
982
+ }
983
+ export interface FaustAudioWorkletProcessorOptions {
984
+ name: string;
985
+ sampleSize: number;
986
+ moduleId?: string;
987
+ instanceId?: string;
988
+ }
989
+ export interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
990
+ factory: LooseFaustDspFactory;
991
+ }
992
+ export interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
993
+ voiceFactory: LooseFaustDspFactory;
994
+ mixerModule: WebAssembly.Module;
995
+ voices: number;
996
+ effectFactory?: LooseFaustDspFactory;
997
+ }
998
+ export declare const getFaustAudioWorkletProcessor: <Poly extends boolean = false>(dependencies: FaustAudioWorkletProcessorDependencies<Poly>, faustData: FaustData, register?: boolean) => {
999
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1000
+ prototype: AudioWorkletProcessor;
1001
+ parameterDescriptors: AudioParamDescriptor[];
1002
+ };
1003
+ export interface FaustFFTOptionsData {
1004
+ fftSize: number;
1005
+ fftOverlap: number;
1006
+ noIFFT: boolean;
1007
+ /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */
1008
+ defaultWindowFunction: number;
1009
+ }
1010
+ /**
1011
+ * Injected in the string to be compiled on AudioWorkletProcessor side
1012
+ */
1013
+ export interface FaustFFTData {
1014
+ processorName: string;
1015
+ dspName: string;
1016
+ dspMeta: FaustDspMeta;
1017
+ fftOptions?: Partial<FaustFFTOptionsData>;
1018
+ }
1019
+ export interface FaustFFTAudioWorkletProcessorDependencies {
1020
+ FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;
1021
+ FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;
1022
+ FaustWasmInstantiator: typeof FaustWasmInstantiator;
1023
+ FaustAudioWorkletProcessorCommunicator: typeof FaustAudioWorkletProcessorCommunicator;
1024
+ FFTUtils: typeof FFTUtils;
1025
+ }
1026
+ export interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
1027
+ processorOptions: FaustFFTAudioWorkletProcessorOptions;
1028
+ }
1029
+ export interface FaustFFTAudioWorkletProcessorOptions {
1030
+ name: string;
1031
+ sampleSize: number;
1032
+ factory: LooseFaustDspFactory;
1033
+ moduleId?: string;
1034
+ instanceId?: string;
1035
+ }
1036
+ export declare const getFaustFFTAudioWorkletProcessor: (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register?: boolean) => {
1037
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1038
+ prototype: AudioWorkletProcessor;
1039
+ parameterDescriptors: AudioParamDescriptor[];
1040
+ };
1041
+ export interface ILibFaust extends LibFaustWasm {
1042
+ module(): FaustModule;
1043
+ fs(): typeof FS;
1044
+ }
1045
+ export declare class LibFaust implements ILibFaust {
1046
+ private fModule;
1047
+ private fCompiler;
1048
+ private fFileSystem;
1049
+ constructor(module: FaustModule);
1050
+ module(): FaustModule;
1051
+ fs(): typeof FS;
1052
+ version(): string;
1053
+ createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean): FaustDspWasm;
1054
+ deleteDSPFactory(cFactory: number): void;
1055
+ expandDSP(name: string, code: string, args: string): string;
1056
+ generateAuxFiles(name: string, code: string, args: string): boolean;
1057
+ deleteAllDSPFactories(): void;
1058
+ getErrorAfterException(): string;
1059
+ cleanupAfterException(): void;
1060
+ getInfos(what: FaustInfoType): string;
1061
+ toString(): string;
1062
+ }
1063
+ export declare const ab2str: (buf: Uint8Array) => any;
1064
+ export declare const str2ab: (str: string) => Uint8Array<ArrayBuffer>;
1065
+ export interface IFaustCompiler {
1066
+ /**
1067
+ * Gives the Faust compiler version.
1068
+ * @return a version string
1069
+ */
1070
+ version(): string;
1071
+ /**
1072
+ * Gives the last compilation error.
1073
+ * @return an error string
1074
+ */
1075
+ getErrorMessage(): string;
1076
+ /**
1077
+ * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances.
1078
+ * This function is running asynchronously.
1079
+ *
1080
+ * @param name - an arbitrary name for the Faust factory
1081
+ * @param code - Faust dsp code
1082
+ * @param args - the compiler options
1083
+ * @returns returns the wasm factory
1084
+ */
1085
+ createMonoDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
1086
+ /**
1087
+ * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances.
1088
+ * This function is running asynchronously.
1089
+ *
1090
+ * @param name - an arbitrary name for the Faust factory
1091
+ * @param code - Faust dsp code
1092
+ * @param args - the compiler options
1093
+ * @returns returns the wasm factory
1094
+ */
1095
+ createPolyDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
1096
+ /**
1097
+ * Delete a dsp factory.
1098
+ *
1099
+ * @param factory - the factory to be deleted
1100
+ */
1101
+ deleteDSPFactory(factory: FaustDspFactory): void;
1102
+ /**
1103
+ * Expand Faust code i.e. linearize included libraries.
1104
+ *
1105
+ * @param code - Faust dsp code
1106
+ * @param args - the compiler options
1107
+ * @returns returns the expanded dsp code
1108
+ */
1109
+ expandDSP(code: string, args: string): string | null;
1110
+ /**
1111
+ * Generates auxiliary files from Faust code. The output depends on the compiler options.
1112
+ *
1113
+ * @param name - an arbitrary name for the Faust module
1114
+ * @param code - Faust dsp code
1115
+ * @param args - the compiler options
1116
+ * @returns whether the generation actually succeded
1117
+ */
1118
+ generateAuxFiles(name: string, code: string, args: string): boolean;
1119
+ /**
1120
+ * Delete all factories.
1121
+ */
1122
+ deleteAllDSPFactories(): void;
1123
+ fs(): typeof FS;
1124
+ getAsyncInternalMixerModule(isDouble?: boolean): Promise<{
1125
+ mixerBuffer: Uint8Array;
1126
+ mixerModule: WebAssembly.Module;
1127
+ }>;
1128
+ getSyncInternalMixerModule(isDouble?: boolean): {
1129
+ mixerBuffer: Uint8Array;
1130
+ mixerModule: WebAssembly.Module;
1131
+ };
1132
+ }
1133
+ export declare class FaustCompiler implements IFaustCompiler {
1134
+ private fLibFaust;
1135
+ private fErrorMessage;
1136
+ private static gFactories;
1137
+ private mixer32Buffer;
1138
+ private mixer64Buffer;
1139
+ private mixer32Module;
1140
+ private mixer64Module;
1141
+ /**
1142
+ * Get a stringified DSP factories table
1143
+ */
1144
+ static serializeDSPFactories(): Record<string, {
1145
+ code: string;
1146
+ json: any;
1147
+ poly: boolean;
1148
+ }>;
1149
+ /**
1150
+ * Get a stringified DSP factories table as string
1151
+ */
1152
+ static stringifyDSPFactories(): string;
1153
+ /**
1154
+ * Import a DSP factories table
1155
+ */
1156
+ static deserializeDSPFactories(table: Record<string, {
1157
+ code: string;
1158
+ json: any;
1159
+ poly: boolean;
1160
+ }>): Promise<Map<string, FaustDspFactory>[]>;
1161
+ /**
1162
+ * Import a stringified DSP factories table
1163
+ */
1164
+ static importDSPFactories(tableStr: string): Promise<Map<string, FaustDspFactory>[]>;
1165
+ constructor(libFaust: ILibFaust);
1166
+ private intVec2intArray;
1167
+ private createDSPFactory;
1168
+ version(): string;
1169
+ getErrorMessage(): string;
1170
+ createMonoDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
1171
+ createPolyDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
1172
+ deleteDSPFactory(factory: FaustDspFactory): void;
1173
+ expandDSP(code: string, args: string): string;
1174
+ generateAuxFiles(name: string, code: string, args: string): boolean;
1175
+ deleteAllDSPFactories(): void;
1176
+ fs(): typeof FS;
1177
+ getAsyncInternalMixerModule(isDouble?: boolean): Promise<{
1178
+ mixerBuffer: Uint8Array<ArrayBufferLike>;
1179
+ mixerModule: WebAssembly.Module;
1180
+ }>;
1181
+ getSyncInternalMixerModule(isDouble?: boolean): {
1182
+ mixerBuffer: Uint8Array<ArrayBufferLike>;
1183
+ mixerModule: WebAssembly.Module;
1184
+ };
1185
+ }
1186
+ /**
1187
+ * For offline rendering.
1188
+ */
1189
+ export interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {
1190
+ render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];
1191
+ }
1192
+ export interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp {
1193
+ }
1194
+ export interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp {
1195
+ }
1196
+ export declare class FaustOfflineProcessor<Poly extends boolean = false> {
1197
+ protected fDSPCode: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;
1198
+ protected fBufferSize: number;
1199
+ protected fInputs: Float32Array[];
1200
+ protected fOutputs: Float32Array[];
1201
+ constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number);
1202
+ getParameterDescriptors(): AudioParamDescriptor[];
1203
+ compute(input: Float32Array[], output: Float32Array[]): boolean;
1204
+ setOutputParamHandler(handler: OutputParamHandler): void;
1205
+ getOutputParamHandler(): OutputParamHandler | null;
1206
+ setComputeHandler(handler: ComputeHandler): void;
1207
+ getComputeHandler(): ComputeHandler | null;
1208
+ setPlotHandler(handler: PlotHandler): void;
1209
+ getPlotHandler(): PlotHandler | null;
1210
+ getNumInputs(): number;
1211
+ getNumOutputs(): number;
1212
+ metadata(handler: MetadataHandler): void;
1213
+ midiMessage(data: number[] | Uint8Array): void;
1214
+ ctrlChange(chan: number, ctrl: number, value: number): void;
1215
+ pitchWheel(chan: number, value: number): void;
1216
+ keyOn(channel: number, pitch: number, velocity: number): void;
1217
+ keyOff(channel: number, pitch: number, velocity: number): void;
1218
+ setParamValue(path: string, value: number): void;
1219
+ getParamValue(path: string): number;
1220
+ getParams(): string[];
1221
+ getMeta(): FaustDspMeta;
1222
+ getJSON(): string;
1223
+ getDescriptors(): FaustUIInputItem[];
1224
+ getUI(): FaustUIDescriptor;
1225
+ start(): void;
1226
+ stop(): void;
1227
+ destroy(): void;
1228
+ get hasAccInput(): boolean;
1229
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
1230
+ get hasGyrInput(): boolean;
1231
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
1232
+ startSensors(): void;
1233
+ stopSensors(): void;
1234
+ /**
1235
+ * Render frames in an array.
1236
+ *
1237
+ * @param inputs - input signal
1238
+ * @param length - the number of frames to render (default: bufferSize)
1239
+ * @param onUpdate - a callback after each buffer calculated, with an argument "current sample"
1240
+ * @return an array of Float32Array with the rendered frames
1241
+ */
1242
+ render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];
1243
+ }
1244
+ export declare class FaustMonoOfflineProcessor extends FaustOfflineProcessor<false> implements IFaustMonoWebAudioDsp {
1245
+ }
1246
+ export declare class FaustPolyOfflineProcessor extends FaustOfflineProcessor<true> implements IFaustPolyWebAudioDsp {
1247
+ keyOn(channel: number, pitch: number, velocity: number): void;
1248
+ keyOff(channel: number, pitch: number, velocity: number): void;
1249
+ allNotesOff(hard: boolean): void;
1250
+ }
1251
+ export interface IFaustSvgDiagrams {
1252
+ /**
1253
+ * Generates auxiliary files from Faust code. The output depends on the compiler options.
1254
+ *
1255
+ * @param name - the DSP's name
1256
+ * @param code - Faust code
1257
+ * @param args - compilation args
1258
+ * @returns the svg diagrams as a filename - svg string map
1259
+ */
1260
+ from(name: string, code: string, args: string): Record<string, string>;
1261
+ }
1262
+ export declare class FaustSvgDiagrams implements IFaustSvgDiagrams {
1263
+ private compiler;
1264
+ constructor(compiler: FaustCompiler);
1265
+ from(name: string, code: string, args: string): Record<string, string>;
1266
+ }
1267
+ export interface IFaustCmajor {
1268
+ /**
1269
+ * Generates auxiliary files from Faust code. The output depends on the compiler options.
1270
+ *
1271
+ * @param name - the DSP's name
1272
+ * @param code - Faust code
1273
+ * @param args - compilation args
1274
+ * @returns the Cmajor compiled string
1275
+ */
1276
+ compile(name: string, code: string, args: string): string;
1277
+ }
1278
+ export declare class FaustCmajor implements IFaustCmajor {
1279
+ private fCompiler;
1280
+ constructor(compiler: FaustCompiler);
1281
+ compile(name: string, code: string, args: string): string;
1282
+ }
1283
+ export interface WavEncoderOptions {
1284
+ bitDepth: number;
1285
+ float?: boolean;
1286
+ symmetric?: boolean;
1287
+ shared?: boolean;
1288
+ sampleRate: number;
1289
+ }
1290
+ /**
1291
+ * Code from https://github.com/mohayonao/wav-encoder
1292
+ */
1293
+ export declare class WavEncoder {
1294
+ static encode(audioBuffer: Float32Array[], options: WavEncoderOptions): ArrayBuffer;
1295
+ private static writeHeader;
1296
+ private static writeData;
1297
+ }
1298
+ export interface WavDecoderOptions {
1299
+ symmetric?: boolean;
1300
+ shared?: boolean;
1301
+ }
1302
+ /**
1303
+ * Code from https://github.com/mohayonao/wav-decoder
1304
+ */
1305
+ export declare class WavDecoder {
1306
+ static decode(buffer: ArrayBuffer, options?: WavDecoderOptions): {
1307
+ numberOfChannels: number;
1308
+ length: number;
1309
+ sampleRate: number;
1310
+ channelData: Float32Array[];
1311
+ };
1312
+ private static decodeFormat;
1313
+ private static decodeData;
1314
+ private static readPCM;
1315
+ }
1316
+ /** Read metadata and fetch soundfiles */
1317
+ export declare class SoundfileReader {
1318
+ static get fallbackPaths(): string[];
1319
+ /**
1320
+ * Extract the parent URL from an URL.
1321
+ * @param url : the URL
1322
+ * @returns : the parent URL
1323
+ */
1324
+ private static getParentUrl;
1325
+ /**
1326
+ * Convert an audio buffer to audio data.
1327
+ *
1328
+ * @param audioBuffer : the audio buffer to convert
1329
+ * @returns : the audio data
1330
+ */
1331
+ private static toAudioData;
1332
+ /**
1333
+ * Extract the URLs from the metadata.
1334
+ *
1335
+ * @param dspMeta : the metadata
1336
+ * @returns : the URLs
1337
+ */
1338
+ static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory["soundfiles"];
1339
+ /**
1340
+ * Check if the file exists.
1341
+ *
1342
+ * @param url : the url of the file to check
1343
+ * @returns : true if the file exists, otherwise false
1344
+ */
1345
+ private static checkFileExists;
1346
+ /**
1347
+ * Fetch the soundfile.
1348
+ *
1349
+ * @param url : the url of the soundfile
1350
+ * @param audioCtx : the audio context
1351
+ * @returns : the audio data
1352
+ */
1353
+ private static fetchSoundfile;
1354
+ /**
1355
+ * Load the soundfile.
1356
+ *
1357
+ * @param filename : the filename
1358
+ * @param metaUrls : the metadata URLs
1359
+ * @param soundfiles : the soundfiles
1360
+ * @param audioCtx : the audio context
1361
+ */
1362
+ private static loadSoundfile;
1363
+ /**
1364
+ * Load the soundfiles, public API.
1365
+ *
1366
+ * @param dspMeta : the metadata
1367
+ * @param soundfilesIn : the soundfiles
1368
+ * @param audioCtx : the audio context
1369
+ * @returns : the soundfiles
1370
+ */
1371
+ static loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory["soundfiles"], audioCtx: BaseAudioContext): Promise<LooseFaustDspFactory["soundfiles"]>;
1372
+ }
1373
+ declare const FaustAudioWorkletNode_base: {
1374
+ new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode;
1375
+ prototype: AudioWorkletNode;
1376
+ };
1377
+ /**
1378
+ * Base class for Monophonic and Polyphonic AudioWorkletNode
1379
+ */
1380
+ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends FaustAudioWorkletNode_base {
1381
+ #private;
1382
+ protected fJSONDsp: FaustDspMeta;
1383
+ protected fJSON: string;
1384
+ protected fInputsItems: string[];
1385
+ protected fOutputHandler: OutputParamHandler | null;
1386
+ protected fComputeHandler: ComputeHandler | null;
1387
+ protected fPlotHandler: PlotHandler | null;
1388
+ protected fUICallback: UIHandler;
1389
+ protected fDescriptor: FaustUIInputItem[];
1390
+ protected fCommunicator: FaustAudioWorkletNodeCommunicator;
1391
+ constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial<FaustAudioWorkletNodeOptions<Poly>>);
1392
+ protected handleMessageAux: (e: MessageEvent) => void;
1393
+ private handleDeviceMotion;
1394
+ private handleDeviceOrientation;
1395
+ /** Setup accelerometer and gyroscope handlers */
1396
+ startSensors(): Promise<void>;
1397
+ stopSensors(): void;
1398
+ setOutputParamHandler(handler: OutputParamHandler | null): void;
1399
+ getOutputParamHandler(): OutputParamHandler | null;
1400
+ setComputeHandler(handler: ComputeHandler | null): void;
1401
+ getComputeHandler(): ComputeHandler | null;
1402
+ setPlotHandler(handler: PlotHandler | null): void;
1403
+ getPlotHandler(): PlotHandler | null;
1404
+ setupWamEventHandler(): void;
1405
+ getNumInputs(): number;
1406
+ getNumOutputs(): number;
1407
+ compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
1408
+ metadata(handler: MetadataHandler): void;
1409
+ midiMessage(data: number[] | Uint8Array): void;
1410
+ ctrlChange(channel: number, ctrl: number, value: number): void;
1411
+ pitchWheel(channel: number, wheel: number): void;
1412
+ keyOn(channel: number, pitch: number, velocity: number): void;
1413
+ keyOff(channel: number, pitch: number, velocity: number): void;
1414
+ get hasAccInput(): boolean;
1415
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
1416
+ get hasGyrInput(): boolean;
1417
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
1418
+ setParamValue(path: string, value: number): void;
1419
+ getParamValue(path: string): number;
1420
+ getParams(): string[];
1421
+ getMeta(): FaustDspMeta;
1422
+ getJSON(): string;
1423
+ getUI(): FaustUIDescriptor;
1424
+ getDescriptors(): FaustUIInputItem[];
1425
+ start(): void;
1426
+ stop(): void;
1427
+ destroy(): void;
1428
+ }
1429
+ /**
1430
+ * Monophonic AudioWorkletNode
1431
+ */
1432
+ export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<false> implements IFaustMonoWebAudioDsp {
1433
+ onprocessorerror: (e: Event) => never;
1434
+ constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<false>> & Pick<FaustAudioWorkletNodeOptions<false>, "processorOptions">);
1435
+ }
1436
+ /**
1437
+ * Polyphonic AudioWorkletNode
1438
+ */
1439
+ export declare class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode<true> implements IFaustPolyWebAudioDsp {
1440
+ private fJSONEffect;
1441
+ onprocessorerror: (e: Event) => never;
1442
+ constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<true>> & Pick<FaustAudioWorkletNodeOptions<true>, "processorOptions">);
1443
+ keyOn(channel: number, pitch: number, velocity: number): void;
1444
+ keyOff(channel: number, pitch: number, velocity: number): void;
1445
+ allNotesOff(hard: boolean): void;
1446
+ getMeta(): FaustDspMeta;
1447
+ getJSON(): string;
1448
+ getUI(): FaustUIDescriptor;
1449
+ }
1450
+ declare const FaustScriptProcessorNode_base: {
1451
+ new (): ScriptProcessorNode;
1452
+ prototype: ScriptProcessorNode;
1453
+ };
1454
+ /**
1455
+ * Base class for Monophonic and Polyphonic ScriptProcessorNode
1456
+ */
1457
+ export declare class FaustScriptProcessorNode<Poly extends boolean = false> extends FaustScriptProcessorNode_base {
1458
+ protected fDSPCode: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;
1459
+ protected fInputs: Float32Array[];
1460
+ protected fOutputs: Float32Array[];
1461
+ protected handleDeviceMotion: any;
1462
+ protected handleDeviceOrientation: any;
1463
+ init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void;
1464
+ /** Start accelerometer and gyroscope handlers */
1465
+ startSensors(): Promise<void>;
1466
+ /** Stop accelerometer and gyroscope handlers */
1467
+ stopSensors(): void;
1468
+ compute(input: Float32Array[], output: Float32Array[]): boolean;
1469
+ setOutputParamHandler(handler: OutputParamHandler): void;
1470
+ getOutputParamHandler(): OutputParamHandler | null;
1471
+ setComputeHandler(handler: ComputeHandler): void;
1472
+ getComputeHandler(): ComputeHandler | null;
1473
+ setPlotHandler(handler: PlotHandler): void;
1474
+ getPlotHandler(): PlotHandler | null;
1475
+ getNumInputs(): number;
1476
+ getNumOutputs(): number;
1477
+ metadata(handler: MetadataHandler): void;
1478
+ midiMessage(data: number[] | Uint8Array): void;
1479
+ ctrlChange(chan: number, ctrl: number, value: number): void;
1480
+ pitchWheel(chan: number, value: number): void;
1481
+ keyOn(channel: number, pitch: number, velocity: number): void;
1482
+ keyOff(channel: number, pitch: number, velocity: number): void;
1483
+ setParamValue(path: string, value: number): void;
1484
+ getParamValue(path: string): number;
1485
+ getParams(): string[];
1486
+ getMeta(): FaustDspMeta;
1487
+ getJSON(): string;
1488
+ getDescriptors(): FaustUIInputItem[];
1489
+ getUI(): FaustUIDescriptor;
1490
+ start(): void;
1491
+ stop(): void;
1492
+ destroy(): void;
1493
+ get hasAccInput(): boolean;
1494
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
1495
+ get hasGyrInput(): boolean;
1496
+ propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
1497
+ }
1498
+ export declare class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode<false> implements IFaustMonoWebAudioDsp {
1499
+ }
1500
+ export declare class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode<true> implements IFaustPolyWebAudioDsp {
1501
+ keyOn(channel: number, pitch: number, velocity: number): void;
1502
+ keyOff(channel: number, pitch: number, velocity: number): void;
1503
+ allNotesOff(hard: boolean): void;
1504
+ }
1505
+ export interface GeneratorSupportingSoundfiles {
1506
+ /**
1507
+ * Attach a map of id - audio data, call after `compile()` before `createNode()`
1508
+ *
1509
+ * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`
1510
+ */
1511
+ addSoundfiles(soundfileMap: Record<string, AudioData$1>): void;
1512
+ /**
1513
+ * Get a list of soundfiles needed, call after `compile()`
1514
+ */
1515
+ getSoundfileList(): string[];
1516
+ }
1517
+ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
1518
+ /**
1519
+ * Compile a monophonic DSP factory from given code.
1520
+ *
1521
+ * @param compiler - the Faust compiler
1522
+ * @param name - the DSP name
1523
+ * @param code - the DSP code
1524
+ * @param args - the compilation parameters
1525
+ * @returns the compiled factory or 'null' if failure
1526
+ */
1527
+ compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{
1528
+ factory: FaustDspFactory | null;
1529
+ name?: string;
1530
+ meta?: FaustDspMeta;
1531
+ } | null>;
1532
+ /**
1533
+ * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1534
+ *
1535
+ * @param context - the WebAudio context
1536
+ * @param name - DSP name, can be used for processorName
1537
+ * @param factory - default is the compiled factory
1538
+ * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
1539
+ * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
1540
+ * @param processorName - AudioWorklet Processor name
1541
+ * @param processorOptions - Additional AudioWorklet Processor options
1542
+ * @returns the compiled WebAudio node or 'null' if failure
1543
+ */
1544
+ createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<IFaustMonoWebAudioNode | null>;
1545
+ /**
1546
+ * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1547
+ *
1548
+ * @param context - the WebAudio context
1549
+ * @param fftUtils - should be an anonymous class with static methods, without any import from outside
1550
+ * @param name - DSP name, can be used for processorName
1551
+ * @param factory - default is the compiled factory
1552
+ * @param fftOptions - initial FFT options
1553
+ * @param processorName - AudioWorklet Processor name
1554
+ * @param processorOptions - Additional AudioWorklet Processor options
1555
+ * @returns the compiled WebAudio node or 'null' if failure
1556
+ */
1557
+ createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
1558
+ /**
1559
+ * Create a monophonic Offline processor.
1560
+ *
1561
+ * @param sampleRate - the sample rate in Hz
1562
+ * @param bufferSize - the buffer size in frames
1563
+ * @param factory - default is the compiled factory
1564
+ * @param context - if this exists, will be used to fetch soundfiles online
1565
+ * @returns the compiled processor or 'null' if failure
1566
+ */
1567
+ createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, context?: BaseAudioContext): Promise<IFaustMonoOfflineProcessor | null>;
1568
+ /**
1569
+ * Get DSP JSON description with its UI and metadata as object.
1570
+ *
1571
+ * @return the DSP JSON description as object
1572
+ */
1573
+ getMeta(): FaustDspMeta;
1574
+ /**
1575
+ * Get DSP JSON description with its UI and metadata.
1576
+ *
1577
+ * @return the DSP JSON description
1578
+ */
1579
+ getJSON(): string;
1580
+ /**
1581
+ * Get DSP UI description.
1582
+ *
1583
+ * @return the DSP UI description
1584
+ */
1585
+ getUI(): FaustUIDescriptor;
1586
+ }
1587
+ export interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {
1588
+ /**
1589
+ * Compile a monophonic DSP factory from given code.
1590
+ *
1591
+ * @param compiler - the Faust compiler
1592
+ * @param name - the DSP name
1593
+ * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)
1594
+ * @param args - the compilation parameters
1595
+ * @param effectCode - optional effect DSP code
1596
+ * @returns the compiled factory or 'null' if failure
1597
+ */
1598
+ compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{
1599
+ voiceFactory: FaustDspFactory | null;
1600
+ effectFactory?: FaustDspFactory | null;
1601
+ } | null>;
1602
+ /**
1603
+ * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1604
+ *
1605
+ * @param context the WebAudio context
1606
+ * @param voices - the number of voices
1607
+ * @param name - AudioWorklet Processor name
1608
+ * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1609
+ * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)
1610
+ * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1611
+ * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
1612
+ * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
1613
+ * @param processorOptions - Additional AudioWorklet Processor options
1614
+ * @returns the compiled WebAudio node or 'null' if failure
1615
+ */
1616
+ 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>;
1617
+ /**
1618
+ * Create a monophonic Offline processor.
1619
+ *
1620
+ * @param sampleRate - the sample rate in Hz
1621
+ * @param bufferSize - the buffer size in frames
1622
+ * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1623
+ * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)
1624
+ * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1625
+ * @param context - if this exists, will be used to fetch soundfiles online
1626
+ * @returns the compiled processor or 'null' if failure
1627
+ */
1628
+ createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, context?: BaseAudioContext): Promise<IFaustPolyOfflineProcessor | null>;
1629
+ /**
1630
+ * Get DSP JSON description with its UI and metadata as object.
1631
+ *
1632
+ * @return the DSP JSON description as object
1633
+ */
1634
+ getMeta(): FaustDspMeta;
1635
+ /**
1636
+ * Get DSP JSON description with its UI and metadata.
1637
+ *
1638
+ * @return the DSP JSON description
1639
+ */
1640
+ getJSON(): string;
1641
+ /**
1642
+ * Get DSP UI description.
1643
+ *
1644
+ * @return the DSP UI description
1645
+ */
1646
+ getUI(): FaustUIDescriptor;
1647
+ }
1648
+ export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
1649
+ private static gWorkletProcessors;
1650
+ name: string;
1651
+ factory: FaustDspFactory | null;
1652
+ constructor();
1653
+ compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<this | null>;
1654
+ addSoundfiles(soundfileMap: Record<string, AudioData$1>): void;
1655
+ getSoundfileList(): string[];
1656
+ 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>;
1657
+ createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
1658
+ createAudioWorkletProcessor(name?: string, factory?: LooseFaustDspFactory, processorName?: string): Promise<{
1659
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1660
+ prototype: AudioWorkletProcessor;
1661
+ parameterDescriptors: AudioParamDescriptor[];
1662
+ }>;
1663
+ createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, context?: BaseAudioContext): Promise<FaustMonoOfflineProcessor>;
1664
+ getMeta(): any;
1665
+ getJSON(): string;
1666
+ getUI(): any;
1667
+ }
1668
+ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
1669
+ private static gWorkletProcessors;
1670
+ name: string;
1671
+ voiceFactory: FaustDspFactory | null;
1672
+ effectFactory: FaustDspFactory | null;
1673
+ mixerBuffer: Uint8Array;
1674
+ mixerModule: WebAssembly.Module;
1675
+ constructor();
1676
+ compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCodeAux?: string): Promise<this | null>;
1677
+ addSoundfiles(soundfileMap: Record<string, AudioData$1>): void;
1678
+ getSoundfileList(): string[];
1679
+ 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>;
1680
+ createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
1681
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1682
+ prototype: AudioWorkletProcessor;
1683
+ parameterDescriptors: AudioParamDescriptor[];
1684
+ }>;
1685
+ createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, context?: BaseAudioContext): Promise<FaustPolyOfflineProcessor>;
1686
+ getMeta(): FaustDspMeta;
1687
+ getJSON(): string;
1688
+ getUI(): FaustUIDescriptor;
1689
+ }
1690
+
1691
+ export {
1692
+ AudioData$1 as AudioData,
1693
+ };
1694
+
1695
+ export {};