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
Define the constructor for AudioNodes (#1117) #1144
Define the constructor for AudioNodes (#1117) #1144
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to review more of the actual constructors, but this is a start.
index.html
Outdated
<p> | ||
<a>AudioNode</a>s can be created in two ways: using the constructor | ||
for this particular interface, or by using the <dfn>factory | ||
method</dfn> on the <a>BaseAudioContext</a>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some methods only exist on AudioContext.
index.html
Outdated
</p><a>AudioNode</a>s can be created in two ways: | ||
</p> | ||
<p> | ||
<a>AudioNode</a>s can be created in two ways: using the constructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammar: s/using the constructor/by using the constructor/
index.html
Outdated
<p> | ||
To create a new <a>AudioNode</a> of a particular type <var>i</var> | ||
using its constructor, with a <a>BaseAudioContext</a> <var>c</var> | ||
as first argument, and a <a>associated option object</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/and a associated/and an associated/
index.html
Outdated
<li>If the <a>AudioNode</a> being constructed is a | ||
<a>ConvolverNode</a>, set its <a href= | ||
"#widl-ConvolverNode-normalize">normalize</a> attribute with the | ||
inverse of the value of the <a href= | ||
"#widl-ConvolverOptions-disableNormalization">disableNormalization</a> | ||
dictionary member, and then set its the <a href= | ||
in <var>dict</var>, and then set its the <a href= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/its the/its/
index.html
Outdated
in, execute these steps, with <var>k</var> the key of the member, and | ||
<var>v</var> its value: | ||
<ol> | ||
<li>If<var>k</var> is <code>disableNormalization</code> or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/If/If /
index.html
Outdated
optional GainOptions options | ||
</dt> | ||
<dd> | ||
An optional initial gain value for this <a>GainNode</a>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|options| isn't the actual initial gain value. Not sure how best to describe this. Maybe say nothing at all since there's a link to the description of the actual GainOptions dict? Same goes for all of the following FooOptions dictionaries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
I notice that we're missing constructors for AudioBuffer, MediaStreamTrackAudioSourceNode, and PeriodicWave. I assume these are oversights.
index.html
Outdated
in <var>dict</var>, and then set its <a href= | ||
"#widl-ConvolverNode-buffer">buffer</a> attribute to the value of the | ||
<a href="#widl-ConvolverOptions-buffer">buffer</a> in <var>dict</var> | ||
member, in this order, and jump to the last step of this algorithm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the constructor, this ordering isn't really required right? The constructor will look at the disableNormalization and buffer attributes and construct the convolver appopriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this algorithm describes a way of getting the desired result. There are other ways to get the same result.
index.html
Outdated
the value of the <a href= | ||
"#widl-ConvolverNode-normalize">normalize</a> attribute. | ||
</div> | ||
<li>If <var>k</var> is the name of an <a>AudioParam</a> on on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "on on"
index.html
Outdated
method</a> function for this <a>AudioNode</a> type. Initialize | ||
all elements of this array to <code>null</code>. | ||
<li>If <var>k</var> is <code>disableNormalization</code> or | ||
<code>buffer</code>, jump to the beginning of this loop. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AudioBufferSourceNode
has a buffer
attribute. It looks like we fail to set it in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
index.html
Outdated
<li>Let <var>o</var> be a new object of type <var>i</var>. | ||
</li> | ||
<li>Let <var>option</var> be a dictionnary of the type associated to | ||
the interface associated to this factory method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a link for "associated to this factory method" to the definition of "associated interface" for a factor method below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I also linked more things.
index.html
Outdated
</p><a>AudioNode</a>s can be created in two ways: | ||
</p> | ||
<p> | ||
<a>AudioNode</a>s can be created in two ways: by using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Editorial: Having this be a subsection is nice so that we can get a link to this entire algorithm.
index.html
Outdated
@@ -4269,6 +4331,31 @@ <h2 id="GainNode"> | |||
"[Constructor(<a>BaseAudioContext</a> context, optional <a>GainOptions</a> options)]interface GainNode : <a>AudioNode</a>" | |||
class="idl"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something strange is happening here. In both Chrome and Firefox, I see the "Constructor" listed twice. Do you see this @padenot? And it seems to be happening for all nodes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apparently when you define it in the <dl>
, then you don't have to do it in the title. I'll fix.
index.html
Outdated
<p> | ||
Let <var>gain</var> be a new <a>GainNode</a> object. <a href= | ||
"#audionode-constructor-common">Initialize the common part</a> of | ||
<var>gain</var>, and return <var>gain</var>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this a bit confusing. You say the common part is initialized. What about the non-common parts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not called "initializing an AudioNode", hopefully less confusing.
index.html
Outdated
</ol> | ||
<p> | ||
<dfn id="audionode-constructor-common">Initializing the common | ||
part</dfn> of an object <var>o</var> of interface <var>i</var> that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This talks about initializing the common parts like the number of inputs/outputs and channel parameters, and it does. But then it also talks about the non-common parts like the node-specific options.
I think this needs to be split up into two pieces or just renamed to so that's not about initializing the common part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed it, you're right.
index.html
Outdated
be <a href="#associated">associated</a> with. | ||
</dd> | ||
<dt> | ||
optional IIRFilterOptions options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
index.html
Outdated
"#associated">associated</a> with. | ||
</dd> | ||
<dt> | ||
optional MediaStreamAudioSourceOptions options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
de7d3ef
to
a338555
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but it seems we're missing AudioBuffer and PeriodicWave constructors.
index.html
Outdated
</p> | ||
<section> | ||
<h3> | ||
AudioNode creation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "creation" should be capitalized.
index.html
Outdated
"associated">associated <a>BaseAudioContext</a></dfn> of the | ||
<a>AudioNode</a> to be created. Similarly, when using the factory | ||
method, the <a>associated <code>BaseAudioContext</code></a> of the | ||
<a>AudioNode</a> is the first argument of the factory method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems wrong since many factory methods don't have a first argument at all. Or perhaps I don't understand what you're trying to say here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is wrong. I meant "The associated BaseAudioContext when calling a factory method is the BaseAudioContext this factory method is called on", which makes sense.
index.html
Outdated
<a>AudioNode</a> is the first argument of the factory method. | ||
</p> | ||
<p> | ||
To create a new <a>AudioNode</a> of a particular type <var>i</var> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use "n" instead of "i"? I find it hard to distinguish between an "i" and a "l" and a "1".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
index.html
Outdated
</li> | ||
<li> | ||
<a href="#audionode-constructor-init">Initialize the common | ||
part</a> of <var>o</var>, with <var>c</var> and <var>option</var> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you don't want to say "Initializing the common part" here anymore because that section isn't about just the common part anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I half assed my regex apparently. Fixed.
index.html
Outdated
<ol> | ||
<li>Let <var>o</var> be a new object of type <var>i</var>. | ||
</li> | ||
<li>Let <var>option</var> be a dictionnary of the type <a href= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "dictionnary" -> "dictionary"
index.html
Outdated
value of this parameter. | ||
</li> | ||
<li> | ||
<a href="#audionode-constructor-init">Initialize the common |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto. It's not the common part anymore.
index.html
Outdated
<dl title= | ||
"[Constructor(<a>AudioBufferOptions<a> options)]interface AudioBuffer" | ||
class="idl"> | ||
<dl title="interface AudioBuffer" class="idl"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you forget to define the actual constructor for this. And the constructor for this doesn't follow the AudioNode constructors because context is not the first arg. Not sure where the best place to describe the constructor should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are not AudioNode
s, the goal is to fix it in a different PR (this PR and issue is about AudioNodes, there are other issues about other objects).
This is different because the notion of "associated AudioContext" does not apply, among other things. I've reinstated this constructor.
Anyways, I plan on following up immediately with defining the ctors for other objects, this PR is big enough already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm.
index.html
Outdated
"#associated">associated</a> with. | ||
</dd> | ||
<dt> | ||
optional MediaElementAudioSourceOptions options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not optional.
index.html
Outdated
</dd> | ||
</dl> | ||
</dd> | ||
</dl> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something is messed up somewhere. The Media* nodes all used to be in successive sections. Now the worklet node comes after MediaElementAudioSource, and the other nodes are all placed at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR does not change this, but I can do a patch to reorder the section if you'd like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you haven't already, don't bother. Recall that we're going to reorder all the sections anyway to roughly alphabetical.
IIRFilterOptions options | ||
</dt> | ||
<dd> | ||
Optional initial parameter value for this <a>IIRFilterNode</a>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
9c37403
to
591f0a7
Compare
For those following along: https://rawgit.com/WebAudio/web-audio-api/591f0a7/index.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. Thanks for working on this!
The first commit is the most important of this PR, it defines what happens when constructing AudioNodes (either via the factory method or the ctor). The second fixes the descriptions of the various factory method to link back to the algorithm used (this is mostly a mechanical change). The third patch fixes a mistake in the first patch, and the fourth one defines the constructors in terms of all the above, linking back to the definitions appropriately: it's mostly mechanical, but adjustments have been performed for the AudioWorklet.