Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
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, 'u32') }}} || undefined,
channelCountMode: [/*'max'*/,'clamped-max','explicit'][{{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.channelCountMode, 'i32') }}}],
channelInterpretation: [/*'speakers'*/,'discrete'][{{{ makeGetValue('options', C_STRUCTS.EmscriptenAudioWorkletNodeCreateOptions.channelInterpretation, 'i32') }}}],
processorOptions: {
callback,
userData,
Expand Down
7 changes: 5 additions & 2 deletions src/struct_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@
],
"EmscriptenWebSocketCreateAttributes": [
"protocols"
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: formatting got lost.

]
}
},
{
Expand Down Expand Up @@ -1293,7 +1293,10 @@
"EmscriptenAudioWorkletNodeCreateOptions": [
"numberOfInputs",
"numberOfOutputs",
"outputChannelCounts"
"outputChannelCounts",
"channelCount",
"channelCountMode",
"channelInterpretation"
]
}
},
Expand Down
5 changes: 4 additions & 1 deletion src/struct_info_generated.json
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,10 @@
"samplesPerChannel": 4
},
"EmscriptenAudioWorkletNodeCreateOptions": {
"__size__": 12,
"__size__": 24,
"channelCount": 12,
"channelCountMode": 16,
"channelInterpretation": 20,
"numberOfInputs": 0,
"numberOfOutputs": 4,
"outputChannelCounts": 8
Expand Down
5 changes: 4 additions & 1 deletion src/struct_info_generated_wasm64.json
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,10 @@
"samplesPerChannel": 4
},
"EmscriptenAudioWorkletNodeCreateOptions": {
"__size__": 16,
"__size__": 32,
"channelCount": 16,
"channelCountMode": 24,
"channelInterpretation": 28,
"numberOfInputs": 0,
"numberOfOutputs": 4,
"outputChannelCounts": 8
Expand Down
18 changes: 18 additions & 0 deletions system/include/emscripten/webaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ typedef struct AudioParamFrame

typedef bool (*EmscriptenWorkletNodeProcessCallback)(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData4);

typedef enum {
WEBAUDIO_CHANNEL_COUNT_MODE_MAX = 0,
WEBAUDIO_CHANNEL_COUNT_MODE_CLAMPED_MAX = 1,
WEBAUDIO_CHANNEL_COUNT_MODE_EXPLICIT = 2
} WEBAUDIO_CHANNEL_COUNT_MODE;

typedef enum {
WEBAUDIO_CHANNEL_INTERPRETATION_SPEAKERS = 0,
WEBAUDIO_CHANNEL_INTERPRETATION_DISCRETE = 1
} WEBAUDIO_CHANNEL_INTERPRETATION;

typedef struct EmscriptenAudioWorkletNodeCreateOptions
{
// How many audio nodes does this node take inputs from? Default=1
Expand All @@ -134,6 +145,13 @@ 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;
// Number of channels used when up-mixing and down-mixing connections to any inputs to the node. Default=2
unsigned long channelCount;
// How channels will be counted when up-mixing and down-mixing connections to any inputs to the node? Default=max
WEBAUDIO_CHANNEL_COUNT_MODE channelCountMode;
// How individual channels will be treated when up-mixing and down-mixing connections to any inputs to the node? Default=speakers
WEBAUDIO_CHANNEL_INTERPRETATION channelInterpretation;

} 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
5 changes: 4 additions & 1 deletion test/webaudio/audioworklet.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool succe
EmscriptenAudioWorkletNodeCreateOptions options = {
.numberOfInputs = 0,
.numberOfOutputs = 1,
.outputChannelCounts = outputChannelCounts
.outputChannelCounts = outputChannelCounts,
.channelCount = 1,
.channelCountMode = WEBAUDIO_CHANNEL_COUNT_MODE_EXPLICIT,
.channelInterpretation = WEBAUDIO_CHANNEL_INTERPRETATION_SPEAKERS,
};

// Instantiate the noise-generator Audio Worklet Processor.
Expand Down