@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/esm-bundle/index.js
CHANGED
|
@@ -6140,7 +6140,7 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
6140
6140
|
const msg = e.data;
|
|
6141
6141
|
switch (msg.type) {
|
|
6142
6142
|
case "acc": {
|
|
6143
|
-
this.propagateAcc(msg.data);
|
|
6143
|
+
this.propagateAcc(msg.data, msg.invert);
|
|
6144
6144
|
break;
|
|
6145
6145
|
}
|
|
6146
6146
|
case "gyr": {
|
|
@@ -6201,8 +6201,8 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
6201
6201
|
pitchWheel(channel, wheel) {
|
|
6202
6202
|
this.fDSPCode.pitchWheel(channel, wheel);
|
|
6203
6203
|
}
|
|
6204
|
-
propagateAcc(accelerationIncludingGravity) {
|
|
6205
|
-
this.fDSPCode.propagateAcc(accelerationIncludingGravity);
|
|
6204
|
+
propagateAcc(accelerationIncludingGravity, invert = false) {
|
|
6205
|
+
this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);
|
|
6206
6206
|
}
|
|
6207
6207
|
propagateGyr(event) {
|
|
6208
6208
|
this.fDSPCode.propagateGyr(event);
|
|
@@ -8105,14 +8105,23 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
8105
8105
|
get hasAccInput() {
|
|
8106
8106
|
return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0;
|
|
8107
8107
|
}
|
|
8108
|
-
propagateAcc(accelerationIncludingGravity) {
|
|
8108
|
+
propagateAcc(accelerationIncludingGravity, invert = false) {
|
|
8109
8109
|
const { x, y, z } = accelerationIncludingGravity;
|
|
8110
|
-
if (
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8110
|
+
if (invert) {
|
|
8111
|
+
if (x !== null)
|
|
8112
|
+
this.fAcc.x.forEach((handler) => handler(-x));
|
|
8113
|
+
if (y !== null)
|
|
8114
|
+
this.fAcc.y.forEach((handler) => handler(-y));
|
|
8115
|
+
if (z !== null)
|
|
8116
|
+
this.fAcc.z.forEach((handler) => handler(-z));
|
|
8117
|
+
} else {
|
|
8118
|
+
if (x !== null)
|
|
8119
|
+
this.fAcc.x.forEach((handler) => handler(x));
|
|
8120
|
+
if (y !== null)
|
|
8121
|
+
this.fAcc.y.forEach((handler) => handler(y));
|
|
8122
|
+
if (z !== null)
|
|
8123
|
+
this.fAcc.z.forEach((handler) => handler(z));
|
|
8124
|
+
}
|
|
8116
8125
|
}
|
|
8117
8126
|
get hasGyrInput() {
|
|
8118
8127
|
return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0;
|
|
@@ -8972,8 +8981,8 @@ var FaustOfflineProcessor = class {
|
|
|
8972
8981
|
get hasAccInput() {
|
|
8973
8982
|
return this.fDSPCode.hasAccInput;
|
|
8974
8983
|
}
|
|
8975
|
-
propagateAcc(accelerationIncludingGravity) {
|
|
8976
|
-
this.fDSPCode.propagateAcc(accelerationIncludingGravity);
|
|
8984
|
+
propagateAcc(accelerationIncludingGravity, invert = false) {
|
|
8985
|
+
this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);
|
|
8977
8986
|
}
|
|
8978
8987
|
get hasGyrInput() {
|
|
8979
8988
|
return this.fDSPCode.hasGyrInput;
|
|
@@ -9649,14 +9658,27 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9649
9658
|
}
|
|
9650
9659
|
// Public API
|
|
9651
9660
|
/** Setup accelerometer and gyroscope handlers */
|
|
9652
|
-
async
|
|
9661
|
+
async listenSensors() {
|
|
9653
9662
|
if (this.hasAccInput) {
|
|
9654
|
-
const
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9663
|
+
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
9664
|
+
console.log(navigator.userAgent);
|
|
9665
|
+
console.log(isAndroid);
|
|
9666
|
+
let handleDeviceMotion = null;
|
|
9667
|
+
if (isAndroid) {
|
|
9668
|
+
handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9669
|
+
if (!accelerationIncludingGravity)
|
|
9670
|
+
return;
|
|
9671
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
9672
|
+
this.propagateAcc({ x, y, z }, true);
|
|
9673
|
+
};
|
|
9674
|
+
} else {
|
|
9675
|
+
handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9676
|
+
if (!accelerationIncludingGravity)
|
|
9677
|
+
return;
|
|
9678
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
9679
|
+
this.propagateAcc({ x, y, z });
|
|
9680
|
+
};
|
|
9681
|
+
}
|
|
9660
9682
|
if (window.DeviceMotionEvent) {
|
|
9661
9683
|
if (typeof window.DeviceMotionEvent.requestPermission === "function") {
|
|
9662
9684
|
try {
|
|
@@ -9757,10 +9779,10 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9757
9779
|
get hasAccInput() {
|
|
9758
9780
|
return __privateGet(this, _hasAccInput);
|
|
9759
9781
|
}
|
|
9760
|
-
propagateAcc(accelerationIncludingGravity) {
|
|
9782
|
+
propagateAcc(accelerationIncludingGravity, invert = false) {
|
|
9761
9783
|
if (!accelerationIncludingGravity)
|
|
9762
9784
|
return;
|
|
9763
|
-
const e = { type: "acc", data: accelerationIncludingGravity };
|
|
9785
|
+
const e = { type: "acc", data: accelerationIncludingGravity, invert };
|
|
9764
9786
|
this.port.postMessage(e);
|
|
9765
9787
|
}
|
|
9766
9788
|
get hasGyrInput() {
|
|
@@ -9907,14 +9929,25 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
9907
9929
|
}
|
|
9908
9930
|
// Public API
|
|
9909
9931
|
/** Setup accelerometer and gyroscope handlers */
|
|
9910
|
-
async
|
|
9932
|
+
async listenSensors() {
|
|
9911
9933
|
if (this.hasAccInput) {
|
|
9912
|
-
const
|
|
9913
|
-
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
|
|
9917
|
-
|
|
9934
|
+
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
9935
|
+
let handleDeviceMotion = null;
|
|
9936
|
+
if (isAndroid) {
|
|
9937
|
+
handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9938
|
+
if (!accelerationIncludingGravity)
|
|
9939
|
+
return;
|
|
9940
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
9941
|
+
this.propagateAcc({ x, y, z }, true);
|
|
9942
|
+
};
|
|
9943
|
+
} else {
|
|
9944
|
+
handleDeviceMotion = ({ accelerationIncludingGravity }) => {
|
|
9945
|
+
if (!accelerationIncludingGravity)
|
|
9946
|
+
return;
|
|
9947
|
+
const { x, y, z } = accelerationIncludingGravity;
|
|
9948
|
+
this.propagateAcc({ x, y, z });
|
|
9949
|
+
};
|
|
9950
|
+
}
|
|
9918
9951
|
if (window.DeviceMotionEvent) {
|
|
9919
9952
|
if (typeof window.DeviceMotionEvent.requestPermission === "function") {
|
|
9920
9953
|
try {
|
|
@@ -10025,8 +10058,8 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
10025
10058
|
get hasAccInput() {
|
|
10026
10059
|
return this.fDSPCode.hasAccInput;
|
|
10027
10060
|
}
|
|
10028
|
-
propagateAcc(accelerationIncludingGravity) {
|
|
10029
|
-
this.fDSPCode.propagateAcc(accelerationIncludingGravity);
|
|
10061
|
+
propagateAcc(accelerationIncludingGravity, invert = false) {
|
|
10062
|
+
this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);
|
|
10030
10063
|
}
|
|
10031
10064
|
get hasGyrInput() {
|
|
10032
10065
|
return this.fDSPCode.hasGyrInput;
|