From 32ee9d957f06ec7103b57711f83dd904552289ce Mon Sep 17 00:00:00 2001 From: Nikitha Mohithe Date: Sun, 5 Oct 2025 09:43:33 +0530 Subject: [PATCH 1/8] fix: added missing options to EmscriptenAudioWorkletNodeCreateOptions --- src/lib/libwebaudio.js | 3 +++ system/include/emscripten/webaudio.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/lib/libwebaudio.js b/src/lib/libwebaudio.js index 3378cc89792d9..6496c043042ec 100644 --- a/src/lib/libwebaudio.js +++ b/src/lib/libwebaudio.js @@ -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, diff --git a/system/include/emscripten/webaudio.h b/system/include/emscripten/webaudio.h index 07d60e8525a86..a67aa69a4d59e 100644 --- a/system/include/emscripten/webaudio.h +++ b/system/include/emscripten/webaudio.h @@ -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 + int channelCount; + int channelCountMode; + int 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. From d9e80993580cf0d043fbbc35058e411c28760c9d Mon Sep 17 00:00:00 2001 From: Nikitha Mohithe Date: Mon, 6 Oct 2025 21:46:41 +0530 Subject: [PATCH 2/8] fix: updated channelCount, mode and interpretation with proper types closes #23982 --- src/lib/libwebaudio.js | 6 +++--- system/include/emscripten/webaudio.h | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/lib/libwebaudio.js b/src/lib/libwebaudio.js index 6496c043042ec..bd8755a5e1503 100644 --- a/src/lib/libwebaudio.js +++ b/src/lib/libwebaudio.js @@ -318,9 +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') }}}, + 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; })(), processorOptions: { callback, userData, diff --git a/system/include/emscripten/webaudio.h b/system/include/emscripten/webaudio.h index a67aa69a4d59e..122ad1e407c3b 100644 --- a/system/include/emscripten/webaudio.h +++ b/system/include/emscripten/webaudio.h @@ -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 @@ -134,10 +145,9 @@ 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 - int channelCount; - int channelCountMode; - int channelInterpretation; + unsigned long channelCount; + WEBAUDIO_CHANNEL_COUNT_MODE channelCountMode; + WEBAUDIO_CHANNEL_INTERPRETATION channelInterpretation; } EmscriptenAudioWorkletNodeCreateOptions; From 9b5b7dc82f5b9c95181a23b7455204e07ab81036 Mon Sep 17 00:00:00 2001 From: Nikitha Mohithe Date: Thu, 9 Oct 2025 16:36:48 +0530 Subject: [PATCH 3/8] added additional fields to struct for test cases --- src/struct_info.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/struct_info.json b/src/struct_info.json index 7000a523fd589..2236e7d2048a3 100644 --- a/src/struct_info.json +++ b/src/struct_info.json @@ -1260,7 +1260,7 @@ ], "EmscriptenWebSocketCreateAttributes": [ "protocols" - ] +] } }, { @@ -1293,7 +1293,10 @@ "EmscriptenAudioWorkletNodeCreateOptions": [ "numberOfInputs", "numberOfOutputs", - "outputChannelCounts" + "outputChannelCounts", + "channelCount", + "channelCountMode", + "channelInterpretation" ] } }, From f9ad38574952224fa9229084cf4407189490c8a9 Mon Sep 17 00:00:00 2001 From: Nikitha Mohithe Date: Thu, 9 Oct 2025 18:49:24 +0530 Subject: [PATCH 4/8] WIP pls work --- test/webaudio/audioworklet.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/webaudio/audioworklet.c b/test/webaudio/audioworklet.c index 883834b3843d7..979b59bb666ff 100644 --- a/test/webaudio/audioworklet.c +++ b/test/webaudio/audioworklet.c @@ -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. From 2d676c5ce551c868207b3637efff9c75c747f755 Mon Sep 17 00:00:00 2001 From: Nikitha Mohithe Date: Thu, 9 Oct 2025 23:27:03 +0530 Subject: [PATCH 5/8] I think im done now --- src/struct_info_generated.json | 7 +++++-- src/struct_info_generated_wasm64.json | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/struct_info_generated.json b/src/struct_info_generated.json index d19c5424c9107..3f251a6710a82 100644 --- a/src/struct_info_generated.json +++ b/src/struct_info_generated.json @@ -535,10 +535,13 @@ "samplesPerChannel": 4 }, "EmscriptenAudioWorkletNodeCreateOptions": { - "__size__": 12, + "__size__": 24, "numberOfInputs": 0, "numberOfOutputs": 4, - "outputChannelCounts": 8 + "outputChannelCounts": 8, + "channelCount": 12, + "channelCountMode": 16, + "channelInterpretation": 20 }, "EmscriptenBatteryEvent": { "__size__": 32, diff --git a/src/struct_info_generated_wasm64.json b/src/struct_info_generated_wasm64.json index 13d51209247f5..137b54b5f8db1 100644 --- a/src/struct_info_generated_wasm64.json +++ b/src/struct_info_generated_wasm64.json @@ -535,10 +535,13 @@ "samplesPerChannel": 4 }, "EmscriptenAudioWorkletNodeCreateOptions": { - "__size__": 16, + "__size__": 24, "numberOfInputs": 0, "numberOfOutputs": 4, - "outputChannelCounts": 8 + "outputChannelCounts": 8, + "channelCount": 12, + "channelCountMode": 16, + "channelInterpretation": 20 }, "EmscriptenBatteryEvent": { "__size__": 32, From 8693ac7380a788423a0aa3b4b5c54673580abf1a Mon Sep 17 00:00:00 2001 From: Nikitha Mohithe Date: Thu, 9 Oct 2025 23:50:30 +0530 Subject: [PATCH 6/8] this time fs --- src/struct_info_generated_wasm64.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/struct_info_generated_wasm64.json b/src/struct_info_generated_wasm64.json index 137b54b5f8db1..5937385ba9396 100644 --- a/src/struct_info_generated_wasm64.json +++ b/src/struct_info_generated_wasm64.json @@ -535,13 +535,13 @@ "samplesPerChannel": 4 }, "EmscriptenAudioWorkletNodeCreateOptions": { - "__size__": 24, + "__size__": 32, "numberOfInputs": 0, "numberOfOutputs": 4, "outputChannelCounts": 8, - "channelCount": 12, - "channelCountMode": 16, - "channelInterpretation": 20 + "channelCount": 16, + "channelCountMode": 24, + "channelInterpretation": 28 }, "EmscriptenBatteryEvent": { "__size__": 32, From 8a67632a0dccbf7aa5584e875dd9ae49c0a514b0 Mon Sep 17 00:00:00 2001 From: Nikitha Mohithe Date: Fri, 10 Oct 2025 00:02:40 +0530 Subject: [PATCH 7/8] nah bro istg this will work --- src/struct_info_generated.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/struct_info_generated.json b/src/struct_info_generated.json index 3f251a6710a82..d1ca2576292f4 100644 --- a/src/struct_info_generated.json +++ b/src/struct_info_generated.json @@ -536,12 +536,12 @@ }, "EmscriptenAudioWorkletNodeCreateOptions": { "__size__": 24, - "numberOfInputs": 0, - "numberOfOutputs": 4, - "outputChannelCounts": 8, "channelCount": 12, "channelCountMode": 16, - "channelInterpretation": 20 + "channelInterpretation": 20, + "numberOfInputs": 0, + "numberOfOutputs": 4, + "outputChannelCounts": 8 }, "EmscriptenBatteryEvent": { "__size__": 32, From 1fd325de0b807b91e7e1c65bac5af66d5b3b71e1 Mon Sep 17 00:00:00 2001 From: Nikitha Mohithe Date: Fri, 10 Oct 2025 00:12:14 +0530 Subject: [PATCH 8/8] life taught me lessons --- src/struct_info_generated_wasm64.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/struct_info_generated_wasm64.json b/src/struct_info_generated_wasm64.json index 5937385ba9396..22254a5516602 100644 --- a/src/struct_info_generated_wasm64.json +++ b/src/struct_info_generated_wasm64.json @@ -536,12 +536,12 @@ }, "EmscriptenAudioWorkletNodeCreateOptions": { "__size__": 32, - "numberOfInputs": 0, - "numberOfOutputs": 4, - "outputChannelCounts": 8, "channelCount": 16, "channelCountMode": 24, - "channelInterpretation": 28 + "channelInterpretation": 28, + "numberOfInputs": 0, + "numberOfOutputs": 4, + "outputChannelCounts": 8 }, "EmscriptenBatteryEvent": { "__size__": 32,