@grame/faustwasm 0.14.2 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/standalone/create-node.js +3 -2
- package/assets/standalone/faustwasm/index.d.ts +35 -0
- package/assets/standalone/faustwasm/index.js +60 -8
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.d.ts +35 -0
- package/dist/cjs/index.js +60 -8
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +35 -0
- package/dist/cjs-bundle/index.js +60 -8
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +35 -0
- package/dist/esm/index.js +60 -8
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +35 -0
- package/dist/esm-bundle/index.js +60 -8
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +1 -1
- package/src/FaustAudioWorkletNode.ts +18 -3
- package/src/FaustAudioWorkletProcessor.ts +8 -2
- package/src/FaustFFTAudioWorkletProcessor.ts +4 -1
- package/src/FaustOfflineProcessor.ts +11 -0
- package/src/FaustScriptProcessorNode.ts +11 -0
- package/src/FaustWebAudioDsp.ts +40 -3
- package/test/faustlive-wasm/faustwasm/index.d.ts +35 -0
- package/test/faustlive-wasm/faustwasm/index.js +60 -8
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
package/dist/cjs/index.d.ts
CHANGED
|
@@ -413,6 +413,7 @@ export declare class FaustWasmInstantiator {
|
|
|
413
413
|
static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance;
|
|
414
414
|
}
|
|
415
415
|
export type OutputParamHandler = (path: string, value: number) => void;
|
|
416
|
+
export type InputParamHandler = (path: string, value: number) => void;
|
|
416
417
|
export type ComputeHandler = (buffer_size: number) => void;
|
|
417
418
|
export type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: {
|
|
418
419
|
type: string;
|
|
@@ -534,6 +535,7 @@ export declare class Soundfile {
|
|
|
534
535
|
* DSP implementation that mimic the C++ 'dsp' class:
|
|
535
536
|
* - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers
|
|
536
537
|
* - an output handler can be set to treat produced output controllers (like 'bargraph')
|
|
538
|
+
* - an input handler can be set to follow control parameter changes (like sliders)
|
|
537
539
|
* - regular controllers are handled using setParamValue/getParamValue and getParams methods
|
|
538
540
|
*/
|
|
539
541
|
export interface IFaustBaseWebAudioDsp {
|
|
@@ -556,6 +558,25 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
556
558
|
* @param value - the float value for the wanted control
|
|
557
559
|
*/
|
|
558
560
|
callOutputParamHandler(path: string, value: number): void;
|
|
561
|
+
/**
|
|
562
|
+
* Set the parameter input handler, to be called when input parameters change (like sliders).
|
|
563
|
+
*
|
|
564
|
+
* @param handler - the input handler
|
|
565
|
+
*/
|
|
566
|
+
setInputParamHandler(handler: InputParamHandler | null): void;
|
|
567
|
+
/**
|
|
568
|
+
* Get the parameter input handler.
|
|
569
|
+
*
|
|
570
|
+
* @return the current input handler
|
|
571
|
+
*/
|
|
572
|
+
getInputParamHandler(): InputParamHandler | null;
|
|
573
|
+
/**
|
|
574
|
+
* Call the input parameter handler with a path and value.
|
|
575
|
+
*
|
|
576
|
+
* @param path - the path to the wanted parameter (retrieved using 'getParams' method)
|
|
577
|
+
* @param value - the float value for the wanted control
|
|
578
|
+
*/
|
|
579
|
+
callInputParamHandler(path: string, value: number): void;
|
|
559
580
|
/**
|
|
560
581
|
* Set the compute handler, to be called in the 'compute' method with buffer size.
|
|
561
582
|
*
|
|
@@ -752,6 +773,7 @@ export interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode
|
|
|
752
773
|
}
|
|
753
774
|
export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
754
775
|
protected fOutputHandler: OutputParamHandler | null;
|
|
776
|
+
protected fInputHandler: InputParamHandler | null;
|
|
755
777
|
protected fComputeHandler: ComputeHandler | null;
|
|
756
778
|
protected fPlotHandler: PlotHandler | null;
|
|
757
779
|
protected fCachedEvents: {
|
|
@@ -857,6 +879,9 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
857
879
|
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
858
880
|
getOutputParamHandler(): OutputParamHandler | null;
|
|
859
881
|
callOutputParamHandler(path: string, value: number): void;
|
|
882
|
+
setInputParamHandler(handler: InputParamHandler | null): void;
|
|
883
|
+
getInputParamHandler(): InputParamHandler | null;
|
|
884
|
+
callInputParamHandler(path: string, value: number): void;
|
|
860
885
|
setComputeHandler(handler: ComputeHandler | null): void;
|
|
861
886
|
getComputeHandler(): ComputeHandler | null;
|
|
862
887
|
setPlotHandler(handler: PlotHandler | null): void;
|
|
@@ -1211,6 +1236,9 @@ export declare class FaustOfflineProcessor<Poly extends boolean = false> {
|
|
|
1211
1236
|
setOutputParamHandler(handler: OutputParamHandler): void;
|
|
1212
1237
|
getOutputParamHandler(): OutputParamHandler | null;
|
|
1213
1238
|
callOutputParamHandler(path: string, value: number): void;
|
|
1239
|
+
setInputParamHandler(handler: InputParamHandler): void;
|
|
1240
|
+
getInputParamHandler(): InputParamHandler | null;
|
|
1241
|
+
callInputParamHandler(path: string, value: number): void;
|
|
1214
1242
|
setComputeHandler(handler: ComputeHandler): void;
|
|
1215
1243
|
getComputeHandler(): ComputeHandler | null;
|
|
1216
1244
|
setPlotHandler(handler: PlotHandler): void;
|
|
@@ -1397,6 +1425,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1397
1425
|
protected fJSON: string;
|
|
1398
1426
|
protected fInputsItems: string[];
|
|
1399
1427
|
protected fOutputHandler: OutputParamHandler | null;
|
|
1428
|
+
protected fInputHandler: InputParamHandler | null;
|
|
1400
1429
|
protected fComputeHandler: ComputeHandler | null;
|
|
1401
1430
|
protected fPlotHandler: PlotHandler | null;
|
|
1402
1431
|
protected fUICallback: UIHandler;
|
|
@@ -1413,6 +1442,9 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1413
1442
|
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
1414
1443
|
getOutputParamHandler(): OutputParamHandler | null;
|
|
1415
1444
|
callOutputParamHandler(path: string, value: number): void;
|
|
1445
|
+
setInputParamHandler(handler: InputParamHandler | null): void;
|
|
1446
|
+
getInputParamHandler(): InputParamHandler | null;
|
|
1447
|
+
callInputParamHandler(path: string, value: number): void;
|
|
1416
1448
|
setComputeHandler(handler: ComputeHandler | null): void;
|
|
1417
1449
|
getComputeHandler(): ComputeHandler | null;
|
|
1418
1450
|
setPlotHandler(handler: PlotHandler | null): void;
|
|
@@ -1485,6 +1517,9 @@ export declare class FaustScriptProcessorNode<Poly extends boolean = false> exte
|
|
|
1485
1517
|
setOutputParamHandler(handler: OutputParamHandler): void;
|
|
1486
1518
|
getOutputParamHandler(): OutputParamHandler | null;
|
|
1487
1519
|
callOutputParamHandler(path: string, value: number): void;
|
|
1520
|
+
setInputParamHandler(handler: InputParamHandler): void;
|
|
1521
|
+
getInputParamHandler(): InputParamHandler | null;
|
|
1522
|
+
callInputParamHandler(path: string, value: number): void;
|
|
1488
1523
|
setComputeHandler(handler: ComputeHandler): void;
|
|
1489
1524
|
getComputeHandler(): ComputeHandler | null;
|
|
1490
1525
|
setPlotHandler(handler: PlotHandler): void;
|
package/dist/cjs/index.js
CHANGED
|
@@ -310,7 +310,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
310
310
|
this.port.addEventListener("message", this.handleMessageAux);
|
|
311
311
|
this.port.start();
|
|
312
312
|
this.fDSPCode.setOutputParamHandler(
|
|
313
|
-
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
313
|
+
(path, value) => this.port.postMessage({ path, value, type: "out-param" })
|
|
314
|
+
);
|
|
315
|
+
this.fDSPCode.setInputParamHandler(
|
|
316
|
+
(path, value) => this.port.postMessage({ path, value, type: "in-param" })
|
|
314
317
|
);
|
|
315
318
|
this.fDSPCode.start();
|
|
316
319
|
}
|
|
@@ -360,7 +363,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
360
363
|
this.port.addEventListener("message", this.handleMessageAux);
|
|
361
364
|
this.port.start();
|
|
362
365
|
this.fDSPCode.setOutputParamHandler(
|
|
363
|
-
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
366
|
+
(path, value) => this.port.postMessage({ path, value, type: "out-param" })
|
|
367
|
+
);
|
|
368
|
+
this.fDSPCode.setInputParamHandler(
|
|
369
|
+
(path, value) => this.port.postMessage({ path, value, type: "in-param" })
|
|
364
370
|
);
|
|
365
371
|
this.fDSPCode.start();
|
|
366
372
|
}
|
|
@@ -896,7 +902,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
896
902
|
this.soundfiles
|
|
897
903
|
);
|
|
898
904
|
this.fDSPCode.setOutputParamHandler(
|
|
899
|
-
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
905
|
+
(path, value) => this.port.postMessage({ path, value, type: "out-param" })
|
|
906
|
+
);
|
|
907
|
+
this.fDSPCode.setInputParamHandler(
|
|
908
|
+
(path, value) => this.port.postMessage({ path, value, type: "in-param" })
|
|
900
909
|
);
|
|
901
910
|
this.fDSPCode.setPlotHandler(this.fPlotHandler);
|
|
902
911
|
const params = this.fDSPCode.getParams();
|
|
@@ -2530,6 +2539,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
2530
2539
|
var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
2531
2540
|
constructor(sampleSize, bufferSize, soundfiles) {
|
|
2532
2541
|
this.fOutputHandler = null;
|
|
2542
|
+
this.fInputHandler = null;
|
|
2533
2543
|
this.fComputeHandler = null;
|
|
2534
2544
|
// To handle MIDI events plot
|
|
2535
2545
|
this.fPlotHandler = null;
|
|
@@ -2952,8 +2962,17 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
2952
2962
|
callOutputParamHandler(path, value) {
|
|
2953
2963
|
if (this.fOutputHandler) {
|
|
2954
2964
|
this.fOutputHandler(path, value);
|
|
2955
|
-
}
|
|
2956
|
-
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
setInputParamHandler(handler) {
|
|
2968
|
+
this.fInputHandler = handler;
|
|
2969
|
+
}
|
|
2970
|
+
getInputParamHandler() {
|
|
2971
|
+
return this.fInputHandler;
|
|
2972
|
+
}
|
|
2973
|
+
callInputParamHandler(path, value) {
|
|
2974
|
+
if (this.fInputHandler) {
|
|
2975
|
+
this.fInputHandler(path, value);
|
|
2957
2976
|
}
|
|
2958
2977
|
}
|
|
2959
2978
|
setComputeHandler(handler) {
|
|
@@ -3145,6 +3164,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
3145
3164
|
destroy() {
|
|
3146
3165
|
this.fDestroyed = true;
|
|
3147
3166
|
this.fOutputHandler = null;
|
|
3167
|
+
this.fInputHandler = null;
|
|
3148
3168
|
this.fComputeHandler = null;
|
|
3149
3169
|
this.fPlotHandler = null;
|
|
3150
3170
|
}
|
|
@@ -3286,6 +3306,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
3286
3306
|
this.fPathTable[path],
|
|
3287
3307
|
value
|
|
3288
3308
|
);
|
|
3309
|
+
this.callInputParamHandler(path, this.getParamValue(path));
|
|
3289
3310
|
}
|
|
3290
3311
|
getParamValue(path) {
|
|
3291
3312
|
return this.fInstance.api.getParamValue(
|
|
@@ -3701,6 +3722,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
3701
3722
|
(voice) => voice.setParamValue(this.fPathTable[path], value)
|
|
3702
3723
|
);
|
|
3703
3724
|
}
|
|
3725
|
+
this.callInputParamHandler(path, this.getParamValue(path));
|
|
3704
3726
|
}
|
|
3705
3727
|
getParamValue(path) {
|
|
3706
3728
|
if (this.fJSONEffect && _FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {
|
|
@@ -3852,6 +3874,15 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
3852
3874
|
callOutputParamHandler(path, value) {
|
|
3853
3875
|
this.fDSPCode.callOutputParamHandler(path, value);
|
|
3854
3876
|
}
|
|
3877
|
+
setInputParamHandler(handler) {
|
|
3878
|
+
this.fDSPCode.setInputParamHandler(handler);
|
|
3879
|
+
}
|
|
3880
|
+
getInputParamHandler() {
|
|
3881
|
+
return this.fDSPCode.getInputParamHandler();
|
|
3882
|
+
}
|
|
3883
|
+
callInputParamHandler(path, value) {
|
|
3884
|
+
this.fDSPCode.callInputParamHandler(path, value);
|
|
3885
|
+
}
|
|
3855
3886
|
setComputeHandler(handler) {
|
|
3856
3887
|
this.fDSPCode.setComputeHandler(handler);
|
|
3857
3888
|
}
|
|
@@ -4757,8 +4788,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
4757
4788
|
__privateAdd(this, _hasAccInput, false);
|
|
4758
4789
|
__privateAdd(this, _hasGyrInput, false);
|
|
4759
4790
|
this.handleMessageAux = (e) => {
|
|
4760
|
-
if (e.data.type === "param" && this.fOutputHandler) {
|
|
4791
|
+
if (e.data.type === "out-param" && this.fOutputHandler) {
|
|
4761
4792
|
this.fOutputHandler(e.data.path, e.data.value);
|
|
4793
|
+
} else if (e.data.type === "in-param" && this.fInputHandler) {
|
|
4794
|
+
this.fInputHandler(e.data.path, e.data.value);
|
|
4762
4795
|
} else if (e.data.type === "plot" && this.fPlotHandler) {
|
|
4763
4796
|
this.fPlotHandler(e.data.value, e.data.index, e.data.events);
|
|
4764
4797
|
}
|
|
@@ -4782,6 +4815,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
4782
4815
|
this.fJSONDsp = JSONObj;
|
|
4783
4816
|
this.fJSON = factory.json;
|
|
4784
4817
|
this.fOutputHandler = null;
|
|
4818
|
+
this.fInputHandler = null;
|
|
4785
4819
|
this.fComputeHandler = null;
|
|
4786
4820
|
this.fPlotHandler = null;
|
|
4787
4821
|
this.fDescriptor = [];
|
|
@@ -4862,8 +4896,17 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
4862
4896
|
callOutputParamHandler(path, value) {
|
|
4863
4897
|
if (this.fOutputHandler) {
|
|
4864
4898
|
this.fOutputHandler(path, value);
|
|
4865
|
-
}
|
|
4866
|
-
|
|
4899
|
+
}
|
|
4900
|
+
}
|
|
4901
|
+
setInputParamHandler(handler) {
|
|
4902
|
+
this.fInputHandler = handler;
|
|
4903
|
+
}
|
|
4904
|
+
getInputParamHandler() {
|
|
4905
|
+
return this.fInputHandler;
|
|
4906
|
+
}
|
|
4907
|
+
callInputParamHandler(path, value) {
|
|
4908
|
+
if (this.fInputHandler) {
|
|
4909
|
+
this.fInputHandler(path, value);
|
|
4867
4910
|
}
|
|
4868
4911
|
}
|
|
4869
4912
|
setComputeHandler(handler) {
|
|
@@ -5158,6 +5201,15 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
5158
5201
|
callOutputParamHandler(path, value) {
|
|
5159
5202
|
this.fDSPCode.callOutputParamHandler(path, value);
|
|
5160
5203
|
}
|
|
5204
|
+
setInputParamHandler(handler) {
|
|
5205
|
+
this.fDSPCode.setInputParamHandler(handler);
|
|
5206
|
+
}
|
|
5207
|
+
getInputParamHandler() {
|
|
5208
|
+
return this.fDSPCode.getInputParamHandler();
|
|
5209
|
+
}
|
|
5210
|
+
callInputParamHandler(path, value) {
|
|
5211
|
+
this.fDSPCode.callInputParamHandler(path, value);
|
|
5212
|
+
}
|
|
5161
5213
|
setComputeHandler(handler) {
|
|
5162
5214
|
this.fDSPCode.setComputeHandler(handler);
|
|
5163
5215
|
}
|