Skip to content

Commit 4c4d5dd

Browse files
committed
Clarification on render size
1 parent 36d6f60 commit 4c4d5dd

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

system/include/emscripten/webaudio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ typedef void (*EmscriptenWorkletProcessorCreatedCallback)(EMSCRIPTEN_WEBAUDIO_T
102102
void emscripten_create_wasm_audio_worklet_processor_async(EMSCRIPTEN_WEBAUDIO_T audioContext, const WebAudioWorkletProcessorCreateOptions *options, EmscriptenWorkletProcessorCreatedCallback callback, void *userData3);
103103

104104
// Returns the number of samples processed per channel in an AudioSampleFrame, fixed at 128 in the Web Audio API 1.0 specification, and valid for the lifetime of the audio context.
105-
// For this to change from the default 128, the context would need to be created with a yet unexposed WebAudioWorkletProcessorCreateOptions renderSizeHint, part of the 1.1 Web Audio API.
105+
// For this to differ from the default 128, the context would need to be created with a WebAudioWorkletProcessorCreateOptions renderSizeHint, part of the 1.1 Web Audio API.
106106
int emscripten_audio_context_quantum_size(EMSCRIPTEN_WEBAUDIO_T audioContext);
107107

108108
// Returns the sampling rate of the given Audio Context, e.g. 48000 or 44100 or similar.

test/webaudio/audioworklet_test_shared.inc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,24 @@ EmscriptenStartWebAudioWorkletCallback getStartCallback(void);
9090

9191
// Common entry point for the mixer tests
9292
int main(void) {
93-
char* const workletStack = memalign(16, AUDIO_STACK_SIZE);
94-
emscripten_outf("Audio worklet stack at 0x%p", workletStack);
95-
assert(workletStack);
96-
97-
// Set at least the latency hint to test the attribute setting
98-
// (The render size we take from the calling code if set)
93+
// Set at least the latency hint to test the attribute setting (the render
94+
// size we take from the calling code if set).
9995
EmscriptenWebAudioCreateAttributes attrs = {
10096
.latencyHint = "balanced",
10197
#ifdef RENDER_SIZE_HINT
10298
.renderSizeHint = RENDER_SIZE_HINT
10399
#endif
104100
};
105101
EMSCRIPTEN_WEBAUDIO_T context = emscripten_create_audio_context(&attrs);
102+
// With the 1.1 API this may be values other than 128
103+
emscripten_outf("Audio context created with quantum size of %d samples", emscripten_audio_context_quantum_size(context));
104+
105+
// Here we create a fixed sized worklet stack, but could decide based on the
106+
// quantum size above (ins and outs * bytes per quantum)/
107+
char* const workletStack = memalign(16, AUDIO_STACK_SIZE);
108+
emscripten_outf("Audio worklet stack at 0x%p", workletStack);
109+
assert(workletStack);
110+
106111
emscripten_start_wasm_audio_worklet_thread_async(context, workletStack, AUDIO_STACK_SIZE, getStartCallback(), NULL);
107112

108113
#ifdef TEST_AND_EXIT

0 commit comments

Comments
 (0)