@grame/faustwasm 0.3.1 → 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.
@@ -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"]>): void;
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"]>): void;
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"]>): void;
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
  /**
@@ -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"]>): void;
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;
@@ -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"]>): void;
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
  }
@@ -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 (x !== null)
8111
- this.fAcc.x.forEach((handler) => handler(x));
8112
- if (y !== null)
8113
- this.fAcc.y.forEach((handler) => handler(y));
8114
- if (z !== null)
8115
- this.fAcc.z.forEach((handler) => handler(z));
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;
@@ -9651,12 +9660,25 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
9651
9660
  /** Setup accelerometer and gyroscope handlers */
9652
9661
  async listenSensors() {
9653
9662
  if (this.hasAccInput) {
9654
- const handleDeviceMotion = ({ accelerationIncludingGravity }) => {
9655
- if (!accelerationIncludingGravity)
9656
- return;
9657
- const { x, y, z } = accelerationIncludingGravity;
9658
- this.propagateAcc({ x, y, z });
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() {
@@ -9909,12 +9931,23 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
9909
9931
  /** Setup accelerometer and gyroscope handlers */
9910
9932
  async listenSensors() {
9911
9933
  if (this.hasAccInput) {
9912
- const handleDeviceMotion = ({ accelerationIncludingGravity }) => {
9913
- if (!accelerationIncludingGravity)
9914
- return;
9915
- const { x, y, z } = accelerationIncludingGravity;
9916
- this.propagateAcc({ x, y, z });
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;