@grame/faustwasm 0.6.4 → 0.7.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/faustwasm/index.d.ts +8 -2
- package/assets/standalone/faustwasm/index.js +61 -34
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/assets/standalone/index-pwa.js +56 -7
- package/assets/standalone/index-template.js +3 -3
- package/assets/standalone/index.js +4 -4
- package/dist/cjs/index.d.ts +8 -2
- package/dist/cjs/index.js +61 -34
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +8 -2
- package/dist/cjs-bundle/index.js +61 -34
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +8 -2
- package/dist/esm/index.js +61 -34
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +8 -2
- package/dist/esm-bundle/index.js +61 -34
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +1 -1
- package/src/FaustAudioWorkletNode.ts +35 -16
- package/src/FaustScriptProcessorNode.ts +26 -14
- package/src/FaustWebAudioDsp.ts +0 -1
- package/test/faustlive-wasm/faustwasm/index.d.ts +8 -2
- package/test/faustlive-wasm/faustwasm/index.js +61 -34
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/faustlive-wasm/index.js +1 -1
- package/test/osc2.dsp +1 -1
- package/test/tables.dsp +71 -0
|
@@ -1296,8 +1296,11 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1296
1296
|
protected fUICallback: UIHandler;
|
|
1297
1297
|
protected fDescriptor: FaustUIInputItem[];
|
|
1298
1298
|
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options?: Partial<FaustAudioWorkletNodeOptions<Poly>>);
|
|
1299
|
+
private handleDeviceMotion;
|
|
1300
|
+
private handleDeviceOrientation;
|
|
1299
1301
|
/** Setup accelerometer and gyroscope handlers */
|
|
1300
|
-
|
|
1302
|
+
startSensors(): Promise<void>;
|
|
1303
|
+
stopSensors(): void;
|
|
1301
1304
|
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
1302
1305
|
getOutputParamHandler(): OutputParamHandler | null;
|
|
1303
1306
|
setComputeHandler(handler: ComputeHandler | null): void;
|
|
@@ -1360,8 +1363,11 @@ export declare class FaustScriptProcessorNode<Poly extends boolean = false> exte
|
|
|
1360
1363
|
protected fInputs: Float32Array[];
|
|
1361
1364
|
protected fOutputs: Float32Array[];
|
|
1362
1365
|
init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void;
|
|
1366
|
+
private handleDeviceMotion;
|
|
1367
|
+
private handleDeviceOrientation;
|
|
1363
1368
|
/** Setup accelerometer and gyroscope handlers */
|
|
1364
|
-
|
|
1369
|
+
startSensors(): Promise<void>;
|
|
1370
|
+
stopSensors(): void;
|
|
1365
1371
|
compute(input: Float32Array[], output: Float32Array[]): boolean;
|
|
1366
1372
|
setOutputParamHandler(handler: OutputParamHandler): void;
|
|
1367
1373
|
getOutputParamHandler(): OutputParamHandler | null;
|
package/dist/esm-bundle/index.js
CHANGED
|
@@ -9698,6 +9698,18 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9698
9698
|
});
|
|
9699
9699
|
__privateAdd(this, _hasAccInput, false);
|
|
9700
9700
|
__privateAdd(this, _hasGyrInput, false);
|
|
9701
|
+
// Public API
|
|
9702
|
+
// Accelerometer and gyroscope handlers
|
|
9703
|
+
this.handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9704
|
+
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
9705
|
+
if (!accelerationIncludingGravity)
|
|
9706
|
+
return;
|
|
9707
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
9708
|
+
this.propagateAcc({ x, y, z }, isAndroid);
|
|
9709
|
+
};
|
|
9710
|
+
this.handleDeviceOrientation = ({ alpha, beta, gamma }) => {
|
|
9711
|
+
this.propagateGyr({ alpha, beta, gamma });
|
|
9712
|
+
};
|
|
9701
9713
|
this.fJSONDsp = JSONObj;
|
|
9702
9714
|
this.fJSON = factory.json;
|
|
9703
9715
|
this.fOutputHandler = null;
|
|
@@ -9729,56 +9741,59 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9729
9741
|
}
|
|
9730
9742
|
};
|
|
9731
9743
|
}
|
|
9732
|
-
// Public API
|
|
9733
9744
|
/** Setup accelerometer and gyroscope handlers */
|
|
9734
|
-
async
|
|
9745
|
+
async startSensors() {
|
|
9735
9746
|
if (this.hasAccInput) {
|
|
9736
|
-
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
9737
|
-
const handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9738
|
-
if (!accelerationIncludingGravity)
|
|
9739
|
-
return;
|
|
9740
|
-
const { x, y, z } = accelerationIncludingGravity;
|
|
9741
|
-
this.propagateAcc({ x, y, z }, isAndroid);
|
|
9742
|
-
};
|
|
9743
9747
|
if (window.DeviceMotionEvent) {
|
|
9744
9748
|
if (typeof window.DeviceMotionEvent.requestPermission === "function") {
|
|
9745
9749
|
try {
|
|
9746
9750
|
const response = await window.DeviceMotionEvent.requestPermission();
|
|
9747
|
-
if (response
|
|
9751
|
+
if (response === "granted") {
|
|
9752
|
+
window.addEventListener("devicemotion", this.handleDeviceMotion, true);
|
|
9753
|
+
} else if (response === "denied") {
|
|
9754
|
+
alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.");
|
|
9748
9755
|
throw new Error("Unable to access the accelerometer.");
|
|
9749
|
-
|
|
9756
|
+
}
|
|
9750
9757
|
} catch (error) {
|
|
9751
9758
|
console.error(error);
|
|
9752
9759
|
}
|
|
9753
9760
|
} else {
|
|
9754
|
-
window.addEventListener("devicemotion", handleDeviceMotion, true);
|
|
9761
|
+
window.addEventListener("devicemotion", this.handleDeviceMotion, true);
|
|
9755
9762
|
}
|
|
9756
9763
|
} else {
|
|
9757
9764
|
console.log("Cannot set the accelerometer handler.");
|
|
9758
9765
|
}
|
|
9759
9766
|
}
|
|
9760
9767
|
if (this.hasGyrInput) {
|
|
9761
|
-
const handleDeviceOrientation = ({ alpha, beta, gamma }) => {
|
|
9762
|
-
this.propagateGyr({ alpha, beta, gamma });
|
|
9763
|
-
};
|
|
9764
9768
|
if (window.DeviceMotionEvent) {
|
|
9765
9769
|
if (typeof window.DeviceOrientationEvent.requestPermission === "function") {
|
|
9766
9770
|
try {
|
|
9767
9771
|
const response = await window.DeviceOrientationEvent.requestPermission();
|
|
9768
|
-
if (response
|
|
9772
|
+
if (response === "granted") {
|
|
9773
|
+
window.addEventListener("deviceorientation", this.handleDeviceOrientation, true);
|
|
9774
|
+
} else if (response === "denied") {
|
|
9775
|
+
alert("You have denied access to motion and orientation data. To enable it, go to Settings > Safari > Motion & Orientation Access.");
|
|
9769
9776
|
throw new Error("Unable to access the gyroscope.");
|
|
9770
|
-
|
|
9777
|
+
}
|
|
9771
9778
|
} catch (error) {
|
|
9772
9779
|
console.error(error);
|
|
9773
9780
|
}
|
|
9774
9781
|
} else {
|
|
9775
|
-
window.addEventListener("deviceorientation", handleDeviceOrientation, true);
|
|
9782
|
+
window.addEventListener("deviceorientation", this.handleDeviceOrientation, true);
|
|
9776
9783
|
}
|
|
9777
9784
|
} else {
|
|
9778
9785
|
console.log("Cannot set the gyroscope handler.");
|
|
9779
9786
|
}
|
|
9780
9787
|
}
|
|
9781
9788
|
}
|
|
9789
|
+
stopSensors() {
|
|
9790
|
+
if (this.hasAccInput) {
|
|
9791
|
+
window.removeEventListener("devicemotion", this.handleDeviceMotion, true);
|
|
9792
|
+
}
|
|
9793
|
+
if (this.hasGyrInput) {
|
|
9794
|
+
window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true);
|
|
9795
|
+
}
|
|
9796
|
+
}
|
|
9782
9797
|
setOutputParamHandler(handler) {
|
|
9783
9798
|
this.fOutputHandler = handler;
|
|
9784
9799
|
}
|
|
@@ -9968,6 +9983,21 @@ var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode {
|
|
|
9968
9983
|
|
|
9969
9984
|
// src/FaustScriptProcessorNode.ts
|
|
9970
9985
|
var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode || null) {
|
|
9986
|
+
constructor() {
|
|
9987
|
+
super(...arguments);
|
|
9988
|
+
// Public API
|
|
9989
|
+
// Accelerometer and gyroscope handlers
|
|
9990
|
+
this.handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9991
|
+
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
9992
|
+
if (!accelerationIncludingGravity)
|
|
9993
|
+
return;
|
|
9994
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
9995
|
+
this.propagateAcc({ x, y, z }, isAndroid);
|
|
9996
|
+
};
|
|
9997
|
+
this.handleDeviceOrientation = ({ alpha, beta, gamma }) => {
|
|
9998
|
+
this.propagateGyr({ alpha, beta, gamma });
|
|
9999
|
+
};
|
|
10000
|
+
}
|
|
9971
10001
|
init(instance) {
|
|
9972
10002
|
this.fDSPCode = instance;
|
|
9973
10003
|
this.fInputs = new Array(this.fDSPCode.getNumInputs());
|
|
@@ -9983,56 +10013,53 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
9983
10013
|
};
|
|
9984
10014
|
this.start();
|
|
9985
10015
|
}
|
|
9986
|
-
// Public API
|
|
9987
10016
|
/** Setup accelerometer and gyroscope handlers */
|
|
9988
|
-
async
|
|
10017
|
+
async startSensors() {
|
|
9989
10018
|
if (this.hasAccInput) {
|
|
9990
|
-
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
9991
|
-
const handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9992
|
-
if (!accelerationIncludingGravity)
|
|
9993
|
-
return;
|
|
9994
|
-
const { x, y, z } = accelerationIncludingGravity;
|
|
9995
|
-
this.propagateAcc({ x, y, z }, isAndroid);
|
|
9996
|
-
};
|
|
9997
10019
|
if (window.DeviceMotionEvent) {
|
|
9998
10020
|
if (typeof window.DeviceMotionEvent.requestPermission === "function") {
|
|
9999
10021
|
try {
|
|
10000
10022
|
const response = await window.DeviceMotionEvent.requestPermission();
|
|
10001
10023
|
if (response !== "granted")
|
|
10002
10024
|
throw new Error("Unable to access the accelerometer.");
|
|
10003
|
-
window.addEventListener("devicemotion", handleDeviceMotion, true);
|
|
10025
|
+
window.addEventListener("devicemotion", this.handleDeviceMotion, true);
|
|
10004
10026
|
} catch (error) {
|
|
10005
10027
|
console.error(error);
|
|
10006
10028
|
}
|
|
10007
10029
|
} else {
|
|
10008
|
-
window.addEventListener("devicemotion", handleDeviceMotion, true);
|
|
10030
|
+
window.addEventListener("devicemotion", this.handleDeviceMotion, true);
|
|
10009
10031
|
}
|
|
10010
10032
|
} else {
|
|
10011
10033
|
console.log("Cannot set the accelerometer handler.");
|
|
10012
10034
|
}
|
|
10013
10035
|
}
|
|
10014
10036
|
if (this.hasGyrInput) {
|
|
10015
|
-
const handleDeviceOrientation = ({ alpha, beta, gamma }) => {
|
|
10016
|
-
this.propagateGyr({ alpha, beta, gamma });
|
|
10017
|
-
};
|
|
10018
10037
|
if (window.DeviceMotionEvent) {
|
|
10019
10038
|
if (typeof window.DeviceOrientationEvent.requestPermission === "function") {
|
|
10020
10039
|
try {
|
|
10021
10040
|
const response = await window.DeviceOrientationEvent.requestPermission();
|
|
10022
10041
|
if (response !== "granted")
|
|
10023
10042
|
throw new Error("Unable to access the gyroscope.");
|
|
10024
|
-
window.addEventListener("deviceorientation", handleDeviceOrientation, true);
|
|
10043
|
+
window.addEventListener("deviceorientation", this.handleDeviceOrientation, true);
|
|
10025
10044
|
} catch (error) {
|
|
10026
10045
|
console.error(error);
|
|
10027
10046
|
}
|
|
10028
10047
|
} else {
|
|
10029
|
-
window.addEventListener("deviceorientation", handleDeviceOrientation, true);
|
|
10048
|
+
window.addEventListener("deviceorientation", this.handleDeviceOrientation, true);
|
|
10030
10049
|
}
|
|
10031
10050
|
} else {
|
|
10032
10051
|
console.log("Cannot set the gyroscope handler.");
|
|
10033
10052
|
}
|
|
10034
10053
|
}
|
|
10035
10054
|
}
|
|
10055
|
+
stopSensors() {
|
|
10056
|
+
if (this.hasAccInput) {
|
|
10057
|
+
window.removeEventListener("devicemotion", this.handleDeviceMotion, true);
|
|
10058
|
+
}
|
|
10059
|
+
if (this.hasGyrInput) {
|
|
10060
|
+
window.removeEventListener("deviceorientation", this.handleDeviceOrientation, true);
|
|
10061
|
+
}
|
|
10062
|
+
}
|
|
10036
10063
|
compute(input, output) {
|
|
10037
10064
|
return this.fDSPCode.compute(input, output);
|
|
10038
10065
|
}
|