Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/lib/libwebaudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ var LibraryWebAudio = {
numberOfInputs: {{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.numberOfInputs, 'i32') }}},
numberOfOutputs: optionsOutputs,
outputChannelCount: readChannelCountArray({{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.outputChannelCounts, 'i32*') }}}, optionsOutputs),
channelCount: {{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.channelCount, 'i32') }}},
channelCountMode: {{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.channelCountMode, 'i32') }}},
channelInterpretation: {{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.channelInterpretation, 'i32') }}},
processorOptions: {
callback,
userData,
Expand Down
5 changes: 5 additions & 0 deletions system/include/emscripten/webaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ typedef struct EmscriptenAudioWorkletNodeCreateOptions
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?

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.


} EmscriptenAudioWorkletNodeCreateOptions;

// Instantiates the given AudioWorkletProcessor as an AudioWorkletNode, which continuously calls the specified processCallback() function on the browser's audio thread to perform audio processing.
Expand Down