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