Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1316: use table to define process #1618

Merged
merged 11 commits into from
May 17, 2018
68 changes: 35 additions & 33 deletions expected-errs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,55 @@ WARNING: Multiple elements have the same ID 'dom-decodeerrorcallback-error'.
Deduping, but this ID may not be stable across revisions.
WARNING: Multiple elements have the same ID 'dom-decodesuccesscallback-decodeddata'.
Deduping, but this ID may not be stable across revisions.
LINE 1904: Can't find the 'contextOptions' argument of method 'OfflineAudioContext/OfflineAudioContext(numberOfChannels, length, sampleRate)' in the argumentdef block.
LINE 2907: Can't find the 'destinationNode' argument of method 'AudioNode/connect(destinationParam, output)' in the argumentdef block.
LINE 2907: Can't find the 'input' argument of method 'AudioNode/connect(destinationParam, output)' in the argumentdef block.
LINE 3008: Can't find the 'destinationNode' argument of method 'AudioNode/disconnect(destinationParam, output)' in the argumentdef block.
LINE 3018: Can't find the 'destinationNode' argument of method 'AudioNode/disconnect(destinationParam, output)' in the argumentdef block.
LINE 3033: Can't find the 'destinationNode' argument of method 'AudioNode/disconnect(destinationParam, output)' in the argumentdef block.
LINE 3033: Can't find the 'input' argument of method 'AudioNode/disconnect(destinationParam, output)' in the argumentdef block.
LINE 1901: Can't find the 'contextOptions' argument of method 'OfflineAudioContext/OfflineAudioContext(numberOfChannels, length, sampleRate)' in the argumentdef block.
LINE 2900: Can't find the 'destinationNode' argument of method 'AudioNode/connect(destinationParam, output)' in the argumentdef block.
LINE 2900: Can't find the 'input' argument of method 'AudioNode/connect(destinationParam, output)' in the argumentdef block.
LINE 3001: Can't find the 'destinationNode' argument of method 'AudioNode/disconnect(destinationParam, output)' in the argumentdef block.
LINE 3011: Can't find the 'destinationNode' argument of method 'AudioNode/disconnect(destinationParam, output)' in the argumentdef block.
LINE 3026: Can't find the 'destinationNode' argument of method 'AudioNode/disconnect(destinationParam, output)' in the argumentdef block.
LINE 3026: Can't find the 'input' argument of method 'AudioNode/disconnect(destinationParam, output)' in the argumentdef block.
LINE 9887: Can't find method '['AudioWorkletProcessor/process(inputs, outputs, parameters))']'.
LINK ERROR: No 'idl-name' refs found for 'MediaStream'.
<a data-link-type="idl-name" class="n" data-lt="MediaStream">MediaStream</a>
LINK ERROR: No 'idl-name' refs found for 'MediaStreamTrack'.
<a data-link-type="idl-name" class="n" data-lt="MediaStreamTrack">MediaStreamTrack</a>
LINE 1470: No 'method' refs found for 'AudioContext()'.
LINE 1469: No 'method' refs found for 'AudioContext()'.
LINK ERROR: No 'idl-name' refs found for 'DOMHighResTimeStamp'.
<a data-link-type="idl-name" class="n" data-lt="DOMHighResTimeStamp">DOMHighResTimeStamp</a>
LINK ERROR: No 'idl-name' refs found for 'DOMHighResTimeStamp'.
<a data-link-type="idl-name" data-lt="DOMHighResTimeStamp">DOMHighResTimeStamp</a>
LINE 1904: No 'method' refs found for 'OfflineAudioContext(contextOptions)'.
LINE 1928: No 'method' refs found for 'OfflineAudioContext(numberOfChannels, length, sampleRate)'.
LINE 2222: No 'method' refs found for 'AudioBuffer()'.
LINE 4091: No 'method' refs found for 'AnalyserNode()'.
LINE 4528: No 'method' refs found for 'AudioBufferSourceNode()'.
LINE 5743: No 'method' refs found for 'BiquadFilterNode()'.
LINE 6157: No 'method' refs found for 'ChannelMergerNode()'.
LINE 6269: No 'method' refs found for 'ChannelSplitterNode()'.
LINE 6351: No 'method' refs found for 'ConstantSourceNode()'.
LINE 6462: No 'method' refs found for 'ConvolverNode()'.
LINE 6731: No 'method' refs found for 'DelayNode()'.
LINE 6865: No 'method' refs found for 'DynamicsCompressorNode()'.
LINE 7308: No 'method' refs found for 'GainNode()'.
LINE 7415: No 'method' refs found for 'IIRFilterNode()'.
LINE 7559: No 'method' refs found for 'MediaElementAudioSourceNode()'.
LINE 7688: No 'method' refs found for 'MediaStreamAudioDestinationNode()'.
LINE 1901: No 'method' refs found for 'OfflineAudioContext(contextOptions)'.
LINE 1925: No 'method' refs found for 'OfflineAudioContext(numberOfChannels, length, sampleRate)'.
LINE 2217: No 'method' refs found for 'AudioBuffer()'.
LINE 4084: No 'method' refs found for 'AnalyserNode()'.
LINE 4521: No 'method' refs found for 'AudioBufferSourceNode()'.
LINE 5736: No 'method' refs found for 'BiquadFilterNode()'.
LINE 6150: No 'method' refs found for 'ChannelMergerNode()'.
LINE 6262: No 'method' refs found for 'ChannelSplitterNode()'.
LINE 6344: No 'method' refs found for 'ConstantSourceNode()'.
LINE 6455: No 'method' refs found for 'ConvolverNode()'.
LINE 6724: No 'method' refs found for 'DelayNode()'.
LINE 6858: No 'method' refs found for 'DynamicsCompressorNode()'.
LINE 7301: No 'method' refs found for 'GainNode()'.
LINE 7408: No 'method' refs found for 'IIRFilterNode()'.
LINE 7552: No 'method' refs found for 'MediaElementAudioSourceNode()'.
LINE 7681: No 'method' refs found for 'MediaStreamAudioDestinationNode()'.
LINK ERROR: No 'idl-name' refs found for 'MediaStream'.
<a data-link-type="idl-name" data-lt="MediaStream">MediaStream</a>
LINE 7755: No 'method' refs found for 'MediaStreamAudioSourceNode()'.
LINE 7825: No 'method' refs found for 'MediaStreamTrackAudioSourceNode()'.
LINE 7748: No 'method' refs found for 'MediaStreamAudioSourceNode()'.
LINE 7818: No 'method' refs found for 'MediaStreamTrackAudioSourceNode()'.
LINK ERROR: No 'idl-name' refs found for 'MediaStreamTrack'.
<a data-link-type="idl-name" data-lt="MediaStreamTrack">MediaStreamTrack</a>
LINE 7964: No 'method' refs found for 'OscillatorNode()'.
LINE 8339: No 'method' refs found for 'PannerNode()'.
LINE 8744: No 'method' refs found for 'PeriodicWave()'.
LINE 9056: No 'method' refs found for 'StereoPannerNode()'.
LINE 9186: No 'method' refs found for 'WaveShaperNode()'.
LINE 9624: No 'method' refs found for 'AudioWorkletNode()'.
LINE 7957: No 'method' refs found for 'OscillatorNode()'.
LINE 8332: No 'method' refs found for 'PannerNode()'.
LINE 8737: No 'method' refs found for 'PeriodicWave()'.
LINE 9049: No 'method' refs found for 'StereoPannerNode()'.
LINE 9179: No 'method' refs found for 'WaveShaperNode()'.
LINE 9618: No 'method' refs found for 'AudioWorkletNode()'.
LINK ERROR: No 'idl-name' refs found for 'sequence<unsigned long>'.
<a data-link-type="idl-name" data-lt="sequence&lt;unsigned long&gt;">sequence&lt;unsigned long&gt;</a>
LINK ERROR: No 'idl-name' refs found for 'record<DOMString, double>'.
<a data-link-type="idl-name" data-lt="record&lt;DOMString, double&gt;">record&lt;DOMString, double&gt;</a>
LINE 9798: No 'method' refs found for 'AudioWorkletProcessor()'.
LINE 9792: No 'method' refs found for 'AudioWorkletProcessor()'.
LINE 9887: No 'method' refs found for 'process(inputs, outputs, parameters))'.
YAY Successfully generated, but fatal errors were suppressed
211 changes: 79 additions & 132 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -9807,12 +9807,12 @@ Attributes</h5>
{{AudioWorkletNode}} and {{AudioWorkletProcessor}}.
</dl>

<h5 id="defining-a-valid-audioworkletprocessor">
Defining A Valid AudioWorkletProcessor</h5>
<h5 id="AudioWorkletProcessor-methods">
Methods</h5>

User can define a custom audio processor by extending
{{AudioWorkletProcessor}}. The subclass MUST define a method
named <code><dfn id="audioworkletprocessor-process">process()</dfn></code> that implements the audio processing
named {{process()}} that implements the audio processing
algorithm and have a valid static property named
<code><dfn>parameterDescriptors</dfn></code> which is an iterable
of {{AudioParamDescriptor}} that is looked up by the
Expand All @@ -9821,141 +9821,89 @@ of {{AudioParamDescriptor}} that is looked up by the
in the node. The <a href="#check-prototype-type">prototype type check step</a> and the <a href="#check-is-callable">process method is callable step</a> of <a data-link-for="AudioWorkletGlobalScope">registerProcessor()</a> ensure the
validity of a given {{AudioWorkletProcessor}} subclass.

An example of a valid subclass is as follows:

<pre line-numbers class="example" highlight="js" title="Subclassing AudioWorkletProcessor">
class MyProcessor extends AudioWorkletProcessor {
static get parameterDescriptors() {
return [{
name: 'myParam',
defaultValue: 0.5,
minValue: 0,
maxValue: 1,
automationRate: "k-rate"
}];
}

process(inputs, outputs, parameters) {
// Get the first input and output.
let input = inputs[0];
let output = outputs[0];
let myParam = parameters.myParam;

// A simple amplifier for single input and output.
for (let channel = 0; channel &lt; output.length; ++channel) {
for (let i = 0; i &lt; output[channel].length; ++i) {
output[channel][i] = input[channel][i] * myParam[0];
}
}

// To keep this processor alive.
return true;
}
}
</pre>

The <code>process()</code> method is called synchronously by the
audio <a>rendering thread</a> at every <a>render quantum</a>, if
ANY of the following <dfn>active processing conditions</dfn> are
true:
<dl dfn-type=method dfn-for="AudioWorkletProcessor">
: <dfn>process(inputs, outputs, parameters)</dfn>
::
Implements the audio processing algorithm for the
{{AudioWorkletProcessor}}.

1. The associated {{AudioWorkletProcessor}}'s <a>active
source</a> flag is equal to `true`.
The {{process()}} method is called
synchronously by the audio <a>rendering thread</a> at
every <a>render quantum</a>, if ANY of the following
<dfn dfn>active processing conditions</dfn> are true:

1. The associated {{AudioWorkletProcessor}}'s
<a>active source</a> flag is equal to `true`.

2. There are one or more connected inputs to the {{AudioWorkletNode}}.

The return value of this method controls the lifetime of the
{{AudioWorkletProcessor}}'s associated
{{AudioWorkletNode}}. At the conclusion of each call to the
{{process()}} method, <a href="https://tc39.github.io/ecma262/#sec-toboolean"><code>ToBoolean</code></a> (described in [[!ECMASCRIPT]])
is applied to the return value and the result is assigned to the associated AudioWorkletProcessor's <a>active source</a> flag. This in turn affects whether subsequent
invocations of {{process()}} occur, and has an impact on the lifetime of the node.
To propagate the flag change <a>queue a task</a> on the control thread to update the corresponding {{AudioWorkletNode}}'s <code>state</code> property accordingly.

<div class="note">
This lifetime policy can support a variety of approaches found in
built-in nodes, including the following:

* Nodes that transform their inputs, and are active only
while connected inputs and/or script references exist. Such
nodes SHOULD return <code>false</code> from
{{process()}} which allows the presence or absence of
connected inputs to determine whether active processing occurs.

* Nodes that transform their inputs, but which remain active
for a <a>tail-time</a> after their inputs are disconnected. In
this case, {{process()}} SHOULD return
`true` for some period of time after
<code>inputs</code> is found to contain zero channels. The
current time may be obtained from the global scope's
{{AudioWorkletGlobalScope/currentTime}} to
measure the start and end of this tail-time interval, or the
interval could be calculated dynamically depending on the
processor's internal state.

* Nodes that act as sources of output, typically with a
lifetime. Such nodes SHOULD return `true` from
{{process()}} until the point at which they are no
longer producing an output.

Note that the preceding definition implies that when no
return value is provided from an implementation of
{{process()}}, the effect is identical to returning
<code>false</code> (since the effective return value is the falsy
value <code>undefined</code>). This is a reasonable behavior for
any {{AudioWorkletProcessor}} that is active only when it has
active inputs.
</div>

2. There are one or more connected inputs to the
{{AudioWorkletNode}}.
If {{process()}} is not called during some rendering
quantum due to the lack of any applicable [=active processing conditions=], the result is as if the processor emitted
silence for this period.

The method is invoked with the following arguments:
<pre class=argumentdef for="AudioWorkletProcessor/process(inputs, outputs, parameters))">
inputs:
The input audio buffer from the incoming connections provided by the user agent. It has type <code>&lt;sequence&lt;sequence&lt;Float32Array>></code>. <code>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.

: <code>inputs</code> of type <code>sequence&lt;sequence&lt;Float32Array>></code>
::
The input audio buffer from the incoming connections provided
by the user agent. <code>inputs[n][m]</code> is a
{{Float32Array}} of audio samples for the
<code>m</code>th channel of <code>n</code>th input. While the
number of inputs is fixed at construction, the number of
channels can be changed dynamically based on
<a>computedNumberOfChannels</a>.

If no connections exist to the <code>n</code>th input of the
node during 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.

: <code>outputs</code> of type <code>sequence&lt;sequence&lt;Float32Array>></code>
::
The output audio buffer that is to be consumed by the user
agent. <code>outputs[n][m]</code> is a
{{Float32Array}} object containing the audio samples
for <code>m</code>th channel of <code>n</code>th output. The
number of channels in the output will match
<a>computedNumberOfChannels</a> only when the node has single
output.
If no connections exist to the \(n\)th input of the node during 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.

: <code>parameters</code> of type <code>Object</code>
::
A map of string keys and associated {{Float32Array}}s.
<code>parameters["name"]</code> corresponds to the automation
values of the {{AudioParam}} named
<code>"name"</code>.

For each array, the array contains the [=computedValue=] or
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=].

The return value of this method controls the lifetime of the
{{AudioWorkletProcessor}}'s associated
{{AudioWorkletNode}}. At the conclusion of each call to the
<code>process()</code> method, <a href="https://tc39.github.io/ecma262/#sec-toboolean"><code>ToBoolean</code></a> (described in [[!ECMASCRIPT]])
is applied to the return value and the result is assigned to the associated AudioWorkletProcessor's <a>active source</a> flag. This in turn affects whether subsequent
invocations of <code>process()</code> occur, and has an impact on the lifetime of the node.
To propagate the flag change <a>queue a task</a> on the control thread to update the corresponding {{AudioWorkletNode}}'s <code>state</code> property accordingly.
outputs:
The output audio buffer that is to be consumed by the user agent. It has type <code>&lt;sequence&lt;sequence&lt;Float32Array>></code>. <code>outputs[n][m]</code> is a {{Float32Array}} object containing the audio samples for \(m\)th channel of \(n\)th output. The number of channels in the output will match [=computedNumberOfChannels=] only when the node has single output.

<div class="note">
This lifetime policy can support a variety of approaches found in
built-in nodes, including the following:

* Nodes that transform their inputs, and are active only
while connected inputs and/or script references exist. Such
nodes SHOULD return <code>false</code> from
<code>process()</code> which allows the presence or absence of
connected inputs to determine whether active processing occurs.

* Nodes that transform their inputs, but which remain active
for a <a>tail-time</a> after their inputs are disconnected. In
this case, <code>process()</code> SHOULD return
`true` for some period of time after
<code>inputs</code> is found to contain zero channels. The
current time may be obtained from the global scope's
{{AudioWorkletGlobalScope/currentTime}} to
measure the start and end of this tail-time interval, or the
interval could be calculated dynamically depending on the
processor's internal state.

* Nodes that act as sources of output, typically with a
lifetime. Such nodes SHOULD return `true` from
<code>process()</code> until the point at which they are no
longer producing an output.

Note that the preceding definition implies that when no
return value is provided from an implementation of
<code>process()</code>, the effect is identical to returning
<code>false</code> (since the effective return value is the falsy
value <code>undefined</code>). This is a reasonable behavior for
any {{AudioWorkletProcessor}} that is active only when it has
active inputs.
</div>
parameters:
A map of string keys and associated {{Float32Array}}s. <code>parameters["name"]</code> corresponds to the automation values of the AudioParam named <code>"name"</code>.

If <code>process()</code> is not called during some rendering
quantum due to the lack of any applicable <a>active processing
conditions</a>, the result is as if the processor emitted
silence for this period.
For each array, the array contains the [=computedValue=] or 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=].
</pre>

<div>
<em>Return type:</em> {{boolean}}
</div>
</dl>

<h5 dictionary lt="AudioParamDescriptor">
{{AudioParamDescriptor}}</h5>

Expand Down Expand Up @@ -10723,8 +10671,7 @@ operation such as resolution of {{Promise}}s in the {{AudioWorkletGlobalScope}}.
<a href="#available-for-reading">make it available for reading</a>.

4. If this {{AudioNode}} is an {{AudioWorkletNode}}, invoke associated
{{AudioWorkletProcessor}}'s <a href="#audioworkletprocessor-process">
process</a> method to [=Computing a block of audio|compute a block of
{{AudioWorkletProcessor}}'s {{AudioWorkletProcessor/process()}} method to [=Computing a block of audio|compute a block of
audio=] with the argument of [=input buffer=], output
buffer and <a href="#input-audioparam-buffer">input AudioParam buffer
</a>.
Expand Down