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?

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