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 #2361: Use new Web IDL buffer primitives #2363

Merged
merged 19 commits into from
Aug 26, 2021
Merged
243 changes: 210 additions & 33 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,82 @@ window.addEventListener("DOMContentLoaded", function () {
});
});
</script>
<script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a separate amendments.js file above, yet it is being included directly in this HTML file. Is this intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amendment.js should be removed since I moved all of that into index.bs so that the preview works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood.

// This replaces the contents of "divID" with an unordered list of all the
// amendment boxes with a prefix of "prefix". Each item of the list will be of
// the form "label n", where "label" is the specified label to use via "label".
// "n" is just a sequential number starting at 1.
//
// Example usage where we want a list of all the changes whose id begins with
// "c2361".
//
// (div id="change-list-2361")
// (/div)
//
// And add
//
// ListAmendments("c2361", "Correction", "change-list-2361")
//
// to the onload event listener at the bottom of this file.
//
// (Replace the "(", ")" with "<", ">", respectively above. Bikeshed mangles
// this if we use "<" above.

function ListAmendments(prefix, label, divID) {
// Find all the nodes whose id starts with prefix.
let nodes = document.querySelectorAll('*[id^="' + prefix + '"]');
// Find the div element which will be replaced by the unordered list.
let div = document.getElementById(divID);

// Create the unordered list
let text = '<ul>';
let index = 1;
nodes.forEach(x => {
text += '<li><a href="#' + x.id + '">' + label + ' ' + index + '</a></li>';
++index;
// Insert buttons for prev and next change
InsertButtons(x);
});
text += '</ul>';

div.innerHTML = text;
}

// Search for the class "amendment-buttons", and replace the contents of the div
// with a set of buttons which link to the previous and next related amendment.

function InsertButtons(node) {
let list = node.getElementsByClassName("amendment-buttons");

// We only add buttons to the first class inside the node.
if (list && list.length > 0) {
let matches = node.id.match(/([ac]\d+)-(\d+)/);
let changeID = matches[1];
let changeNum = parseInt(matches[2]);
// Create buttons.
let text = "";
if (changeNum > 1) {
// Add "previous" button, only if there is a previous change.
text += "<button onclick='location.href=";
text += '"#' + changeID + '-' + (changeNum-1) + '"';
text += "'>Previous Change</button>";
}

if (document.getElementById(changeID + "-" + (changeNum + 1))) {
// Add "next" button only if there is a next change
text += "<button onclick='location.href=";
text += '"#' + changeID + '-' + (changeNum + 1) + '"';
text += "'>Next Change</button>";
}

list[0].innerHTML = text;
}
}
window.addEventListener('load', (event) => {
// Add entries here for each change
ListAmendments("c2361", "Proposed Correction", "change-list-2361");
});
</script>
<style>
@media (prefers-color-scheme: light) {
:root {
Expand Down Expand Up @@ -1145,17 +1221,35 @@ Methods</h4>

2. Let <var>promise</var> be a new Promise.

3. If the operation <a href="https://tc39.github.io/ecma262/#sec-isdetachedbuffer"><code>IsDetachedBuffer</code></a>
(described in [[!ECMASCRIPT]]) on {{BaseAudioContext/decodeAudioData(audioData, successCallback, errorCallback)/audioData!!argument}} is
<code>false</code>, execute the following steps:
3. <div class="correction proposed" id="c2361-1">
<span class="marker">Proposed Correction
<a href="https://github.com/WebAudio/web-audio-api/issues/2361">Issue 2361</a>-1.
</span>
Use new Web IDL buffer primitives
<div class="amendment-buttons">
Buttons here
</div>
If <del>
the operation <a href="https://tc39.github.io/ecma262/#sec-isdetachedbuffer"><code>IsDetachedBuffer</code></a> (described in [[!ECMASCRIPT]]) on
{{BaseAudioContext/decodeAudioData(audioData, successCallback, errorCallback)/audioData!!argument}}
is <code>false</code>,</del><ins> {{BaseAudioContext/decodeAudioData(audioData, successCallback, errorCallback)/audioData!!argument}} is [=BufferSource/detached=],</ins> execute the following steps:
</div>

1. Append <var>promise</var> to {{BaseAudioContext/[[pending promises]]}}.

2. <a href="https://tc39.github.io/ecma262/#sec-detacharraybuffer">
Detach</a> the {{BaseAudioContext/decodeAudioData(audioData,
successCallback, errorCallback)/audioData!!argument}} {{ArrayBuffer}}.
This operation is described in [[!ECMASCRIPT]]. If this operations
throws, jump to the step 3.
2. <div class="correction proposed" id="c2361-2">
<span class="marker">Proposed Correction
<a href="https://github.com/WebAudio/web-audio-api/issues/2361">Issue 2361</a>-2.
</span>
Use new Web IDL buffer primitives
<div class="amendment-buttons">
Buttons here
</div>
<del><a href="https://tc39.github.io/ecma262/#sec-detacharraybuffer">Detach</a></del><ins>[=ArrayBuffer/Detach=]</ins>
the {{BaseAudioContext/decodeAudioData(audioData, successCallback, errorCallback)/audioData!!argument}} {{ArrayBuffer}}.
<del>This operation is described in [[!ECMASCRIPT]].</del>
If this operations throws, jump to the step 3.
</div>

3. Queue a decoding operation to be performed on another thread.

Expand Down Expand Up @@ -2512,11 +2606,20 @@ Methods</h4>

: <dfn>getChannelData(channel)</dfn>
::
<div class="correction proposed" id="c2361-3">
<span class="marker">Proposed Correction
<a href="https://github.com/WebAudio/web-audio-api/issues/2361">Issue 2361</a>-3.
</span>
Use new Web IDL buffer primitives
<div class="amendment-buttons">
Buttons here
</div>
According to the rules described in <a href="#acquire-the-content">acquire the content</a>
either [=get a reference to the buffer source|get a reference to=]
or [=get a copy of the buffer source|get a copy of=]
either <del>get a reference to</del><ins>allow [=ArrayBufferView/write|writing=] into</ins>
or [=get a copy of the buffer source|getting a copy of=]
the bytes stored in {{[[internal data]]}} in a new
{{Float32Array}}
</div>

A {{UnknownError}} may be thrown if the {{[[internal
data]]}} or the new {{Float32Array}} cannot be
Expand Down Expand Up @@ -2550,14 +2653,33 @@ invoker.
When an <dfn lt="acquire the content|acquire the contents of an AudioBuffer">acquire the content</dfn>
operation occurs on an {{AudioBuffer}}, run the following steps:

1. If the operation <a href="https://tc39.github.io/ecma262/#sec-isdetachedbuffer"><code>IsDetachedBuffer</code></a>
on any of the {{AudioBuffer}}'s {{ArrayBuffer}}s return
`true`, abort these steps, and return a zero-length
channel data buffer to the invoker.

1.
<div class="correction proposed" id="c2361-4">
<span class="marker">Proposed Correction
<a href="https://github.com/WebAudio/web-audio-api/issues/2361">Issue 2361</a>-4.
</span>
Use new Web IDL buffer primitives
<div class="amendment-buttons">
Buttons here
</div>
If <del>the operation <a href="https://tc39.github.io/ecma262/#sec-isdetachedbuffer"><code>IsDetachedBuffer</code></a>
on any of the {{AudioBuffer}}'s {{ArrayBuffer}}s</del><ins>any of the {{AudioBuffer}}'s {{ArrayBuffer}}s are
[=BufferSource/detached=]</ins>, return `true`, abort these steps, and
return a zero-length channel data buffer to the invoker.
</div>

2. <a href="https://tc39.github.io/ecma262/#sec-detacharraybuffer">Detach</a>
all {{ArrayBuffer}}s for arrays previously returned by
{{AudioBuffer/getChannelData()}} on this {{AudioBuffer}}.
2. <div class="correction proposed" id="c2361-5">
<span class="marker">Proposed Correction
<a href="https://github.com/WebAudio/web-audio-api/issues/2361">Issue 2361</a>-5.
</span>
Use new Web IDL buffer primitives
<div class="amendment-buttons">
Buttons here
</div>
<del><a href="https://tc39.github.io/ecma262/#sec-detacharraybuffer">Detach</a></del><ins>[=ArrayBuffer/Detach=]</ins> all {{ArrayBuffer}}s for arrays previously returned
by {{AudioBuffer/getChannelData()}} on this {{AudioBuffer}}.
</div>

Note: Because {{AudioBuffer}} can only be created via
{{BaseAudioContext/createBuffer()}} or via the {{AudioBuffer}} constructor, this
Expand Down Expand Up @@ -3692,7 +3814,7 @@ Methods</h4>
are also removed if the hold time occurs after
{{AudioParam/cancelScheduledValues()/cancelTime!!argument}}.

For a {{AudioParam/setValueCurveAtTime()}}, let \(T_0\) and \(T_D\) be the corresponding
For a {{AudioParam/setValueCurveAtTime()}}, let \(T_0\) and \(T_D\) be the corresponding
{{AudioParam/setValueCurveAtTime()/startTime!!argument}} and {{AudioParam/setValueCurveAtTime()/duration!!argument}}, respectively of this event.
Then if {{AudioParam/cancelScheduledValues()/cancelTime!!argument}}
is in the range \([T_0, T_0 + T_D]\), the event is
Expand Down Expand Up @@ -4364,15 +4486,28 @@ Methods</h4>
<dl dfn-type=method dfn-for="AnalyserNode">
: <dfn>getByteFrequencyData(array)</dfn>
::
Get a
<div class="correction proposed" id="c2361-6">
<span class="marker">Proposed Correction
<a href="https://github.com/WebAudio/web-audio-api/issues/2361">Issue 2361</a>-6.
</span>
Use new Web IDL buffer primitives
<div class="amendment-buttons">
Buttons here
</div>
<del>Get a
<a href="https://heycam.github.io/webidl/#dfn-get-buffer-source-reference">
reference to the bytes</a> held by the {{Uint8Array}}
passed as an argument. Copies the <a>current frequency data</a> to those
bytes. If the array has fewer elements than the {{frequencyBinCount}}, the
excess elements will be dropped. If the array has more elements than the
{{frequencyBinCount}}, the excess elements will be ignored. The most
recent {{AnalyserNode/fftSize}} frames are used in computing the frequency
data.
{{frequencyBinCount}}</del><ins>
[=ArrayBufferView/Write=] the [=current frequency data=] into |array|. If
|array|'s [=BufferSource/byte length=] is less than {{frequencyBinCount}},
the excess elements will be dropped. If |array|'s
[=BufferSource/byte length=] is greater than the {{frequencyBinCount}}</ins>, the
excess elements will be ignored. The most recent {{AnalyserNode/fftSize}}
frames are used in computing the frequency data.
</div>

If another call to {{AnalyserNode/getByteFrequencyData()}} or
{{AnalyserNode/getFloatFrequencyData()}} occurs within the same
Expand Down Expand Up @@ -4409,15 +4544,27 @@ Methods</h4>

: <dfn>getByteTimeDomainData(array)</dfn>
::
Get a
<div class="correction proposed" id="c2361-7">
<span class="marker">Proposed Correction
<a href="https://github.com/WebAudio/web-audio-api/issues/2361">Issue 2361</a>-7.
</span>
Use new Web IDL buffer primitives
<div class="amendment-buttons">
Buttons here
</div>
<del>Get a
<a href="https://heycam.github.io/webidl/#dfn-get-buffer-source-reference">
reference to the bytes</a> held by the {{Uint8Array}}
passed as an argument. Copies the <a>current time-domain data</a>
(waveform data) into those bytes. If the array has fewer elements than the
value of {{AnalyserNode/fftSize}}, the excess elements will be dropped. If
the array has more elements than {{AnalyserNode/fftSize}}, the excess
elements will be ignored. The most recent {{AnalyserNode/fftSize}} frames
are used in computing the byte data.
the array has more elements than {{AnalyserNode/fftSize}},</del><ins>[=ArrayBufferView/Write=] the [=current time-domain data=] (waveform data)
into |array|. If |array|'s [=BufferSource/byte length=] is less than
{{AnalyserNode/fftSize}}, the excess elements will be dropped. If |array|'s
[=BufferSource/byte length=] is greater than the {{AnalyserNode/fftSize}},</ins>
the excess elements will be ignored. The most recent
{{AnalyserNode/fftSize}} frames are used in computing the byte data.
</div>

The values stored in the unsigned byte array are computed in
the following way. Let \(x[k]\) be the time-domain data. Then
Expand All @@ -4442,15 +4589,25 @@ Methods</h4>

: <dfn>getFloatFrequencyData(array)</dfn>
::
Get a
<div class="correction proposed" id="c2361-8">
<span class="marker">Proposed Correction
<a href="https://github.com/WebAudio/web-audio-api/issues/2361">Issue 2361</a>-8.
</span>
Use new Web IDL buffer primitives
<div class="amendment-buttons">
Buttons here
</div>
<del>Get a
<a href="https://heycam.github.io/webidl/#dfn-get-buffer-source-reference">
reference to the bytes</a> held by the
{{Float32Array}} passed as an argument. Copies
the <a>current frequency data</a> into those bytes. If the array has
fewer elements than the {{frequencyBinCount}}, the excess elements will be
dropped. If the array has more elements than the {{frequencyBinCount}},
the excess elements will be ignored. The most recent
fewer elements than the {{frequencyBinCount}},</del><ins>[=ArrayBufferView/Write=] the [=current frequency data=] into |array|. If
|array| has fewer elements than the {{frequencyBinCount}}, the excess
elements will be dropped. If |array| has more elements than the
{{frequencyBinCount}},</ins> the excess elements will be ignored. The most recent
{{AnalyserNode/fftSize}} frames are used in computing the frequency data.
</div>

If another call to {{AnalyserNode/getFloatFrequencyData()}} or
{{AnalyserNode/getByteFrequencyData()}} occurs within the same
Expand All @@ -4470,15 +4627,28 @@ Methods</h4>

: <dfn>getFloatTimeDomainData(array)</dfn>
::
Get a
<div class="correction proposed" id="c2361-9">
<span class="marker">Proposed Correction
<a href="https://github.com/WebAudio/web-audio-api/issues/2361">Issue 2361</a>-9.
</span>
Use new Web IDL buffer primitives
<div class="amendment-buttons">
Buttons here
</div>
<del>Get a
<a href="https://heycam.github.io/webidl/#dfn-get-buffer-source-reference">
reference to the bytes</a> held by the
{{Float32Array}} passed as an argument. Copies the
<a>current time-domain data</a> (waveform data) into those bytes. If the
array has fewer elements than the value of {{AnalyserNode/fftSize}}, the
excess elements will be dropped. If the array has more elements than
{{AnalyserNode/fftSize}}, the excess elements will be ignored. The most
recent {{AnalyserNode/fftSize}} frames are returned (after downmixing).
{{AnalyserNode/fftSize}},</del><ins>[=ArrayBufferView/Write=] the [=current time-domain data=] (waveform data)
into |array|. If |array| has fewer elements than the value of
{{AnalyserNode/fftSize}}, the excess elements will be dropped. If |array|
has more elements than the value of {{AnalyserNode/fftSize}},</ins> the excess
elements will be ignored. The most recent {{AnalyserNode/fftSize}} frames
are written (after downmixing).
</div>

<pre class=argumentdef for="AnalyserNode/getFloatTimeDomainData()">
array: This parameter is where the time-domain sample data will be copied.
Expand Down Expand Up @@ -12680,6 +12850,13 @@ class Vec3 {

<h2 id="changes">
Change Log</h2>
<h3 id="recommendation-changes-1">
Changes since Recommendation of 17 Jun 2021
</h3>
* <a href="https://github.com/WebAudio/web-audio-api/issue/2361">Issue 2361</a>: Use new Web IDL buffer primitives
<div id="change-list-2361">
</div>

<h3 id="changes-2021-05-06">
Since Proposed Recommendation of 6 May 2021
</h3>
Expand Down