@grame/faustwasm 0.0.25

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 (111) hide show
  1. package/README.md +181 -0
  2. package/assets/standalone/faust-ui/index.css +414 -0
  3. package/assets/standalone/faust-ui/index.css.map +1 -0
  4. package/assets/standalone/faust-ui/index.d.ts +1 -0
  5. package/assets/standalone/faust-ui/index.js +3478 -0
  6. package/assets/standalone/faust-ui/index.js.map +1 -0
  7. package/assets/standalone/faustwasm/index.d.ts +1252 -0
  8. package/assets/standalone/faustwasm/index.js +3772 -0
  9. package/assets/standalone/faustwasm/index.js.map +7 -0
  10. package/assets/standalone/index.html +73 -0
  11. package/assets/standalone/index.js +198 -0
  12. package/assets/standalone/types.d.ts +9 -0
  13. package/dist/cjs/index.d.ts +1252 -0
  14. package/dist/cjs/index.js +3752 -0
  15. package/dist/cjs/index.js.map +7 -0
  16. package/dist/cjs-bundle/index.d.ts +1259 -0
  17. package/dist/cjs-bundle/index.js +11507 -0
  18. package/dist/cjs-bundle/index.js.map +7 -0
  19. package/dist/esm/index.d.ts +1252 -0
  20. package/dist/esm/index.js +3772 -0
  21. package/dist/esm/index.js.map +7 -0
  22. package/dist/esm-bundle/index.d.ts +1259 -0
  23. package/dist/esm-bundle/index.js +11495 -0
  24. package/dist/esm-bundle/index.js.map +7 -0
  25. package/fileutils.js +40 -0
  26. package/libfaust-wasm/libfaust-wasm.d.cts +3 -0
  27. package/libfaust-wasm/libfaust-wasm.d.ts +3 -0
  28. package/libfaust-wasm/libfaust-wasm.data +0 -0
  29. package/libfaust-wasm/libfaust-wasm.data.d.ts +2 -0
  30. package/libfaust-wasm/libfaust-wasm.js +21 -0
  31. package/libfaust-wasm/libfaust-wasm.wasm +0 -0
  32. package/libfaust-wasm/libfaust-wasm.wasm.d.ts +2 -0
  33. package/library.md +91 -0
  34. package/package.json +43 -0
  35. package/postbuild-bundled.js +11 -0
  36. package/postbuild.js +63 -0
  37. package/prebuild-bundled.js +11 -0
  38. package/rsrc/overview.png +0 -0
  39. package/rsrc/overview.xlsx +0 -0
  40. package/scripts/faust2sndfile.js +43 -0
  41. package/scripts/faust2svg.js +17 -0
  42. package/scripts/faust2wasm.js +29 -0
  43. package/src/FaustAudioWorkletNode.ts +264 -0
  44. package/src/FaustAudioWorkletProcessor.ts +273 -0
  45. package/src/FaustCompiler.ts +252 -0
  46. package/src/FaustDspGenerator.ts +498 -0
  47. package/src/FaustDspInstance.ts +141 -0
  48. package/src/FaustFFTAudioWorkletProcessor.ts +554 -0
  49. package/src/FaustOfflineProcessor.ts +141 -0
  50. package/src/FaustScriptProcessorNode.ts +80 -0
  51. package/src/FaustSvgDiagrams.ts +37 -0
  52. package/src/FaustWasmInstantiator.ts +202 -0
  53. package/src/FaustWebAudioDsp.ts +1060 -0
  54. package/src/LibFaust.ts +57 -0
  55. package/src/WavDecoder.ts +207 -0
  56. package/src/WavEncoder.ts +204 -0
  57. package/src/copyWebStandaloneAssets.d.ts +3 -0
  58. package/src/copyWebStandaloneAssets.js +20 -0
  59. package/src/exports-bundle.ts +5 -0
  60. package/src/exports.ts +24 -0
  61. package/src/faust2svgFiles.d.ts +3 -0
  62. package/src/faust2svgFiles.js +43 -0
  63. package/src/faust2wasmFiles.d.ts +5 -0
  64. package/src/faust2wasmFiles.js +93 -0
  65. package/src/faust2wavFiles.d.ts +3 -0
  66. package/src/faust2wavFiles.js +58 -0
  67. package/src/index-bundle-iife.ts +7 -0
  68. package/src/index-bundle.ts +5 -0
  69. package/src/index.ts +5 -0
  70. package/src/instantiateFaustModule.ts +32 -0
  71. package/src/instantiateFaustModuleFromFile.ts +57 -0
  72. package/src/types.ts +234 -0
  73. package/test/clarinet.dsp +1 -0
  74. package/test/faustlive-wasm/faust-ui/index.css +414 -0
  75. package/test/faustlive-wasm/faust-ui/index.css.map +1 -0
  76. package/test/faustlive-wasm/faust-ui/index.d.ts +1 -0
  77. package/test/faustlive-wasm/faust-ui/index.js +3478 -0
  78. package/test/faustlive-wasm/faust-ui/index.js.map +1 -0
  79. package/test/faustlive-wasm/faustwasm/index.d.ts +1252 -0
  80. package/test/faustlive-wasm/faustwasm/index.js +3772 -0
  81. package/test/faustlive-wasm/faustwasm/index.js.map +7 -0
  82. package/test/faustlive-wasm/index.css +97 -0
  83. package/test/faustlive-wasm/index.html +130 -0
  84. package/test/faustlive-wasm/index.js +638 -0
  85. package/test/guitar.dsp +1 -0
  86. package/test/guitar1.dsp +2 -0
  87. package/test/libfaust-in-worklet/index.html +13 -0
  88. package/test/libfaust-in-worklet/index.js +40 -0
  89. package/test/mono.dsp +8 -0
  90. package/test/node/test.js +17 -0
  91. package/test/noise.dsp +3 -0
  92. package/test/organ.dsp +5 -0
  93. package/test/organ1.dsp +6 -0
  94. package/test/osc.dsp +4 -0
  95. package/test/osc2.dsp +5 -0
  96. package/test/osc3.dsp +4 -0
  97. package/test/p-dj.dsp +4 -0
  98. package/test/poly.dsp +13 -0
  99. package/test/rev.dsp +2 -0
  100. package/test/t1.dsp +1 -0
  101. package/test/web/fft.html +87 -0
  102. package/test/web/fft1.html +88 -0
  103. package/test/web/fft2.html +114 -0
  104. package/test/web/fftw.js +1907 -0
  105. package/test/web/index.html +12 -0
  106. package/test/web/index.js +235 -0
  107. package/test/web/kissfft.js +904 -0
  108. package/test/web/mono.html +46 -0
  109. package/test/web/poly-key.html +62 -0
  110. package/test/web/poly.html +59 -0
  111. package/tsconfig.json +22 -0
@@ -0,0 +1,1252 @@
1
+ // Generated by dts-bundle-generator v6.13.0
2
+
3
+ /// <reference types="emscripten" />
4
+ /// <reference types="node" />
5
+
6
+ export declare 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 declare 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 declare type FaustUIDescriptor = FaustUIGroup[];
129
+ export declare type FaustUIItem = FaustUIInputItem | FaustUIOutputItem | FaustUIGroup;
130
+ export interface FaustUIInputItem {
131
+ type: FaustUIInputType;
132
+ label: string;
133
+ address: string;
134
+ index: number;
135
+ init?: number;
136
+ min?: number;
137
+ max?: number;
138
+ step?: number;
139
+ meta?: FaustUIMeta[];
140
+ }
141
+ export interface FaustUIOutputItem {
142
+ type: FaustUIOutputType;
143
+ label: string;
144
+ address: string;
145
+ index: number;
146
+ min?: number;
147
+ max?: number;
148
+ meta?: FaustUIMeta[];
149
+ }
150
+ export interface FaustUIMeta {
151
+ [order: number]: string;
152
+ style?: string;
153
+ unit?: string;
154
+ scale?: "linear" | "exp" | "log";
155
+ tooltip?: string;
156
+ hidden?: string;
157
+ [key: string]: string | undefined;
158
+ }
159
+ export declare type FaustUIGroupType = "vgroup" | "hgroup" | "tgroup";
160
+ export declare type FaustUIOutputType = "hbargraph" | "vbargraph";
161
+ export declare type FaustUIInputType = "vslider" | "hslider" | "button" | "checkbox" | "nentry";
162
+ export interface FaustUIGroup {
163
+ type: FaustUIGroupType;
164
+ label: string;
165
+ items: FaustUIItem[];
166
+ }
167
+ export declare type FaustUIType = FaustUIGroupType | FaustUIOutputType | FaustUIInputType;
168
+ export interface AudioParamDescriptor {
169
+ automationRate?: AutomationRate;
170
+ defaultValue?: number;
171
+ maxValue?: number;
172
+ minValue?: number;
173
+ name: string;
174
+ }
175
+ export interface AudioWorkletProcessor {
176
+ port: MessagePort;
177
+ process(inputs: Float32Array[][], outputs: Float32Array[][], parameters: Record<string, Float32Array>): boolean;
178
+ }
179
+ export declare const AudioWorkletProcessor: {
180
+ prototype: AudioWorkletProcessor;
181
+ parameterDescriptors: AudioParamDescriptor[];
182
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
183
+ };
184
+ export interface AudioWorkletGlobalScope {
185
+ AudioWorkletGlobalScope: any;
186
+ globalThis: AudioWorkletGlobalScope;
187
+ registerProcessor: (name: string, constructor: new (options: any) => AudioWorkletProcessor) => void;
188
+ currentFrame: number;
189
+ currentTime: number;
190
+ sampleRate: number;
191
+ AudioWorkletProcessor: typeof AudioWorkletProcessor;
192
+ }
193
+ export interface InterfaceFFT {
194
+ forward(arr: ArrayLike<number> | ((arr: Float32Array) => any)): Float32Array;
195
+ inverse(arr: ArrayLike<number> | ((arr: Float32Array) => any)): Float32Array;
196
+ dispose(): void;
197
+ }
198
+ export declare const InterfaceFFT: {
199
+ new (size: number): InterfaceFFT;
200
+ };
201
+ export declare type TWindowFunction = (index: number, length: number, ...args: any[]) => number;
202
+ export declare type Writeable<T> = {
203
+ -readonly [P in keyof T]: T[P];
204
+ };
205
+ export declare type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
206
+ export declare type TypedArrayConstructor = typeof Int8Array | typeof Uint8Array | typeof Int16Array | typeof Uint16Array | typeof Int32Array | typeof Uint32Array | typeof Uint8ClampedArray | typeof Float32Array | typeof Float64Array;
207
+ export declare const FFTUtils: {
208
+ /** Inject window functions as array, no need to add rectangular (no windowing) */
209
+ windowFunctions?: TWindowFunction[];
210
+ /** Get a FFT interface constructor */
211
+ getFFT: () => Promise<typeof InterfaceFFT>;
212
+ /** 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 */
213
+ fftToSignal: (fft: Float32Array | Float64Array, real: Float32Array | Float64Array, imag?: Float32Array | Float64Array, index?: Float32Array | Float64Array) => any;
214
+ /** 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 */
215
+ signalToFFT: (real: Float32Array | Float64Array, imag: Float32Array | Float64Array, fft: Float32Array | Float64Array) => any;
216
+ /** Convert from Faust processor's output to direct audio output, real/imag are readonly, fft length = fftSize = (real/imag length - 1) * 2 */
217
+ signalToNoFFT: (real: Float32Array | Float64Array, imag: Float32Array | Float64Array, fft: Float32Array | Float64Array) => any;
218
+ };
219
+ /**
220
+ * Load libfaust-wasm files, than instantiate libFaust
221
+ * @param jsFile path to `libfaust-wasm.js`
222
+ * @param dataFile path to `libfaust-wasm.data`
223
+ * @param wasmFile path to `libfaust-wasm.wasm`
224
+ */
225
+ export declare const instantiateFaustModuleFromFile: (jsFile: string, dataFile?: string, wasmFile?: string) => Promise<FaustModule>;
226
+ /**
227
+ * The Faust wasm instance interface.
228
+ */
229
+ export interface IFaustDspInstance {
230
+ /**
231
+ * The dsp computation, to be called with successive input/output audio buffers.
232
+ *
233
+ * @param $dsp - the DSP pointer
234
+ * @param count - the audio buffer size in frames
235
+ * @param $inputs - the input audio buffer as in index in wasm memory
236
+ * @param $output - the output audio buffer as in index in wasm memory
237
+ */
238
+ compute($dsp: number, count: number, $inputs: number, $output: number): void;
239
+ /**
240
+ * Give the number of inputs of a Faust wasm instance.
241
+ *
242
+ * @param $dsp - the DSP pointer
243
+ */
244
+ getNumInputs($dsp: number): number;
245
+ /**
246
+ * Give the number of outputs of a Faust wasm instance.
247
+ *
248
+ * @param $dsp - the DSP pointer
249
+ */
250
+ getNumOutputs($dsp: number): number;
251
+ /**
252
+ * Give a parameter current value.
253
+ *
254
+ * @param $dsp - the DSP pointer
255
+ * @param index - the parameter index
256
+ * @preturn the parameter value
257
+ */
258
+ getParamValue($dsp: number, index: number): number;
259
+ /**
260
+ * Give the Faust wasm instance sample rate.
261
+ *
262
+ * @param $dsp - the DSP pointer
263
+ * @preturn the sample rate
264
+ */
265
+ getSampleRate($dsp: number): number;
266
+ /**
267
+ * Global init, calls the following methods:
268
+ * - static class 'classInit': static tables initialization
269
+ * - 'instanceInit': constants and instance state initialization
270
+ *
271
+ * @param $dsp - the DSP pointer
272
+ * @param sampleRate - the sampling rate in Hertz
273
+ */
274
+ init($dsp: number, sampleRate: number): void;
275
+ /** Init instance state (delay lines...).
276
+ *
277
+ * @param $dsp - the DSP pointer
278
+ */
279
+ instanceClear($dsp: number): void;
280
+ /** Init instance constant state.
281
+ *
282
+ * @param $dsp - the DSP pointer
283
+ * @param sampleRate - the sampling rate in Hertz
284
+ */
285
+ instanceConstants($dsp: number, sampleRate: number): void;
286
+ /** Init instance state.
287
+ *
288
+ * @param $dsp - the DSP pointer
289
+ * @param sampleRate - the sampling rate in Hertz
290
+ */
291
+ instanceInit($dsp: number, sampleRate: number): void;
292
+ /** Init default control parameters values.
293
+ *
294
+ * @param $dsp - the DSP pointer
295
+ */
296
+ instanceResetUserInterface($dsp: number): void;
297
+ /**
298
+ * Set a parameter current value.
299
+ *
300
+ * @param $dsp - the DSP pointer
301
+ * @param index - the parameter index
302
+ * @param value - the parameter value
303
+ */
304
+ setParamValue($dsp: number, index: number, value: number): void;
305
+ }
306
+ /**
307
+ * Mixer used in polyphonic mode.
308
+ */
309
+ export interface IFaustMixerInstance {
310
+ clearOutput(bufferSize: number, chans: number, $outputs: number): void;
311
+ mixCheckVoice(bufferSize: number, chans: number, $inputs: number, $outputs: number): number;
312
+ fadeOut(bufferSize: number, chans: number, $outputs: number): void;
313
+ }
314
+ /**
315
+ * Monophonic instance.
316
+ */
317
+ export interface FaustMonoDspInstance {
318
+ memory: WebAssembly.Memory;
319
+ api: IFaustDspInstance;
320
+ json: string;
321
+ }
322
+ /**
323
+ * Polyphonic instance.
324
+ */
325
+ export interface FaustPolyDspInstance {
326
+ memory: WebAssembly.Memory;
327
+ voices: number;
328
+ voiceAPI: IFaustDspInstance;
329
+ effectAPI?: IFaustDspInstance;
330
+ mixerAPI: IFaustMixerInstance;
331
+ voiceJSON: string;
332
+ effectJSON?: string;
333
+ }
334
+ export declare class FaustDspInstance implements IFaustDspInstance {
335
+ private readonly fExports;
336
+ constructor(exports: IFaustDspInstance);
337
+ compute($dsp: number, count: number, $input: number, $output: number): void;
338
+ getNumInputs($dsp: number): number;
339
+ getNumOutputs($dsp: number): number;
340
+ getParamValue($dsp: number, index: number): number;
341
+ getSampleRate($dsp: number): number;
342
+ init($dsp: number, sampleRate: number): void;
343
+ instanceClear($dsp: number): void;
344
+ instanceConstants($dsp: number, sampleRate: number): void;
345
+ instanceInit($dsp: number, sampleRate: number): void;
346
+ instanceResetUserInterface($dsp: number): void;
347
+ setParamValue($dsp: number, index: number, value: number): void;
348
+ }
349
+ export declare class FaustWasmInstantiator {
350
+ private static createWasmImport;
351
+ private static createWasmMemory;
352
+ private static createMonoDSPInstanceAux;
353
+ private static createMemoryAux;
354
+ private static createMixerAux;
355
+ static loadDSPFactory(wasmPath: string, jsonPath: string): Promise<FaustDspFactory>;
356
+ static loadDSPMixer(mixerPath: string, fs?: typeof FS): Promise<WebAssembly.Module>;
357
+ static createAsyncMonoDSPInstance(factory: LooseFaustDspFactory): Promise<FaustMonoDspInstance>;
358
+ static createSyncMonoDSPInstance(factory: LooseFaustDspFactory): FaustMonoDspInstance;
359
+ static createAsyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): Promise<FaustPolyDspInstance>;
360
+ static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance;
361
+ }
362
+ export declare type OutputParamHandler = (path: string, value: number) => void;
363
+ export declare type ComputeHandler = (buffer_size: number) => void;
364
+ export declare type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: {
365
+ type: string;
366
+ data: any;
367
+ }[]) => void;
368
+ export declare type MetadataHandler = (key: string, value: string) => void;
369
+ export declare type UIHandler = (item: FaustUIItem) => void;
370
+ /**
371
+ * DSP implementation: mimic the C++ 'dsp' class:
372
+ * - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers
373
+ * - an output handler can be set to treat produced output controllers (like 'bargraph')
374
+ * - regular controllers are handled using setParamValue/getParamValue
375
+ */
376
+ export interface IFaustBaseWebAudioDsp {
377
+ /**
378
+ * Set the parameter output handler, to be called in the 'compute' method with output parameters (like bargraph).
379
+ *
380
+ * @param handler - the output handler
381
+ */
382
+ setOutputParamHandler(handler: OutputParamHandler | null): void;
383
+ /**
384
+ * Get the parameter output handler.
385
+ *
386
+ * @return the current output handler
387
+ */
388
+ getOutputParamHandler(): OutputParamHandler | null;
389
+ /**
390
+ * Set the compute handler, to be called in the 'compute' method with buffer size.
391
+ *
392
+ * @param handler - the compute handler
393
+ */
394
+ setComputeHandler(handler: ComputeHandler | null): void;
395
+ /**
396
+ * Get the compute handler.
397
+ *
398
+ * @return the current output handler
399
+ */
400
+ getComputeHandler(): ComputeHandler | null;
401
+ /**
402
+ * Set the plot handler, to be called in the 'compute' method with various info (see PlotHandler type).
403
+ *
404
+ * @param handler - the plot handler
405
+ */
406
+ setPlotHandler(handler: PlotHandler | null): void;
407
+ /**
408
+ * Get the plot handler.
409
+ *
410
+ * @return the current plot handler
411
+ */
412
+ getPlotHandler(): PlotHandler | null;
413
+ /**
414
+ * Return instance number of audio inputs.
415
+ *
416
+ * @return the instance number of audio inputs
417
+ */
418
+ getNumInputs(): number;
419
+ /**
420
+ * Return instance number of audio outputs.
421
+ *
422
+ * @return the instance number of audio outputs
423
+ */
424
+ getNumOutputs(): number;
425
+ /**
426
+ * DSP instance computation, to be called with successive input/output audio buffers, using their size.
427
+ *
428
+ * @param inputs - the input audio buffers
429
+ * @param outputs - the output audio buffers
430
+ */
431
+ compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
432
+ /**
433
+ * Give a handler to be called on 'declare key value' kind of metadata.
434
+ *
435
+ * @param handler - the handler to be used
436
+ */
437
+ metadata(handler: MetadataHandler): void;
438
+ /**
439
+ * Handle untyped MIDI messages.
440
+ *
441
+ * @param data - and arry of MIDI bytes
442
+ */
443
+ midiMessage(data: number[] | Uint8Array): void;
444
+ /**
445
+ * Handle MIDI ctrlChange messages.
446
+ *
447
+ * @param channel - the MIDI channel (0..15, not used for now)
448
+ * @param ctrl - the MIDI controller number (0..127)
449
+ * @param value - the MIDI controller value (0..127)
450
+ */
451
+ ctrlChange(chan: number, ctrl: number, value: number): void;
452
+ /**
453
+ * Handle MIDI pitchWheel messages.
454
+ *
455
+ * @param channel - the MIDI channel (0..15, not used for now)
456
+ * @param value - the MIDI controller value (0..16383)
457
+ */
458
+ pitchWheel(chan: number, value: number): void;
459
+ /**
460
+ * Set parameter value.
461
+ *
462
+ * @param path - the path to the wanted parameter (retrieved using 'getParams' method)
463
+ * @param val - the float value for the wanted control
464
+ */
465
+ setParamValue(path: string, value: number): void;
466
+ /**
467
+ * Get parameter value.
468
+ *
469
+ * @param path - the path to the wanted parameter (retrieved using 'getParams' method)
470
+ *
471
+ * @return the float value
472
+ */
473
+ getParamValue(path: string): number;
474
+ /**
475
+ * Get the table of all input parameters paths.
476
+ *
477
+ * @return the table of all input parameters paths
478
+ */
479
+ getParams(): string[];
480
+ /**
481
+ * Get DSP JSON description with its UI and metadata as object.
482
+ *
483
+ * @return the DSP JSON description as object
484
+ */
485
+ getMeta(): FaustDspMeta;
486
+ /**
487
+ * Get DSP JSON description with its UI and metadata.
488
+ *
489
+ * @return the DSP JSON description
490
+ */
491
+ getJSON(): string;
492
+ /**
493
+ * Get DSP UI description.
494
+ *
495
+ * @return the DSP UI description
496
+ */
497
+ getUI(): FaustUIDescriptor;
498
+ /**
499
+ * Get DSP UI items description.
500
+ *
501
+ * @return the DSP UI items description
502
+ */
503
+ getDescriptors(): FaustUIInputItem[];
504
+ /**
505
+ * Start the DSP.
506
+ */
507
+ start(): void;
508
+ /**
509
+ * Stop the DSP.
510
+ */
511
+ stop(): void;
512
+ /**
513
+ * Destroy the DSP.
514
+ */
515
+ destroy(): void;
516
+ }
517
+ export interface IFaustMonoWebAudioDsp extends IFaustBaseWebAudioDsp {
518
+ }
519
+ export interface IFaustMonoWebAudioNode extends IFaustMonoWebAudioDsp, AudioNode {
520
+ }
521
+ export interface IFaustPolyWebAudioDsp extends IFaustBaseWebAudioDsp {
522
+ /**
523
+ * Handle MIDI keyOn messages.
524
+ *
525
+ * @param channel - the MIDI channel (0..15, not used for now)
526
+ * @param pitch - the MIDI pitch value (0..127)
527
+ * @param velocity - the MIDI velocity value (0..127)
528
+ */
529
+ keyOn(channel: number, pitch: number, velocity: number): void;
530
+ /**
531
+ * Handle MIDI keyOff messages.
532
+ *
533
+ * @param channel - the MIDI channel (0..15, not used for now)
534
+ * @param pitch - the MIDI pitch value (0..127)
535
+ * @param velocity - the MIDI velocity value (0..127)
536
+ */
537
+ keyOff(channel: number, pitch: number, velocity: number): void;
538
+ /**
539
+ * Stop all playing notes.
540
+ *
541
+ * @param hard - whether to immediately stop notes or put them in release mode
542
+ */
543
+ allNotesOff(hard: boolean): void;
544
+ }
545
+ export interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode {
546
+ }
547
+ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
548
+ protected fOutputHandler: OutputParamHandler | null;
549
+ protected fComputeHandler: ComputeHandler | null;
550
+ protected fPlotHandler: PlotHandler | null;
551
+ protected fCachedEvents: {
552
+ type: string;
553
+ data: any;
554
+ }[];
555
+ protected fBufferNum: number;
556
+ protected fInChannels: Float32Array[] | Float64Array[];
557
+ protected fOutChannels: Float32Array[] | Float64Array[];
558
+ protected fOutputsTimer: number;
559
+ protected fInputsItems: string[];
560
+ protected fOutputsItems: string[];
561
+ protected fDescriptor: FaustUIInputItem[];
562
+ protected fAudioInputs: number;
563
+ protected fAudioOutputs: number;
564
+ protected fBufferSize: number;
565
+ protected gPtrSize: number;
566
+ protected gSampleSize: number;
567
+ protected fPitchwheelLabel: {
568
+ path: string;
569
+ min: number;
570
+ max: number;
571
+ }[];
572
+ protected fCtrlLabel: {
573
+ path: string;
574
+ min: number;
575
+ max: number;
576
+ }[][];
577
+ protected fPathTable: {
578
+ [address: string]: number;
579
+ };
580
+ protected fUICallback: UIHandler;
581
+ protected fProcessing: boolean;
582
+ protected fDestroyed: boolean;
583
+ protected fJSONDsp: FaustDspMeta;
584
+ constructor(sampleSize: number, bufferSize: number);
585
+ static remap(v: number, mn0: number, mx0: number, mn1: number, mx1: number): number;
586
+ static parseUI(ui: FaustUIDescriptor, callback: (item: FaustUIItem) => any): void;
587
+ static parseGroup(group: FaustUIGroup, callback: (item: FaustUIItem) => any): void;
588
+ static parseItems(items: FaustUIItem[], callback: (item: FaustUIItem) => any): void;
589
+ static parseItem(item: FaustUIItem, callback: (item: FaustUIItem) => any): void;
590
+ protected updateOutputs(): void;
591
+ metadata(handler: MetadataHandler): void;
592
+ compute(input: Float32Array[], output: Float32Array[]): boolean;
593
+ setOutputParamHandler(handler: OutputParamHandler | null): void;
594
+ getOutputParamHandler(): OutputParamHandler | null;
595
+ setComputeHandler(handler: ComputeHandler | null): void;
596
+ getComputeHandler(): ComputeHandler | null;
597
+ setPlotHandler(handler: PlotHandler | null): void;
598
+ getPlotHandler(): PlotHandler | null;
599
+ getNumInputs(): number;
600
+ getNumOutputs(): number;
601
+ midiMessage(data: number[] | Uint8Array): void;
602
+ ctrlChange(channel: number, ctrl: number, value: number): void;
603
+ pitchWheel(channel: number, wheel: number): void;
604
+ setParamValue(path: string, value: number): void;
605
+ getParamValue(path: string): number;
606
+ getParams(): string[];
607
+ getMeta(): FaustDspMeta;
608
+ getJSON(): string;
609
+ getUI(): FaustUIDescriptor;
610
+ getDescriptors(): FaustUIInputItem[];
611
+ start(): void;
612
+ stop(): void;
613
+ destroy(): void;
614
+ }
615
+ export declare class FaustMonoWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustMonoWebAudioDsp {
616
+ private fInstance;
617
+ private fDSP;
618
+ constructor(instance: FaustMonoDspInstance, sampleRate: number, sampleSize: number, bufferSize: number);
619
+ private initMemory;
620
+ toString(): string;
621
+ compute(input: Float32Array[] | ((input: Float32Array[] | Float64Array[]) => any), output: Float32Array[] | ((output: Float32Array[] | Float64Array[]) => any)): boolean;
622
+ metadata(handler: MetadataHandler): void;
623
+ getNumInputs(): number;
624
+ getNumOutputs(): number;
625
+ setParamValue(path: string, value: number): void;
626
+ getParamValue(path: string): number;
627
+ getMeta(): FaustDspMeta;
628
+ getJSON(): string;
629
+ getDescriptors(): FaustUIInputItem[];
630
+ getUI(): FaustUIDescriptor;
631
+ }
632
+ export declare class FaustWebAudioDspVoice {
633
+ static kActiveVoice: number;
634
+ static kFreeVoice: number;
635
+ static kReleaseVoice: number;
636
+ static kLegatoVoice: number;
637
+ static kNoVoice: number;
638
+ static VOICE_STOP_LEVEL: number;
639
+ private fFreqLabel;
640
+ private fGateLabel;
641
+ private fGainLabel;
642
+ private fKeyLabel;
643
+ private fVelLabel;
644
+ private fDSP;
645
+ private fAPI;
646
+ fCurNote: number;
647
+ fNextNote: number;
648
+ fNextVel: number;
649
+ fDate: number;
650
+ fLevel: number;
651
+ fRelease: number;
652
+ constructor($dsp: number, api: IFaustDspInstance, inputItems: string[], pathTable: {
653
+ [address: string]: number;
654
+ }, sampleRate: number);
655
+ static midiToFreq(note: number): number;
656
+ static normalizeVelocity(velocity: number): number;
657
+ private extractPaths;
658
+ keyOn(pitch: number, velocity: number, legato?: boolean): void;
659
+ keyOff(hard?: boolean): void;
660
+ computeLegato(bufferSize: number, $inputs: number, $outputZero: number, $outputsHalf: number): void;
661
+ compute(bufferSize: number, $inputs: number, $outputs: number): void;
662
+ setParamValue(index: number, value: number): void;
663
+ getParamValue(index: number): number;
664
+ }
665
+ export declare class FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp implements IFaustPolyWebAudioDsp {
666
+ private fInstance;
667
+ private fEffect;
668
+ private fJSONEffect;
669
+ private fAudioMixing;
670
+ private fAudioMixingHalf;
671
+ private fVoiceTable;
672
+ constructor(instance: FaustPolyDspInstance, sampleRate: number, sampleSize: number, bufferSize: number);
673
+ private initMemory;
674
+ toString(): string;
675
+ private allocVoice;
676
+ private getPlayingVoice;
677
+ private getFreeVoice;
678
+ compute(input: Float32Array[], output: Float32Array[]): boolean;
679
+ getNumInputs(): number;
680
+ getNumOutputs(): number;
681
+ private static findPath;
682
+ setParamValue(path: string, value: number): void;
683
+ getParamValue(path: string): number;
684
+ getMeta(): FaustDspMeta;
685
+ getJSON(): string;
686
+ getUI(): FaustUIDescriptor;
687
+ getDescriptors(): FaustUIInputItem[];
688
+ midiMessage(data: number[] | Uint8Array): void;
689
+ ctrlChange(channel: number, ctrl: number, value: number): void;
690
+ keyOn(channel: number, pitch: number, velocity: number): void;
691
+ keyOff(channel: number, pitch: number, velocity: number): void;
692
+ allNotesOff(hard?: boolean): void;
693
+ }
694
+ /**
695
+ * Injected in the string to be compiled on AudioWorkletProcessor side
696
+ */
697
+ export interface FaustData {
698
+ processorName: string;
699
+ dspName: string;
700
+ dspMeta: FaustDspMeta;
701
+ poly: boolean;
702
+ effectMeta?: FaustDspMeta;
703
+ }
704
+ export interface FaustAudioWorkletProcessorDependencies<Poly extends boolean = false> {
705
+ FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;
706
+ FaustMonoWebAudioDsp: Poly extends true ? undefined : typeof FaustMonoWebAudioDsp;
707
+ FaustPolyWebAudioDsp: Poly extends true ? typeof FaustPolyWebAudioDsp : undefined;
708
+ FaustWebAudioDspVoice: Poly extends true ? typeof FaustWebAudioDspVoice : undefined;
709
+ FaustWasmInstantiator: typeof FaustWasmInstantiator;
710
+ }
711
+ export interface FaustAudioWorkletNodeOptions<Poly extends boolean = false> extends AudioWorkletNodeOptions {
712
+ processorOptions: Poly extends true ? FaustPolyAudioWorkletProcessorOptions : FaustMonoAudioWorkletProcessorOptions;
713
+ }
714
+ export interface FaustMonoAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
715
+ processorOptions: FaustMonoAudioWorkletProcessorOptions;
716
+ }
717
+ export interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
718
+ processorOptions: FaustPolyAudioWorkletProcessorOptions;
719
+ }
720
+ export interface FaustAudioWorkletProcessorOptions {
721
+ name: string;
722
+ sampleSize: number;
723
+ }
724
+ export interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
725
+ factory: LooseFaustDspFactory;
726
+ }
727
+ export interface FaustPolyAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
728
+ voiceFactory: LooseFaustDspFactory;
729
+ mixerModule: WebAssembly.Module;
730
+ voices: number;
731
+ effectFactory?: LooseFaustDspFactory;
732
+ }
733
+ export declare const getFaustAudioWorkletProcessor: <Poly extends boolean = false>(dependencies: FaustAudioWorkletProcessorDependencies<Poly>, faustData: FaustData, register?: boolean) => {
734
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
735
+ prototype: AudioWorkletProcessor;
736
+ parameterDescriptors: AudioParamDescriptor[];
737
+ };
738
+ export interface FaustFFTOptionsData {
739
+ fftSize: number;
740
+ fftOverlap: number;
741
+ noIFFT: boolean;
742
+ /** Index number of the default window function, leave undefined or -1 for rectangular (no windowing) */
743
+ defaultWindowFunction: number;
744
+ }
745
+ /**
746
+ * Injected in the string to be compiled on AudioWorkletProcessor side
747
+ */
748
+ export interface FaustFFTData {
749
+ processorName: string;
750
+ dspName: string;
751
+ dspMeta: FaustDspMeta;
752
+ fftOptions?: Partial<FaustFFTOptionsData>;
753
+ }
754
+ export interface FaustFFTAudioWorkletProcessorDependencies {
755
+ FaustBaseWebAudioDsp: typeof FaustBaseWebAudioDsp;
756
+ FaustMonoWebAudioDsp: typeof FaustMonoWebAudioDsp;
757
+ FaustWasmInstantiator: typeof FaustWasmInstantiator;
758
+ FFTUtils: typeof FFTUtils;
759
+ }
760
+ export interface FaustFFTAudioWorkletNodeOptions extends AudioWorkletNodeOptions {
761
+ processorOptions: FaustFFTAudioWorkletProcessorOptions;
762
+ }
763
+ export interface FaustFFTAudioWorkletProcessorOptions {
764
+ name: string;
765
+ sampleSize: number;
766
+ factory: LooseFaustDspFactory;
767
+ }
768
+ export declare const getFaustFFTAudioWorkletProcessor: (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register?: boolean) => {
769
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
770
+ prototype: AudioWorkletProcessor; /** Generated from the current window function */
771
+ parameterDescriptors: AudioParamDescriptor[];
772
+ };
773
+ export interface ILibFaust extends LibFaustWasm {
774
+ module(): FaustModule;
775
+ fs(): typeof FS;
776
+ }
777
+ export declare class LibFaust implements ILibFaust {
778
+ private fModule;
779
+ private fCompiler;
780
+ private fFileSystem;
781
+ constructor(module: FaustModule);
782
+ module(): FaustModule;
783
+ fs(): typeof FS;
784
+ version(): string;
785
+ createDSPFactory(name: string, code: string, args: string, useInternalMemory: boolean): FaustDspWasm;
786
+ deleteDSPFactory(cFactory: number): void;
787
+ expandDSP(name: string, code: string, args: string): string;
788
+ generateAuxFiles(name: string, code: string, args: string): boolean;
789
+ deleteAllDSPFactories(): void;
790
+ getErrorAfterException(): string;
791
+ cleanupAfterException(): void;
792
+ getInfos(what: FaustInfoType): string;
793
+ toString(): string;
794
+ }
795
+ export declare const ab2str: (buf: Uint8Array) => any;
796
+ export declare const str2ab: (str: string) => Uint8Array;
797
+ export interface IFaustCompiler {
798
+ /**
799
+ * Gives the Faust compiler version.
800
+ * @return a version string
801
+ */
802
+ version(): string;
803
+ /**
804
+ * Gives the last compilation error.
805
+ * @return an error string
806
+ */
807
+ getErrorMessage(): string;
808
+ /**
809
+ * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create monophonic instances.
810
+ * This function is running asynchronously.
811
+ *
812
+ * @param name - an arbitrary name for the Faust factory
813
+ * @param code - Faust dsp code
814
+ * @param args - the compiler options
815
+ * @returns returns the wasm factory
816
+ */
817
+ createMonoDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
818
+ /**
819
+ * Create a wasm factory from Faust code i.e. wasm compiled code, to be used to create polyphonic instances.
820
+ * This function is running asynchronously.
821
+ *
822
+ * @param name - an arbitrary name for the Faust factory
823
+ * @param code - Faust dsp code
824
+ * @param args - the compiler options
825
+ * @returns returns the wasm factory
826
+ */
827
+ createPolyDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
828
+ /**
829
+ * Delete a dsp factory.
830
+ *
831
+ * @param factory - the factory to be deleted
832
+ */
833
+ deleteDSPFactory(factory: FaustDspFactory): void;
834
+ /**
835
+ * Expand Faust code i.e. linearize included libraries.
836
+ *
837
+ * @param code - Faust dsp code
838
+ * @param args - the compiler options
839
+ * @returns returns the expanded dsp code
840
+ */
841
+ expandDSP(code: string, args: string): string | null;
842
+ /**
843
+ * Generates auxiliary files from Faust code. The output depends on the compiler options.
844
+ *
845
+ * @param name - an arbitrary name for the Faust module
846
+ * @param code - Faust dsp code
847
+ * @param args - the compiler options
848
+ * @returns whether the generation actually succeded
849
+ */
850
+ generateAuxFiles(name: string, code: string, args: string): boolean;
851
+ /**
852
+ * Delete all factories.
853
+ */
854
+ deleteAllDSPFactories(): void;
855
+ fs(): typeof FS;
856
+ getAsyncInternalMixerModule(isDouble?: boolean): Promise<{
857
+ mixerBuffer: Uint8Array;
858
+ mixerModule: WebAssembly.Module;
859
+ }>;
860
+ getSyncInternalMixerModule(isDouble?: boolean): {
861
+ mixerBuffer: Uint8Array;
862
+ mixerModule: WebAssembly.Module;
863
+ };
864
+ }
865
+ export declare class FaustCompiler implements IFaustCompiler {
866
+ private fLibFaust;
867
+ private fErrorMessage;
868
+ private static gFactories;
869
+ private mixer32Buffer;
870
+ private mixer64Buffer;
871
+ private mixer32Module;
872
+ private mixer64Module;
873
+ /**
874
+ * Get a stringified DSP factories table
875
+ */
876
+ static serializeDSPFactories(): Record<string, {
877
+ code: string;
878
+ json: any;
879
+ poly: boolean;
880
+ }>;
881
+ /**
882
+ * Get a stringified DSP factories table as string
883
+ */
884
+ static stringifyDSPFactories(): string;
885
+ /**
886
+ * Import a DSP factories table
887
+ */
888
+ static deserializeDSPFactories(table: Record<string, {
889
+ code: string;
890
+ json: any;
891
+ poly: boolean;
892
+ }>): Promise<Map<string, FaustDspFactory>[]>;
893
+ /**
894
+ * Import a stringified DSP factories table
895
+ */
896
+ static importDSPFactories(tableStr: string): Promise<Map<string, FaustDspFactory>[]>;
897
+ constructor(libFaust: ILibFaust);
898
+ private intVec2intArray;
899
+ private createDSPFactory;
900
+ version(): string;
901
+ getErrorMessage(): string;
902
+ createMonoDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
903
+ createPolyDSPFactory(name: string, code: string, args: string): Promise<FaustDspFactory | null>;
904
+ deleteDSPFactory(factory: FaustDspFactory): void;
905
+ expandDSP(code: string, args: string): string;
906
+ generateAuxFiles(name: string, code: string, args: string): boolean;
907
+ deleteAllDSPFactories(): void;
908
+ fs(): typeof FS;
909
+ getAsyncInternalMixerModule(isDouble?: boolean): Promise<{
910
+ mixerBuffer: Uint8Array;
911
+ mixerModule: WebAssembly.Module;
912
+ }>;
913
+ getSyncInternalMixerModule(isDouble?: boolean): {
914
+ mixerBuffer: Uint8Array;
915
+ mixerModule: WebAssembly.Module;
916
+ };
917
+ }
918
+ /**
919
+ * For offline rendering.
920
+ */
921
+ export interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {
922
+ render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];
923
+ }
924
+ export interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp {
925
+ }
926
+ export interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp {
927
+ }
928
+ export declare class FaustOfflineProcessor<Poly extends boolean = false> {
929
+ protected fDSPCode: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;
930
+ protected fBufferSize: number;
931
+ protected fInputs: Float32Array[];
932
+ protected fOutputs: Float32Array[];
933
+ constructor(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp, bufferSize: number);
934
+ getParameterDescriptors(): AudioParamDescriptor[];
935
+ compute(input: Float32Array[], output: Float32Array[]): boolean;
936
+ setOutputParamHandler(handler: OutputParamHandler): void;
937
+ getOutputParamHandler(): OutputParamHandler | null;
938
+ setComputeHandler(handler: ComputeHandler): void;
939
+ getComputeHandler(): ComputeHandler | null;
940
+ setPlotHandler(handler: PlotHandler): void;
941
+ getPlotHandler(): PlotHandler | null;
942
+ getNumInputs(): number;
943
+ getNumOutputs(): number;
944
+ metadata(handler: MetadataHandler): void;
945
+ midiMessage(data: number[] | Uint8Array): void;
946
+ ctrlChange(chan: number, ctrl: number, value: number): void;
947
+ pitchWheel(chan: number, value: number): void;
948
+ setParamValue(path: string, value: number): void;
949
+ getParamValue(path: string): number;
950
+ getParams(): string[];
951
+ getMeta(): FaustDspMeta;
952
+ getJSON(): string;
953
+ getDescriptors(): FaustUIInputItem[];
954
+ getUI(): FaustUIDescriptor;
955
+ start(): void;
956
+ stop(): void;
957
+ destroy(): void;
958
+ /**
959
+ * Render frames in an array.
960
+ *
961
+ * @param inputs - input signal
962
+ * @param length - the number of frames to render (default: bufferSize)
963
+ * @param onUpdate - a callback after each buffer calculated, with an argument "current sample"
964
+ * @return an array of Float32Array with the rendered frames
965
+ */
966
+ render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];
967
+ }
968
+ export declare class FaustMonoOfflineProcessor extends FaustOfflineProcessor<false> implements IFaustMonoWebAudioDsp {
969
+ }
970
+ export declare class FaustPolyOfflineProcessor extends FaustOfflineProcessor<true> implements IFaustPolyWebAudioDsp {
971
+ keyOn(channel: number, pitch: number, velocity: number): void;
972
+ keyOff(channel: number, pitch: number, velocity: number): void;
973
+ allNotesOff(hard: boolean): void;
974
+ }
975
+ export interface IFaustSvgDiagrams {
976
+ /**
977
+ * Generates auxiliary files from Faust code. The output depends on the compiler options.
978
+ *
979
+ * @param name - the DSP's name
980
+ * @param code - Faust code
981
+ * @param args - compilation args
982
+ * @returns the svg diagrams as a filename - svg string map
983
+ */
984
+ from(name: string, code: string, args: string): Record<string, string>;
985
+ }
986
+ export declare class FaustSvgDiagrams implements IFaustSvgDiagrams {
987
+ private compiler;
988
+ constructor(compiler: FaustCompiler);
989
+ from(name: string, code: string, args: string): Record<string, string>;
990
+ }
991
+ export interface WavEncoderOptions {
992
+ bitDepth: number;
993
+ float?: boolean;
994
+ symmetric?: boolean;
995
+ shared?: boolean;
996
+ sampleRate: number;
997
+ }
998
+ /**
999
+ * Code from https://github.com/mohayonao/wav-encoder
1000
+ */
1001
+ export declare class WavEncoder {
1002
+ static encode(audioBuffer: Float32Array[], options: WavEncoderOptions): ArrayBuffer;
1003
+ private static writeHeader;
1004
+ private static writeData;
1005
+ }
1006
+ export interface WavDecoderOptions {
1007
+ symmetric?: boolean;
1008
+ shared?: boolean;
1009
+ }
1010
+ /**
1011
+ * Code from https://github.com/mohayonao/wav-decoder
1012
+ */
1013
+ export declare class WavDecoder {
1014
+ static decode(buffer: ArrayBuffer, options?: WavDecoderOptions): {
1015
+ numberOfChannels: number;
1016
+ length: number;
1017
+ sampleRate: number;
1018
+ channelData: Float32Array[];
1019
+ };
1020
+ private static decodeFormat;
1021
+ private static decodeData;
1022
+ private static readPCM;
1023
+ }
1024
+ declare const FaustAudioWorkletNode_base: {
1025
+ new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions | undefined): AudioWorkletNode;
1026
+ prototype: AudioWorkletNode;
1027
+ };
1028
+ /**
1029
+ * Base class for Monophonic and Polyphonic AudioWorkletNode
1030
+ */
1031
+ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends FaustAudioWorkletNode_base {
1032
+ protected fJSONDsp: FaustDspMeta;
1033
+ protected fJSON: string;
1034
+ protected fInputsItems: string[];
1035
+ protected fOutputHandler: OutputParamHandler | null;
1036
+ protected fComputeHandler: ComputeHandler | null;
1037
+ protected fPlotHandler: PlotHandler | null;
1038
+ protected fUICallback: UIHandler;
1039
+ protected fDescriptor: FaustUIInputItem[];
1040
+ constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: FaustAudioWorkletNodeOptions<Poly>["processorOptions"], nodeOptions?: Partial<FaustAudioWorkletNodeOptions>);
1041
+ setOutputParamHandler(handler: OutputParamHandler | null): void;
1042
+ getOutputParamHandler(): OutputParamHandler | null;
1043
+ setComputeHandler(handler: ComputeHandler | null): void;
1044
+ getComputeHandler(): ComputeHandler | null;
1045
+ setPlotHandler(handler: PlotHandler | null): void;
1046
+ getPlotHandler(): PlotHandler | null;
1047
+ getNumInputs(): number;
1048
+ getNumOutputs(): number;
1049
+ compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
1050
+ metadata(handler: MetadataHandler): void;
1051
+ midiMessage(data: number[] | Uint8Array): void;
1052
+ ctrlChange(channel: number, ctrl: number, value: number): void;
1053
+ pitchWheel(channel: number, wheel: number): void;
1054
+ setParamValue(path: string, value: number): void;
1055
+ getParamValue(path: string): number;
1056
+ getParams(): string[];
1057
+ getMeta(): FaustDspMeta;
1058
+ getJSON(): string;
1059
+ getUI(): FaustUIDescriptor;
1060
+ getDescriptors(): FaustUIInputItem[];
1061
+ start(): void;
1062
+ stop(): void;
1063
+ destroy(): void;
1064
+ }
1065
+ /**
1066
+ * Monophonic AudioWorkletNode
1067
+ */
1068
+ export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<false> implements IFaustMonoWebAudioDsp {
1069
+ onprocessorerror: (e: Event) => never;
1070
+ constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, sampleSize: number, nodeOptions?: Partial<FaustAudioWorkletNodeOptions>);
1071
+ }
1072
+ /**
1073
+ * Polyphonic AudioWorkletNode
1074
+ */
1075
+ export declare class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode<true> implements IFaustPolyWebAudioDsp {
1076
+ private fJSONEffect;
1077
+ onprocessorerror: (e: Event) => never;
1078
+ constructor(context: BaseAudioContext, name: string, voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, sampleSize: number, effectFactory?: LooseFaustDspFactory, nodeOptions?: Partial<FaustAudioWorkletNodeOptions>);
1079
+ keyOn(channel: number, pitch: number, velocity: number): void;
1080
+ keyOff(channel: number, pitch: number, velocity: number): void;
1081
+ allNotesOff(hard: boolean): void;
1082
+ getMeta(): FaustDspMeta;
1083
+ getJSON(): string;
1084
+ getUI(): FaustUIDescriptor;
1085
+ }
1086
+ declare const FaustScriptProcessorNode_base: {
1087
+ new (): ScriptProcessorNode;
1088
+ prototype: ScriptProcessorNode;
1089
+ };
1090
+ /**
1091
+ * Base class for Monophonic and Polyphonic ScriptProcessorNode
1092
+ */
1093
+ export declare class FaustScriptProcessorNode<Poly extends boolean = false> extends FaustScriptProcessorNode_base {
1094
+ protected fDSPCode: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;
1095
+ protected fInputs: Float32Array[];
1096
+ protected fOutputs: Float32Array[];
1097
+ init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void;
1098
+ compute(input: Float32Array[], output: Float32Array[]): boolean;
1099
+ setOutputParamHandler(handler: OutputParamHandler): void;
1100
+ getOutputParamHandler(): OutputParamHandler | null;
1101
+ setComputeHandler(handler: ComputeHandler): void;
1102
+ getComputeHandler(): ComputeHandler | null;
1103
+ setPlotHandler(handler: PlotHandler): void;
1104
+ getPlotHandler(): PlotHandler | null;
1105
+ getNumInputs(): number;
1106
+ getNumOutputs(): number;
1107
+ metadata(handler: MetadataHandler): void;
1108
+ midiMessage(data: number[] | Uint8Array): void;
1109
+ ctrlChange(chan: number, ctrl: number, value: number): void;
1110
+ pitchWheel(chan: number, value: number): void;
1111
+ setParamValue(path: string, value: number): void;
1112
+ getParamValue(path: string): number;
1113
+ getParams(): string[];
1114
+ getMeta(): FaustDspMeta;
1115
+ getJSON(): string;
1116
+ getDescriptors(): FaustUIInputItem[];
1117
+ getUI(): FaustUIDescriptor;
1118
+ start(): void;
1119
+ stop(): void;
1120
+ destroy(): void;
1121
+ }
1122
+ export declare class FaustMonoScriptProcessorNode extends FaustScriptProcessorNode<false> implements IFaustMonoWebAudioDsp {
1123
+ }
1124
+ export declare class FaustPolyScriptProcessorNode extends FaustScriptProcessorNode<true> implements IFaustPolyWebAudioDsp {
1125
+ keyOn(channel: number, pitch: number, velocity: number): void;
1126
+ keyOff(channel: number, pitch: number, velocity: number): void;
1127
+ allNotesOff(hard: boolean): void;
1128
+ }
1129
+ export interface IFaustMonoDspGenerator {
1130
+ /**
1131
+ * Compile a monophonic DSP factory from given code.
1132
+ *
1133
+ * @param compiler - the Faust compiler
1134
+ * @param name - the DSP name
1135
+ * @param code - the DSP code
1136
+ * @param args - the compilation parameters
1137
+ * @returns the compiled factory or 'null' if failure
1138
+ */
1139
+ compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<{
1140
+ factory: FaustDspFactory | null;
1141
+ name?: string;
1142
+ meta?: FaustDspMeta;
1143
+ } | null>;
1144
+ /**
1145
+ * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1146
+ *
1147
+ * @param context - the WebAudio context
1148
+ * @param name - DSP name, can be used for processorName
1149
+ * @param factory - default is the compiled factory
1150
+ * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
1151
+ * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
1152
+ * @param processorName - AudioWorklet Processor name
1153
+ * @returns the compiled WebAudio node or 'null' if failure
1154
+ */
1155
+ createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string): Promise<IFaustMonoWebAudioNode | null>;
1156
+ /**
1157
+ * Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1158
+ *
1159
+ * @param context - the WebAudio context
1160
+ * @param fftUtils - should be an anonymous class with static methods, without any import from outside
1161
+ * @param name - DSP name, can be used for processorName
1162
+ * @param factory - default is the compiled factory
1163
+ * @param fftOptions - initial FFT options
1164
+ * @param processorName - AudioWorklet Processor name
1165
+ * @returns the compiled WebAudio node or 'null' if failure
1166
+ */
1167
+ createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
1168
+ /**
1169
+ * Create a monophonic Offline processor.
1170
+ *
1171
+ * @param sampleRate - the sample rate in Hz
1172
+ * @param bufferSize - the buffer size in frames
1173
+ * @param factory - default is the compiled factory
1174
+ * @returns the compiled processor or 'null' if failure
1175
+ */
1176
+ createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, meta?: FaustDspMeta): Promise<IFaustMonoOfflineProcessor | null>;
1177
+ }
1178
+ export interface IFaustPolyDspGenerator {
1179
+ /**
1180
+ * Compile a monophonic DSP factory from given code.
1181
+ *
1182
+ * @param compiler - the Faust compiler
1183
+ * @param name - the DSP name
1184
+ * @param dspCode - the DSP code ('dsp_code' can possibly contain an integrated effect)
1185
+ * @param args - the compilation parameters
1186
+ * @param effectCode - optional effect DSP code
1187
+ * @returns the compiled factory or 'null' if failure
1188
+ */
1189
+ compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<{
1190
+ voiceFactory: FaustDspFactory | null;
1191
+ effectFactory?: FaustDspFactory | null;
1192
+ } | null>;
1193
+ /**
1194
+ * Create a polyphonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
1195
+ *
1196
+ * @param context the WebAudio context
1197
+ * @param voices - the number of voices
1198
+ * @param name - AudioWorklet Processor name
1199
+ * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1200
+ * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)
1201
+ * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1202
+ * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
1203
+ * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
1204
+ * @returns the compiled WebAudio node or 'null' if failure
1205
+ */
1206
+ createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: boolean, bufferSize?: number): Promise<IFaustPolyWebAudioNode | null>;
1207
+ /**
1208
+ * Create a monophonic Offline processor.
1209
+ *
1210
+ * @param sampleRate - the sample rate in Hz
1211
+ * @param bufferSize - the buffer size in frames
1212
+ * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1213
+ * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)
1214
+ * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1215
+ * @returns the compiled processor or 'null' if failure
1216
+ */
1217
+ createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null): Promise<IFaustPolyOfflineProcessor | null>;
1218
+ }
1219
+ export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
1220
+ private static gWorkletProcessors;
1221
+ name: string;
1222
+ factory: FaustDspFactory | null;
1223
+ constructor();
1224
+ compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<this | null>;
1225
+ 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>;
1226
+ createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
1227
+ createAudioWorkletProcessor(name?: string, factory?: LooseFaustDspFactory, processorName?: string): Promise<{
1228
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1229
+ prototype: AudioWorkletProcessor;
1230
+ parameterDescriptors: AudioParamDescriptor[];
1231
+ }>;
1232
+ createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory): Promise<FaustMonoOfflineProcessor>;
1233
+ }
1234
+ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
1235
+ private static gWorkletProcessors;
1236
+ name: string;
1237
+ voiceFactory: FaustDspFactory | null;
1238
+ effectFactory: FaustDspFactory | null;
1239
+ mixerBuffer: Uint8Array;
1240
+ mixerModule: WebAssembly.Module;
1241
+ constructor();
1242
+ compile(compiler: IFaustCompiler, name: string, dspCode: string, args: string, effectCode?: string): Promise<this | null>;
1243
+ 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>;
1244
+ createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
1245
+ new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
1246
+ prototype: AudioWorkletProcessor;
1247
+ parameterDescriptors: AudioParamDescriptor[];
1248
+ }>;
1249
+ createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null): Promise<FaustPolyOfflineProcessor>;
1250
+ }
1251
+
1252
+ export {};