WebAudio / web-audio-api

The Web Audio API v1.0, developed by the W3C Audio WG
https://webaudio.github.io/web-audio-api/
Other
1.04k stars 166 forks source link

[audioworklet] node options not passed to processor #1442

Closed joeberkovitz closed 6 years ago

joeberkovitz commented 6 years ago

It looks from https://webaudio.github.io/web-audio-api/#instantiation-of-AudioWorkletNode-and-AudioWorkletProcessor as though the options passed to the node are not communicated to the processor, although this is clearly implied by the text in https://webaudio.github.io/web-audio-api/#AudioWorklet-Sequence

One of the above has to be wrong.

joeberkovitz commented 6 years ago

I further note that the BitCrusher and VUMeter examples both clearly show an options argument to AudioWorkletProcessor, but the interface of AudioWorkletProcessor doesn't show a constructor signature.

joeberkovitz commented 6 years ago

Summary of WG discussion:

This was an oversight, since the AWP options argument is a huge benefit in a clean initialization path that conducts settings other than AudioParams from the main thread AWN to the audio thread side. That's why we designed that path, but somehow it got elided.

We can change the text of https://webaudio.github.io/web-audio-api/#instantiation-of-AudioWorkletNode-and-AudioWorkletProcessor to incorporate a new step after step 7 to create an optionsSerialization variable, and pass this in the control message described in step 10.

We can also change the text of the subsequent control message processing to deserialize optionsSerialization into options, and then pass this to the AWP's constructor in step 4.

Finally, we decided to add an explicit constructor signature to AudioWorkletProcessor that takes an options dictionary. This makes it clear to implementors that subclasses should expect this argument in their constructors too.