@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
|
@@ -132,8 +132,9 @@ async function createFaustUI(divFaustUI, faustNode) {
|
|
|
132
132
|
listenWindowMessage: false,
|
|
133
133
|
listenWindowResize: true,
|
|
134
134
|
});
|
|
135
|
-
faustUI.paramChangeByUI = (path, value) => faustNode.setParamValue(path, value);
|
|
136
|
-
faustNode.setOutputParamHandler((path, value) => faustUI.paramChangeByDSP(path, value));
|
|
135
|
+
faustUI.paramChangeByUI = (path, value) => faustNode.setParamValue(path, value);
|
|
136
|
+
faustNode.setOutputParamHandler((path, value) => faustUI.paramChangeByDSP(path, value));
|
|
137
|
+
faustNode.setInputParamHandler((path, value) => faustUI.paramChangeByDSP(path, value));
|
|
137
138
|
$container.style.minWidth = `${faustUI.minWidth}px`;
|
|
138
139
|
$container.style.minHeight = `${faustUI.minHeight}px`;
|
|
139
140
|
faustUI.resize();
|
|
@@ -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;
|
|
@@ -281,7 +281,10 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
281
281
|
this.port.addEventListener("message", this.handleMessageAux);
|
|
282
282
|
this.port.start();
|
|
283
283
|
this.fDSPCode.setOutputParamHandler(
|
|
284
|
-
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
284
|
+
(path, value) => this.port.postMessage({ path, value, type: "out-param" })
|
|
285
|
+
);
|
|
286
|
+
this.fDSPCode.setInputParamHandler(
|
|
287
|
+
(path, value) => this.port.postMessage({ path, value, type: "in-param" })
|
|
285
288
|
);
|
|
286
289
|
this.fDSPCode.start();
|
|
287
290
|
}
|
|
@@ -331,7 +334,10 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
331
334
|
this.port.addEventListener("message", this.handleMessageAux);
|
|
332
335
|
this.port.start();
|
|
333
336
|
this.fDSPCode.setOutputParamHandler(
|
|
334
|
-
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
337
|
+
(path, value) => this.port.postMessage({ path, value, type: "out-param" })
|
|
338
|
+
);
|
|
339
|
+
this.fDSPCode.setInputParamHandler(
|
|
340
|
+
(path, value) => this.port.postMessage({ path, value, type: "in-param" })
|
|
335
341
|
);
|
|
336
342
|
this.fDSPCode.start();
|
|
337
343
|
}
|
|
@@ -867,7 +873,10 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
867
873
|
this.soundfiles
|
|
868
874
|
);
|
|
869
875
|
this.fDSPCode.setOutputParamHandler(
|
|
870
|
-
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
876
|
+
(path, value) => this.port.postMessage({ path, value, type: "out-param" })
|
|
877
|
+
);
|
|
878
|
+
this.fDSPCode.setInputParamHandler(
|
|
879
|
+
(path, value) => this.port.postMessage({ path, value, type: "in-param" })
|
|
871
880
|
);
|
|
872
881
|
this.fDSPCode.setPlotHandler(this.fPlotHandler);
|
|
873
882
|
const params = this.fDSPCode.getParams();
|
|
@@ -2501,6 +2510,7 @@ var Soundfile = class _Soundfile {
|
|
|
2501
2510
|
var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
2502
2511
|
constructor(sampleSize, bufferSize, soundfiles) {
|
|
2503
2512
|
this.fOutputHandler = null;
|
|
2513
|
+
this.fInputHandler = null;
|
|
2504
2514
|
this.fComputeHandler = null;
|
|
2505
2515
|
// To handle MIDI events plot
|
|
2506
2516
|
this.fPlotHandler = null;
|
|
@@ -2923,8 +2933,17 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
2923
2933
|
callOutputParamHandler(path, value) {
|
|
2924
2934
|
if (this.fOutputHandler) {
|
|
2925
2935
|
this.fOutputHandler(path, value);
|
|
2926
|
-
}
|
|
2927
|
-
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
setInputParamHandler(handler) {
|
|
2939
|
+
this.fInputHandler = handler;
|
|
2940
|
+
}
|
|
2941
|
+
getInputParamHandler() {
|
|
2942
|
+
return this.fInputHandler;
|
|
2943
|
+
}
|
|
2944
|
+
callInputParamHandler(path, value) {
|
|
2945
|
+
if (this.fInputHandler) {
|
|
2946
|
+
this.fInputHandler(path, value);
|
|
2928
2947
|
}
|
|
2929
2948
|
}
|
|
2930
2949
|
setComputeHandler(handler) {
|
|
@@ -3116,6 +3135,7 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
3116
3135
|
destroy() {
|
|
3117
3136
|
this.fDestroyed = true;
|
|
3118
3137
|
this.fOutputHandler = null;
|
|
3138
|
+
this.fInputHandler = null;
|
|
3119
3139
|
this.fComputeHandler = null;
|
|
3120
3140
|
this.fPlotHandler = null;
|
|
3121
3141
|
}
|
|
@@ -3257,6 +3277,7 @@ var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
3257
3277
|
this.fPathTable[path],
|
|
3258
3278
|
value
|
|
3259
3279
|
);
|
|
3280
|
+
this.callInputParamHandler(path, this.getParamValue(path));
|
|
3260
3281
|
}
|
|
3261
3282
|
getParamValue(path) {
|
|
3262
3283
|
return this.fInstance.api.getParamValue(
|
|
@@ -3672,6 +3693,7 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
3672
3693
|
(voice) => voice.setParamValue(this.fPathTable[path], value)
|
|
3673
3694
|
);
|
|
3674
3695
|
}
|
|
3696
|
+
this.callInputParamHandler(path, this.getParamValue(path));
|
|
3675
3697
|
}
|
|
3676
3698
|
getParamValue(path) {
|
|
3677
3699
|
if (this.fJSONEffect && _FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {
|
|
@@ -3823,6 +3845,15 @@ var FaustOfflineProcessor = class {
|
|
|
3823
3845
|
callOutputParamHandler(path, value) {
|
|
3824
3846
|
this.fDSPCode.callOutputParamHandler(path, value);
|
|
3825
3847
|
}
|
|
3848
|
+
setInputParamHandler(handler) {
|
|
3849
|
+
this.fDSPCode.setInputParamHandler(handler);
|
|
3850
|
+
}
|
|
3851
|
+
getInputParamHandler() {
|
|
3852
|
+
return this.fDSPCode.getInputParamHandler();
|
|
3853
|
+
}
|
|
3854
|
+
callInputParamHandler(path, value) {
|
|
3855
|
+
this.fDSPCode.callInputParamHandler(path, value);
|
|
3856
|
+
}
|
|
3826
3857
|
setComputeHandler(handler) {
|
|
3827
3858
|
this.fDSPCode.setComputeHandler(handler);
|
|
3828
3859
|
}
|
|
@@ -4728,8 +4759,10 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
4728
4759
|
__privateAdd(this, _hasAccInput, false);
|
|
4729
4760
|
__privateAdd(this, _hasGyrInput, false);
|
|
4730
4761
|
this.handleMessageAux = (e) => {
|
|
4731
|
-
if (e.data.type === "param" && this.fOutputHandler) {
|
|
4762
|
+
if (e.data.type === "out-param" && this.fOutputHandler) {
|
|
4732
4763
|
this.fOutputHandler(e.data.path, e.data.value);
|
|
4764
|
+
} else if (e.data.type === "in-param" && this.fInputHandler) {
|
|
4765
|
+
this.fInputHandler(e.data.path, e.data.value);
|
|
4733
4766
|
} else if (e.data.type === "plot" && this.fPlotHandler) {
|
|
4734
4767
|
this.fPlotHandler(e.data.value, e.data.index, e.data.events);
|
|
4735
4768
|
}
|
|
@@ -4753,6 +4786,7 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
4753
4786
|
this.fJSONDsp = JSONObj;
|
|
4754
4787
|
this.fJSON = factory.json;
|
|
4755
4788
|
this.fOutputHandler = null;
|
|
4789
|
+
this.fInputHandler = null;
|
|
4756
4790
|
this.fComputeHandler = null;
|
|
4757
4791
|
this.fPlotHandler = null;
|
|
4758
4792
|
this.fDescriptor = [];
|
|
@@ -4833,8 +4867,17 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
4833
4867
|
callOutputParamHandler(path, value) {
|
|
4834
4868
|
if (this.fOutputHandler) {
|
|
4835
4869
|
this.fOutputHandler(path, value);
|
|
4836
|
-
}
|
|
4837
|
-
|
|
4870
|
+
}
|
|
4871
|
+
}
|
|
4872
|
+
setInputParamHandler(handler) {
|
|
4873
|
+
this.fInputHandler = handler;
|
|
4874
|
+
}
|
|
4875
|
+
getInputParamHandler() {
|
|
4876
|
+
return this.fInputHandler;
|
|
4877
|
+
}
|
|
4878
|
+
callInputParamHandler(path, value) {
|
|
4879
|
+
if (this.fInputHandler) {
|
|
4880
|
+
this.fInputHandler(path, value);
|
|
4838
4881
|
}
|
|
4839
4882
|
}
|
|
4840
4883
|
setComputeHandler(handler) {
|
|
@@ -5129,6 +5172,15 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
5129
5172
|
callOutputParamHandler(path, value) {
|
|
5130
5173
|
this.fDSPCode.callOutputParamHandler(path, value);
|
|
5131
5174
|
}
|
|
5175
|
+
setInputParamHandler(handler) {
|
|
5176
|
+
this.fDSPCode.setInputParamHandler(handler);
|
|
5177
|
+
}
|
|
5178
|
+
getInputParamHandler() {
|
|
5179
|
+
return this.fDSPCode.getInputParamHandler();
|
|
5180
|
+
}
|
|
5181
|
+
callInputParamHandler(path, value) {
|
|
5182
|
+
this.fDSPCode.callInputParamHandler(path, value);
|
|
5183
|
+
}
|
|
5132
5184
|
setComputeHandler(handler) {
|
|
5133
5185
|
this.fDSPCode.setComputeHandler(handler);
|
|
5134
5186
|
}
|