@grame/faustwasm 0.4.4 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COPYING.txt +520 -0
- package/README.md +3 -0
- package/assets/standalone/faust-ui/index.css +8 -0
- package/assets/standalone/faust-ui/index.css.map +1 -1
- package/assets/standalone/faust-ui/index.js +56 -30
- package/assets/standalone/faust-ui/index.js.map +1 -1
- package/assets/standalone/faustwasm/index.d.ts +18 -10
- package/assets/standalone/faustwasm/index.js +69 -24
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.d.ts +18 -10
- package/dist/cjs/index.js +69 -24
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +18 -10
- package/dist/cjs-bundle/index.js +72 -27
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +18 -10
- package/dist/esm/index.js +69 -24
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +18 -10
- package/dist/esm-bundle/index.js +72 -27
- 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/node +0 -0
- package/package.json +4 -2
- package/src/FaustAudioWorkletNode.ts +13 -24
- package/src/FaustAudioWorkletProcessor.ts +28 -1
- package/src/FaustDspGenerator.ts +18 -9
- package/src/FaustFFTAudioWorkletProcessor.ts +27 -0
- package/src/instantiateFaustModule.js +82 -0
- package/test/faustlive-wasm/faust-ui/index.css +8 -0
- package/test/faustlive-wasm/faust-ui/index.css.map +1 -1
- package/test/faustlive-wasm/faust-ui/index.js +56 -30
- package/test/faustlive-wasm/faust-ui/index.js.map +1 -1
- package/test/faustlive-wasm/faustwasm/index.d.ts +18 -10
- package/test/faustlive-wasm/faustwasm/index.js +69 -24
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
package/dist/cjs/index.d.ts
CHANGED
|
@@ -887,6 +887,8 @@ export interface FaustPolyAudioWorkletNodeOptions extends AudioWorkletNodeOption
|
|
|
887
887
|
export interface FaustAudioWorkletProcessorOptions {
|
|
888
888
|
name: string;
|
|
889
889
|
sampleSize: number;
|
|
890
|
+
moduleId?: string;
|
|
891
|
+
instanceId?: string;
|
|
890
892
|
}
|
|
891
893
|
export interface FaustMonoAudioWorkletProcessorOptions extends FaustAudioWorkletProcessorOptions {
|
|
892
894
|
factory: LooseFaustDspFactory;
|
|
@@ -931,6 +933,8 @@ export interface FaustFFTAudioWorkletProcessorOptions {
|
|
|
931
933
|
name: string;
|
|
932
934
|
sampleSize: number;
|
|
933
935
|
factory: LooseFaustDspFactory;
|
|
936
|
+
moduleId?: string;
|
|
937
|
+
instanceId?: string;
|
|
934
938
|
}
|
|
935
939
|
export declare const getFaustFFTAudioWorkletProcessor: (dependencies: FaustFFTAudioWorkletProcessorDependencies, faustData: FaustFFTData, register?: boolean) => {
|
|
936
940
|
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
@@ -1266,7 +1270,7 @@ export declare class SoundfileReader {
|
|
|
1266
1270
|
static loadSoundfiles(dspMeta: FaustDspMeta, soundfilesIn: LooseFaustDspFactory["soundfiles"], audioCtx: BaseAudioContext): Promise<LooseFaustDspFactory["soundfiles"]>;
|
|
1267
1271
|
}
|
|
1268
1272
|
declare const FaustAudioWorkletNode_base: {
|
|
1269
|
-
new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions
|
|
1273
|
+
new (context: BaseAudioContext, name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode;
|
|
1270
1274
|
prototype: AudioWorkletNode;
|
|
1271
1275
|
};
|
|
1272
1276
|
/**
|
|
@@ -1282,7 +1286,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1282
1286
|
protected fPlotHandler: PlotHandler | null;
|
|
1283
1287
|
protected fUICallback: UIHandler;
|
|
1284
1288
|
protected fDescriptor: FaustUIInputItem[];
|
|
1285
|
-
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options
|
|
1289
|
+
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial<FaustAudioWorkletNodeOptions<Poly>>);
|
|
1286
1290
|
/** Setup accelerometer and gyroscope handlers */
|
|
1287
1291
|
listenSensors(): Promise<void>;
|
|
1288
1292
|
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
@@ -1291,6 +1295,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1291
1295
|
getComputeHandler(): ComputeHandler | null;
|
|
1292
1296
|
setPlotHandler(handler: PlotHandler | null): void;
|
|
1293
1297
|
getPlotHandler(): PlotHandler | null;
|
|
1298
|
+
setupWamEventHandler(): void;
|
|
1294
1299
|
getNumInputs(): number;
|
|
1295
1300
|
getNumOutputs(): number;
|
|
1296
1301
|
compute(inputs: Float32Array[], outputs: Float32Array[]): boolean;
|
|
@@ -1318,7 +1323,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1318
1323
|
*/
|
|
1319
1324
|
export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<false> implements IFaustMonoWebAudioDsp {
|
|
1320
1325
|
onprocessorerror: (e: Event) => never;
|
|
1321
|
-
constructor(context: BaseAudioContext,
|
|
1326
|
+
constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<false>> & Pick<FaustAudioWorkletNodeOptions<false>, "processorOptions">);
|
|
1322
1327
|
}
|
|
1323
1328
|
/**
|
|
1324
1329
|
* Polyphonic AudioWorkletNode
|
|
@@ -1326,7 +1331,7 @@ export declare class FaustMonoAudioWorkletNode extends FaustAudioWorkletNode<fal
|
|
|
1326
1331
|
export declare class FaustPolyAudioWorkletNode extends FaustAudioWorkletNode<true> implements IFaustPolyWebAudioDsp {
|
|
1327
1332
|
private fJSONEffect;
|
|
1328
1333
|
onprocessorerror: (e: Event) => never;
|
|
1329
|
-
constructor(context: BaseAudioContext,
|
|
1334
|
+
constructor(context: BaseAudioContext, options: Partial<FaustAudioWorkletNodeOptions<true>> & Pick<FaustAudioWorkletNodeOptions<true>, "processorOptions">);
|
|
1330
1335
|
keyOn(channel: number, pitch: number, velocity: number): void;
|
|
1331
1336
|
keyOff(channel: number, pitch: number, velocity: number): void;
|
|
1332
1337
|
allNotesOff(hard: boolean): void;
|
|
@@ -1419,9 +1424,10 @@ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
|
|
|
1419
1424
|
* @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
|
|
1420
1425
|
* @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
|
|
1421
1426
|
* @param processorName - AudioWorklet Processor name
|
|
1427
|
+
* @param processorOptions - Additional AudioWorklet Processor options
|
|
1422
1428
|
* @returns the compiled WebAudio node or 'null' if failure
|
|
1423
1429
|
*/
|
|
1424
|
-
createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string): Promise<IFaustMonoWebAudioNode | null>;
|
|
1430
|
+
createNode(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<IFaustMonoWebAudioNode | null>;
|
|
1425
1431
|
/**
|
|
1426
1432
|
* Create a monophonic WebAudio node (either ScriptProcessorNode or AudioWorkletNode).
|
|
1427
1433
|
*
|
|
@@ -1431,9 +1437,10 @@ export interface IFaustMonoDspGenerator extends GeneratorSupportingSoundfiles {
|
|
|
1431
1437
|
* @param factory - default is the compiled factory
|
|
1432
1438
|
* @param fftOptions - initial FFT options
|
|
1433
1439
|
* @param processorName - AudioWorklet Processor name
|
|
1440
|
+
* @param processorOptions - Additional AudioWorklet Processor options
|
|
1434
1441
|
* @returns the compiled WebAudio node or 'null' if failure
|
|
1435
1442
|
*/
|
|
1436
|
-
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1443
|
+
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1437
1444
|
/**
|
|
1438
1445
|
* Create a monophonic Offline processor.
|
|
1439
1446
|
*
|
|
@@ -1489,9 +1496,10 @@ export interface IFaustPolyDspGenerator extends GeneratorSupportingSoundfiles {
|
|
|
1489
1496
|
* @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
|
|
1490
1497
|
* @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
|
|
1491
1498
|
* @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
|
|
1499
|
+
* @param processorOptions - Additional AudioWorklet Processor options
|
|
1492
1500
|
* @returns the compiled WebAudio node or 'null' if failure
|
|
1493
1501
|
*/
|
|
1494
|
-
createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: boolean, bufferSize?: number, processorName?: string): Promise<IFaustPolyWebAudioNode | null>;
|
|
1502
|
+
createNode(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: boolean, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<IFaustPolyWebAudioNode | null>;
|
|
1495
1503
|
/**
|
|
1496
1504
|
* Create a monophonic Offline processor.
|
|
1497
1505
|
*
|
|
@@ -1531,8 +1539,8 @@ export declare class FaustMonoDspGenerator implements IFaustMonoDspGenerator {
|
|
|
1531
1539
|
compile(compiler: IFaustCompiler, name: string, code: string, args: string): Promise<this | null>;
|
|
1532
1540
|
addSoundfiles(soundfileMap: Record<string, AudioData>): void;
|
|
1533
1541
|
getSoundfileList(): string[];
|
|
1534
|
-
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>;
|
|
1535
|
-
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1542
|
+
createNode<SP extends boolean = false>(context: BaseAudioContext, name?: string, factory?: LooseFaustDspFactory, sp?: SP, bufferSize?: number, processorName?: string, processorOptions?: Record<string, any>): Promise<SP extends true ? FaustMonoScriptProcessorNode | null : FaustMonoAudioWorkletNode | null>;
|
|
1543
|
+
createFFTNode(context: BaseAudioContext, fftUtils: typeof FFTUtils, name?: string, factory?: LooseFaustDspFactory, fftOptions?: Partial<FaustFFTOptionsData>, processorName?: string, processorOptions?: Record<string, any>): Promise<FaustMonoAudioWorkletNode | null>;
|
|
1536
1544
|
createAudioWorkletProcessor(name?: string, factory?: LooseFaustDspFactory, processorName?: string): Promise<{
|
|
1537
1545
|
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
1538
1546
|
prototype: AudioWorkletProcessor;
|
|
@@ -1554,7 +1562,7 @@ export declare class FaustPolyDspGenerator implements IFaustPolyDspGenerator {
|
|
|
1554
1562
|
compile(compiler: IFaustCompiler, name: string, dspCodeAux: string, args: string, effectCodeAux?: string): Promise<this | null>;
|
|
1555
1563
|
addSoundfiles(soundfileMap: Record<string, AudioData>): void;
|
|
1556
1564
|
getSoundfileList(): string[];
|
|
1557
|
-
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>;
|
|
1565
|
+
createNode<SP extends boolean = false>(context: BaseAudioContext, voices: number, name?: string, voiceFactory?: LooseFaustDspFactory, mixerModule?: WebAssembly.Module, effectFactory?: LooseFaustDspFactory | null, sp?: SP, bufferSize?: number, processorName?: string, processorOptions?: {}): Promise<SP extends true ? FaustPolyScriptProcessorNode | null : FaustPolyAudioWorkletNode | null>;
|
|
1558
1566
|
createAudioWorkletProcessor(name?: string, voiceFactory?: LooseFaustDspFactory, effectFactory?: LooseFaustDspFactory | null, processorName?: string): Promise<{
|
|
1559
1567
|
new (options: AudioWorkletNodeOptions): AudioWorkletProcessor;
|
|
1560
1568
|
prototype: AudioWorkletProcessor;
|
package/dist/cjs/index.js
CHANGED
|
@@ -141,6 +141,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
141
141
|
parameterDescriptors.forEach((pd) => {
|
|
142
142
|
this.paramValuesCache[pd.name] = pd.defaultValue || 0;
|
|
143
143
|
});
|
|
144
|
+
const { moduleId, instanceId } = options.processorOptions;
|
|
145
|
+
if (!moduleId || !instanceId)
|
|
146
|
+
return;
|
|
147
|
+
this.wamInfo = { moduleId, instanceId };
|
|
144
148
|
}
|
|
145
149
|
static get parameterDescriptors() {
|
|
146
150
|
const params = [];
|
|
@@ -154,6 +158,23 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
154
158
|
FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, callback);
|
|
155
159
|
return params;
|
|
156
160
|
}
|
|
161
|
+
setupWamEventHandler() {
|
|
162
|
+
var _a;
|
|
163
|
+
if (!this.wamInfo)
|
|
164
|
+
return;
|
|
165
|
+
const { moduleId, instanceId } = this.wamInfo;
|
|
166
|
+
const { webAudioModules } = globalThis;
|
|
167
|
+
const ModuleScope = webAudioModules.getModuleScope(moduleId);
|
|
168
|
+
const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId];
|
|
169
|
+
if (!paramMgrProcessor)
|
|
170
|
+
return;
|
|
171
|
+
if (paramMgrProcessor.handleEvent)
|
|
172
|
+
return;
|
|
173
|
+
paramMgrProcessor.handleEvent = (event) => {
|
|
174
|
+
if (event.type === "wam-midi")
|
|
175
|
+
this.midiMessage(event.data.bytes);
|
|
176
|
+
};
|
|
177
|
+
}
|
|
157
178
|
process(inputs, outputs, parameters) {
|
|
158
179
|
for (const path in parameters) {
|
|
159
180
|
const [paramValue] = parameters[path];
|
|
@@ -199,6 +220,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
199
220
|
}
|
|
200
221
|
break;
|
|
201
222
|
}
|
|
223
|
+
case "setupWamEventHandler": {
|
|
224
|
+
this.setupWamEventHandler();
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
202
227
|
case "start": {
|
|
203
228
|
this.fDSPCode.start();
|
|
204
229
|
break;
|
|
@@ -408,6 +433,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
408
433
|
this.sampleSize = sampleSize;
|
|
409
434
|
this.soundfiles = factory.soundfiles;
|
|
410
435
|
this.initFFT();
|
|
436
|
+
const { moduleId, instanceId } = options.processorOptions;
|
|
437
|
+
if (!moduleId || !instanceId)
|
|
438
|
+
return;
|
|
439
|
+
this.wamInfo = { moduleId, instanceId };
|
|
411
440
|
}
|
|
412
441
|
get fftProcessorBufferSize() {
|
|
413
442
|
return this.fftSize / 2 + 1;
|
|
@@ -453,6 +482,23 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
453
482
|
}
|
|
454
483
|
];
|
|
455
484
|
}
|
|
485
|
+
setupWamEventHandler() {
|
|
486
|
+
var _a;
|
|
487
|
+
if (!this.wamInfo)
|
|
488
|
+
return;
|
|
489
|
+
const { moduleId, instanceId } = this.wamInfo;
|
|
490
|
+
const { webAudioModules } = globalThis;
|
|
491
|
+
const ModuleScope = webAudioModules.getModuleScope(moduleId);
|
|
492
|
+
const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId];
|
|
493
|
+
if (!paramMgrProcessor)
|
|
494
|
+
return;
|
|
495
|
+
if (paramMgrProcessor.handleEvent)
|
|
496
|
+
return;
|
|
497
|
+
paramMgrProcessor.handleEvent = (event) => {
|
|
498
|
+
if (event.type === "wam-midi")
|
|
499
|
+
this.midiMessage(event.data.bytes);
|
|
500
|
+
};
|
|
501
|
+
}
|
|
456
502
|
processFFT() {
|
|
457
503
|
let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;
|
|
458
504
|
while (samplesForFFT >= this.fftSize) {
|
|
@@ -590,6 +636,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
590
636
|
(_a = this.fDSPCode) == null ? void 0 : _a.setPlotHandler(this.fPlotHandler);
|
|
591
637
|
break;
|
|
592
638
|
}
|
|
639
|
+
case "setupWamEventHandler": {
|
|
640
|
+
this.setupWamEventHandler();
|
|
641
|
+
break;
|
|
642
|
+
}
|
|
593
643
|
case "start": {
|
|
594
644
|
(_b = this.fDSPCode) == null ? void 0 : _b.start();
|
|
595
645
|
break;
|
|
@@ -3649,7 +3699,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
3649
3699
|
// src/FaustAudioWorkletNode.ts
|
|
3650
3700
|
var _hasAccInput, _hasGyrInput;
|
|
3651
3701
|
var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) {
|
|
3652
|
-
constructor(context, name, factory, options
|
|
3702
|
+
constructor(context, name, factory, options = {}) {
|
|
3653
3703
|
const JSONObj = JSON.parse(factory.json);
|
|
3654
3704
|
super(context, name, {
|
|
3655
3705
|
numberOfInputs: JSONObj.inputs > 0 ? 1 : 0,
|
|
@@ -3658,8 +3708,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
3658
3708
|
outputChannelCount: [JSONObj.outputs],
|
|
3659
3709
|
channelCountMode: "explicit",
|
|
3660
3710
|
channelInterpretation: "speakers",
|
|
3661
|
-
processorOptions: options,
|
|
3662
|
-
...
|
|
3711
|
+
processorOptions: options.processorOptions,
|
|
3712
|
+
...options
|
|
3663
3713
|
});
|
|
3664
3714
|
__privateAdd(this, _hasAccInput, false);
|
|
3665
3715
|
__privateAdd(this, _hasGyrInput, false);
|
|
@@ -3777,6 +3827,9 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
3777
3827
|
getPlotHandler() {
|
|
3778
3828
|
return this.fPlotHandler;
|
|
3779
3829
|
}
|
|
3830
|
+
setupWamEventHandler() {
|
|
3831
|
+
this.port.postMessage({ type: "setupWamEventHandler" });
|
|
3832
|
+
}
|
|
3780
3833
|
getNumInputs() {
|
|
3781
3834
|
return this.fJSONDsp.inputs;
|
|
3782
3835
|
}
|
|
@@ -3870,33 +3923,25 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
3870
3923
|
_hasAccInput = new WeakMap();
|
|
3871
3924
|
_hasGyrInput = new WeakMap();
|
|
3872
3925
|
var FaustMonoAudioWorkletNode = class extends FaustAudioWorkletNode {
|
|
3873
|
-
constructor(context,
|
|
3874
|
-
super(context, name, factory,
|
|
3926
|
+
constructor(context, options) {
|
|
3927
|
+
super(context, options.processorOptions.name, options.processorOptions.factory, options);
|
|
3875
3928
|
this.onprocessorerror = (e) => {
|
|
3876
3929
|
throw e;
|
|
3877
3930
|
};
|
|
3878
3931
|
}
|
|
3879
3932
|
};
|
|
3880
3933
|
var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode {
|
|
3881
|
-
constructor(context,
|
|
3934
|
+
constructor(context, options) {
|
|
3882
3935
|
super(
|
|
3883
3936
|
context,
|
|
3884
|
-
name,
|
|
3885
|
-
voiceFactory,
|
|
3886
|
-
|
|
3887
|
-
name,
|
|
3888
|
-
voiceFactory,
|
|
3889
|
-
mixerModule,
|
|
3890
|
-
voices,
|
|
3891
|
-
sampleSize,
|
|
3892
|
-
effectFactory
|
|
3893
|
-
},
|
|
3894
|
-
nodeOptions
|
|
3937
|
+
options.processorOptions.name,
|
|
3938
|
+
options.processorOptions.voiceFactory,
|
|
3939
|
+
options
|
|
3895
3940
|
);
|
|
3896
3941
|
this.onprocessorerror = (e) => {
|
|
3897
3942
|
throw e;
|
|
3898
3943
|
};
|
|
3899
|
-
this.fJSONEffect = effectFactory ? JSON.parse(effectFactory.json) : null;
|
|
3944
|
+
this.fJSONEffect = options.processorOptions.effectFactory ? JSON.parse(options.processorOptions.effectFactory.json) : null;
|
|
3900
3945
|
if (this.fJSONEffect) {
|
|
3901
3946
|
FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);
|
|
3902
3947
|
}
|
|
@@ -4146,7 +4191,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
4146
4191
|
const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
|
|
4147
4192
|
return Object.keys(map);
|
|
4148
4193
|
}
|
|
4149
|
-
async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name) {
|
|
4194
|
+
async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name, processorOptions = {}) {
|
|
4150
4195
|
var _a, _b;
|
|
4151
4196
|
if (!factory)
|
|
4152
4197
|
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
@@ -4204,11 +4249,11 @@ const dependencies = {
|
|
|
4204
4249
|
throw e;
|
|
4205
4250
|
}
|
|
4206
4251
|
}
|
|
4207
|
-
const node = new FaustMonoAudioWorkletNode(context, processorName, factory, sampleSize);
|
|
4252
|
+
const node = new FaustMonoAudioWorkletNode(context, { processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });
|
|
4208
4253
|
return node;
|
|
4209
4254
|
}
|
|
4210
4255
|
}
|
|
4211
|
-
async createFFTNode(context, fftUtils, name = this.name, factory = this.factory, fftOptions = {}, processorName = (factory == null ? void 0 : factory.shaKey) ? `${factory.shaKey}_fft` : name) {
|
|
4256
|
+
async createFFTNode(context, fftUtils, name = this.name, factory = this.factory, fftOptions = {}, processorName = (factory == null ? void 0 : factory.shaKey) ? `${factory.shaKey}_fft` : name, processorOptions = {}) {
|
|
4212
4257
|
var _a, _b;
|
|
4213
4258
|
if (!factory)
|
|
4214
4259
|
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
@@ -4260,7 +4305,7 @@ const dependencies = {
|
|
|
4260
4305
|
throw e;
|
|
4261
4306
|
}
|
|
4262
4307
|
}
|
|
4263
|
-
const node = new FaustMonoAudioWorkletNode(context,
|
|
4308
|
+
const node = new FaustMonoAudioWorkletNode(context, { channelCount: Math.max(1, Math.ceil(meta.inputs / 3)), outputChannelCount: [Math.ceil(meta.outputs / 2)], processorOptions: { name: processorName, factory, sampleSize, ...processorOptions } });
|
|
4264
4309
|
if (fftOptions.fftSize) {
|
|
4265
4310
|
const param = node.parameters.get("fftSize");
|
|
4266
4311
|
if (param)
|
|
@@ -4422,7 +4467,7 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
|
|
|
4422
4467
|
const effectMap = SoundfileReader_default.findSoundfilesFromMeta(effectMeta);
|
|
4423
4468
|
return Object.keys({ ...effectMap, ...map });
|
|
4424
4469
|
}
|
|
4425
|
-
async createNode(context, voices, name = this.name, voiceFactory = this.voiceFactory, mixerModule = this.mixerModule, effectFactory = this.effectFactory, sp = false, bufferSize = 1024, processorName = ((voiceFactory == null ? void 0 : voiceFactory.shaKey) || "") + ((effectFactory == null ? void 0 : effectFactory.shaKey) || "") || `${name}_poly
|
|
4470
|
+
async createNode(context, voices, name = this.name, voiceFactory = this.voiceFactory, mixerModule = this.mixerModule, effectFactory = this.effectFactory, sp = false, bufferSize = 1024, processorName = ((voiceFactory == null ? void 0 : voiceFactory.shaKey) || "") + ((effectFactory == null ? void 0 : effectFactory.shaKey) || "") || `${name}_poly`, processorOptions = {}) {
|
|
4426
4471
|
var _a, _b;
|
|
4427
4472
|
if (!voiceFactory)
|
|
4428
4473
|
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
@@ -4487,7 +4532,7 @@ const dependencies = {
|
|
|
4487
4532
|
throw e;
|
|
4488
4533
|
}
|
|
4489
4534
|
}
|
|
4490
|
-
const node = new FaustPolyAudioWorkletNode(context, processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory || void 0);
|
|
4535
|
+
const node = new FaustPolyAudioWorkletNode(context, { processorOptions: { name: processorName, voiceFactory, mixerModule, voices, sampleSize, effectFactory: effectFactory || void 0, ...processorOptions } });
|
|
4491
4536
|
return node;
|
|
4492
4537
|
}
|
|
4493
4538
|
}
|