Skip to content

Conversation

nikitha-m
Copy link

Problem Description

The EmscriptenAudioWorkletNodeCreateOptions struct currently only exposes options specific to AudioWorkletNode itself (numberOfInputs, numberOfOutputs, outputChannelCounts), but AudioWorkletNode inherits from AudioNode which has additional properties:

  • channelCount
  • channelCountMode
  • channelInterpretation

Fix

  • Extend the C struct in system/include/emscripten/webaudio.h.
  • Update the JavaScript implementation in src/lib/libwebaudio.js to pass these options to the AudioWorkletNode constructor.

Closes #23982

// Extended options from AudioWorkletNode
int channelCount;
int channelCountMode;
int channelInterpretation;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

channelCountMode and channelInterpretation are strings, so an integer will not work.

Create an enum for those, and in the JS code, index the enum into an array of strings.

See e.g. https://github.com/juj/wasm_webgpu/blob/3ed529956d1ee3f14f64c07769385e1929908f68/lib/lib_webgpu.js#L615 and https://github.com/juj/wasm_webgpu/blob/3ed529956d1ee3f14f64c07769385e1929908f68/lib/lib_webgpu.js#L729 in another repo for examples.

int numberOfOutputs;
// For each output, specifies the number of audio channels (1=mono/2=stereo/etc.) for that output. Default=an array of ones for each output channel.
int *outputChannelCounts;
// Extended options from AudioWorkletNode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment documents the history of evolution of the codebase (i.e. "before this PR, we had a 'basic' set, after this PR, we now have 'extended' set"), but in the Web Audio specification, there is no distinction between basic and extended options - there are just options.

So instead of documenting history of evolution, maybe add short comments that describe the new parameters?

@nikitha-m
Copy link
Author

@juj how do i run test cases locally? I followed the docs but I'm facing some issues while running these commands

emsdk install tot
emsdk activate tot

@juj
Copy link
Collaborator

juj commented Oct 9, 2025

Yeah, that is how you install a pre-compiled Emscripten. If installing tot doesn't work, you can also try emsdk install latest followed by emsdk activate latest.

To run browser audio-related tests, you can run test/runner browser.test_*audio* and test/runner interactive.test_*audio*. The first suite is automated, but the second suite requires an interactive user to prod the tests forward.

If installing tot or latest doesn't work out, you can also try these steps to build all from source: https://bugzilla.mozilla.org/show_bug.cgi?id=1992558#c2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EmscriptenAudioWorkletNodeCreateOptions missing couple of options
2 participants