You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[AUDIO_WORKLET] Add new emscripten_audio_node_connect API (#22667)
In all the examples and in the docs, connecting the context and worklet
is done with the following type of code:
```
EM_ASM({
emscriptenGetAudioObject($0).connect(emscriptenGetAudioObject($1).destination)
}, wasmAudioWorklet, audioContext);
```
Every example or usage needs this to play audio. Granted, more complex
graphs will add more node types and `emscriptenGetAudioObject()` will
have its uses, but for the general use case a simpler call without JS is
preferred:
```
emscripten_audio_worklet_node_connect(audioContext, wasmAudioWorklet);
```
See here for how it's done in the examples:
https://github.com/emscripten-core/emscripten/blob/7df48f680e2e901b9bf1f5312d27ca939753548d/test/webaudio/audioworklet.c#L50
I updated the examples and the documentation.
@juj Comments or ideas?
assert(srcNode,`Called emscripten_audio_node_connect() with an invalid AudioNode handle ${source}`);
301
+
assert(srcNodeinstanceofwindow.AudioNode,`Called emscripten_audio_node_connect() on handle ${source} that is not an AudiotNode, but of type ${srcNode}`);
302
+
assert(dstNode,`Called emscripten_audio_node_connect() with an invalid AudioNode handle ${destination}!`);
303
+
assert(dstNodeinstanceof(window.AudioContext||window.webkitAudioContext)||dstNodeinstanceofwindow.AudioNode,`Called emscripten_audio_node_connect() on handle ${destination} that is not an AudioContext or AudioNode, but of type ${dstNode}`);
304
+
#endif
305
+
#if WEBAUDIO_DEBUG
306
+
console.log(`Connecting audio node ID ${source} to audio node ID ${destination} (${srcNode} to ${dstNode})`);
// userData4: A custom userdata pointer to pass to the callback function. This value will be passed on to the call to the given EmscriptenWorkletNodeProcessCallback callback function.
0 commit comments