@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/esm-bundle/index.js
CHANGED
|
@@ -6069,7 +6069,10 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
6069
6069
|
this.port.addEventListener("message", this.handleMessageAux);
|
|
6070
6070
|
this.port.start();
|
|
6071
6071
|
this.fDSPCode.setOutputParamHandler(
|
|
6072
|
-
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
6072
|
+
(path, value) => this.port.postMessage({ path, value, type: "out-param" })
|
|
6073
|
+
);
|
|
6074
|
+
this.fDSPCode.setInputParamHandler(
|
|
6075
|
+
(path, value) => this.port.postMessage({ path, value, type: "in-param" })
|
|
6073
6076
|
);
|
|
6074
6077
|
this.fDSPCode.start();
|
|
6075
6078
|
}
|
|
@@ -6119,7 +6122,10 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
6119
6122
|
this.port.addEventListener("message", this.handleMessageAux);
|
|
6120
6123
|
this.port.start();
|
|
6121
6124
|
this.fDSPCode.setOutputParamHandler(
|
|
6122
|
-
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
6125
|
+
(path, value) => this.port.postMessage({ path, value, type: "out-param" })
|
|
6126
|
+
);
|
|
6127
|
+
this.fDSPCode.setInputParamHandler(
|
|
6128
|
+
(path, value) => this.port.postMessage({ path, value, type: "in-param" })
|
|
6123
6129
|
);
|
|
6124
6130
|
this.fDSPCode.start();
|
|
6125
6131
|
}
|
|
@@ -6655,7 +6661,10 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6655
6661
|
this.soundfiles
|
|
6656
6662
|
);
|
|
6657
6663
|
this.fDSPCode.setOutputParamHandler(
|
|
6658
|
-
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
6664
|
+
(path, value) => this.port.postMessage({ path, value, type: "out-param" })
|
|
6665
|
+
);
|
|
6666
|
+
this.fDSPCode.setInputParamHandler(
|
|
6667
|
+
(path, value) => this.port.postMessage({ path, value, type: "in-param" })
|
|
6659
6668
|
);
|
|
6660
6669
|
this.fDSPCode.setPlotHandler(this.fPlotHandler);
|
|
6661
6670
|
const params = this.fDSPCode.getParams();
|
|
@@ -8289,6 +8298,7 @@ var Soundfile = class _Soundfile {
|
|
|
8289
8298
|
var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
8290
8299
|
constructor(sampleSize, bufferSize, soundfiles) {
|
|
8291
8300
|
this.fOutputHandler = null;
|
|
8301
|
+
this.fInputHandler = null;
|
|
8292
8302
|
this.fComputeHandler = null;
|
|
8293
8303
|
// To handle MIDI events plot
|
|
8294
8304
|
this.fPlotHandler = null;
|
|
@@ -8711,8 +8721,17 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
8711
8721
|
callOutputParamHandler(path, value) {
|
|
8712
8722
|
if (this.fOutputHandler) {
|
|
8713
8723
|
this.fOutputHandler(path, value);
|
|
8714
|
-
}
|
|
8715
|
-
|
|
8724
|
+
}
|
|
8725
|
+
}
|
|
8726
|
+
setInputParamHandler(handler) {
|
|
8727
|
+
this.fInputHandler = handler;
|
|
8728
|
+
}
|
|
8729
|
+
getInputParamHandler() {
|
|
8730
|
+
return this.fInputHandler;
|
|
8731
|
+
}
|
|
8732
|
+
callInputParamHandler(path, value) {
|
|
8733
|
+
if (this.fInputHandler) {
|
|
8734
|
+
this.fInputHandler(path, value);
|
|
8716
8735
|
}
|
|
8717
8736
|
}
|
|
8718
8737
|
setComputeHandler(handler) {
|
|
@@ -8904,6 +8923,7 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
8904
8923
|
destroy() {
|
|
8905
8924
|
this.fDestroyed = true;
|
|
8906
8925
|
this.fOutputHandler = null;
|
|
8926
|
+
this.fInputHandler = null;
|
|
8907
8927
|
this.fComputeHandler = null;
|
|
8908
8928
|
this.fPlotHandler = null;
|
|
8909
8929
|
}
|
|
@@ -9045,6 +9065,7 @@ var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
9045
9065
|
this.fPathTable[path],
|
|
9046
9066
|
value
|
|
9047
9067
|
);
|
|
9068
|
+
this.callInputParamHandler(path, this.getParamValue(path));
|
|
9048
9069
|
}
|
|
9049
9070
|
getParamValue(path) {
|
|
9050
9071
|
return this.fInstance.api.getParamValue(
|
|
@@ -9460,6 +9481,7 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
9460
9481
|
(voice) => voice.setParamValue(this.fPathTable[path], value)
|
|
9461
9482
|
);
|
|
9462
9483
|
}
|
|
9484
|
+
this.callInputParamHandler(path, this.getParamValue(path));
|
|
9463
9485
|
}
|
|
9464
9486
|
getParamValue(path) {
|
|
9465
9487
|
if (this.fJSONEffect && _FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {
|
|
@@ -9611,6 +9633,15 @@ var FaustOfflineProcessor = class {
|
|
|
9611
9633
|
callOutputParamHandler(path, value) {
|
|
9612
9634
|
this.fDSPCode.callOutputParamHandler(path, value);
|
|
9613
9635
|
}
|
|
9636
|
+
setInputParamHandler(handler) {
|
|
9637
|
+
this.fDSPCode.setInputParamHandler(handler);
|
|
9638
|
+
}
|
|
9639
|
+
getInputParamHandler() {
|
|
9640
|
+
return this.fDSPCode.getInputParamHandler();
|
|
9641
|
+
}
|
|
9642
|
+
callInputParamHandler(path, value) {
|
|
9643
|
+
this.fDSPCode.callInputParamHandler(path, value);
|
|
9644
|
+
}
|
|
9614
9645
|
setComputeHandler(handler) {
|
|
9615
9646
|
this.fDSPCode.setComputeHandler(handler);
|
|
9616
9647
|
}
|
|
@@ -10516,8 +10547,10 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
10516
10547
|
__privateAdd(this, _hasAccInput, false);
|
|
10517
10548
|
__privateAdd(this, _hasGyrInput, false);
|
|
10518
10549
|
this.handleMessageAux = (e) => {
|
|
10519
|
-
if (e.data.type === "param" && this.fOutputHandler) {
|
|
10550
|
+
if (e.data.type === "out-param" && this.fOutputHandler) {
|
|
10520
10551
|
this.fOutputHandler(e.data.path, e.data.value);
|
|
10552
|
+
} else if (e.data.type === "in-param" && this.fInputHandler) {
|
|
10553
|
+
this.fInputHandler(e.data.path, e.data.value);
|
|
10521
10554
|
} else if (e.data.type === "plot" && this.fPlotHandler) {
|
|
10522
10555
|
this.fPlotHandler(e.data.value, e.data.index, e.data.events);
|
|
10523
10556
|
}
|
|
@@ -10541,6 +10574,7 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
10541
10574
|
this.fJSONDsp = JSONObj;
|
|
10542
10575
|
this.fJSON = factory.json;
|
|
10543
10576
|
this.fOutputHandler = null;
|
|
10577
|
+
this.fInputHandler = null;
|
|
10544
10578
|
this.fComputeHandler = null;
|
|
10545
10579
|
this.fPlotHandler = null;
|
|
10546
10580
|
this.fDescriptor = [];
|
|
@@ -10621,8 +10655,17 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
10621
10655
|
callOutputParamHandler(path, value) {
|
|
10622
10656
|
if (this.fOutputHandler) {
|
|
10623
10657
|
this.fOutputHandler(path, value);
|
|
10624
|
-
}
|
|
10625
|
-
|
|
10658
|
+
}
|
|
10659
|
+
}
|
|
10660
|
+
setInputParamHandler(handler) {
|
|
10661
|
+
this.fInputHandler = handler;
|
|
10662
|
+
}
|
|
10663
|
+
getInputParamHandler() {
|
|
10664
|
+
return this.fInputHandler;
|
|
10665
|
+
}
|
|
10666
|
+
callInputParamHandler(path, value) {
|
|
10667
|
+
if (this.fInputHandler) {
|
|
10668
|
+
this.fInputHandler(path, value);
|
|
10626
10669
|
}
|
|
10627
10670
|
}
|
|
10628
10671
|
setComputeHandler(handler) {
|
|
@@ -10917,6 +10960,15 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
10917
10960
|
callOutputParamHandler(path, value) {
|
|
10918
10961
|
this.fDSPCode.callOutputParamHandler(path, value);
|
|
10919
10962
|
}
|
|
10963
|
+
setInputParamHandler(handler) {
|
|
10964
|
+
this.fDSPCode.setInputParamHandler(handler);
|
|
10965
|
+
}
|
|
10966
|
+
getInputParamHandler() {
|
|
10967
|
+
return this.fDSPCode.getInputParamHandler();
|
|
10968
|
+
}
|
|
10969
|
+
callInputParamHandler(path, value) {
|
|
10970
|
+
this.fDSPCode.callInputParamHandler(path, value);
|
|
10971
|
+
}
|
|
10920
10972
|
setComputeHandler(handler) {
|
|
10921
10973
|
this.fDSPCode.setComputeHandler(handler);
|
|
10922
10974
|
}
|