@grame/faustwasm 0.3.0 → 0.3.2
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/0001-Invert-x-y-z-accelerometer-on-Android.patch +194 -0
- package/assets/standalone/faustwasm/index.d.ts +7 -7
- package/assets/standalone/faustwasm/index.js +63 -30
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/assets/standalone/index-poly.js +15 -11
- package/assets/standalone/index.js +1 -1
- package/build +17 -0
- package/dist/cjs/index.d.ts +7 -7
- package/dist/cjs/index.js +63 -30
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +7 -7
- package/dist/cjs-bundle/index.js +63 -30
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +7 -7
- package/dist/esm/index.js +63 -30
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +7 -7
- package/dist/esm-bundle/index.js +63 -30
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +1 -1
- package/src/FaustAudioWorkletNode.ts +20 -8
- package/src/FaustAudioWorkletProcessor.ts +3 -3
- package/src/FaustOfflineProcessor.ts +4 -4
- package/src/FaustScriptProcessorNode.ts +20 -10
- package/src/FaustWebAudioDsp.ts +13 -6
- package/test/faustlive-wasm/faustwasm/index.d.ts +7 -7
- package/test/faustlive-wasm/faustwasm/index.js +63 -30
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
|
@@ -642,7 +642,7 @@ export interface IFaustBaseWebAudioDsp {
|
|
|
642
642
|
/** Indicating if the DSP handles the accelerometer */
|
|
643
643
|
readonly hasAccInput: boolean;
|
|
644
644
|
/** Accelerometer handling */
|
|
645
|
-
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]
|
|
645
|
+
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert: boolean): void;
|
|
646
646
|
/** Indicating if the DSP handles the gyroscope */
|
|
647
647
|
readonly hasGyrInput: boolean;
|
|
648
648
|
/** Gyroscope handling */
|
|
@@ -731,7 +731,7 @@ export declare class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
|
731
731
|
/** Split the soundfile names and return an array of names */
|
|
732
732
|
static splitSoundfileNames(input: string): string[];
|
|
733
733
|
get hasAccInput(): boolean;
|
|
734
|
-
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]
|
|
734
|
+
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
|
|
735
735
|
get hasGyrInput(): boolean;
|
|
736
736
|
propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
|
|
737
737
|
/** Build the accelerometer handler */
|
|
@@ -1130,7 +1130,7 @@ export declare class FaustOfflineProcessor<Poly extends boolean = false> {
|
|
|
1130
1130
|
stop(): void;
|
|
1131
1131
|
destroy(): void;
|
|
1132
1132
|
get hasAccInput(): boolean;
|
|
1133
|
-
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]
|
|
1133
|
+
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
|
|
1134
1134
|
get hasGyrInput(): boolean;
|
|
1135
1135
|
propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
|
|
1136
1136
|
/**
|
|
@@ -1285,7 +1285,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1285
1285
|
protected fDescriptor: FaustUIInputItem[];
|
|
1286
1286
|
constructor(context: BaseAudioContext, name: string, factory: LooseFaustDspFactory, options: FaustAudioWorkletNodeOptions<Poly>["processorOptions"], nodeOptions?: Partial<FaustAudioWorkletNodeOptions>);
|
|
1287
1287
|
/** Setup accelerometer and gyroscope handlers */
|
|
1288
|
-
|
|
1288
|
+
listenSensors(): Promise<void>;
|
|
1289
1289
|
setOutputParamHandler(handler: OutputParamHandler | null): void;
|
|
1290
1290
|
getOutputParamHandler(): OutputParamHandler | null;
|
|
1291
1291
|
setComputeHandler(handler: ComputeHandler | null): void;
|
|
@@ -1300,7 +1300,7 @@ export declare class FaustAudioWorkletNode<Poly extends boolean = false> extends
|
|
|
1300
1300
|
ctrlChange(channel: number, ctrl: number, value: number): void;
|
|
1301
1301
|
pitchWheel(channel: number, wheel: number): void;
|
|
1302
1302
|
get hasAccInput(): boolean;
|
|
1303
|
-
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]
|
|
1303
|
+
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
|
|
1304
1304
|
get hasGyrInput(): boolean;
|
|
1305
1305
|
propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
|
|
1306
1306
|
setParamValue(path: string, value: number): void;
|
|
@@ -1348,7 +1348,7 @@ export declare class FaustScriptProcessorNode<Poly extends boolean = false> exte
|
|
|
1348
1348
|
protected fOutputs: Float32Array[];
|
|
1349
1349
|
init(instance: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp): void;
|
|
1350
1350
|
/** Setup accelerometer and gyroscope handlers */
|
|
1351
|
-
|
|
1351
|
+
listenSensors(): Promise<void>;
|
|
1352
1352
|
compute(input: Float32Array[], output: Float32Array[]): boolean;
|
|
1353
1353
|
setOutputParamHandler(handler: OutputParamHandler): void;
|
|
1354
1354
|
getOutputParamHandler(): OutputParamHandler | null;
|
|
@@ -1373,7 +1373,7 @@ export declare class FaustScriptProcessorNode<Poly extends boolean = false> exte
|
|
|
1373
1373
|
stop(): void;
|
|
1374
1374
|
destroy(): void;
|
|
1375
1375
|
get hasAccInput(): boolean;
|
|
1376
|
-
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]
|
|
1376
|
+
propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert?: boolean): void;
|
|
1377
1377
|
get hasGyrInput(): boolean;
|
|
1378
1378
|
propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">): void;
|
|
1379
1379
|
}
|
package/dist/cjs-bundle/index.js
CHANGED
|
@@ -6185,7 +6185,7 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
6185
6185
|
const msg = e.data;
|
|
6186
6186
|
switch (msg.type) {
|
|
6187
6187
|
case "acc": {
|
|
6188
|
-
this.propagateAcc(msg.data);
|
|
6188
|
+
this.propagateAcc(msg.data, msg.invert);
|
|
6189
6189
|
break;
|
|
6190
6190
|
}
|
|
6191
6191
|
case "gyr": {
|
|
@@ -6246,8 +6246,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
6246
6246
|
pitchWheel(channel, wheel) {
|
|
6247
6247
|
this.fDSPCode.pitchWheel(channel, wheel);
|
|
6248
6248
|
}
|
|
6249
|
-
propagateAcc(accelerationIncludingGravity) {
|
|
6250
|
-
this.fDSPCode.propagateAcc(accelerationIncludingGravity);
|
|
6249
|
+
propagateAcc(accelerationIncludingGravity, invert = false) {
|
|
6250
|
+
this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);
|
|
6251
6251
|
}
|
|
6252
6252
|
propagateGyr(event) {
|
|
6253
6253
|
this.fDSPCode.propagateGyr(event);
|
|
@@ -8150,14 +8150,23 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
8150
8150
|
get hasAccInput() {
|
|
8151
8151
|
return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0;
|
|
8152
8152
|
}
|
|
8153
|
-
propagateAcc(accelerationIncludingGravity) {
|
|
8153
|
+
propagateAcc(accelerationIncludingGravity, invert = false) {
|
|
8154
8154
|
const { x, y, z } = accelerationIncludingGravity;
|
|
8155
|
-
if (
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8155
|
+
if (invert) {
|
|
8156
|
+
if (x !== null)
|
|
8157
|
+
this.fAcc.x.forEach((handler) => handler(-x));
|
|
8158
|
+
if (y !== null)
|
|
8159
|
+
this.fAcc.y.forEach((handler) => handler(-y));
|
|
8160
|
+
if (z !== null)
|
|
8161
|
+
this.fAcc.z.forEach((handler) => handler(-z));
|
|
8162
|
+
} else {
|
|
8163
|
+
if (x !== null)
|
|
8164
|
+
this.fAcc.x.forEach((handler) => handler(x));
|
|
8165
|
+
if (y !== null)
|
|
8166
|
+
this.fAcc.y.forEach((handler) => handler(y));
|
|
8167
|
+
if (z !== null)
|
|
8168
|
+
this.fAcc.z.forEach((handler) => handler(z));
|
|
8169
|
+
}
|
|
8161
8170
|
}
|
|
8162
8171
|
get hasGyrInput() {
|
|
8163
8172
|
return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0;
|
|
@@ -9017,8 +9026,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
9017
9026
|
get hasAccInput() {
|
|
9018
9027
|
return this.fDSPCode.hasAccInput;
|
|
9019
9028
|
}
|
|
9020
|
-
propagateAcc(accelerationIncludingGravity) {
|
|
9021
|
-
this.fDSPCode.propagateAcc(accelerationIncludingGravity);
|
|
9029
|
+
propagateAcc(accelerationIncludingGravity, invert = false) {
|
|
9030
|
+
this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);
|
|
9022
9031
|
}
|
|
9023
9032
|
get hasGyrInput() {
|
|
9024
9033
|
return this.fDSPCode.hasGyrInput;
|
|
@@ -9694,14 +9703,27 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
9694
9703
|
}
|
|
9695
9704
|
// Public API
|
|
9696
9705
|
/** Setup accelerometer and gyroscope handlers */
|
|
9697
|
-
async
|
|
9706
|
+
async listenSensors() {
|
|
9698
9707
|
if (this.hasAccInput) {
|
|
9699
|
-
const
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9708
|
+
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
9709
|
+
console.log(navigator.userAgent);
|
|
9710
|
+
console.log(isAndroid);
|
|
9711
|
+
let handleDeviceMotion = null;
|
|
9712
|
+
if (isAndroid) {
|
|
9713
|
+
handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9714
|
+
if (!accelerationIncludingGravity)
|
|
9715
|
+
return;
|
|
9716
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
9717
|
+
this.propagateAcc({ x, y, z }, true);
|
|
9718
|
+
};
|
|
9719
|
+
} else {
|
|
9720
|
+
handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9721
|
+
if (!accelerationIncludingGravity)
|
|
9722
|
+
return;
|
|
9723
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
9724
|
+
this.propagateAcc({ x, y, z });
|
|
9725
|
+
};
|
|
9726
|
+
}
|
|
9705
9727
|
if (window.DeviceMotionEvent) {
|
|
9706
9728
|
if (typeof window.DeviceMotionEvent.requestPermission === "function") {
|
|
9707
9729
|
try {
|
|
@@ -9802,10 +9824,10 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
9802
9824
|
get hasAccInput() {
|
|
9803
9825
|
return __privateGet(this, _hasAccInput);
|
|
9804
9826
|
}
|
|
9805
|
-
propagateAcc(accelerationIncludingGravity) {
|
|
9827
|
+
propagateAcc(accelerationIncludingGravity, invert = false) {
|
|
9806
9828
|
if (!accelerationIncludingGravity)
|
|
9807
9829
|
return;
|
|
9808
|
-
const e = { type: "acc", data: accelerationIncludingGravity };
|
|
9830
|
+
const e = { type: "acc", data: accelerationIncludingGravity, invert };
|
|
9809
9831
|
this.port.postMessage(e);
|
|
9810
9832
|
}
|
|
9811
9833
|
get hasGyrInput() {
|
|
@@ -9952,14 +9974,25 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
9952
9974
|
}
|
|
9953
9975
|
// Public API
|
|
9954
9976
|
/** Setup accelerometer and gyroscope handlers */
|
|
9955
|
-
async
|
|
9977
|
+
async listenSensors() {
|
|
9956
9978
|
if (this.hasAccInput) {
|
|
9957
|
-
const
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
9961
|
-
|
|
9962
|
-
|
|
9979
|
+
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
9980
|
+
let handleDeviceMotion = null;
|
|
9981
|
+
if (isAndroid) {
|
|
9982
|
+
handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9983
|
+
if (!accelerationIncludingGravity)
|
|
9984
|
+
return;
|
|
9985
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
9986
|
+
this.propagateAcc({ x, y, z }, true);
|
|
9987
|
+
};
|
|
9988
|
+
} else {
|
|
9989
|
+
handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9990
|
+
if (!accelerationIncludingGravity)
|
|
9991
|
+
return;
|
|
9992
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
9993
|
+
this.propagateAcc({ x, y, z });
|
|
9994
|
+
};
|
|
9995
|
+
}
|
|
9963
9996
|
if (window.DeviceMotionEvent) {
|
|
9964
9997
|
if (typeof window.DeviceMotionEvent.requestPermission === "function") {
|
|
9965
9998
|
try {
|
|
@@ -10070,8 +10103,8 @@ export default ${(_b = jsCode.match(jsCodeHead)) == null ? void 0 : _b[1]};
|
|
|
10070
10103
|
get hasAccInput() {
|
|
10071
10104
|
return this.fDSPCode.hasAccInput;
|
|
10072
10105
|
}
|
|
10073
|
-
propagateAcc(accelerationIncludingGravity) {
|
|
10074
|
-
this.fDSPCode.propagateAcc(accelerationIncludingGravity);
|
|
10106
|
+
propagateAcc(accelerationIncludingGravity, invert = false) {
|
|
10107
|
+
this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);
|
|
10075
10108
|
}
|
|
10076
10109
|
get hasGyrInput() {
|
|
10077
10110
|
return this.fDSPCode.hasGyrInput;
|