Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: added missing options to EmscriptenAudioWorkletNodeCreateOptions closes #23982 #25497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nikitha-m wants to merge 10 commits into emscripten-core:main
base: main
Choose a base branch
Loading
from nikitha-m:add_missing_options

Conversation

Copy link

@nikitha-m nikitha-m commented Oct 5, 2025

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

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

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

Copy link
Author

@juj i think it's done. Is this fine?

outputChannelCount: readChannelCountArray({{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.outputChannelCounts, 'i32*') }}}, optionsOutputs),
channelCount: (function(){ var v = {{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.channelCount, 'u32') }}}; return v > 0 ? v : undefined; })(),
channelCountMode: (function(){ var v = {{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.channelCountMode, 'i32') }}}; var arr = ['max','clamped-max','explicit']; return arr[v] || undefined; })(),
channelInterpretation: (function(){ var v = {{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.channelInterpretation, 'i32') }}}; var arr = ['speakers','discrete']; return arr[v] || undefined; })(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

The anonymous functions and || undefined should be unnecessary here, they take up code size for no benefit.

E.g. channelCountMode: ['max','clamped-max','explicit'][{{{ makeGetValue(...) }}}], looks like would be enough here?

One thing to verify here is how do older browsers behave (or Safari) that do not yet support these options? If you run in an older browser that does not support any of this, would that cause an error?

It would be good to have a short test of non-default channelCountMode and non-default channelInterpretation to ensure that it works.

Copy link
Collaborator

@juj juj Oct 16, 2025
edited
Loading

Choose a reason for hiding this comment

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

Did you have a chance to look at the above review comment?

How about this code:

 channelCount: {{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.channelCount, 'u32') }}} || undefined,
 channelCountMode: [/*'max'*/,'clamped-max','explicit'][{{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.channelCountMode, 'i32') }}}],
 channelInterpretation: [/*'speakers'*/,'discrete'][{{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.channelInterpretation, 'i32') }}}],

It is shorter for the same effect? ('max' and 'speakers' are the default in the spec if I understand correctly)

Copy link
Author

@juj @cwoffenden could you please lmk if any changes are required other than adding comments?

Copy link
Contributor

could you please lmk if any changes are required other than adding comments?

I'm out sick, I should be able to take a look next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@juj juj juj left review comments

+1 more reviewer

@cwoffenden cwoffenden cwoffenden left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

EmscriptenAudioWorkletNodeCreateOptions missing couple of options

AltStyle によって変換されたページ (->オリジナル) /