@grame/faustwasm 0.0.30 → 0.0.33
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.
- package/assets/standalone/faustwasm/index.d.ts +42 -0
- package/assets/standalone/faustwasm/index.js +41 -2
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.d.ts +42 -0
- package/dist/cjs/index.js +41 -2
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +42 -0
- package/dist/cjs-bundle/index.js +45 -6
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +42 -0
- package/dist/esm/index.js +41 -2
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +42 -0
- package/dist/esm-bundle/index.js +45 -6
- package/dist/esm-bundle/index.js.map +2 -2
- package/libfaust-wasm/libfaust-wasm.data +0 -0
- package/libfaust-wasm/libfaust-wasm.js +1 -1
- package/libfaust-wasm/libfaust-wasm.wasm +0 -0
- package/package.json +1 -1
- package/src/FaustDspGenerator.ts +111 -36
- package/src/FaustWasmInstantiator.ts +2 -2
- package/test/faustlive-wasm/faustwasm/index.d.ts +42 -0
- package/test/faustlive-wasm/faustwasm/index.js +41 -2
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
|
Binary file
|
package/package.json
CHANGED
package/src/FaustDspGenerator.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { FaustMonoOfflineProcessor, FaustPolyOfflineProcessor, IFaustMonoOffline
|
|
|
7
7
|
import { FaustMonoScriptProcessorNode, FaustPolyScriptProcessorNode } from "./FaustScriptProcessorNode";
|
|
8
8
|
import { FaustBaseWebAudioDsp, FaustMonoWebAudioDsp, FaustPolyWebAudioDsp, FaustWebAudioDspVoice, IFaustMonoWebAudioNode, IFaustPolyWebAudioNode } from "./FaustWebAudioDsp";
|
|
9
9
|
import type { IFaustCompiler } from "./FaustCompiler";
|
|
10
|
-
import type { FaustDspFactory, FaustDspMeta, FFTUtils, LooseFaustDspFactory } from "./types";
|
|
10
|
+
import type { FaustDspFactory, FaustUIDescriptor, FaustDspMeta, FFTUtils, LooseFaustDspFactory } from "./types";
|
|
11
11
|
|
|
12
12
|
export interface IFaustMonoDspGenerator {
|
|
13
13
|
/**
|
|
@@ -44,7 +44,7 @@ export interface IFaustMonoDspGenerator {
|
|
|
44
44
|
bufferSize?: number,
|
|
45
45
|
processorName?: string
|
|
46
46
|
): Promise<IFaustMonoWebAudioNode | null>;
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
/**
|
|
49
49
|
* Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
|
|
50
50
|
*
|
|
@@ -64,7 +64,7 @@ export interface IFaustMonoDspGenerator {
|
|
|
64
64
|
fftOptions?: Partial<FaustFFTOptionsData>,
|
|
65
65
|
processorName?: string
|
|
66
66
|
): Promise<FaustMonoAudioWorkletNode | null>;
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
/**
|
|
69
69
|
* Create a monophonic Offline processor.
|
|
70
70
|
*
|
|
@@ -74,6 +74,27 @@ export interface IFaustMonoDspGenerator {
|
|
|
74
74
|
* @returns the compiled processor or 'null' if failure
|
|
75
75
|
*/
|
|
76
76
|
createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, meta?: FaustDspMeta): Promise<IFaustMonoOfflineProcessor | null>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get DSP JSON description with its UI and metadata as object.
|
|
80
|
+
*
|
|
81
|
+
* @return the DSP JSON description as object
|
|
82
|
+
*/
|
|
83
|
+
getMeta(): FaustDspMeta;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get DSP JSON description with its UI and metadata.
|
|
87
|
+
*
|
|
88
|
+
* @return the DSP JSON description
|
|
89
|
+
*/
|
|
90
|
+
getJSON(): string;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Get DSP UI description.
|
|
94
|
+
*
|
|
95
|
+
* @return the DSP UI description
|
|
96
|
+
*/
|
|
97
|
+
getUI(): FaustUIDescriptor;
|
|
77
98
|
}
|
|
78
99
|
|
|
79
100
|
export interface IFaustPolyDspGenerator {
|
|
@@ -131,8 +152,29 @@ export interface IFaustPolyDspGenerator {
|
|
|
131
152
|
voices: number,
|
|
132
153
|
voiceFactory?: LooseFaustDspFactory,
|
|
133
154
|
mixerModule?: WebAssembly.Module,
|
|
134
|
-
effectFactory?: LooseFaustDspFactory | null
|
|
155
|
+
effectFactory?: LooseFaustDspFactory | null
|
|
135
156
|
): Promise<IFaustPolyOfflineProcessor | null>;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Get DSP JSON description with its UI and metadata as object.
|
|
160
|
+
*
|
|
161
|
+
* @return the DSP JSON description as object
|
|
162
|
+
*/
|
|
163
|
+
getMeta(): FaustDspMeta;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Get DSP JSON description with its UI and metadata.
|
|
167
|
+
*
|
|
168
|
+
* @return the DSP JSON description
|
|
169
|
+
*/
|
|
170
|
+
getJSON(): string;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Get DSP UI description.
|
|
174
|
+
*
|
|
175
|
+
* @return the DSP UI description
|
|
176
|
+
*/
|
|
177
|
+
getUI(): FaustUIDescriptor;
|
|
136
178
|
}
|
|
137
179
|
|
|
138
180
|
export class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
|
|
@@ -179,11 +221,11 @@ export class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
|
|
|
179
221
|
const processorCode = `
|
|
180
222
|
// DSP name and JSON string for DSP are generated
|
|
181
223
|
const faustData = ${JSON.stringify({
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
} as FaustData)};
|
|
224
|
+
processorName,
|
|
225
|
+
dspName: name,
|
|
226
|
+
dspMeta: meta,
|
|
227
|
+
poly: false
|
|
228
|
+
} as FaustData)};
|
|
187
229
|
// Implementation needed classes of functions
|
|
188
230
|
const ${FaustDspInstance.name} = ${FaustDspInstance.toString()}
|
|
189
231
|
const ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}
|
|
@@ -232,11 +274,11 @@ const dependencies = {
|
|
|
232
274
|
const processorCode = `
|
|
233
275
|
// DSP name and JSON string for DSP are generated
|
|
234
276
|
const faustData = ${JSON.stringify({
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
} as FaustFFTData)};
|
|
277
|
+
processorName,
|
|
278
|
+
dspName: name,
|
|
279
|
+
dspMeta: meta,
|
|
280
|
+
fftOptions
|
|
281
|
+
} as FaustFFTData)};
|
|
240
282
|
// Implementation needed classes of functions
|
|
241
283
|
const ${FaustDspInstance.name} = ${FaustDspInstance.toString()}
|
|
242
284
|
const ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}
|
|
@@ -300,22 +342,22 @@ const dependencies = {
|
|
|
300
342
|
}
|
|
301
343
|
// const sampleSize = meta.compile_options.match("-double") ? 8 : 4;
|
|
302
344
|
// Dynamically create AudioWorkletProcessor if code not yet created
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
345
|
+
try {
|
|
346
|
+
// DSP name and JSON string for DSP are generated
|
|
347
|
+
const faustData = {
|
|
348
|
+
processorName,
|
|
349
|
+
dspName: name,
|
|
350
|
+
dspMeta: meta,
|
|
351
|
+
poly: false
|
|
352
|
+
} as FaustData;
|
|
353
|
+
// Generate the actual AudioWorkletProcessor code
|
|
354
|
+
const Processor = getFaustAudioWorkletProcessor(dependencies, faustData);
|
|
355
|
+
return Processor;
|
|
356
|
+
} catch (e) {
|
|
357
|
+
// console.error(`=> exception raised while running createMonoNode: ${e}`);
|
|
358
|
+
// console.error(`=> check that your page is served using https.${e}`);
|
|
359
|
+
throw e;
|
|
360
|
+
}
|
|
319
361
|
}
|
|
320
362
|
async createOfflineProcessor(
|
|
321
363
|
sampleRate: number,
|
|
@@ -330,6 +372,10 @@ const dependencies = {
|
|
|
330
372
|
const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize);
|
|
331
373
|
return new FaustMonoOfflineProcessor(monoDsp, bufferSize);
|
|
332
374
|
}
|
|
375
|
+
|
|
376
|
+
getMeta() { return JSON.parse(this.factory!.json); }
|
|
377
|
+
getJSON() { return JSON.stringify(this.getMeta()); }
|
|
378
|
+
getUI() { return this.getMeta(); }
|
|
333
379
|
}
|
|
334
380
|
|
|
335
381
|
export class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
|
|
@@ -405,12 +451,12 @@ process = adaptor(dsp_code.process, dsp_code.effect) : dsp_code.effect;`
|
|
|
405
451
|
const processorCode = `
|
|
406
452
|
// DSP name and JSON string for DSP are generated
|
|
407
453
|
const faustData = ${JSON.stringify({
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
} as FaustData)};
|
|
454
|
+
processorName,
|
|
455
|
+
dspName: name,
|
|
456
|
+
dspMeta: voiceMeta,
|
|
457
|
+
poly: true,
|
|
458
|
+
effectMeta
|
|
459
|
+
} as FaustData)};
|
|
414
460
|
// Implementation needed classes of functions
|
|
415
461
|
const ${FaustDspInstance.name} = ${FaustDspInstance.toString()}
|
|
416
462
|
const ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}
|
|
@@ -495,4 +541,33 @@ const dependencies = {
|
|
|
495
541
|
const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize);
|
|
496
542
|
return new FaustPolyOfflineProcessor(polyDsp, bufferSize);
|
|
497
543
|
}
|
|
544
|
+
|
|
545
|
+
getMeta() {
|
|
546
|
+
const o = (this.voiceFactory) ? JSON.parse(this.voiceFactory.json) : null;
|
|
547
|
+
const e = (this.effectFactory) ? JSON.parse(this.effectFactory.json) : null;
|
|
548
|
+
const r = { ...o };
|
|
549
|
+
if (e) {
|
|
550
|
+
r.ui = [{
|
|
551
|
+
type: "tgroup", label: "Sequencer", items: [
|
|
552
|
+
{ type: "vgroup", label: "Instrument", items: o.ui },
|
|
553
|
+
{ type: "vgroup", label: "Effect", items: e.ui }
|
|
554
|
+
]
|
|
555
|
+
}];
|
|
556
|
+
} else {
|
|
557
|
+
r.ui = [{
|
|
558
|
+
type: "tgroup", label: "Polyphonic", items: [
|
|
559
|
+
{ type: "vgroup", label: "Voices", items: o.ui }
|
|
560
|
+
]
|
|
561
|
+
}];
|
|
562
|
+
}
|
|
563
|
+
return r as FaustDspMeta;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
getJSON() {
|
|
567
|
+
return JSON.stringify(this.getMeta());
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
getUI() {
|
|
571
|
+
return this.getMeta().ui;
|
|
572
|
+
}
|
|
498
573
|
}
|
|
@@ -16,7 +16,7 @@ class FaustWasmInstantiator {
|
|
|
16
16
|
_fmodf: (x: number, y: number) => x % y,
|
|
17
17
|
_logf: Math.log, _log10f: Math.log10, _max_f: Math.max, _min_f: Math.min,
|
|
18
18
|
_remainderf: (x: number, y: number) => x - Math.round(x / y) * y,
|
|
19
|
-
_powf: Math.pow, _roundf: Math.
|
|
19
|
+
_powf: Math.pow, _roundf: Math.round, _sinf: Math.sin, _sqrtf: Math.sqrt, _tanf: Math.tan,
|
|
20
20
|
_acoshf: Math.acosh, _asinhf: Math.asinh, _atanhf: Math.atanh,
|
|
21
21
|
_coshf: Math.cosh, _sinhf: Math.sinh, _tanhf: Math.tanh,
|
|
22
22
|
_isnanf: Number.isNaN, _isinff: (x: number) => !isFinite(x),
|
|
@@ -28,7 +28,7 @@ class FaustWasmInstantiator {
|
|
|
28
28
|
_fmod: (x: number, y: number) => x % y,
|
|
29
29
|
_log: Math.log, _log10: Math.log10, _max_: Math.max, _min_: Math.min,
|
|
30
30
|
_remainder: (x: number, y: number) => x - Math.round(x / y) * y,
|
|
31
|
-
_pow: Math.pow, _round: Math.
|
|
31
|
+
_pow: Math.pow, _round: Math.round, _sin: Math.sin, _sqrt: Math.sqrt, _tan: Math.tan,
|
|
32
32
|
_acosh: Math.acosh, _asinh: Math.asinh, _atanh: Math.atanh,
|
|
33
33
|
_cosh: Math.cosh, _sinh: Math.sinh, _tanh: Math.tanh,
|
|
34
34
|
_isnan: Number.isNaN, _isinf: (x: number) => !isFinite(x),
|
|
@@ -1174,6 +1174,24 @@ export interface IFaustMonoDspGenerator {
|
|
|
1174
1174
|
* @returns the compiled processor or 'null' if failure
|
|
1175
1175
|
*/
|
|
1176
1176
|
createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory, meta?: FaustDspMeta): Promise<IFaustMonoOfflineProcessor | null>;
|
|
1177
|
+
/**
|
|
1178
|
+
* Get DSP JSON description with its UI and metadata as object.
|
|
1179
|
+
*
|
|
1180
|
+
* @return the DSP JSON description as object
|
|
1181
|
+
*/
|
|
1182
|
+
getMeta(): FaustDspMeta;
|
|
1183
|
+
/**
|
|
1184
|
+
* Get DSP JSON description with its UI and metadata.
|
|
1185
|
+
*
|
|
1186
|
+
* @return the DSP JSON description
|
|
1187
|
+
*/
|
|
1188
|
+
getJSON(): string;
|
|
1189
|
+
/**
|
|
1190
|
+
* Get DSP UI description.
|
|
1191
|
+
*
|
|
1192
|
+
* @return the DSP UI description
|
|
1193
|
+
*/
|
|
1194
|
+
getUI(): FaustUIDescriptor;
|
|
1177
1195
|
}
|
|
1178
1196
|
export interface IFaustPolyDspGenerator {
|
|
1179
1197
|
/**
|
|
@@ -1215,6 +1233,24 @@ export interface IFaustPolyDspGenerator {
|
|
|
1215
1233
|
* @returns the compiled processor or 'null' if failure
|
|
1216
1234
|
*/
|
|
1217
1235
|
createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null): Promise<IFaustPolyOfflineProcessor | null>;
|
|
1236
|
+
/**
|
|
1237
|
+
* Get DSP JSON description with its UI and metadata as object.
|
|
1238
|
+
*
|
|
1239
|
+
* @return the DSP JSON description as object
|
|
1240
|
+
*/
|
|
1241
|
+
getMeta(): FaustDspMeta;
|
|
1242
|
+
/**
|
|
1243
|
+
* Get DSP JSON description with its UI and metadata.
|
|
1244
|
+
*
|
|
1245
|
+
* @return the DSP JSON description
|
|
1246
|
+
*/
|
|
1247
|
+
getJSON(): string;
|
|
1248
|
+
/**
|
|
1249
|
+
* Get DSP UI description.
|
|
1250
|
+
*
|
|
1251
|
+
* @return the DSP UI description
|
|
1252
|
+
*/
|
|
1253
|
+
getUI(): FaustUIDescriptor;
|
|
1218
1254
|
}
|
|
1219
1255
|
export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
|
|
1220
1256
|
private static gWorkletProcessors;
|
|
@@ -1230,6 +1266,9 @@ export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
|
|
|
1230
1266
|
parameterDescriptors: AudioParamDescriptor[];
|
|
1231
1267
|
}>;
|
|
1232
1268
|
createOfflineProcessor(sampleRate: number, bufferSize: number, factory?: LooseFaustDspFactory): Promise<FaustMonoOfflineProcessor>;
|
|
1269
|
+
getMeta(): any;
|
|
1270
|
+
getJSON(): string;
|
|
1271
|
+
getUI(): any;
|
|
1233
1272
|
}
|
|
1234
1273
|
export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
|
|
1235
1274
|
private static gWorkletProcessors;
|
|
@@ -1247,6 +1286,9 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
|
|
|
1247
1286
|
parameterDescriptors: AudioParamDescriptor[];
|
|
1248
1287
|
}>;
|
|
1249
1288
|
createOfflineProcessor(sampleRate: number, bufferSize: number, voices: number, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null): Promise<FaustPolyOfflineProcessor>;
|
|
1289
|
+
getMeta(): FaustDspMeta;
|
|
1290
|
+
getJSON(): string;
|
|
1291
|
+
getUI(): FaustUIDescriptor;
|
|
1250
1292
|
}
|
|
1251
1293
|
|
|
1252
1294
|
export {};
|
|
@@ -1748,7 +1748,7 @@ var FaustWasmInstantiator = class {
|
|
|
1748
1748
|
_min_f: Math.min,
|
|
1749
1749
|
_remainderf: (x, y) => x - Math.round(x / y) * y,
|
|
1750
1750
|
_powf: Math.pow,
|
|
1751
|
-
_roundf: Math.
|
|
1751
|
+
_roundf: Math.round,
|
|
1752
1752
|
_sinf: Math.sin,
|
|
1753
1753
|
_sqrtf: Math.sqrt,
|
|
1754
1754
|
_tanf: Math.tan,
|
|
@@ -1776,7 +1776,7 @@ var FaustWasmInstantiator = class {
|
|
|
1776
1776
|
_min_: Math.min,
|
|
1777
1777
|
_remainder: (x, y) => x - Math.round(x / y) * y,
|
|
1778
1778
|
_pow: Math.pow,
|
|
1779
|
-
_round: Math.
|
|
1779
|
+
_round: Math.round,
|
|
1780
1780
|
_sin: Math.sin,
|
|
1781
1781
|
_sqrt: Math.sqrt,
|
|
1782
1782
|
_tan: Math.tan,
|
|
@@ -3619,6 +3619,15 @@ const dependencies = {
|
|
|
3619
3619
|
const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize);
|
|
3620
3620
|
return new FaustMonoOfflineProcessor(monoDsp, bufferSize);
|
|
3621
3621
|
}
|
|
3622
|
+
getMeta() {
|
|
3623
|
+
return JSON.parse(this.factory.json);
|
|
3624
|
+
}
|
|
3625
|
+
getJSON() {
|
|
3626
|
+
return JSON.stringify(this.getMeta());
|
|
3627
|
+
}
|
|
3628
|
+
getUI() {
|
|
3629
|
+
return this.getMeta();
|
|
3630
|
+
}
|
|
3622
3631
|
};
|
|
3623
3632
|
var FaustMonoDspGenerator = _FaustMonoDspGenerator;
|
|
3624
3633
|
FaustMonoDspGenerator.gWorkletProcessors = /* @__PURE__ */ new Map();
|
|
@@ -3739,6 +3748,36 @@ const dependencies = {
|
|
|
3739
3748
|
const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize);
|
|
3740
3749
|
return new FaustPolyOfflineProcessor(polyDsp, bufferSize);
|
|
3741
3750
|
}
|
|
3751
|
+
getMeta() {
|
|
3752
|
+
const o = this.voiceFactory ? JSON.parse(this.voiceFactory.json) : null;
|
|
3753
|
+
const e = this.effectFactory ? JSON.parse(this.effectFactory.json) : null;
|
|
3754
|
+
const r = { ...o };
|
|
3755
|
+
if (e) {
|
|
3756
|
+
r.ui = [{
|
|
3757
|
+
type: "tgroup",
|
|
3758
|
+
label: "Sequencer",
|
|
3759
|
+
items: [
|
|
3760
|
+
{ type: "vgroup", label: "Instrument", items: o.ui },
|
|
3761
|
+
{ type: "vgroup", label: "Effect", items: e.ui }
|
|
3762
|
+
]
|
|
3763
|
+
}];
|
|
3764
|
+
} else {
|
|
3765
|
+
r.ui = [{
|
|
3766
|
+
type: "tgroup",
|
|
3767
|
+
label: "Polyphonic",
|
|
3768
|
+
items: [
|
|
3769
|
+
{ type: "vgroup", label: "Voices", items: o.ui }
|
|
3770
|
+
]
|
|
3771
|
+
}];
|
|
3772
|
+
}
|
|
3773
|
+
return r;
|
|
3774
|
+
}
|
|
3775
|
+
getJSON() {
|
|
3776
|
+
return JSON.stringify(this.getMeta());
|
|
3777
|
+
}
|
|
3778
|
+
getUI() {
|
|
3779
|
+
return this.getMeta().ui;
|
|
3780
|
+
}
|
|
3742
3781
|
};
|
|
3743
3782
|
var FaustPolyDspGenerator = _FaustPolyDspGenerator;
|
|
3744
3783
|
FaustPolyDspGenerator.gWorkletProcessors = /* @__PURE__ */ new Map();
|