@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
|
@@ -420,6 +420,7 @@ export declare class FaustWasmInstantiator {
|
|
|
420
420
|
static createSyncPolyDSPInstance(voiceFactory: LooseFaustDspFactory, mixerModule: WebAssembly.Module, voices: number, effectFactory?: LooseFaustDspFactory): FaustPolyDspInstance;
|
|
421
421
|
}
|
|
422
422
|
export type OutputParamHandler = (path: string, value: number) => void;
|
|
423
|
+
export type InputParamHandler = (path: string, value: number) => void;
|
|
423
424
|
export type ComputeHandler = (buffer_size: number) => void;
|
|
424
425
|
export type PlotHandler = (plotted: Float32Array[] | Float64Array[], index: number, events?: {
|
|
425
426
|
type: string;
|
|
@@ -541,6 +542,7 @@ export declare class Soundfile {
|
|
|
541
542
|
* DSP implementation that mimic the C++ 'dsp' class:
|
|
542
543
|
* - adding MIDI control: metadata are decoded and incoming MIDI messages will control the associated controllers
|
|
543
544
|
* - an output handler can be set to treat produced output controllers (like 'bargraph')
|
|
545
|
+
* - an input handler can be set to follow control parameter changes (like sliders)
|
|
544
546
|
* - regular controllers are handled using setParamValue/getParamValue and getParams methods
|
|
545
547
|
*/
|
|
546
548
|
export interface IFaustBaseWebAudioDsp {
|
|
@@ -563,6 +565,25 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
563
565
|
* @param value - the float value for the wanted control
|
|
564
566
|
*/
|
|
565
567
|
callOutputParamHandler(path: string, value: number): void;
|
|
568
|
+
/**
|
|
569
|
+
* Set the parameter input handler, to be called when input parameters change (like sliders).
|
|
570
|
+
*
|
|
571
|
+
* @param handler - the input handler
|
|
572
|
+
*/
|
|
573
|
+
setInputParamHandler(handler: InputParamHandler | null): void;
|
|
574
|
+
/**
|
|
575
|
+
* Get the parameter input handler.
|
|
576
|
+
*
|
|
577
|
+
* @return the current input handler
|
|
578
|
+
*/
|
|
579
|
+
getInputParamHandler(): InputParamHandler | null;
|
|
580
|
+
/**
|
|
581
|
+
* Call the input parameter handler with a path and value.
|
|
582
|
+
*
|
|
583
|
+
* @param path - the path to the wanted parameter (retrieved using 'getParams' method)
|
|
584
|
+
* @param value - the float value for the wanted control
|
|
585
|
+
*/
|
|
586
|
+
callInputParamHandler(path: string, value: number): void;
|
|
566
587
|
/**
|
|
567
588
|
* Set the compute handler, to be called in the 'compute' method with buffer size.
|
|
568
589
|
*
|
|
@@ -759,6 +780,7 @@ export interface IFaustPolyWebAudioNode extends IFaustPolyWebAudioDsp, AudioNode
|
|
|
759
780
|
}
|
|
760
781
|
export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
761
782
|
protected fOutputHandler: OutputParamHandler | null;
|
|
783
|
+
protected fInputHandler: InputParamHandler | null;
|
|
762
784
|
protected fComputeHandler: ComputeHandler | null;
|
|
763
785
|
protected fPlotHandler: PlotHandler | null;
|
|
764
786
|
protected fCachedEvents: {
|
|
@@ -864,6 +886,9 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
864
886
|
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
865
887
|
getOutputParamHandler(): OutputParamHandler | null;
|
|
866
888
|
callOutputParamHandler(path: string, value: number): void;
|
|
889
|
+
setInputParamHandler(handler: InputParamHandler | null): void;
|
|
890
|
+
getInputParamHandler(): InputParamHandler | null;
|
|
891
|
+
callInputParamHandler(path: string, value: number): void;
|
|
867
892
|
setComputeHandler(handler: ComputeHandler | null): void;
|
|
868
893
|
getComputeHandler(): ComputeHandler | null;
|
|
869
894
|
setPlotHandler(handler: PlotHandler | null): void;
|
|
@@ -1218,6 +1243,9 @@ export declare class FaustOfflineProcessor<Poly extends boolean = false> {
|
|
|
1218
1243
|
setOutputParamHandler(handler: OutputParamHandler): void;
|
|
1219
1244
|
getOutputParamHandler(): OutputParamHandler | null;
|
|
1220
1245
|
callOutputParamHandler(path: string, value: number): void;
|
|
1246
|
+
setInputParamHandler(handler: InputParamHandler): void;
|
|
1247
|
+
getInputParamHandler(): InputParamHandler | null;
|
|
1248
|
+
callInputParamHandler(path: string, value: number): void;
|
|
1221
1249
|
setComputeHandler(handler: ComputeHandler): void;
|
|
1222
1250
|
getComputeHandler(): ComputeHandler | null;
|
|
1223
1251
|
setPlotHandler(handler: PlotHandler): void;
|
|
@@ -1404,6 +1432,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1404
1432
|
protected fJSON: string;
|
|
1405
1433
|
protected fInputsItems: string[];
|
|
1406
1434
|
protected fOutputHandler: OutputParamHandler | null;
|
|
1435
|
+
protected fInputHandler: InputParamHandler | null;
|
|
1407
1436
|
protected fComputeHandler: ComputeHandler | null;
|
|
1408
1437
|
protected fPlotHandler: PlotHandler | null;
|
|
1409
1438
|
protected fUICallback: UIHandler;
|
|
@@ -1420,6 +1449,9 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1420
1449
|
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
1421
1450
|
getOutputParamHandler(): OutputParamHandler | null;
|
|
1422
1451
|
callOutputParamHandler(path: string, value: number): void;
|
|
1452
|
+
setInputParamHandler(handler: InputParamHandler | null): void;
|
|
1453
|
+
getInputParamHandler(): InputParamHandler | null;
|
|
1454
|
+
callInputParamHandler(path: string, value: number): void;
|
|
1423
1455
|
setComputeHandler(handler: ComputeHandler | null): void;
|
|
1424
1456
|
getComputeHandler(): ComputeHandler | null;
|
|
1425
1457
|
setPlotHandler(handler: PlotHandler | null): void;
|
|
@@ -1492,6 +1524,9 @@ export declare class FaustScriptProcessorNode<Poly extends boolean = false> exte
|
|
|
1492
1524
|
setOutputParamHandler(handler: OutputParamHandler): void;
|
|
1493
1525
|
getOutputParamHandler(): OutputParamHandler | null;
|
|
1494
1526
|
callOutputParamHandler(path: string, value: number): void;
|
|
1527
|
+
setInputParamHandler(handler: InputParamHandler): void;
|
|
1528
|
+
getInputParamHandler(): InputParamHandler | null;
|
|
1529
|
+
callInputParamHandler(path: string, value: number): void;
|
|
1495
1530
|
setComputeHandler(handler: ComputeHandler): void;
|
|
1496
1531
|
getComputeHandler(): ComputeHandler | null;
|
|
1497
1532
|
setPlotHandler(handler: PlotHandler): void;
|
package/dist/cjs-bundle/index.js
CHANGED
|
@@ -6115,7 +6115,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
6115
6115
|
this.port.addEventListener("message", this.handleMessageAux);
|
|
6116
6116
|
this.port.start();
|
|
6117
6117
|
this.fDSPCode.setOutputParamHandler(
|
|
6118
|
-
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
6118
|
+
(path, value) => this.port.postMessage({ path, value, type: "out-param" })
|
|
6119
|
+
);
|
|
6120
|
+
this.fDSPCode.setInputParamHandler(
|
|
6121
|
+
(path, value) => this.port.postMessage({ path, value, type: "in-param" })
|
|
6119
6122
|
);
|
|
6120
6123
|
this.fDSPCode.start();
|
|
6121
6124
|
}
|
|
@@ -6165,7 +6168,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
6165
6168
|
this.port.addEventListener("message", this.handleMessageAux);
|
|
6166
6169
|
this.port.start();
|
|
6167
6170
|
this.fDSPCode.setOutputParamHandler(
|
|
6168
|
-
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
6171
|
+
(path, value) => this.port.postMessage({ path, value, type: "out-param" })
|
|
6172
|
+
);
|
|
6173
|
+
this.fDSPCode.setInputParamHandler(
|
|
6174
|
+
(path, value) => this.port.postMessage({ path, value, type: "in-param" })
|
|
6169
6175
|
);
|
|
6170
6176
|
this.fDSPCode.start();
|
|
6171
6177
|
}
|
|
@@ -6701,7 +6707,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
6701
6707
|
this.soundfiles
|
|
6702
6708
|
);
|
|
6703
6709
|
this.fDSPCode.setOutputParamHandler(
|
|
6704
|
-
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
6710
|
+
(path, value) => this.port.postMessage({ path, value, type: "out-param" })
|
|
6711
|
+
);
|
|
6712
|
+
this.fDSPCode.setInputParamHandler(
|
|
6713
|
+
(path, value) => this.port.postMessage({ path, value, type: "in-param" })
|
|
6705
6714
|
);
|
|
6706
6715
|
this.fDSPCode.setPlotHandler(this.fPlotHandler);
|
|
6707
6716
|
const params = this.fDSPCode.getParams();
|
|
@@ -8335,6 +8344,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
8335
8344
|
var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
8336
8345
|
constructor(sampleSize, bufferSize, soundfiles) {
|
|
8337
8346
|
this.fOutputHandler = null;
|
|
8347
|
+
this.fInputHandler = null;
|
|
8338
8348
|
this.fComputeHandler = null;
|
|
8339
8349
|
// To handle MIDI events plot
|
|
8340
8350
|
this.fPlotHandler = null;
|
|
@@ -8757,8 +8767,17 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
8757
8767
|
callOutputParamHandler(path, value) {
|
|
8758
8768
|
if (this.fOutputHandler) {
|
|
8759
8769
|
this.fOutputHandler(path, value);
|
|
8760
|
-
}
|
|
8761
|
-
|
|
8770
|
+
}
|
|
8771
|
+
}
|
|
8772
|
+
setInputParamHandler(handler) {
|
|
8773
|
+
this.fInputHandler = handler;
|
|
8774
|
+
}
|
|
8775
|
+
getInputParamHandler() {
|
|
8776
|
+
return this.fInputHandler;
|
|
8777
|
+
}
|
|
8778
|
+
callInputParamHandler(path, value) {
|
|
8779
|
+
if (this.fInputHandler) {
|
|
8780
|
+
this.fInputHandler(path, value);
|
|
8762
8781
|
}
|
|
8763
8782
|
}
|
|
8764
8783
|
setComputeHandler(handler) {
|
|
@@ -8950,6 +8969,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
8950
8969
|
destroy() {
|
|
8951
8970
|
this.fDestroyed = true;
|
|
8952
8971
|
this.fOutputHandler = null;
|
|
8972
|
+
this.fInputHandler = null;
|
|
8953
8973
|
this.fComputeHandler = null;
|
|
8954
8974
|
this.fPlotHandler = null;
|
|
8955
8975
|
}
|
|
@@ -9091,6 +9111,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
9091
9111
|
this.fPathTable[path],
|
|
9092
9112
|
value
|
|
9093
9113
|
);
|
|
9114
|
+
this.callInputParamHandler(path, this.getParamValue(path));
|
|
9094
9115
|
}
|
|
9095
9116
|
getParamValue(path) {
|
|
9096
9117
|
return this.fInstance.api.getParamValue(
|
|
@@ -9506,6 +9527,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
9506
9527
|
(voice) => voice.setParamValue(this.fPathTable[path], value)
|
|
9507
9528
|
);
|
|
9508
9529
|
}
|
|
9530
|
+
this.callInputParamHandler(path, this.getParamValue(path));
|
|
9509
9531
|
}
|
|
9510
9532
|
getParamValue(path) {
|
|
9511
9533
|
if (this.fJSONEffect && _FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {
|
|
@@ -9657,6 +9679,15 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
9657
9679
|
callOutputParamHandler(path, value) {
|
|
9658
9680
|
this.fDSPCode.callOutputParamHandler(path, value);
|
|
9659
9681
|
}
|
|
9682
|
+
setInputParamHandler(handler) {
|
|
9683
|
+
this.fDSPCode.setInputParamHandler(handler);
|
|
9684
|
+
}
|
|
9685
|
+
getInputParamHandler() {
|
|
9686
|
+
return this.fDSPCode.getInputParamHandler();
|
|
9687
|
+
}
|
|
9688
|
+
callInputParamHandler(path, value) {
|
|
9689
|
+
this.fDSPCode.callInputParamHandler(path, value);
|
|
9690
|
+
}
|
|
9660
9691
|
setComputeHandler(handler) {
|
|
9661
9692
|
this.fDSPCode.setComputeHandler(handler);
|
|
9662
9693
|
}
|
|
@@ -10562,8 +10593,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
10562
10593
|
__privateAdd(this, _hasAccInput, false);
|
|
10563
10594
|
__privateAdd(this, _hasGyrInput, false);
|
|
10564
10595
|
this.handleMessageAux = (e) => {
|
|
10565
|
-
if (e.data.type === "param" && this.fOutputHandler) {
|
|
10596
|
+
if (e.data.type === "out-param" && this.fOutputHandler) {
|
|
10566
10597
|
this.fOutputHandler(e.data.path, e.data.value);
|
|
10598
|
+
} else if (e.data.type === "in-param" && this.fInputHandler) {
|
|
10599
|
+
this.fInputHandler(e.data.path, e.data.value);
|
|
10567
10600
|
} else if (e.data.type === "plot" && this.fPlotHandler) {
|
|
10568
10601
|
this.fPlotHandler(e.data.value, e.data.index, e.data.events);
|
|
10569
10602
|
}
|
|
@@ -10587,6 +10620,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
10587
10620
|
this.fJSONDsp = JSONObj;
|
|
10588
10621
|
this.fJSON = factory.json;
|
|
10589
10622
|
this.fOutputHandler = null;
|
|
10623
|
+
this.fInputHandler = null;
|
|
10590
10624
|
this.fComputeHandler = null;
|
|
10591
10625
|
this.fPlotHandler = null;
|
|
10592
10626
|
this.fDescriptor = [];
|
|
@@ -10667,8 +10701,17 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
10667
10701
|
callOutputParamHandler(path, value) {
|
|
10668
10702
|
if (this.fOutputHandler) {
|
|
10669
10703
|
this.fOutputHandler(path, value);
|
|
10670
|
-
}
|
|
10671
|
-
|
|
10704
|
+
}
|
|
10705
|
+
}
|
|
10706
|
+
setInputParamHandler(handler) {
|
|
10707
|
+
this.fInputHandler = handler;
|
|
10708
|
+
}
|
|
10709
|
+
getInputParamHandler() {
|
|
10710
|
+
return this.fInputHandler;
|
|
10711
|
+
}
|
|
10712
|
+
callInputParamHandler(path, value) {
|
|
10713
|
+
if (this.fInputHandler) {
|
|
10714
|
+
this.fInputHandler(path, value);
|
|
10672
10715
|
}
|
|
10673
10716
|
}
|
|
10674
10717
|
setComputeHandler(handler) {
|
|
@@ -10963,6 +11006,15 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
10963
11006
|
callOutputParamHandler(path, value) {
|
|
10964
11007
|
this.fDSPCode.callOutputParamHandler(path, value);
|
|
10965
11008
|
}
|
|
11009
|
+
setInputParamHandler(handler) {
|
|
11010
|
+
this.fDSPCode.setInputParamHandler(handler);
|
|
11011
|
+
}
|
|
11012
|
+
getInputParamHandler() {
|
|
11013
|
+
return this.fDSPCode.getInputParamHandler();
|
|
11014
|
+
}
|
|
11015
|
+
callInputParamHandler(path, value) {
|
|
11016
|
+
this.fDSPCode.callInputParamHandler(path, value);
|
|
11017
|
+
}
|
|
10966
11018
|
setComputeHandler(handler) {
|
|
10967
11019
|
this.fDSPCode.setComputeHandler(handler);
|
|
10968
11020
|
}
|