@grame/faustwasm 0.3.2 → 0.4.1
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/README.md +10 -4
- package/assets/standalone/faust-ui/index.js +177 -247
- package/assets/standalone/faust-ui/index.js.map +1 -1
- package/assets/standalone/faustwasm/index.d.ts +6 -0
- package/assets/standalone/faustwasm/index.js +12 -4
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/assets/standalone/icon.png +0 -0
- package/assets/standalone/index-poly.js +11 -0
- package/assets/standalone/index.html +4 -2
- package/assets/standalone/index.js +11 -0
- package/assets/standalone/manifest.json +18 -0
- package/assets/standalone/service-worker.js +48 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +12 -4
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +6 -0
- package/dist/cjs-bundle/index.js +12 -4
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +12 -4
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +6 -0
- package/dist/esm-bundle/index.js +12 -4
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +2 -2
- package/src/FaustAudioWorkletNode.ts +0 -3
- package/src/SoundfileReader.ts +16 -2
- package/src/copyWebStandaloneAssets.js +11 -1
- package/test/faustlive-wasm/faust-ui/index.js +177 -247
- package/test/faustlive-wasm/faust-ui/index.js.map +1 -1
- package/test/faustlive-wasm/faustwasm/index.d.ts +6 -0
- package/test/faustlive-wasm/faustwasm/index.js +12 -4
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/osc2.dsp +1 -1
- package/0001-Invert-x-y-z-accelerometer-on-Android.patch +0 -194
- package/build +0 -17
package/test/osc2.dsp
CHANGED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
From 401272a08a44c5c7bc8a33db920fe3bd7a246241 Mon Sep 17 00:00:00 2001
|
|
2
|
-
From: Stephane Letz <letz@grame.fr>
|
|
3
|
-
Date: Mon, 17 Jun 2024 18:04:39 +0200
|
|
4
|
-
Subject: [PATCH] Invert x,y,z accelerometer on Android.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
src/FaustAudioWorkletNode.ts | 26 +++++++++++++++++++-------
|
|
8
|
-
src/FaustAudioWorkletProcessor.ts | 6 +++---
|
|
9
|
-
src/FaustOfflineProcessor.ts | 8 ++++----
|
|
10
|
-
src/FaustScriptProcessorNode.ts | 24 +++++++++++++++++-------
|
|
11
|
-
src/FaustWebAudioDsp.ts | 19 +++++++++++++------
|
|
12
|
-
5 files changed, 56 insertions(+), 27 deletions(-)
|
|
13
|
-
|
|
14
|
-
diff --git a/src/FaustAudioWorkletNode.ts b/src/FaustAudioWorkletNode.ts
|
|
15
|
-
index efbb741..ca64f0b 100644
|
|
16
|
-
--- a/src/FaustAudioWorkletNode.ts
|
|
17
|
-
+++ b/src/FaustAudioWorkletNode.ts
|
|
18
|
-
@@ -75,11 +75,23 @@ export class FaustAudioWorkletNode<Poly extends boolean = false> extends (global
|
|
19
|
-
/** Setup accelerometer and gyroscope handlers */
|
|
20
|
-
async listenSensors() {
|
|
21
|
-
if (this.hasAccInput) {
|
|
22
|
-
- const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {
|
|
23
|
-
- if (!accelerationIncludingGravity) return;
|
|
24
|
-
- const { x, y, z } = accelerationIncludingGravity;
|
|
25
|
-
- this.propagateAcc({ x, y, z });
|
|
26
|
-
- };
|
|
27
|
-
+ const isAndroid: boolean = /Android/i.test(navigator.userAgent);
|
|
28
|
-
+ console.log(navigator.userAgent);
|
|
29
|
-
+ console.log(isAndroid);
|
|
30
|
-
+ let handleDeviceMotion = null;
|
|
31
|
-
+ if (isAndroid) {
|
|
32
|
-
+ handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {
|
|
33
|
-
+ if (!accelerationIncludingGravity) return;
|
|
34
|
-
+ const { x, y, z } = accelerationIncludingGravity;
|
|
35
|
-
+ this.propagateAcc({ x, y, z }, true);
|
|
36
|
-
+ }
|
|
37
|
-
+ } else {
|
|
38
|
-
+ handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {
|
|
39
|
-
+ if (!accelerationIncludingGravity) return;
|
|
40
|
-
+ const { x, y, z } = accelerationIncludingGravity;
|
|
41
|
-
+ this.propagateAcc({ x, y, z });
|
|
42
|
-
+ }
|
|
43
|
-
+ }
|
|
44
|
-
if (window.DeviceMotionEvent) {
|
|
45
|
-
if (typeof (window.DeviceMotionEvent as any).requestPermission === "function") { // for iOS 13+
|
|
46
|
-
try {
|
|
47
|
-
@@ -185,9 +197,9 @@ export class FaustAudioWorkletNode<Poly extends boolean = false> extends (global
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
get hasAccInput() { return this.#hasAccInput; }
|
|
51
|
-
- propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>) {
|
|
52
|
-
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert: boolean = false) {
|
|
53
|
-
if (!accelerationIncludingGravity) return;
|
|
54
|
-
- const e = { type: "acc", data: accelerationIncludingGravity };
|
|
55
|
-
+ const e = { type: "acc", data: accelerationIncludingGravity, invert: invert };
|
|
56
|
-
this.port.postMessage(e);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
diff --git a/src/FaustAudioWorkletProcessor.ts b/src/FaustAudioWorkletProcessor.ts
|
|
60
|
-
index 2b9be9a..1eba4e2 100644
|
|
61
|
-
--- a/src/FaustAudioWorkletProcessor.ts
|
|
62
|
-
+++ b/src/FaustAudioWorkletProcessor.ts
|
|
63
|
-
@@ -127,7 +127,7 @@ const getFaustAudioWorkletProcessor = <Poly extends boolean = false>(dependencie
|
|
64
|
-
switch (msg.type) {
|
|
65
|
-
// Sensors messages
|
|
66
|
-
case "acc": {
|
|
67
|
-
- this.propagateAcc(msg.data);
|
|
68
|
-
+ this.propagateAcc(msg.data, msg.invert);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
case "gyr": {
|
|
72
|
-
@@ -197,8 +197,8 @@ const getFaustAudioWorkletProcessor = <Poly extends boolean = false>(dependencie
|
|
73
|
-
this.fDSPCode.pitchWheel(channel, wheel);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
- protected propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>) {
|
|
77
|
-
- this.fDSPCode.propagateAcc(accelerationIncludingGravity);
|
|
78
|
-
+ protected propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert: boolean = false) {
|
|
79
|
-
+ this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
protected propagateGyr(event: Pick<DeviceOrientationEvent, "alpha" | "beta" | "gamma">) {
|
|
83
|
-
diff --git a/src/FaustOfflineProcessor.ts b/src/FaustOfflineProcessor.ts
|
|
84
|
-
index b08414a..d3d6d91 100644
|
|
85
|
-
--- a/src/FaustOfflineProcessor.ts
|
|
86
|
-
+++ b/src/FaustOfflineProcessor.ts
|
|
87
|
-
@@ -8,8 +8,8 @@ export interface IFaustOfflineProcessor extends IFaustBaseWebAudioDsp {
|
|
88
|
-
render(inputs?: Float32Array[], length?: number, onUpdate?: (sample: number) => any): Float32Array[];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
-export interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp {}
|
|
92
|
-
-export interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp {}
|
|
93
|
-
+export interface IFaustMonoOfflineProcessor extends IFaustOfflineProcessor, IFaustMonoWebAudioDsp { }
|
|
94
|
-
+export interface IFaustPolyOfflineProcessor extends IFaustOfflineProcessor, IFaustPolyWebAudioDsp { }
|
|
95
|
-
|
|
96
|
-
export class FaustOfflineProcessor<Poly extends boolean = false> {
|
|
97
|
-
protected fDSPCode!: Poly extends true ? FaustPolyWebAudioDsp : FaustMonoWebAudioDsp;
|
|
98
|
-
@@ -82,8 +82,8 @@ export class FaustOfflineProcessor<Poly extends boolean = false> {
|
|
99
|
-
destroy() { this.fDSPCode.destroy(); }
|
|
100
|
-
|
|
101
|
-
get hasAccInput() { return this.fDSPCode.hasAccInput; }
|
|
102
|
-
- propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>) {
|
|
103
|
-
- this.fDSPCode.propagateAcc(accelerationIncludingGravity);
|
|
104
|
-
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert: boolean = false) {
|
|
105
|
-
+ this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
get hasGyrInput() { return this.fDSPCode.hasGyrInput; }
|
|
109
|
-
diff --git a/src/FaustScriptProcessorNode.ts b/src/FaustScriptProcessorNode.ts
|
|
110
|
-
index 0c73ae8..36ce3b3 100644
|
|
111
|
-
--- a/src/FaustScriptProcessorNode.ts
|
|
112
|
-
+++ b/src/FaustScriptProcessorNode.ts
|
|
113
|
-
@@ -39,11 +39,21 @@ export class FaustScriptProcessorNode<Poly extends boolean = false> extends (glo
|
|
114
|
-
/** Setup accelerometer and gyroscope handlers */
|
|
115
|
-
async listenSensors() {
|
|
116
|
-
if (this.hasAccInput) {
|
|
117
|
-
- const handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {
|
|
118
|
-
- if (!accelerationIncludingGravity) return;
|
|
119
|
-
- const { x, y, z } = accelerationIncludingGravity;
|
|
120
|
-
- this.propagateAcc({ x, y, z });
|
|
121
|
-
- };
|
|
122
|
-
+ const isAndroid: boolean = /Android/i.test(navigator.userAgent);
|
|
123
|
-
+ let handleDeviceMotion = null;
|
|
124
|
-
+ if (isAndroid) {
|
|
125
|
-
+ handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {
|
|
126
|
-
+ if (!accelerationIncludingGravity) return;
|
|
127
|
-
+ const { x, y, z } = accelerationIncludingGravity;
|
|
128
|
-
+ this.propagateAcc({ x, y, z }, true);
|
|
129
|
-
+ }
|
|
130
|
-
+ } else {
|
|
131
|
-
+ handleDeviceMotion = ({ accelerationIncludingGravity }: DeviceMotionEvent) => {
|
|
132
|
-
+ if (!accelerationIncludingGravity) return;
|
|
133
|
-
+ const { x, y, z } = accelerationIncludingGravity;
|
|
134
|
-
+ this.propagateAcc({ x, y, z });
|
|
135
|
-
+ }
|
|
136
|
-
+ }
|
|
137
|
-
if (window.DeviceMotionEvent) {
|
|
138
|
-
if (typeof (window.DeviceMotionEvent as any).requestPermission === "function") { // for iOS 13+
|
|
139
|
-
try {
|
|
140
|
-
@@ -120,8 +130,8 @@ export class FaustScriptProcessorNode<Poly extends boolean = false> extends (glo
|
|
141
|
-
destroy() { this.fDSPCode.destroy(); }
|
|
142
|
-
|
|
143
|
-
get hasAccInput() { return this.fDSPCode.hasAccInput; }
|
|
144
|
-
- propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>) {
|
|
145
|
-
- this.fDSPCode.propagateAcc(accelerationIncludingGravity);
|
|
146
|
-
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert: boolean = false) {
|
|
147
|
-
+ this.fDSPCode.propagateAcc(accelerationIncludingGravity, invert);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
get hasGyrInput() { return this.fDSPCode.hasGyrInput; }
|
|
151
|
-
diff --git a/src/FaustWebAudioDsp.ts b/src/FaustWebAudioDsp.ts
|
|
152
|
-
index b3e728f..c225d11 100644
|
|
153
|
-
--- a/src/FaustWebAudioDsp.ts
|
|
154
|
-
+++ b/src/FaustWebAudioDsp.ts
|
|
155
|
-
@@ -514,7 +514,7 @@ export interface IFaustBaseWebAudioDsp {
|
|
156
|
-
/** Indicating if the DSP handles the accelerometer */
|
|
157
|
-
readonly hasAccInput: boolean;
|
|
158
|
-
/** Accelerometer handling */
|
|
159
|
-
- propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>): void;
|
|
160
|
-
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert: boolean): void;
|
|
161
|
-
|
|
162
|
-
/** Indicating if the DSP handles the gyroscope */
|
|
163
|
-
readonly hasGyrInput: boolean;
|
|
164
|
-
@@ -687,15 +687,22 @@ export class FaustBaseWebAudioDsp implements IFaustBaseWebAudioDsp {
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
get hasAccInput() { return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0; }
|
|
168
|
-
- propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>) {
|
|
169
|
-
+ propagateAcc(accelerationIncludingGravity: NonNullable<DeviceMotionEvent["accelerationIncludingGravity"]>, invert: boolean = false) {
|
|
170
|
-
|
|
171
|
-
// Get accelerometervalues
|
|
172
|
-
const { x, y, z } = accelerationIncludingGravity;
|
|
173
|
-
|
|
174
|
-
- // Call the accelerometer handlers
|
|
175
|
-
- if (x !== null) this.fAcc.x.forEach(handler => handler(x));
|
|
176
|
-
- if (y !== null) this.fAcc.y.forEach(handler => handler(y));
|
|
177
|
-
- if (z !== null) this.fAcc.z.forEach(handler => handler(z));
|
|
178
|
-
+ if (invert) {
|
|
179
|
-
+ // Call the accelerometer handlers
|
|
180
|
-
+ if (x !== null) this.fAcc.x.forEach(handler => handler(-x));
|
|
181
|
-
+ if (y !== null) this.fAcc.y.forEach(handler => handler(-y));
|
|
182
|
-
+ if (z !== null) this.fAcc.z.forEach(handler => handler(-z));
|
|
183
|
-
+ } else {
|
|
184
|
-
+ // Call the accelerometer handlers
|
|
185
|
-
+ if (x !== null) this.fAcc.x.forEach(handler => handler(x));
|
|
186
|
-
+ if (y !== null) this.fAcc.y.forEach(handler => handler(y));
|
|
187
|
-
+ if (z !== null) this.fAcc.z.forEach(handler => handler(z));
|
|
188
|
-
+ }
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
get hasGyrInput() { return this.fGyr.x.length + this.fGyr.y.length + this.fGyr.z.length > 0; }
|
|
192
|
-
--
|
|
193
|
-
2.37.1 (Apple Git-137.1)
|
|
194
|
-
|
package/build
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
node scripts/faust2wasm.js /Users/letz/Developpements/GameLAN/atomicro/atomicro.dsp /Users/letz/Developpements/sletz.github.io/atomicro -standalone
|
|
2
|
-
|
|
3
|
-
node scripts/faust2wasm.js /Users/letz/Developpements/GameLAN/attackey/attackey.dsp /Users/letz/Developpements/sletz.github.io/attackey -standalone
|
|
4
|
-
|
|
5
|
-
node scripts/faust2wasm.js /Users/letz/Developpements/GameLAN/baliphone/baliphone.dsp /Users/letz/Developpements/sletz.github.io/baliphone -standalone
|
|
6
|
-
|
|
7
|
-
node scripts/faust2wasm.js /Users/letz/Developpements/GameLAN/drone/drone.dsp /Users/letz/Developpements/sletz.github.io/drone -standalone
|
|
8
|
-
|
|
9
|
-
node scripts/faust2wasm.js /Users/letz/Developpements/GameLAN/sequenceur/sequenceur.dsp /Users/letz/Developpements/sletz.github.io/sequenceur -standalone
|
|
10
|
-
|
|
11
|
-
node scripts/faust2wasm.js /Users/letz/Developpements/GameLAN/shakerxy/shakerxy.dsp /Users/letz/Developpements/sletz.github.io/shakerxy -standalone
|
|
12
|
-
|
|
13
|
-
node scripts/faust2wasm.js /Users/letz/Developpements/GameLAN/sinusoide/sinusoide.dsp /Users/letz/Developpements/sletz.github.io/sinusoide -standalone
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
#node scripts/faust2wasm.js /Users/letz/Developpements/GameLAN/test.dsp /Users/letz/Developpements/sletz.github.io/out -standalone
|
|
17
|
-
#node scripts/faust2wasm.js test/organ.dsp /Users/letz/Developpements/sletz.github.io/organ -poly -standalone
|