@grame/faustwasm 0.8.0 → 0.9.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/create-node.js +46 -9
- package/assets/standalone/faust-ui/index.js +2 -2
- package/assets/standalone/faust-ui/index.js.map +1 -1
- package/assets/standalone/faustwasm/index.d.ts +42 -2
- package/assets/standalone/faustwasm/index.js +117 -66
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/assets/standalone/index-pwa.js +125 -90
- package/assets/standalone/index-template.js +43 -22
- package/assets/standalone/index.js +36 -19
- package/assets/standalone/service-worker.js +58 -5
- package/dist/cjs/index.d.ts +42 -2
- package/dist/cjs/index.js +117 -66
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +42 -2
- package/dist/cjs-bundle/index.js +117 -66
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +42 -2
- package/dist/esm/index.js +117 -66
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +42 -2
- package/dist/esm-bundle/index.js +117 -66
- package/dist/esm-bundle/index.js.map +2 -2
- package/package.json +2 -2
- package/src/FaustAudioWorkletNode.ts +14 -30
- package/src/FaustAudioWorkletProcessor.ts +16 -0
- package/src/FaustOfflineProcessor.ts +2 -0
- package/src/FaustScriptProcessorNode.ts +6 -30
- package/src/FaustWebAudioDsp.ts +88 -0
- package/src/copyWebStandaloneAssets.js +14 -0
- package/test/faustlive-wasm/faust-ui/index.js +2 -2
- package/test/faustlive-wasm/faust-ui/index.js.map +1 -1
- package/test/faustlive-wasm/faustwasm/index.d.ts +42 -2
- package/test/faustlive-wasm/faustwasm/index.js +117 -66
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/midi/create-node.js +177 -0
- package/test/midi/dsp-meta.json +133 -0
- package/test/midi/dsp-module.wasm +0 -0
- package/test/midi/faust-ui/index.css +442 -0
- package/test/midi/faust-ui/index.css.map +1 -0
- package/test/midi/faust-ui/index.d.ts +1 -0
- package/test/midi/faust-ui/index.js +3729 -0
- package/test/midi/faust-ui/index.js.map +1 -0
- package/test/midi/faustwasm/index.d.ts +1680 -0
- package/test/midi/faustwasm/index.js +4884 -0
- package/test/midi/faustwasm/index.js.map +7 -0
- package/test/midi/icon.png +0 -0
- package/test/midi/index.html +76 -0
- package/test/midi/index.js +183 -0
- package/test/midi/manifest.json +17 -0
- package/test/midi/service-worker.js +165 -0
- package/test/midi.dsp +8 -1
- package/test/organ1/create-node.js +177 -0
- package/test/organ1/dsp-meta.json +126 -0
- package/test/organ1/dsp-module.wasm +0 -0
- package/test/organ1/faust-ui/index.css +442 -0
- package/test/organ1/faust-ui/index.css.map +1 -0
- package/test/organ1/faust-ui/index.d.ts +1 -0
- package/test/organ1/faust-ui/index.js +3729 -0
- package/test/organ1/faust-ui/index.js.map +1 -0
- package/test/organ1/faustwasm/index.d.ts +1656 -0
- package/test/organ1/faustwasm/index.js +4783 -0
- package/test/organ1/faustwasm/index.js.map +7 -0
- package/test/organ1/icon.png +0 -0
- package/test/organ1/index.html +76 -0
- package/test/organ1/index.js +203 -0
- package/test/organ1/manifest.json +17 -0
- package/test/organ1/service-worker.js +181 -0
|
@@ -80,15 +80,15 @@ const createFaustNode = async (audioContext, dspName = "template", voices = 0, s
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
* Connects an audio input stream to a Faust
|
|
83
|
+
* Connects an audio input stream to a Faust WebAudio node.
|
|
84
84
|
*
|
|
85
85
|
* @param {AudioContext} audioContext - The Web Audio API AudioContext to which the Faust audio node is connected.
|
|
86
86
|
* @param {string} id - The ID of the audio input device to connect.
|
|
87
87
|
* @param {FaustNode} faustNode - The Faust audio node to which the audio input stream will be connected.
|
|
88
|
-
* @param {MediaStreamAudioSourceNode}
|
|
89
|
-
* @returns {Promise<MediaStreamAudioSourceNode>} - The audio input stream node connected to the Faust audio node.
|
|
88
|
+
* @param {MediaStreamAudioSourceNode} oldInputStreamNode - The old audio input stream node to be disconnected from the Faust audio node.
|
|
89
|
+
* @returns {Promise<MediaStreamAudioSourceNode>} - The new audio input stream node connected to the Faust audio node.
|
|
90
90
|
*/
|
|
91
|
-
async function connectToAudioInput(audioContext, id, faustNode,
|
|
91
|
+
async function connectToAudioInput(audioContext, id, faustNode, oldInputStreamNode) {
|
|
92
92
|
// Create an audio input stream node
|
|
93
93
|
const constraints = {
|
|
94
94
|
audio: {
|
|
@@ -101,14 +101,18 @@ async function connectToAudioInput(audioContext, id, faustNode, inputStreamNode)
|
|
|
101
101
|
// Get the audio input stream
|
|
102
102
|
const stream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
103
103
|
if (stream) {
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
if (oldInputStreamNode) oldInputStreamNode.disconnect();
|
|
105
|
+
const newInputStreamNode = audioContext.createMediaStreamSource(stream);
|
|
106
|
+
newInputStreamNode.connect(faustNode);
|
|
107
|
+
return newInputStreamNode;
|
|
108
|
+
} else {
|
|
109
|
+
return oldInputStreamNode;
|
|
107
110
|
}
|
|
108
|
-
return inputStreamNode;
|
|
109
111
|
};
|
|
110
112
|
|
|
111
113
|
/**
|
|
114
|
+
* Creates a Faust UI for a Faust audio node.
|
|
115
|
+
*
|
|
112
116
|
* @param {FaustAudioWorkletNode} faustNode
|
|
113
117
|
*/
|
|
114
118
|
async function createFaustUI(divFaustUI, faustNode) {
|
|
@@ -135,6 +139,39 @@ async function createFaustUI(divFaustUI, faustNode) {
|
|
|
135
139
|
faustUI.resize();
|
|
136
140
|
};
|
|
137
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Request permission to use motion and orientation sensors.
|
|
144
|
+
*/
|
|
145
|
+
async function requestPermissions() {
|
|
146
|
+
|
|
147
|
+
// Explicitly request permission on iOS before calling startSensors()
|
|
148
|
+
if (typeof window.DeviceMotionEvent !== "undefined" && typeof window.DeviceMotionEvent.requestPermission === "function") {
|
|
149
|
+
try {
|
|
150
|
+
const permissionState = await window.DeviceMotionEvent.requestPermission();
|
|
151
|
+
if (permissionState !== "granted") {
|
|
152
|
+
console.warn("Motion sensor permission denied.");
|
|
153
|
+
} else {
|
|
154
|
+
console.log("Motion sensor permission granted.");
|
|
155
|
+
}
|
|
156
|
+
} catch (error) {
|
|
157
|
+
console.error("Error requesting motion sensor permission:", error);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (typeof window.DeviceOrientationEvent !== "undefined" && typeof window.DeviceOrientationEvent.requestPermission === "function") {
|
|
162
|
+
try {
|
|
163
|
+
const permissionState = await window.DeviceOrientationEvent.requestPermission();
|
|
164
|
+
if (permissionState !== "granted") {
|
|
165
|
+
console.warn("Orientation sensor permission denied.");
|
|
166
|
+
} else {
|
|
167
|
+
console.log("Orientation sensor permission granted.");
|
|
168
|
+
}
|
|
169
|
+
} catch (error) {
|
|
170
|
+
console.error("Error requesting orientation sensor permission:", error);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
138
175
|
// Export the functions
|
|
139
|
-
export { createFaustNode, createFaustUI, connectToAudioInput };
|
|
176
|
+
export { createFaustNode, createFaustUI, connectToAudioInput, requestPermissions };
|
|
140
177
|
|
|
@@ -946,10 +946,10 @@ class Group extends _AbstractComponent__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
946
946
|
if (!metaIn) return { metaObject };
|
|
947
947
|
metaIn.forEach((m) => Object.assign(metaObject, m));
|
|
948
948
|
if (metaObject.style) {
|
|
949
|
-
const enumsRegex = /\{(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]
|
|
949
|
+
const enumsRegex = /\{(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]+);)+(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]+))\}/;
|
|
950
950
|
const matched = metaObject.style.match(enumsRegex);
|
|
951
951
|
if (matched) {
|
|
952
|
-
const itemsRegex = /(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]
|
|
952
|
+
const itemsRegex = /(?:(?:'|_|-)(.+?)(?:'|_|-):([-+]?[0-9]*\.?[0-9]+))/g;
|
|
953
953
|
const enums = {};
|
|
954
954
|
let item;
|
|
955
955
|
while (item = itemsRegex.exec(matched[0])) {
|