Closed joeberkovitz closed 7 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.
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 AudioParam
s 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.
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-SequenceOne of the above has to be wrong.