@grame/faustwasm 0.15.7 → 0.16.1
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/faustwasm/index.d.ts +59 -1
- package/assets/standalone/faustwasm/index.js +147 -6
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.d.ts +59 -1
- package/dist/cjs/index.js +147 -6
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +59 -1
- package/dist/cjs-bundle/index.js +147 -6
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +59 -1
- package/dist/esm/index.js +147 -6
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +59 -1
- package/dist/esm-bundle/index.js +147 -6
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +1 -1
- package/src/FaustAudioWorkletNode.ts +24 -1
- package/src/FaustAudioWorkletProcessor.ts +27 -10
- package/src/FaustDspGenerator.ts +2 -2
- package/src/FaustOfflineProcessor.ts +22 -4
- package/src/FaustScriptProcessorNode.ts +21 -1
- package/src/FaustWebAudioDsp.ts +120 -5
- package/test/faustlive-wasm/faustwasm/index.d.ts +59 -1
- package/test/faustlive-wasm/faustwasm/index.js +147 -6
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
|
@@ -219,6 +219,26 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
219
219
|
this.setupWamEventHandler();
|
|
220
220
|
break;
|
|
221
221
|
}
|
|
222
|
+
case "init": {
|
|
223
|
+
this.fDSPCode.init();
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
case "instanceInit": {
|
|
227
|
+
this.fDSPCode.instanceInit();
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
case "instanceClear": {
|
|
231
|
+
this.fDSPCode.instanceClear();
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
case "instanceConstants": {
|
|
235
|
+
this.fDSPCode.instanceConstants();
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
case "instanceResetUserInterface": {
|
|
239
|
+
this.fDSPCode.instanceResetUserInterface();
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
222
242
|
case "start": {
|
|
223
243
|
this.fDSPCode.start();
|
|
224
244
|
break;
|
|
@@ -3126,6 +3146,16 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
3126
3146
|
stopSensors() {
|
|
3127
3147
|
this.stopSensors();
|
|
3128
3148
|
}
|
|
3149
|
+
init() {
|
|
3150
|
+
}
|
|
3151
|
+
instanceInit() {
|
|
3152
|
+
}
|
|
3153
|
+
instanceClear() {
|
|
3154
|
+
}
|
|
3155
|
+
instanceConstants() {
|
|
3156
|
+
}
|
|
3157
|
+
instanceResetUserInterface() {
|
|
3158
|
+
}
|
|
3129
3159
|
start() {
|
|
3130
3160
|
this.fProcessing = true;
|
|
3131
3161
|
}
|
|
@@ -3144,6 +3174,7 @@ var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
3144
3174
|
constructor(instance, sampleRate, sampleSize, bufferSize, soundfiles) {
|
|
3145
3175
|
super(sampleSize, bufferSize, soundfiles);
|
|
3146
3176
|
this.fInstance = instance;
|
|
3177
|
+
this.fSampleRate = sampleRate;
|
|
3147
3178
|
console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);
|
|
3148
3179
|
this.fJSONDsp = JSON.parse(this.fInstance.json);
|
|
3149
3180
|
FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);
|
|
@@ -3157,6 +3188,21 @@ var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
3157
3188
|
this.initSoundfileMemory(allocator, this.fDSP);
|
|
3158
3189
|
}
|
|
3159
3190
|
}
|
|
3191
|
+
init() {
|
|
3192
|
+
this.fInstance.api.init(this.fDSP, this.fSampleRate);
|
|
3193
|
+
}
|
|
3194
|
+
instanceInit() {
|
|
3195
|
+
this.fInstance.api.instanceInit(this.fDSP, this.fSampleRate);
|
|
3196
|
+
}
|
|
3197
|
+
instanceClear() {
|
|
3198
|
+
this.fInstance.api.instanceClear(this.fDSP);
|
|
3199
|
+
}
|
|
3200
|
+
instanceConstants() {
|
|
3201
|
+
this.fInstance.api.instanceConstants(this.fDSP, this.fSampleRate);
|
|
3202
|
+
}
|
|
3203
|
+
instanceResetUserInterface() {
|
|
3204
|
+
this.fInstance.api.instanceResetUserInterface(this.fDSP);
|
|
3205
|
+
}
|
|
3160
3206
|
initMemory() {
|
|
3161
3207
|
this.fDSP = 0;
|
|
3162
3208
|
const $audio = this.fJSONDsp.size;
|
|
@@ -3306,7 +3352,6 @@ var FaustWebAudioDspVoice = class _FaustWebAudioDspVoice {
|
|
|
3306
3352
|
this.fGainLabel = [];
|
|
3307
3353
|
this.fKeyLabel = [];
|
|
3308
3354
|
this.fVelLabel = [];
|
|
3309
|
-
// Voice DSP code
|
|
3310
3355
|
// Accessed by PolyDSPImp class
|
|
3311
3356
|
this.fCurNote = _FaustWebAudioDspVoice.kFreeVoice;
|
|
3312
3357
|
this.fNextNote = -1;
|
|
@@ -3315,7 +3360,8 @@ var FaustWebAudioDspVoice = class _FaustWebAudioDspVoice {
|
|
|
3315
3360
|
this.fLevel = 0;
|
|
3316
3361
|
this.fDSP = $dsp;
|
|
3317
3362
|
this.fAPI = api;
|
|
3318
|
-
this.
|
|
3363
|
+
this.fSampleRate = sampleRate;
|
|
3364
|
+
this.init(sampleRate);
|
|
3319
3365
|
this.extractPaths(inputItems, pathTable);
|
|
3320
3366
|
}
|
|
3321
3367
|
// Voice state
|
|
@@ -3343,6 +3389,21 @@ var FaustWebAudioDspVoice = class _FaustWebAudioDspVoice {
|
|
|
3343
3389
|
static normalizeVelocity(velocity) {
|
|
3344
3390
|
return velocity / 127;
|
|
3345
3391
|
}
|
|
3392
|
+
init(sampleRate) {
|
|
3393
|
+
this.fAPI.init(this.fDSP, sampleRate);
|
|
3394
|
+
}
|
|
3395
|
+
instanceInit() {
|
|
3396
|
+
this.fAPI.instanceInit(this.fDSP, this.fSampleRate);
|
|
3397
|
+
}
|
|
3398
|
+
instanceClear() {
|
|
3399
|
+
this.fAPI.instanceClear(this.fDSP);
|
|
3400
|
+
}
|
|
3401
|
+
instanceConstants() {
|
|
3402
|
+
this.fAPI.instanceConstants(this.fDSP, this.fSampleRate);
|
|
3403
|
+
}
|
|
3404
|
+
instanceResetUserInterface() {
|
|
3405
|
+
this.fAPI.instanceResetUserInterface(this.fDSP);
|
|
3406
|
+
}
|
|
3346
3407
|
extractPaths(inputItems, pathTable) {
|
|
3347
3408
|
inputItems.forEach((item) => {
|
|
3348
3409
|
if (item.endsWith("/gate")) {
|
|
@@ -3423,6 +3484,7 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
3423
3484
|
constructor(instance, sampleRate, sampleSize, bufferSize, soundfiles) {
|
|
3424
3485
|
super(sampleSize, bufferSize, soundfiles);
|
|
3425
3486
|
this.fInstance = instance;
|
|
3487
|
+
this.fSampleRate = sampleRate;
|
|
3426
3488
|
console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);
|
|
3427
3489
|
this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);
|
|
3428
3490
|
this.fJSONEffect = this.fInstance.effectAPI && this.fInstance.effectJSON ? JSON.parse(this.fInstance.effectJSON) : null;
|
|
@@ -3454,6 +3516,37 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
3454
3516
|
}
|
|
3455
3517
|
}
|
|
3456
3518
|
}
|
|
3519
|
+
init() {
|
|
3520
|
+
this.fVoiceTable.forEach((voice) => voice.init(this.fSampleRate));
|
|
3521
|
+
if (this.fInstance.effectAPI)
|
|
3522
|
+
this.fInstance.effectAPI.init(this.fEffect, this.fSampleRate);
|
|
3523
|
+
}
|
|
3524
|
+
instanceInit() {
|
|
3525
|
+
this.fVoiceTable.forEach((voice) => voice.instanceInit());
|
|
3526
|
+
if (this.fInstance.effectAPI)
|
|
3527
|
+
this.fInstance.effectAPI.instanceInit(
|
|
3528
|
+
this.fEffect,
|
|
3529
|
+
this.fSampleRate
|
|
3530
|
+
);
|
|
3531
|
+
}
|
|
3532
|
+
instanceClear() {
|
|
3533
|
+
this.fVoiceTable.forEach((voice) => voice.instanceClear());
|
|
3534
|
+
if (this.fInstance.effectAPI)
|
|
3535
|
+
this.fInstance.effectAPI.instanceClear(this.fEffect);
|
|
3536
|
+
}
|
|
3537
|
+
instanceConstants() {
|
|
3538
|
+
this.fVoiceTable.forEach((voice) => voice.instanceConstants());
|
|
3539
|
+
if (this.fInstance.effectAPI)
|
|
3540
|
+
this.fInstance.effectAPI.instanceConstants(
|
|
3541
|
+
this.fEffect,
|
|
3542
|
+
this.fSampleRate
|
|
3543
|
+
);
|
|
3544
|
+
}
|
|
3545
|
+
instanceResetUserInterface() {
|
|
3546
|
+
this.fVoiceTable.forEach((voice) => voice.instanceResetUserInterface());
|
|
3547
|
+
if (this.fInstance.effectAPI)
|
|
3548
|
+
this.fInstance.effectAPI.instanceResetUserInterface(this.fEffect);
|
|
3549
|
+
}
|
|
3457
3550
|
initMemory() {
|
|
3458
3551
|
this.fEffect = this.fJSONDsp.size * this.fInstance.voices;
|
|
3459
3552
|
const $audio = this.fEffect + (this.fJSONEffect ? this.fJSONEffect.size : 0);
|
|
@@ -3910,6 +4003,21 @@ var FaustOfflineProcessor = class {
|
|
|
3910
4003
|
getUI() {
|
|
3911
4004
|
return this.fDSPCode.getUI();
|
|
3912
4005
|
}
|
|
4006
|
+
init() {
|
|
4007
|
+
this.fDSPCode.init();
|
|
4008
|
+
}
|
|
4009
|
+
instanceInit() {
|
|
4010
|
+
this.fDSPCode.instanceInit();
|
|
4011
|
+
}
|
|
4012
|
+
instanceClear() {
|
|
4013
|
+
this.fDSPCode.instanceClear();
|
|
4014
|
+
}
|
|
4015
|
+
instanceConstants() {
|
|
4016
|
+
this.fDSPCode.instanceConstants();
|
|
4017
|
+
}
|
|
4018
|
+
instanceResetUserInterface() {
|
|
4019
|
+
this.fDSPCode.instanceResetUserInterface();
|
|
4020
|
+
}
|
|
3913
4021
|
start() {
|
|
3914
4022
|
this.fDSPCode.start();
|
|
3915
4023
|
}
|
|
@@ -4953,7 +5061,10 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
4953
5061
|
}
|
|
4954
5062
|
setParamValue(path, value) {
|
|
4955
5063
|
const resolved = this.fParamAliases[path] || path;
|
|
4956
|
-
this.port.postMessage({
|
|
5064
|
+
this.port.postMessage({
|
|
5065
|
+
type: "param",
|
|
5066
|
+
data: { path: resolved, value }
|
|
5067
|
+
});
|
|
4957
5068
|
const param = this.parameters.get(resolved);
|
|
4958
5069
|
if (param) param.setValueAtTime(value, this.context.currentTime);
|
|
4959
5070
|
}
|
|
@@ -4977,6 +5088,21 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
4977
5088
|
getDescriptors() {
|
|
4978
5089
|
return this.fDescriptor;
|
|
4979
5090
|
}
|
|
5091
|
+
init() {
|
|
5092
|
+
this.port.postMessage({ type: "init" });
|
|
5093
|
+
}
|
|
5094
|
+
instanceInit() {
|
|
5095
|
+
this.port.postMessage({ type: "instanceInit" });
|
|
5096
|
+
}
|
|
5097
|
+
instanceClear() {
|
|
5098
|
+
this.port.postMessage({ type: "instanceClear" });
|
|
5099
|
+
}
|
|
5100
|
+
instanceConstants() {
|
|
5101
|
+
this.port.postMessage({ type: "instanceConstants" });
|
|
5102
|
+
}
|
|
5103
|
+
instanceResetUserInterface() {
|
|
5104
|
+
this.port.postMessage({ type: "instanceResetUserInterface" });
|
|
5105
|
+
}
|
|
4980
5106
|
start() {
|
|
4981
5107
|
this.port.postMessage({ type: "start" });
|
|
4982
5108
|
}
|
|
@@ -5073,7 +5199,7 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
5073
5199
|
this.handleDeviceMotion = void 0;
|
|
5074
5200
|
this.handleDeviceOrientation = void 0;
|
|
5075
5201
|
}
|
|
5076
|
-
|
|
5202
|
+
setupNode(instance) {
|
|
5077
5203
|
this.fDSPCode = instance;
|
|
5078
5204
|
this.fInputs = new Array(this.fDSPCode.getNumInputs());
|
|
5079
5205
|
this.fOutputs = new Array(this.fDSPCode.getNumOutputs());
|
|
@@ -5103,6 +5229,21 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
5103
5229
|
};
|
|
5104
5230
|
this.start();
|
|
5105
5231
|
}
|
|
5232
|
+
init() {
|
|
5233
|
+
this.fDSPCode.init();
|
|
5234
|
+
}
|
|
5235
|
+
instanceInit() {
|
|
5236
|
+
this.fDSPCode.instanceInit();
|
|
5237
|
+
}
|
|
5238
|
+
instanceClear() {
|
|
5239
|
+
this.fDSPCode.instanceClear();
|
|
5240
|
+
}
|
|
5241
|
+
instanceConstants() {
|
|
5242
|
+
this.fDSPCode.instanceConstants();
|
|
5243
|
+
}
|
|
5244
|
+
instanceResetUserInterface() {
|
|
5245
|
+
this.fDSPCode.instanceResetUserInterface();
|
|
5246
|
+
}
|
|
5106
5247
|
// Public API
|
|
5107
5248
|
/** Start accelerometer and gyroscope handlers */
|
|
5108
5249
|
async startSensors() {
|
|
@@ -5320,7 +5461,7 @@ var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
|
|
|
5320
5461
|
monoDsp.getNumOutputs()
|
|
5321
5462
|
);
|
|
5322
5463
|
Object.setPrototypeOf(sp2, FaustMonoScriptProcessorNode.prototype);
|
|
5323
|
-
sp2.
|
|
5464
|
+
sp2.setupNode(monoDsp);
|
|
5324
5465
|
return sp2;
|
|
5325
5466
|
} else {
|
|
5326
5467
|
if (!_FaustMonoDspGenerator.gWorkletProcessors.has(context))
|
|
@@ -5704,7 +5845,7 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
|
|
|
5704
5845
|
polyDsp.getNumOutputs()
|
|
5705
5846
|
);
|
|
5706
5847
|
Object.setPrototypeOf(sp2, FaustPolyScriptProcessorNode.prototype);
|
|
5707
|
-
sp2.
|
|
5848
|
+
sp2.setupNode(polyDsp);
|
|
5708
5849
|
return sp2;
|
|
5709
5850
|
} else {
|
|
5710
5851
|
if (!_FaustPolyDspGenerator.gWorkletProcessors.has(context))
|