Skip to content

Commit 607eb07

Browse files
committed
Fix WebAudio#1933: Use FrozeArray for AudioWorkletProcessor process()
Instead of `sequence<sequence<Float32Array>>`, use `FrozenArray<FrozenArray<Float32Array>>`. Define a callback function as well.
1 parent dfefdc5 commit 607eb07

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

index.bs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10356,13 +10356,18 @@ and the definition of the class manifests the actual audio processing.
1035610356
Note that the an {{AudioWorkletProcessor}} construction can only happen as a
1035710357
result of an {{AudioWorkletNode}} contruction.
1035810358

10359-
<pre class="idl">
10359+
<xmp class="idl">
1036010360
[Exposed=AudioWorklet]
1036110361
interface AudioWorkletProcessor {
1036210362
constructor ();
1036310363
readonly attribute MessagePort port;
1036410364
};
10365-
</pre>
10365+
10366+
callback AudioWorkletProcessorCallback =
10367+
boolean (FrozenArray<FrozenArray<Float32Array>> input,
10368+
FrozenArray<FrozenArray<Float32Array>> output,
10369+
FrozenArray<Float32Array> parameters);
10370+
</xmp>
1036610371

1036710372
{{AudioWorkletProcessor}} has two internal slots:
1036810373

@@ -10517,15 +10522,15 @@ of {{AudioParamDescriptor}}s.
1051710522

1051810523
<pre class=argumentdef for="AudioWorkletProcessor/process(inputs, outputs, parameters))">
1051910524
inputs:
10520-
The input audio buffer from the incoming connections provided by the user agent. It has type <code>sequence&lt;sequence&lt;Float32Array>></code>.<code class="nobreak">inputs[n][m]</code> is a {{Float32Array}} of audio samples for the \(m\)th channel of the \(n\)th input. While the number of inputs is fixed at construction, the number of channels can be changed dynamically based on [=computedNumberOfChannels=].
10525+
The input audio buffer from the incoming connections provided by the user agent. It has type <code>{{FrozenArray}}&lt;{{FrozenArray}}&lt;{{Float32Array}}&gt;&gt;</code>.<code class="nobreak">inputs[n][m]</code> is a {{Float32Array}} of audio samples for the \(m\)th channel of the \(n\)th input. While the number of inputs is fixed at construction, the number of channels can be changed dynamically based on [=computedNumberOfChannels=].
1052110526

1052210527
If there are no [=actively processing=] {{AudioNode}}s connected to the \(n\)th input of the {{AudioWorkletNode}} for the current render quantum, then the content of <code>inputs[n]</code> is an empty array, indicating that zero channels of input are available. This is the only circumstance under which the number of elements of <code>inputs[n]</code> can be zero.
1052310528

1052410529
outputs:
10525-
The output audio buffer that is to be consumed by the user agent. It has type <code>sequence&lt;sequence&lt;Float32Array>></code>.<code class="nobreak">outputs[n][m]</code> is a {{Float32Array}} object containing the audio samples for \(m\)th channel of \(n\)th output. Each of the {{Float32Array}}s are zero-filled. The number of channels in the output will match [=computedNumberOfChannels=] only when the node has a single output.
10530+
The output audio buffer that is to be consumed by the user agent. It has type <code>{{FrozenArray}}&lt;{{FrozenArray}}&lt;{{Float32Array}}>></code>.<code class="nobreak">outputs[n][m]</code> is a {{Float32Array}} object containing the audio samples for \(m\)th channel of \(n\)th output. Each of the {{Float32Array}}s are zero-filled. The number of channels in the output will match [=computedNumberOfChannels=] only when the node has a single output.
1052610531

1052710532
parameters:
10528-
An [=ordered map=] of <var>name</var><var>parameterValues</var>. <code>parameters["<var>name</var>"]</code> returns <var>parameterValues</var>, which is a {{Float32Array}} with the automation values of the <var>name</var> {{AudioParam}}.
10533+
An [=ordered map=] of <var>name</var><var>parameterValues</var>. <code>parameters["<var>name</var>"]</code> returns <var>parameterValues</var>, which is a {{FrozenArray}}&lt;{{Float32Array}}> with the automation values of the <var>name</var> {{AudioParam}}.
1052910534

1053010535
For each array, the array contains the [=computedValue=] of the parameter for all frames in the [=render quantum=]. However, if no automation is scheduled during this render quantum, the array MAY have length 1 with the array element being the constant value of the {{AudioParam}} for the [=render quantum=].
1053110536
</pre>

0 commit comments

Comments
 (0)