@grame/faustwasm 0.7.0 → 0.7.3
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 +5 -3
- package/assets/standalone/faustwasm/index.d.ts +4 -4
- package/assets/standalone/faustwasm/index.js +18 -11
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/assets/standalone/index-pwa.js +1 -1
- package/dist/cjs/index.d.ts +4 -4
- package/dist/cjs/index.js +18 -11
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +4 -4
- package/dist/cjs-bundle/index.js +20 -13
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +18 -11
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +4 -4
- package/dist/esm-bundle/index.js +20 -13
- package/dist/esm-bundle/index.js.map +2 -2
- package/libfaust-wasm/libfaust-wasm.js +1 -1
- package/libfaust-wasm/libfaust-wasm.wasm +0 -0
- package/package.json +1 -1
- package/src/FaustScriptProcessorNode.ts +26 -16
- package/src/FaustWebAudioDsp.ts +2 -2
- package/test/faustlive-wasm/faustwasm/index.d.ts +4 -4
- package/test/faustlive-wasm/faustwasm/index.js +18 -11
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/faustlive-wasm/index.js +2 -1
- package/test/tables.dsp +0 -71
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* @param {boolean} [sp] - Whether to create a ScriptProcessorNode instead of an AudioWorkletNode.
|
|
20
20
|
* @returns {Promise<{ faustNode: FaustNode | null; dspMeta: FaustDspMeta }>} - An object containing the Faust audio node and the DSP metadata.
|
|
21
21
|
*/
|
|
22
|
-
const createFaustNode = async (audioContext, dspName = "template", voices = 0, sp = false) => {
|
|
22
|
+
const createFaustNode = async (audioContext, dspName = "template", voices = 0, sp = false, bufferSize = 512) => {
|
|
23
23
|
// Set to true if the DSP has an effect
|
|
24
24
|
const FAUST_DSP_HAS_EFFECT = false;
|
|
25
25
|
|
|
@@ -60,7 +60,8 @@ const createFaustNode = async (audioContext, dspName = "template", voices = 0, s
|
|
|
60
60
|
{ module: faustDsp.dspModule, json: JSON.stringify(faustDsp.dspMeta), soundfiles: {} },
|
|
61
61
|
faustDsp.mixerModule,
|
|
62
62
|
faustDsp.effectModule ? { module: faustDsp.effectModule, json: JSON.stringify(faustDsp.effectMeta), soundfiles: {} } : undefined,
|
|
63
|
-
sp
|
|
63
|
+
sp,
|
|
64
|
+
bufferSize
|
|
64
65
|
);
|
|
65
66
|
} else {
|
|
66
67
|
// Create a standard Faust audio node
|
|
@@ -69,7 +70,8 @@ const createFaustNode = async (audioContext, dspName = "template", voices = 0, s
|
|
|
69
70
|
audioContext,
|
|
70
71
|
dspName,
|
|
71
72
|
{ module: faustDsp.dspModule, json: JSON.stringify(faustDsp.dspMeta), soundfiles: {} },
|
|
72
|
-
sp
|
|
73
|
+
sp,
|
|
74
|
+
bufferSize
|
|
73
75
|
);
|
|
74
76
|
}
|
|
75
77
|
|
|
@@ -621,11 +621,11 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
621
621
|
*/
|
|
622
622
|
getJSON(): string;
|
|
623
623
|
/**
|
|
624
|
-
* Start the DSP.
|
|
624
|
+
* Start the DSP audio processing.
|
|
625
625
|
*/
|
|
626
626
|
start(): void;
|
|
627
627
|
/**
|
|
628
|
-
* Stop the DSP.
|
|
628
|
+
* Stop the DSP audio processing.
|
|
629
629
|
*/
|
|
630
630
|
stop(): void;
|
|
631
631
|
/**
|
|
@@ -1355,9 +1355,9 @@ export declare class FaustScriptProcessorNode<Poly extends boolean = false> exte
|
|
|
1355
1355
|
protected fDSPCode: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;
|
|
1356
1356
|
protected fInputs: Float32Array[];
|
|
1357
1357
|
protected fOutputs: Float32Array[];
|
|
1358
|
+
protected handleDeviceMotion: any;
|
|
1359
|
+
protected handleDeviceOrientation: any;
|
|
1358
1360
|
init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void;
|
|
1359
|
-
private handleDeviceMotion;
|
|
1360
|
-
private handleDeviceOrientation;
|
|
1361
1361
|
/** Setup accelerometer and gyroscope handlers */
|
|
1362
1362
|
startSensors(): Promise<void>;
|
|
1363
1363
|
stopSensors(): void;
|
|
@@ -3983,8 +3983,13 @@ var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode {
|
|
|
3983
3983
|
var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || null) {
|
|
3984
3984
|
constructor() {
|
|
3985
3985
|
super(...arguments);
|
|
3986
|
-
|
|
3987
|
-
|
|
3986
|
+
this.handleDeviceMotion = void 0;
|
|
3987
|
+
this.handleDeviceOrientation = void 0;
|
|
3988
|
+
}
|
|
3989
|
+
init(instance) {
|
|
3990
|
+
this.fDSPCode = instance;
|
|
3991
|
+
this.fInputs = new Array(this.fDSPCode.getNumInputs());
|
|
3992
|
+
this.fOutputs = new Array(this.fDSPCode.getNumOutputs());
|
|
3988
3993
|
this.handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
3989
3994
|
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
3990
3995
|
if (!accelerationIncludingGravity)
|
|
@@ -3995,11 +4000,6 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
3995
4000
|
this.handleDeviceOrientation = ({ alpha, beta, gamma }) => {
|
|
3996
4001
|
this.propagateGyr({ alpha, beta, gamma });
|
|
3997
4002
|
};
|
|
3998
|
-
}
|
|
3999
|
-
init(instance) {
|
|
4000
|
-
this.fDSPCode = instance;
|
|
4001
|
-
this.fInputs = new Array(this.fDSPCode.getNumInputs());
|
|
4002
|
-
this.fOutputs = new Array(this.fDSPCode.getNumOutputs());
|
|
4003
4003
|
this.onaudioprocess = (e) => {
|
|
4004
4004
|
for (let chan = 0; chan < this.fDSPCode.getNumInputs(); chan++) {
|
|
4005
4005
|
this.fInputs[chan] = e.inputBuffer.getChannelData(chan);
|
|
@@ -4011,6 +4011,7 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
4011
4011
|
};
|
|
4012
4012
|
this.start();
|
|
4013
4013
|
}
|
|
4014
|
+
// Public API
|
|
4014
4015
|
/** Setup accelerometer and gyroscope handlers */
|
|
4015
4016
|
async startSensors() {
|
|
4016
4017
|
if (this.hasAccInput) {
|
|
@@ -4018,9 +4019,12 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
4018
4019
|
if (typeof window.DeviceMotionEvent.requestPermission === "function") {
|
|
4019
4020
|
try {
|
|
4020
4021
|
const response = await window.DeviceMotionEvent.requestPermission();
|
|
4021
|
-
if (response
|
|
4022
|
+
if (response === "granted") {
|
|
4023
|
+
window.addEventListener("devicemotion", this.handleDeviceMotion, true);
|
|
4024
|
+
} else if (response === "denied") {
|
|
4025
|
+
alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.");
|
|
4022
4026
|
throw new Error("Unable to access the accelerometer.");
|
|
4023
|
-
|
|
4027
|
+
}
|
|
4024
4028
|
} catch (error) {
|
|
4025
4029
|
console.error(error);
|
|
4026
4030
|
}
|
|
@@ -4036,9 +4040,12 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
4036
4040
|
if (typeof window.DeviceOrientationEvent.requestPermission === "function") {
|
|
4037
4041
|
try {
|
|
4038
4042
|
const response = await window.DeviceOrientationEvent.requestPermission();
|
|
4039
|
-
if (response
|
|
4043
|
+
if (response === "granted") {
|
|
4044
|
+
window.addEventListener("deviceorientation", this.handleDeviceOrientation, true);
|
|
4045
|
+
} else if (response === "denied") {
|
|
4046
|
+
alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.");
|
|
4040
4047
|
throw new Error("Unable to access the gyroscope.");
|
|
4041
|
-
|
|
4048
|
+
}
|
|
4042
4049
|
} catch (error) {
|
|
4043
4050
|
console.error(error);
|
|
4044
4051
|
}
|