@grame/faustwasm 0.16.4 → 0.16.6

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.
@@ -1,1824 +0,0 @@
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 InputParamHandler = (path: string, value: number) => void;
417
- export type ComputeHandler = (buffer_size: number) => void;
418
- export type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: {
419
- type: string;
420
- data: any;
421
- }[]) => void;
422
- export type MetadataHandler = (key: string, value: string) => void;
423
- export type UIHandler = (item: FaustUIItem) => void;
424
- export type SensorEventHandler = (val: number) => void;
425
- export type SensorEventHandlers = {
426
- x: SensorEventHandler[];
427
- y: SensorEventHandler[];
428
- z: SensorEventHandler[];
429
- };
430
- /** Definition of the AudioBufferItem type */
431
- export interface AudioBufferItem {
432
- pathName: string;
433
- audioBuffer: AudioBuffer;
434
- }
435
- /** Definition of the SoundfileItem type */
436
- export interface SoundfileItem {
437
- /** Name of the soundfile */
438
- name: string;
439
- /** URL of the soundfile */
440
- url: string;
441
- /** Index in the DSP struct */
442
- index: number;
443
- /** Base pointer in wasm memory */
444
- basePtr: number;
445
- }
446
- /**
447
- * WasmAllocator is a basic memory management class designed to allocate
448
- * blocks of memory within a WebAssembly.Memory object. It provides a simple
449
- * alloc method to allocate a contiguous block of memory of a specified size.
450
- *
451
- * The allocator operates by keeping a linear progression through the memory,
452
- * always allocating the next block at the end of the last. This approach does not
453
- * handle freeing of memory or reuse of memory spaces.
454
- */
455
- export declare class WasmAllocator {
456
- private readonly memory;
457
- private allocatedBytes;
458
- constructor(memory: WebAssembly.Memory, offset: number);
459
- /**
460
- * Allocates a block of memory of the specified size, returning the pointer to the
461
- * beginning of the block. The block is allocated at the current offset and the
462
- * offset is incremented by the size of the block.
463
- *
464
- * @param sizeInBytes The size of the block to allocate in bytes.
465
- * @returns The offset (pointer) to the beginning of the allocated block.
466
- */
467
- alloc(sizeInBytes: number): number;
468
- /**
469
- * Returns the underlying buffer object.
470
- *
471
- * @returns The buffer object.
472
- */
473
- getBuffer(): ArrayBuffer;
474
- /**
475
- * Returns the Int32 view of the underlying buffer object.
476
- *
477
- * @returns The view of the memory buffer as Int32Array.
478
- */
479
- getInt32Array(): Int32Array;
480
- /**
481
- * Returns the Int64 view of the underlying buffer object.
482
- *
483
- * @returns The view of the memory buffer as BigInt64Array.
484
- */
485
- getInt64Array(): BigInt64Array;
486
- /**
487
- * Returns the Float32 view of the underlying buffer object.
488
- *
489
- * @returns The view of the memory buffer as Float32Array.
490
- */
491
- getFloat32Array(): Float32Array;
492
- /**
493
- * Returns the Float64 view of the underlying buffer object..
494
- *
495
- * @returns The view of the memory buffer as Float64Array.
496
- */
497
- getFloat64Array(): Float64Array;
498
- }
499
- /**
500
- * Soundfile class to handle soundfile data in wasm memory.
501
- */
502
- export declare class Soundfile {
503
- /** Maximum number of soundfile parts. */
504
- static get MAX_SOUNDFILE_PARTS(): number;
505
- /** Maximum number of channels. */
506
- static get MAX_CHAN(): number;
507
- /** Maximum buffer size in frames. */
508
- static get BUFFER_SIZE(): number;
509
- /** Default sample rate. */
510
- static get SAMPLE_RATE(): number;
511
- /** Pointer to the soundfile structure in wasm memory */
512
- private readonly fPtr;
513
- private readonly fBuffers;
514
- private readonly fLength;
515
- private readonly fSR;
516
- private readonly fOffset;
517
- private readonly fSampleSize;
518
- private readonly fPtrSize;
519
- private readonly fIntSize;
520
- private readonly fAllocator;
521
- constructor(allocator: WasmAllocator, sampleSize: number, curChan: number, length: number, maxChan: number, totalParts: number);
522
- private allocBuffers;
523
- shareBuffers(curChan: number, maxChan: number): void;
524
- copyToOut(part: number, maxChannels: number, offset: number, audioData: AudioData$1): void;
525
- copyToOutReal32(maxChannels: number, offset: number, audioData: AudioData$1): void;
526
- copyToOutReal64(maxChannels: number, offset: number, audioData: AudioData$1): void;
527
- emptyFile(part: number, offset: number): number;
528
- displayMemory(where?: string, mem?: boolean): void;
529
- getPtr(): number;
530
- getHEAP32(): Int32Array;
531
- getHEAPFloat32(): Float32Array;
532
- getHEAPFloat64(): Float64Array;
533
- }
534
- /**
535
- * DSP implementation that mimic the C++ 'dsp' class:
536
- * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers
537
- * - an output handler can be set to treat produced output controllers (like 'bargraph')
538
- * - an input handler can be set to follow control parameter changes (like sliders)
539
- * - regular controllers are handled using setParamValue/getParamValue and getParams methods
540
- */
541
- export interface IFaustBaseWebAudioDsp {
542
- /**
543
- * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).
544
- *
545
- * @param handler - the output handler
546
- */
547
- setOutputParamHandler(handler: OutputParamHandler | null): void;
548
- /**
549
- * Get the parameter output handler.
550
- *
551
- * @return the current output handler
552
- */
553
- getOutputParamHandler(): OutputParamHandler | null;
554
- /**
555
- * Call the output parameter handler with a path and value.
556
- *
557
- * @param path - the path to the wanted parameter (retrieved using 'getParams' method)
558
- * @param value - the float value for the wanted control
559
- */
560
- callOutputParamHandler(path: string, value: number): void;
561
- /**
562
- * Set the parameter input handler, to be called when input parameters change (like sliders).
563
- *
564
- * @param handler - the input handler
565
- */
566
- setInputParamHandler(handler: InputParamHandler | null): void;
567
- /**
568
- * Get the parameter input handler.
569
- *
570
- * @return the current input handler
571
- */
572
- getInputParamHandler(): InputParamHandler | null;
573
- /**
574
- * Call the input parameter handler with a path and value.
575
- *
576
- * @param path - the path to the wanted parameter (retrieved using 'getParams' method)
577
- * @param value - the float value for the wanted control
578
- */
579
- callInputParamHandler(path: string, value: number): void;
580
- /**
581
- * Set the compute handler, to be called in the 'compute' method with buffer size.
582
- *
583
- * @param handler - the compute handler
584
- */
585
- setComputeHandler(handler: ComputeHandler | null): void;
586
- /**
587
- * Get the compute handler.
588
- *
589
- * @return the current output handler
590
- */
591
- getComputeHandler(): ComputeHandler | null;
592
- /**
593
- * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).
594
- *
595
- * @param handler - the plot handler
596
- */
597
- setPlotHandler(handler: PlotHandler | null): void;
598
- /**
599
- * Get the plot handler.
600
- *
601
- * @return the current plot handler
602
- */
603
- getPlotHandler(): PlotHandler | null;
604
- /**
605
- * Return instance number of audio inputs.
606
- *
607
- * @return the instance number of audio inputs
608
- */
609
- getNumInputs(): number;
610
- /**
611
- * Return instance number of audio outputs.
612
- *
613
- * @return the instance number of audio outputs
614
- */
615
- getNumOutputs(): number;
616
- /**
617
- * DSP instance computation, to be called with successive input/output audio buffers, using their size.
618
- *
619
- * @param inputs - the input audio buffers
620
- * @param outputs - the output audio buffers
621
- */
622
- compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
623
- /**
624
- * Give a handler to be called on 'declare key value' kind of metadata.
625
- *
626
- * @param handler - the handler to be used
627
- */
628
- metadata(handler: MetadataHandler): void;
629
- /**
630
- * Handle untyped MIDI messages.
631
- *
632
- * @param data - and arry of MIDI bytes
633
- */
634
- midiMessage(data: number[] | Uint8Array): void;
635
- /**
636
- * Handle MIDI ctrlChange messages.
637
- *
638
- * @param channel - the MIDI channel (0..15, not used for now)
639
- * @param ctrl - the MIDI controller number (0..127)
640
- * @param value - the MIDI controller value (0..127)
641
- */
642
- ctrlChange(chan: number, ctrl: number, value: number): void;
643
- /**
644
- * Handle MIDI pitchWheel messages.
645
- *
646
- * @param channel - the MIDI channel (0..15, not used for now)
647
- * @param value - the MIDI controller value (0..16383)
648
- */
649
- pitchWheel(chan: number, value: number): void;
650
- /**
651
- * Handle MIDI keyOn messages.
652
- * @param channel
653
- * @param pitch
654
- * @param velocity
655
- */
656
- keyOn(channel: number, pitch: number, velocity: number): void;
657
- /**
658
- * Handle MIDI keyOn messages.
659
- * @param channel
660
- * @param pitch
661
- * @param velocity
662
- */
663
- keyOff(channel: number, pitch: number, velocity: number): void;
664
- /**
665
- * Set parameter value.
666
- *
667
- * @param path - the path to the wanted parameter (retrieved using 'getParams' method)
668
- * @param val - the float value for the wanted control
669
- */
670
- setParamValue(path: string, value: number): void;
671
- /**
672
- * Get parameter value.
673
- *
674
- * @param path - the path to the wanted parameter (retrieved using 'getParams' method)
675
- *
676
- * @return the float value
677
- */
678
- getParamValue(path: string): number;
679
- /**
680
- * Get the table of all input parameters paths.
681
- *
682
- * @return the table of all input parameters paths
683
- */
684
- getParams(): string[];
685
- /**
686
- * Get DSP JSON description with its UI and metadata as object.
687
- *
688
- * @return the DSP JSON description as object
689
- */
690
- getMeta(): FaustDspMeta;
691
- /**
692
- * Get DSP UI description.
693
- *
694
- * @return the DSP UI description
695
- */
696
- getUI(): FaustUIDescriptor;
697
- /**
698
- * Get DSP UI items description.
699
- *
700
- * @return the DSP UI items description
701
- */
702
- getDescriptors(): FaustUIInputItem[];
703
- /**
704
- * Get DSP JSON description with its UI and metadata.
705
- *
706
- * @return the DSP JSON description
707
- */
708
- getJSON(): string;
709
- /**
710
- * Start accelerometer and gyroscope handlers.
711
- */
712
- startSensors(): void;
713
- /**
714
- * Stop accelerometer and gyroscope handlers.
715
- */
716
- stopSensors(): void;
717
- /** Indicating if the DSP handles the accelerometer */
718
- readonly hasAccInput: boolean;
719
- /**
720
- * Accelerometer handling.
721
- * accelerationIncludingGravity: DeviceMotionEvent["accelerationIncludingGravity"]
722
- * invert: boolean
723
- */
724
- propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert: boolean): void;
725
- /** Indicating if the DSP handles the gyroscope */
726
- readonly hasGyrInput: boolean;
727
- /**
728
- * Gyroscope handling.
729
- * event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">
730
- */
731
- propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
732
- /**
733
- * Reinitialize the DSP using its configured sample rate.
734
- */
735
- init(): void;
736
- /**
737
- * Reinitialize the DSP instance state using its configured sample rate.
738
- */
739
- instanceInit(): void;
740
- /**
741
- * Clear the DSP instance state.
742
- */
743
- instanceClear(): void;
744
- /**
745
- * Reinitialize the DSP instance constants using its configured sample rate.
746
- */
747
- instanceConstants(): void;
748
- /**
749
- * Reset DSP user interface parameters to their default values.
750
- */
751
- instanceResetUserInterface(): void;
752
- /**
753
- * Start the DSP audio processing.
754
- */
755
- start(): void;
756
- /**
757
- * Stop the DSP audio processing.
758
- */
759
- stop(): void;
760
- /**
761
- * Destroy the DSP.
762
- */
763
- destroy(): void;
764
- }
765
- export type IFaustMonoWebAudioDsp = IFaustBaseWebAudioDsp;
766
- export interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode {
767
- }
768
- export interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {
769
- /**
770
- * Handle MIDI keyOn messages.
771
- *
772
- * @param channel - the MIDI channel (0..15, not used for now)
773
- * @param pitch - the MIDI pitch value (0..127)
774
- * @param velocity - the MIDI velocity value (0..127)
775
- */
776
- keyOn(channel: number, pitch: number, velocity: number): void;
777
- /**
778
- * Handle MIDI keyOff messages.
779
- *
780
- * @param channel - the MIDI channel (0..15, not used for now)
781
- * @param pitch - the MIDI pitch value (0..127)
782
- * @param velocity - the MIDI velocity value (0..127)
783
- */
784
- keyOff(channel: number, pitch: number, velocity: number): void;
785
- /**
786
- * Stop all playing notes.
787
- *
788
- * @param hard - whether to immediately stop notes or put them in release mode
789
- */
790
- allNotesOff(hard: boolean): void;
791
- }
792
- export interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode {
793
- }
794
- export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
795
- protected fOutputHandler: OutputParamHandler | null;
796
- protected fInputHandler: InputParamHandler | null;
797
- protected fComputeHandler: ComputeHandler | null;
798
- protected fPlotHandler: PlotHandler | null;
799
- protected fCachedEvents: {
800
- type: string;
801
- data: any;
802
- }[];
803
- protected fBufferNum: number;
804
- protected fInChannels: Float32Array[] | Float64Array[];
805
- protected fOutChannels: Float32Array[] | Float64Array[];
806
- protected fOutputsTimer: number;
807
- protected fInputsItems: string[];
808
- protected fOutputsItems: string[];
809
- protected fDescriptor: FaustUIInputItem[];
810
- protected fSoundfiles: SoundfileItem[];
811
- protected fSoundfileBuffers: LooseFaustDspFactory["soundfiles"];
812
- /** Keep the end of memory offset before soundfiles */
813
- protected fEndMemory: number;
814
- protected fAcc: SensorEventHandlers;
815
- protected fGyr: SensorEventHandlers;
816
- protected fAudioInputs: number;
817
- protected fAudioOutputs: number;
818
- protected fBufferSize: number;
819
- protected fPtrSize: number;
820
- protected fSampleSize: number;
821
- protected fPitchwheelLabel: {
822
- path: string;
823
- chan: number;
824
- min: number;
825
- max: number;
826
- }[];
827
- protected fCtrlLabel: {
828
- path: string;
829
- chan: number;
830
- min: number;
831
- max: number;
832
- }[][];
833
- protected fMidiKeyLabel: {
834
- path: string;
835
- chan: number;
836
- min: number;
837
- max: number;
838
- }[][];
839
- protected fMidiKeyOnLabel: {
840
- path: string;
841
- chan: number;
842
- min: number;
843
- max: number;
844
- }[][];
845
- protected fMidiKeyOffLabel: {
846
- path: string;
847
- chan: number;
848
- min: number;
849
- max: number;
850
- }[][];
851
- protected fPathTable: {
852
- [address: string]: number;
853
- };
854
- protected fUICallback: UIHandler;
855
- protected fProcessing: boolean;
856
- protected fDestroyed: boolean;
857
- protected fFirstCall: boolean;
858
- protected fJSONDsp: FaustDspMeta;
859
- constructor(sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory["soundfiles"]);
860
- static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number): number;
861
- static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any): void;
862
- static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any): void;
863
- static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any): void;
864
- static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any): void;
865
- /** Split the soundfile names and return an array of names */
866
- static splitSoundfileNames(input: string): string[];
867
- get hasAccInput(): boolean;
868
- propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
869
- get hasGyrInput(): boolean;
870
- propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
871
- /** Build the accelerometer handler */
872
- private setupAccHandler;
873
- /** Build the gyroscope handler */
874
- private setupGyrHandler;
875
- static extractUrlsFromMeta(dspMeta: FaustDspMeta): string[];
876
- /**
877
- * Load a soundfile possibly containing several parts in the DSP struct.
878
- * Soundfile pointers are located at 'index' offset, to be read in the JSON file.
879
- * The DSP struct is located at baseDSP in the wasm memory,
880
- * either a monophonic DSP, or a voice in a polyphonic context.
881
- *
882
- * @param allocator : the wasm memory allocator
883
- * @param baseDSP : the base DSP in the wasm memory
884
- * @param name : the name of the soundfile
885
- * @param url : the url of the soundfile
886
- */
887
- private loadSoundfile;
888
- createSoundfile(allocator: WasmAllocator, soundfileIdList: string[], soundfiles: LooseFaustDspFactory["soundfiles"], maxChan?: number): Soundfile;
889
- /**
890
- * Init soundfiles memory.
891
- *
892
- * @param allocator : the wasm memory allocator
893
- * @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory
894
- */
895
- protected initSoundfileMemory(allocator: WasmAllocator, baseDSP: number): void;
896
- protected updateOutputs(): void;
897
- metadata(handler: MetadataHandler): void;
898
- compute(input: Float32Array[], output: Float32Array[]): boolean;
899
- setOutputParamHandler(handler: OutputParamHandler | null): void;
900
- getOutputParamHandler(): OutputParamHandler | null;
901
- callOutputParamHandler(path: string, value: number): void;
902
- setInputParamHandler(handler: InputParamHandler | null): void;
903
- getInputParamHandler(): InputParamHandler | null;
904
- callInputParamHandler(path: string, value: number): void;
905
- setComputeHandler(handler: ComputeHandler | null): void;
906
- getComputeHandler(): ComputeHandler | null;
907
- setPlotHandler(handler: PlotHandler | null): void;
908
- getPlotHandler(): PlotHandler | null;
909
- getNumInputs(): number;
910
- getNumOutputs(): number;
911
- midiMessage(data: number[] | Uint8Array): void;
912
- ctrlChange(channel: number, ctrl: number, value: number): void;
913
- keyOn(channel: number, pitch: number, velocity: number): void;
914
- keyOff(channel: number, pitch: number, velocity: number): void;
915
- pitchWheel(channel: number, wheel: number): void;
916
- setParamValue(path: string, value: number): void;
917
- getParamValue(path: string): number;
918
- getParams(): string[];
919
- getMeta(): FaustDspMeta;
920
- getJSON(): string;
921
- getUI(): FaustUIDescriptor;
922
- getDescriptors(): FaustUIInputItem[];
923
- hasSoundfiles(): boolean;
924
- startSensors(): void;
925
- stopSensors(): void;
926
- init(): void;
927
- instanceInit(): void;
928
- instanceClear(): void;
929
- instanceConstants(): void;
930
- instanceResetUserInterface(): void;
931
- start(): void;
932
- stop(): void;
933
- destroy(): void;
934
- }
935
- export declare class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {
936
- private fInstance;
937
- private fDSP;
938
- private fSampleRate;
939
- constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory["soundfiles"]);
940
- init(): void;
941
- instanceInit(): void;
942
- instanceClear(): void;
943
- instanceConstants(): void;
944
- instanceResetUserInterface(): void;
945
- private initMemory;
946
- toString(): string;
947
- compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)): boolean;
948
- metadata(handler: MetadataHandler): void;
949
- getNumInputs(): number;
950
- getNumOutputs(): number;
951
- setParamValue(path: string, value: number): void;
952
- getParamValue(path: string): number;
953
- getMeta(): FaustDspMeta;
954
- getJSON(): string;
955
- getDescriptors(): FaustUIInputItem[];
956
- getUI(): FaustUIDescriptor;
957
- }
958
- export declare class FaustWebAudioDspVoice {
959
- static get kActiveVoice(): number;
960
- static get kFreeVoice(): number;
961
- static get kReleaseVoice(): number;
962
- static get kLegatoVoice(): number;
963
- static get kNoVoice(): number;
964
- static get VOICE_STOP_LEVEL(): number;
965
- private fFreqLabel;
966
- private fGateLabel;
967
- private fGainLabel;
968
- private fKeyLabel;
969
- private fVelLabel;
970
- private fDSP;
971
- private fAPI;
972
- private fSampleRate;
973
- fCurNote: number;
974
- fNextNote: number;
975
- fNextVel: number;
976
- fDate: number;
977
- fLevel: number;
978
- constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: {
979
- [address: string]: number;
980
- }, sampleRate: number);
981
- static midiToFreq(note: number): number;
982
- static normalizeVelocity(velocity: number): number;
983
- init(sampleRate: number): void;
984
- instanceInit(): void;
985
- instanceClear(): void;
986
- instanceConstants(): void;
987
- instanceResetUserInterface(): void;
988
- private extractPaths;
989
- keyOn(pitch: number, velocity: number, legato?: boolean): void;
990
- keyOff(hard?: boolean): void;
991
- computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number): void;
992
- compute(bufferSize: number, $inputs: number, $outputs: number): void;
993
- setParamValue(index: number, value: number): void;
994
- getParamValue(index: number): number;
995
- }
996
- export declare class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {
997
- private fInstance;
998
- private fEffect;
999
- private fJSONEffect;
1000
- private fAudioMixing;
1001
- private fAudioMixingHalf;
1002
- private fVoiceTable;
1003
- private fSampleRate;
1004
- constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number, soundfiles: LooseFaustDspFactory["soundfiles"]);
1005
- init(): void;
1006
- instanceInit(): void;
1007
- instanceClear(): void;
1008
- instanceConstants(): void;
1009
- instanceResetUserInterface(): void;
1010
- private initMemory;
1011
- toString(): string;
1012
- private allocVoice;
1013
- private getPlayingVoice;
1014
- private getFreeVoice;
1015
- compute(input: Float32Array[], output: Float32Array[]): boolean;
1016
- getNumInputs(): number;
1017
- getNumOutputs(): number;
1018
- private static findPath;
1019
- setParamValue(path: string, value: number): void;
1020
- getParamValue(path: string): number;
1021
- getMeta(): FaustDspMeta;
1022
- getJSON(): string;
1023
- getUI(): FaustUIDescriptor;
1024
- getDescriptors(): FaustUIInputItem[];
1025
- midiMessage(data: number[] | Uint8Array): void;
1026
- ctrlChange(channel: number, ctrl: number, value: number): void;
1027
- keyOn(channel: number, pitch: number, velocity: number): void;
1028
- keyOff(channel: number, pitch: number, velocity: number): void;
1029
- allNotesOff(hard?: boolean): void;
1030
- }
1031
- /**
1032
- * Injected in the string to be compiled on AudioWorkletProcessor side
1033
- */
1034
- export interface FaustData {
1035
- processorName: string;
1036
- dspName: string;
1037
- dspMeta: FaustDspMeta;
1038
- poly: boolean;
1039
- effectMeta?: FaustDspMeta;
1040
- }
1041
- export interface FaustAudioWorkletProcessorDependencies<Poly extends boolean = false> {
1042
- FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;
1043
- FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;
1044
- FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;
1045
- FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;
1046
- FaustWasmInstantiator: typeof FaustWasmInstantiator;
1047
- FaustAudioWorkletProcessorCommunicator: typeof FaustAudioWorkletProcessorCommunicator;
1048
- }
1049
- export interface FaustAudioWorkletNodeOptions<Poly extends boolean = false> extends AudioWorkletNodeOptions {
1050
- processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;
1051
- }
1052
- export interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
1053
- processorOptions: FaustMonoAudioWorkletProcessorOptions;
1054
- }
1055
- export interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
1056
- processorOptions: FaustPolyAudioWorkletProcessorOptions;
1057
- }
1058
- export interface FaustAudioWorkletProcessorOptions {
1059
- name: string;
1060
- sampleSize: number;
1061
- moduleId?: string;
1062
- instanceId?: string;
1063
- }
1064
- export interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
1065
- factory: LooseFaustDspFactory;
1066
- }
1067
- export interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
1068
- voiceFactory: LooseFaustDspFactory;
1069
- mixerModule: WebAssembly.Module;
1070
- voices: number;
1071
- effectFactory?: LooseFaustDspFactory;
1072
- }
1073
- export declare const getFaustAudioWorkletProcessor: <Poly extends boolean = false>(dependencies: FaustAudioWorkletProcessorDependencies<Poly>, faustData: FaustData, register?: boolean) => {
1074
- new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1075
- prototype: AudioWorkletProcessor;
1076
- parameterDescriptors: AudioParamDescriptor[];
1077
- };
1078
- export interface FaustFFTOptionsData {
1079
- fftSize: number;
1080
- fftOverlap: number;
1081
- noIFFT: boolean;
1082
- /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */
1083
- defaultWindowFunction: number;
1084
- }
1085
- /**
1086
- * Injected in the string to be compiled on AudioWorkletProcessor side
1087
- */
1088
- export interface FaustFFTData {
1089
- processorName: string;
1090
- dspName: string;
1091
- dspMeta: FaustDspMeta;
1092
- fftOptions?: Partial<FaustFFTOptionsData>;
1093
- }
1094
- export interface FaustFFTAudioWorkletProcessorDependencies {
1095
- FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;
1096
- FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;
1097
- FaustWasmInstantiator: typeof FaustWasmInstantiator;
1098
- FaustAudioWorkletProcessorCommunicator: typeof FaustAudioWorkletProcessorCommunicator;
1099
- FFTUtils: typeof FFTUtils;
1100
- }
1101
- export interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
1102
- processorOptions: FaustFFTAudioWorkletProcessorOptions;
1103
- }
1104
- export interface FaustFFTAudioWorkletProcessorOptions {
1105
- name: string;
1106
- sampleSize: number;
1107
- factory: LooseFaustDspFactory;
1108
- moduleId?: string;
1109
- instanceId?: string;
1110
- }
1111
- export declare const getFaustFFTAudioWorkletProcessor: (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register?: boolean) => {
1112
- new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1113
- prototype: AudioWorkletProcessor;
1114
- parameterDescriptors: AudioParamDescriptor[];
1115
- };
1116
- export interface ILibFaust extends LibFaustWasm {
1117
- module(): FaustModule;
1118
- fs(): typeof FS;
1119
- }
1120
- export declare class LibFaust implements ILibFaust {
1121
- private fModule;
1122
- private fCompiler;
1123
- private fFileSystem;
1124
- constructor(module: FaustModule);
1125
- module(): FaustModule;
1126
- fs(): typeof FS;
1127
- version(): string;
1128
- createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean): FaustDspWasm;
1129
- deleteDSPFactory(cFactory: number): void;
1130
- expandDSP(name: string, code: string, args: string): string;
1131
- generateAuxFiles(name: string, code: string, args: string): boolean;
1132
- deleteAllDSPFactories(): void;
1133
- getErrorAfterException(): string;
1134
- cleanupAfterException(): void;
1135
- getInfos(what: FaustInfoType): string;
1136
- toString(): string;
1137
- }
1138
- export declare const ab2str: (buf: Uint8Array) => any;
1139
- export declare const str2ab: (str: string) => Uint8Array<ArrayBuffer>;
1140
- export interface IFaustCompiler {
1141
- /**
1142
- * Gives the Faust compiler version.
1143
- * @return a version string
1144
- */
1145
- version(): string;
1146
- /**
1147
- * Gives the last compilation error.
1148
- * @return an error string
1149
- */
1150
- getErrorMessage(): string;
1151
- /**
1152
- * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances.
1153
- * This function is running asynchronously.
1154
- *
1155
- * @param name - an arbitrary name for the Faust factory
1156
- * @param code - Faust dsp code
1157
- * @param args - the compiler options
1158
- * @returns returns the wasm factory
1159
- */
1160
- createMonoDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
1161
- /**
1162
- * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances.
1163
- * This function is running asynchronously.
1164
- *
1165
- * @param name - an arbitrary name for the Faust factory
1166
- * @param code - Faust dsp code
1167
- * @param args - the compiler options
1168
- * @returns returns the wasm factory
1169
- */
1170
- createPolyDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
1171
- /**
1172
- * Delete a dsp factory.
1173
- *
1174
- * @param factory - the factory to be deleted
1175
- */
1176
- deleteDSPFactory(factory: FaustDspFactory): void;
1177
- /**
1178
- * Expand Faust code i.e. linearize included libraries.
1179
- *
1180
- * @param code - Faust dsp code
1181
- * @param args - the compiler options
1182
- * @returns returns the expanded dsp code
1183
- */
1184
- expandDSP(code: string, args: string): string | null;
1185
- /**
1186
- * Generates auxiliary files from Faust code. The output depends on the compiler options.
1187
- *
1188
- * @param name - an arbitrary name for the Faust module
1189
- * @param code - Faust dsp code
1190
- * @param args - the compiler options
1191
- * @returns whether the generation actually succeded
1192
- */
1193
- generateAuxFiles(name: string, code: string, args: string): boolean;
1194
- /**
1195
- * Delete all factories.
1196
- */
1197
- deleteAllDSPFactories(): void;
1198
- fs(): typeof FS;
1199
- getAsyncInternalMixerModule(isDouble?: boolean): Promise<{
1200
- mixerBuffer: Uint8Array;
1201
- mixerModule: WebAssembly.Module;
1202
- }>;
1203
- getSyncInternalMixerModule(isDouble?: boolean): {
1204
- mixerBuffer: Uint8Array;
1205
- mixerModule: WebAssembly.Module;
1206
- };
1207
- }
1208
- export declare class FaustCompiler implements IFaustCompiler {
1209
- private fLibFaust;
1210
- private fErrorMessage;
1211
- private static gFactories;
1212
- private mixer32Buffer;
1213
- private mixer64Buffer;
1214
- private mixer32Module;
1215
- private mixer64Module;
1216
- /**
1217
- * Get a stringified DSP factories table
1218
- */
1219
- static serializeDSPFactories(): Record<string, {
1220
- code: string;
1221
- json: any;
1222
- poly: boolean;
1223
- }>;
1224
- /**
1225
- * Get a stringified DSP factories table as string
1226
- */
1227
- static stringifyDSPFactories(): string;
1228
- /**
1229
- * Import a DSP factories table
1230
- */
1231
- static deserializeDSPFactories(table: Record<string, {
1232
- code: string;
1233
- json: any;
1234
- poly: boolean;
1235
- }>): Promise<Map<string, Required<LooseFaustDspFactory>>[]>;
1236
- /**
1237
- * Import a stringified DSP factories table
1238
- */
1239
- static importDSPFactories(tableStr: string): Promise<Map<string, Required<LooseFaustDspFactory>>[]>;
1240
- constructor(libFaust: ILibFaust);
1241
- private intVec2intArray;
1242
- private createDSPFactory;
1243
- version(): string;
1244
- getErrorMessage(): string;
1245
- createMonoDSPFactory(name: string, code: string, args: string): Promise<Required<LooseFaustDspFactory> | null>;
1246
- createPolyDSPFactory(name: string, code: string, args: string): Promise<Required<LooseFaustDspFactory> | null>;
1247
- deleteDSPFactory(factory: FaustDspFactory): void;
1248
- expandDSP(code: string, args: string): string;
1249
- generateAuxFiles(name: string, code: string, args: string): boolean;
1250
- deleteAllDSPFactories(): void;
1251
- fs(): typeof FS;
1252
- getAsyncInternalMixerModule(isDouble?: boolean): Promise<{
1253
- mixerBuffer: Uint8Array<ArrayBufferLike>;
1254
- mixerModule: WebAssembly.Module;
1255
- }>;
1256
- getSyncInternalMixerModule(isDouble?: boolean): {
1257
- mixerBuffer: Uint8Array<ArrayBufferLike>;
1258
- mixerModule: WebAssembly.Module;
1259
- };
1260
- }
1261
- /**
1262
- * For offline rendering.
1263
- */
1264
- export interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {
1265
- render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];
1266
- }
1267
- export interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp {
1268
- }
1269
- export interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp {
1270
- }
1271
- export declare class FaustOfflineProcessor<Poly extends boolean = false> {
1272
- protected fDSPCode: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;
1273
- protected fBufferSize: number;
1274
- protected fInputs: Float32Array[];
1275
- protected fOutputs: Float32Array[];
1276
- constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number);
1277
- getParameterDescriptors(): AudioParamDescriptor[];
1278
- compute(input: Float32Array[], output: Float32Array[]): boolean;
1279
- setOutputParamHandler(handler: OutputParamHandler): void;
1280
- getOutputParamHandler(): OutputParamHandler | null;
1281
- callOutputParamHandler(path: string, value: number): void;
1282
- setInputParamHandler(handler: InputParamHandler): void;
1283
- getInputParamHandler(): InputParamHandler | null;
1284
- callInputParamHandler(path: string, value: number): void;
1285
- setComputeHandler(handler: ComputeHandler): void;
1286
- getComputeHandler(): ComputeHandler | null;
1287
- setPlotHandler(handler: PlotHandler): void;
1288
- getPlotHandler(): PlotHandler | null;
1289
- getNumInputs(): number;
1290
- getNumOutputs(): number;
1291
- metadata(handler: MetadataHandler): void;
1292
- midiMessage(data: number[] | Uint8Array): void;
1293
- ctrlChange(chan: number, ctrl: number, value: number): void;
1294
- pitchWheel(chan: number, value: number): void;
1295
- keyOn(channel: number, pitch: number, velocity: number): void;
1296
- keyOff(channel: number, pitch: number, velocity: number): void;
1297
- setParamValue(path: string, value: number): void;
1298
- getParamValue(path: string): number;
1299
- getParams(): string[];
1300
- getMeta(): FaustDspMeta;
1301
- getJSON(): string;
1302
- getDescriptors(): FaustUIInputItem[];
1303
- getUI(): FaustUIDescriptor;
1304
- init(): void;
1305
- instanceInit(): void;
1306
- instanceClear(): void;
1307
- instanceConstants(): void;
1308
- instanceResetUserInterface(): void;
1309
- start(): void;
1310
- stop(): void;
1311
- destroy(): void;
1312
- get hasAccInput(): boolean;
1313
- propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
1314
- get hasGyrInput(): boolean;
1315
- propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
1316
- startSensors(): void;
1317
- stopSensors(): void;
1318
- /**
1319
- * Render frames in an array.
1320
- *
1321
- * @param inputs - input signal
1322
- * @param length - the number of frames to render (default: bufferSize)
1323
- * @param onUpdate - a callback after each buffer calculated, with an argument "current sample"
1324
- * @return an array of Float32Array with the rendered frames
1325
- */
1326
- render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];
1327
- }
1328
- export declare class FaustMonoOfflineProcessor extends FaustOfflineProcessor<false> implements IFaustMonoWebAudioDsp {
1329
- }
1330
- export declare class FaustPolyOfflineProcessor extends FaustOfflineProcessor<true> implements IFaustPolyWebAudioDsp {
1331
- keyOn(channel: number, pitch: number, velocity: number): void;
1332
- keyOff(channel: number, pitch: number, velocity: number): void;
1333
- allNotesOff(hard: boolean): void;
1334
- }
1335
- export interface IFaustSvgDiagrams {
1336
- /**
1337
- * Generates auxiliary files from Faust code. The output depends on the compiler options.
1338
- *
1339
- * @param name - the DSP's name
1340
- * @param code - Faust code
1341
- * @param args - compilation args
1342
- * @returns the svg diagrams as a filename - svg string map
1343
- */
1344
- from(name: string, code: string, args: string): Record<string, string>;
1345
- }
1346
- export declare class FaustSvgDiagrams implements IFaustSvgDiagrams {
1347
- private compiler;
1348
- constructor(compiler: FaustCompiler);
1349
- from(name: string, code: string, args: string): Record<string, string>;
1350
- }
1351
- export interface IFaustCmajor {
1352
- /**
1353
- * Generates auxiliary files from Faust code. The output depends on the compiler options.
1354
- *
1355
- * @param name - the DSP's name
1356
- * @param code - Faust code
1357
- * @param args - compilation args
1358
- * @returns the Cmajor compiled string
1359
- */
1360
- compile(name: string, code: string, args: string): string;
1361
- }
1362
- export declare class FaustCmajor implements IFaustCmajor {
1363
- private fCompiler;
1364
- constructor(compiler: FaustCompiler);
1365
- compile(name: string, code: string, args: string): string;
1366
- }
1367
- export interface WavEncoderOptions {
1368
- bitDepth: number;
1369
- float?: boolean;
1370
- symmetric?: boolean;
1371
- shared?: boolean;
1372
- sampleRate: number;
1373
- }
1374
- /**
1375
- * Code from https://github.com/mohayonao/wav-encoder
1376
- */
1377
- export declare class WavEncoder {
1378
- static encode(audioBuffer: Float32Array[], options: WavEncoderOptions): ArrayBuffer | SharedArrayBuffer;
1379
- private static writeHeader;
1380
- private static writeData;
1381
- }
1382
- export interface WavDecoderOptions {
1383
- symmetric?: boolean;
1384
- shared?: boolean;
1385
- }
1386
- /**
1387
- * Code from https://github.com/mohayonao/wav-decoder
1388
- */
1389
- export declare class WavDecoder {
1390
- static decode(buffer: ArrayBuffer, options?: WavDecoderOptions): {
1391
- numberOfChannels: number;
1392
- length: number;
1393
- sampleRate: number;
1394
- channelData: Float32Array[];
1395
- };
1396
- private static decodeFormat;
1397
- private static decodeData;
1398
- private static readPCM;
1399
- }
1400
- /** Read metadata and fetch soundfiles */
1401
- export declare class SoundfileReader {
1402
- /**
1403
- * Set fallback base URLs used to resolve soundfile paths.
1404
- *
1405
- * In Node or other non-browser runtimes, `location` may be undefined;
1406
- * in that case this returns an empty list to avoid resolution errors.
1407
- */
1408
- static get fallbackPaths(): string[];
1409
- /**
1410
- * Extract the parent URL from an URL.
1411
- * @param url : the URL
1412
- * @returns : the parent URL
1413
- */
1414
- private static getParentUrl;
1415
- /**
1416
- * Convert an audio buffer to audio data.
1417
- *
1418
- * @param audioBuffer : the audio buffer to convert
1419
- * @returns : the audio data
1420
- */
1421
- private static toAudioData;
1422
- private static isWaveFile;
1423
- private static decodeWaveFile;
1424
- /**
1425
- * Extract the URLs from the metadata.
1426
- *
1427
- * @param dspMeta : the metadata
1428
- * @returns : the URLs
1429
- */
1430
- static findSoundfilesFromMeta(dspMeta: FaustDspMeta): LooseFaustDspFactory["soundfiles"];
1431
- /**
1432
- * Fetch the soundfile.
1433
- *
1434
- * @param url : the url of the soundfile
1435
- * @param audioCtx : the audio context
1436
- * @returns : the audio data
1437
- */
1438
- private static fetchSoundfile;
1439
- /**
1440
- * Load the soundfile.
1441
- *
1442
- * @param filename : the filename
1443
- * @param metaUrls : the metadata URLs
1444
- * @param soundfiles : the soundfiles
1445
- * @param audioCtx : the audio context
1446
- */
1447
- private static loadSoundfile;
1448
- /**
1449
- * Load the soundfiles, public API.
1450
- *
1451
- * @param dspMeta : the metadata
1452
- * @param soundfilesIn : the soundfiles
1453
- * @param audioCtx : the audio context
1454
- * @returns : the soundfiles
1455
- */
1456
- static loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory["soundfiles"], audioCtx: BaseAudioContext): Promise<LooseFaustDspFactory["soundfiles"]>;
1457
- }
1458
- declare const FaustAudioWorkletNode_base: {
1459
- new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode;
1460
- prototype: AudioWorkletNode;
1461
- };
1462
- /**
1463
- * Base class for Monophonic and Polyphonic AudioWorkletNode
1464
- */
1465
- export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends FaustAudioWorkletNode_base {
1466
- #private;
1467
- protected fJSONDsp: FaustDspMeta;
1468
- protected fJSON: string;
1469
- protected fInputsItems: string[];
1470
- protected fOutputHandler: OutputParamHandler | null;
1471
- protected fInputHandler: InputParamHandler | null;
1472
- protected fComputeHandler: ComputeHandler | null;
1473
- protected fPlotHandler: PlotHandler | null;
1474
- protected fUICallback: UIHandler;
1475
- protected fDescriptor: FaustUIInputItem[];
1476
- protected fCommunicator: FaustAudioWorkletNodeCommunicator;
1477
- protected fParamAliases: Record<string, string>;
1478
- constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial<FaustAudioWorkletNodeOptions<Poly>>);
1479
- protected handleMessageAux: (e: MessageEvent) => void;
1480
- private handleDeviceMotion;
1481
- private handleDeviceOrientation;
1482
- /** Setup accelerometer and gyroscope handlers */
1483
- startSensors(): Promise<void>;
1484
- stopSensors(): void;
1485
- setOutputParamHandler(handler: OutputParamHandler | null): void;
1486
- getOutputParamHandler(): OutputParamHandler | null;
1487
- callOutputParamHandler(path: string, value: number): void;
1488
- setInputParamHandler(handler: InputParamHandler | null): void;
1489
- getInputParamHandler(): InputParamHandler | null;
1490
- callInputParamHandler(path: string, value: number): void;
1491
- setComputeHandler(handler: ComputeHandler | null): void;
1492
- getComputeHandler(): ComputeHandler | null;
1493
- setPlotHandler(handler: PlotHandler | null): void;
1494
- getPlotHandler(): PlotHandler | null;
1495
- setupWamEventHandler(): void;
1496
- getNumInputs(): number;
1497
- getNumOutputs(): number;
1498
- compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
1499
- metadata(handler: MetadataHandler): void;
1500
- midiMessage(data: number[] | Uint8Array): void;
1501
- ctrlChange(channel: number, ctrl: number, value: number): void;
1502
- pitchWheel(channel: number, wheel: number): void;
1503
- keyOn(channel: number, pitch: number, velocity: number): void;
1504
- keyOff(channel: number, pitch: number, velocity: number): void;
1505
- get hasAccInput(): boolean;
1506
- propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
1507
- get hasGyrInput(): boolean;
1508
- propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
1509
- setParamValue(path: string, value: number): void;
1510
- getParamValue(path: string): number;
1511
- getParams(): string[];
1512
- getMeta(): FaustDspMeta;
1513
- getJSON(): string;
1514
- getUI(): FaustUIDescriptor;
1515
- getDescriptors(): FaustUIInputItem[];
1516
- init(): void;
1517
- instanceInit(): void;
1518
- instanceClear(): void;
1519
- instanceConstants(): void;
1520
- instanceResetUserInterface(): void;
1521
- start(): void;
1522
- stop(): void;
1523
- destroy(): void;
1524
- }
1525
- /**
1526
- * Monophonic AudioWorkletNode
1527
- */
1528
- export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<false> implements IFaustMonoWebAudioDsp {
1529
- onprocessorerror: (e: Event) => never;
1530
- constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<false>> & Pick<FaustAudioWorkletNodeOptions<false>, "processorOptions">);
1531
- }
1532
- /**
1533
- * Polyphonic AudioWorkletNode
1534
- */
1535
- export declare class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode<true> implements IFaustPolyWebAudioDsp {
1536
- private fJSONEffect;
1537
- onprocessorerror: (e: Event) => never;
1538
- constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<true>> & Pick<FaustAudioWorkletNodeOptions<true>, "processorOptions">);
1539
- keyOn(channel: number, pitch: number, velocity: number): void;
1540
- keyOff(channel: number, pitch: number, velocity: number): void;
1541
- allNotesOff(hard: boolean): void;
1542
- getMeta(): FaustDspMeta;
1543
- getJSON(): string;
1544
- getUI(): FaustUIDescriptor;
1545
- }
1546
- declare const FaustScriptProcessorNode_base: {
1547
- new (): ScriptProcessorNode;
1548
- prototype: ScriptProcessorNode;
1549
- };
1550
- /**
1551
- * Base class for Monophonic and Polyphonic ScriptProcessorNode
1552
- */
1553
- export declare class FaustScriptProcessorNode<Poly extends boolean = false> extends FaustScriptProcessorNode_base {
1554
- protected fDSPCode: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;
1555
- protected fInputs: Float32Array[];
1556
- protected fOutputs: Float32Array[];
1557
- protected handleDeviceMotion: any;
1558
- protected handleDeviceOrientation: any;
1559
- setupNode(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void;
1560
- init(): void;
1561
- instanceInit(): void;
1562
- instanceClear(): void;
1563
- instanceConstants(): void;
1564
- instanceResetUserInterface(): void;
1565
- /** Start accelerometer and gyroscope handlers */
1566
- startSensors(): Promise<void>;
1567
- /** Stop accelerometer and gyroscope handlers */
1568
- stopSensors(): void;
1569
- compute(input: Float32Array[], output: Float32Array[]): boolean;
1570
- setOutputParamHandler(handler: OutputParamHandler): void;
1571
- getOutputParamHandler(): OutputParamHandler | null;
1572
- callOutputParamHandler(path: string, value: number): void;
1573
- setInputParamHandler(handler: InputParamHandler): void;
1574
- getInputParamHandler(): InputParamHandler | null;
1575
- callInputParamHandler(path: string, value: number): void;
1576
- setComputeHandler(handler: ComputeHandler): void;
1577
- getComputeHandler(): ComputeHandler | null;
1578
- setPlotHandler(handler: PlotHandler): void;
1579
- getPlotHandler(): PlotHandler | null;
1580
- getNumInputs(): number;
1581
- getNumOutputs(): number;
1582
- metadata(handler: MetadataHandler): void;
1583
- midiMessage(data: number[] | Uint8Array): void;
1584
- ctrlChange(chan: number, ctrl: number, value: number): void;
1585
- pitchWheel(chan: number, value: number): void;
1586
- keyOn(channel: number, pitch: number, velocity: number): void;
1587
- keyOff(channel: number, pitch: number, velocity: number): void;
1588
- setParamValue(path: string, value: number): void;
1589
- getParamValue(path: string): number;
1590
- getParams(): string[];
1591
- getMeta(): FaustDspMeta;
1592
- getJSON(): string;
1593
- getDescriptors(): FaustUIInputItem[];
1594
- getUI(): FaustUIDescriptor;
1595
- start(): void;
1596
- stop(): void;
1597
- destroy(): void;
1598
- get hasAccInput(): boolean;
1599
- propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
1600
- get hasGyrInput(): boolean;
1601
- propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
1602
- }
1603
- export declare class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode<false> implements IFaustMonoWebAudioDsp {
1604
- }
1605
- export declare class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode<true> implements IFaustPolyWebAudioDsp {
1606
- keyOn(channel: number, pitch: number, velocity: number): void;
1607
- keyOff(channel: number, pitch: number, velocity: number): void;
1608
- allNotesOff(hard: boolean): void;
1609
- }
1610
- export interface GeneratorSupportingSoundfiles {
1611
- /**
1612
- * Attach a map of id - audio data, call after `compile()` before `createNode()`
1613
- *
1614
- * @param soundfileMap a map of id - `AudioData` as an object where `AudioData` contains channel data as `audioBuffer: Float32Array[]` and `sampleRate: number`
1615
- */
1616
- addSoundfiles(soundfileMap: Record<string, AudioData$1>): void;
1617
- /**
1618
- * Get a list of soundfiles needed, call after `compile()`
1619
- */
1620
- getSoundfileList(): string[];
1621
- }
1622
- export interface IFaustDspGenerator {
1623
- /**
1624
- * Create a monophonic or polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1625
- * Analyze the code to decide whether to create a monophonic or polyphonic node.
1626
- *
1627
- * @param context - the WebAudio context
1628
- * @param name - DSP name, can be used for processorName
1629
- * @param code - the DSP code
1630
- * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
1631
- * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
1632
- * @returns the compiled monophonic or polyphonic WebAudio node or 'null' if failure
1633
- */
1634
- createFaustNode(context: BaseAudioContext, name: string, code: string, sp?: boolean, bufferSize?: number): Promise<IFaustMonoWebAudioNode | IFaustPolyWebAudioNode | null>;
1635
- }
1636
- export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
1637
- /**
1638
- * Compile a monophonic DSP factory from given code.
1639
- *
1640
- * @param compiler - the Faust compiler
1641
- * @param name - the DSP name
1642
- * @param code - the DSP code
1643
- * @param args - the compilation parameters
1644
- * @returns the compiled factory or 'null' if failure
1645
- */
1646
- compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{
1647
- factory: FaustDspFactory | null;
1648
- name?: string;
1649
- meta?: FaustDspMeta;
1650
- } | null>;
1651
- /**
1652
- * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1653
- *
1654
- * @param context - the WebAudio context
1655
- * @param name - DSP name, can be used for processorName
1656
- * @param factory - default is the compiled factory
1657
- * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
1658
- * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
1659
- * @param processorName - AudioWorklet Processor name
1660
- * @param processorOptions - Additional AudioWorklet Processor options
1661
- * @returns the compiled WebAudio node or 'null' if failure
1662
- */
1663
- createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<IFaustMonoWebAudioNode | null>;
1664
- /**
1665
- * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1666
- *
1667
- * @param context - the WebAudio context
1668
- * @param fftUtils - should be an anonymous class with static methods, without any import from outside
1669
- * @param name - DSP name, can be used for processorName
1670
- * @param factory - default is the compiled factory
1671
- * @param fftOptions - initial FFT options
1672
- * @param processorName - AudioWorklet Processor name
1673
- * @param processorOptions - Additional AudioWorklet Processor options
1674
- * @returns the compiled WebAudio node or 'null' if failure
1675
- */
1676
- createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
1677
- /**
1678
- * Create a monophonic Offline processor.
1679
- *
1680
- * @param sampleRate - the sample rate in Hz
1681
- * @param bufferSize - the buffer size in frames
1682
- * @param factory - default is the compiled factory
1683
- * @param context - if this exists, will be used to fetch soundfiles online
1684
- * @returns the compiled processor or 'null' if failure
1685
- */
1686
- createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, context?: BaseAudioContext): Promise<IFaustMonoOfflineProcessor | null>;
1687
- /**
1688
- * Get DSP JSON description with its UI and metadata as object.
1689
- *
1690
- * @return the DSP JSON description as object
1691
- */
1692
- getMeta(): FaustDspMeta;
1693
- /**
1694
- * Get DSP JSON description with its UI and metadata.
1695
- *
1696
- * @return the DSP JSON description
1697
- */
1698
- getJSON(): string;
1699
- /**
1700
- * Get DSP UI description.
1701
- *
1702
- * @return the DSP UI description
1703
- */
1704
- getUI(): FaustUIDescriptor;
1705
- }
1706
- export interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {
1707
- /**
1708
- * Compile a monophonic DSP factory from given code.
1709
- *
1710
- * @param compiler - the Faust compiler
1711
- * @param name - the DSP name
1712
- * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)
1713
- * @param args - the compilation parameters
1714
- * @param effectCode - optional effect DSP code
1715
- * @returns the compiled factory or 'null' if failure
1716
- */
1717
- compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{
1718
- voiceFactory: FaustDspFactory | null;
1719
- effectFactory?: FaustDspFactory | null;
1720
- } | null>;
1721
- /**
1722
- * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1723
- *
1724
- * @param context the WebAudio context
1725
- * @param voices - the number of voices
1726
- * @param name - AudioWorklet Processor name
1727
- * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1728
- * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)
1729
- * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1730
- * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
1731
- * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
1732
- * @param processorOptions - Additional AudioWorklet Processor options
1733
- * @returns the compiled WebAudio node or 'null' if failure
1734
- */
1735
- 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>;
1736
- /**
1737
- * Create a monophonic Offline processor.
1738
- *
1739
- * @param sampleRate - the sample rate in Hz
1740
- * @param bufferSize - the buffer size in frames
1741
- * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1742
- * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)
1743
- * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1744
- * @param context - if this exists, will be used to fetch soundfiles online
1745
- * @returns the compiled processor or 'null' if failure
1746
- */
1747
- createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, context?: BaseAudioContext): Promise<IFaustPolyOfflineProcessor | null>;
1748
- /**
1749
- * Get DSP JSON description with its UI and metadata as object.
1750
- *
1751
- * @return the DSP JSON description as object
1752
- */
1753
- getMeta(): FaustDspMeta;
1754
- /**
1755
- * Get DSP JSON description with its UI and metadata.
1756
- *
1757
- * @return the DSP JSON description
1758
- */
1759
- getJSON(): string;
1760
- /**
1761
- * Get DSP UI description.
1762
- *
1763
- * @return the DSP UI description
1764
- */
1765
- getUI(): FaustUIDescriptor;
1766
- }
1767
- export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
1768
- private static gWorkletProcessors;
1769
- name: string;
1770
- factory: FaustDspFactory | null;
1771
- constructor();
1772
- compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<this | null>;
1773
- addSoundfiles(soundfileMap: Record<string, AudioData$1>): void;
1774
- getSoundfileList(): string[];
1775
- 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>;
1776
- createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
1777
- createAudioWorkletProcessor(name?: string, factory?: LooseFaustDspFactory, processorName?: string): Promise<{
1778
- new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1779
- prototype: AudioWorkletProcessor;
1780
- parameterDescriptors: AudioParamDescriptor[];
1781
- }>;
1782
- createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, context?: BaseAudioContext): Promise<FaustMonoOfflineProcessor>;
1783
- getMeta(): any;
1784
- getJSON(): string;
1785
- getUI(): any;
1786
- }
1787
- export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
1788
- private static gWorkletProcessors;
1789
- name: string;
1790
- voiceFactory: FaustDspFactory | null;
1791
- effectFactory: FaustDspFactory | null;
1792
- mixerBuffer: Uint8Array;
1793
- mixerModule: WebAssembly.Module;
1794
- constructor();
1795
- compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCodeAux?: string): Promise<this | null>;
1796
- addSoundfiles(soundfileMap: Record<string, AudioData$1>): void;
1797
- getSoundfileList(): string[];
1798
- 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>;
1799
- createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
1800
- new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1801
- prototype: AudioWorkletProcessor;
1802
- parameterDescriptors: AudioParamDescriptor[];
1803
- }>;
1804
- createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, context?: BaseAudioContext): Promise<FaustPolyOfflineProcessor>;
1805
- getMeta(): FaustDspMeta;
1806
- getJSON(): string;
1807
- getUI(): FaustUIDescriptor;
1808
- }
1809
- export declare class FaustDspGenerator implements IFaustDspGenerator {
1810
- private static compilerPromise;
1811
- private extractMidiAndNvoices;
1812
- /**
1813
- * Compile DSP code, inspect metadata for [nvoices:] (and optionally [midi:on]), and build either a mono
1814
- * or poly WebAudio node (ScriptProcessor or AudioWorklet depending on `sp`). Compilation uses a shared,
1815
- * lazily-created libfaust instance to avoid repeatedly instantiating the WASM compiler.
1816
- */
1817
- createFaustNode(context: BaseAudioContext, name: string, code: string, sp?: boolean, bufferSize?: number): Promise<IFaustMonoWebAudioNode | IFaustPolyWebAudioNode | null>;
1818
- }
1819
-
1820
- export {
1821
- AudioData$1 as AudioData,
1822
- };
1823
-
1824
- export {};