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