Skip to content

Commit

Permalink
Fix WebAudio#1788: Clarify the value returned by the AudioParam value…
Browse files Browse the repository at this point in the history
… getter. (WebAudio#1838)

* Fix WebAudio#1788: Clarify the value returned by the AudioParam value getter.

Define the intrinsic value and update the algorithm a little bit for
that.

Then update the rendering algorith so that the [[current value]] is
the intrinsic value, not the computed value (that consists of the
automation and any inputs to the param).

I think this could be simplified a bit more, but I didn't really do
that.  Perhaps all references to intrinsic value could be replaced by
[[current value]]?

* Refine algorithm based on review comments

* Fix a few nits

* Address comments.

    * Remove garbage
    * Wrap line.
  • Loading branch information
rtoy committed May 13, 2019
1 parent f47c7f5 commit d7b9c7e
Showing 1 changed file with 34 additions and 22 deletions.
56 changes: 34 additions & 22 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3496,10 +3496,9 @@ Attributes</h4>
initialized to the <code>defaultValue</code>.

Getting this attribute returns the contents of the
{{[[current value]]}} slot, which maintains the value of
this parameter at the conclusion of the most recent render
quantum on the audio rendering thread, or the most recently
assigned value if no rendering has taken place.
{{[[current value]]}} slot. See
[[#computation-of-value]] for the algorithm for the
value that is returned.

Setting this attribute has the effect of assigning the
requested value to the {{[[current value]]}} slot, and
Expand Down Expand Up @@ -3860,30 +3859,44 @@ parameters</dfn> are {{AudioParam}}s that are used with other
{{AudioParam}}s to compute a value that is then used as an input
to compute the output of an {{AudioNode}}.

The <dfn>computedValue</dfn> is the final value controlling the
audio DSP and is computed by the audio rendering thread during each
rendering time quantum. It MUST be internally computed as follows:
The <dfn>computedValue</dfn> is the final value controlling the audio
DSP and is computed by the audio rendering thread during each
rendering time quantum.

<div algorithm="computation-of-value">
1. An <em>intrinsic</em> parameter value will be calculated at
each time, which is either the value set directly to the
<code>value</code> attribute, or, if there are any <a href="#dfn-automation-event">automation events</a> with times before or
at this time, the value as calculated from these events. When read,
the <code>value</code> attribute always returns the
<em>intrinsic</em> value for the current time. If automation events
are removed from a given time range, then the <em>intrinsic</em>
value will remain unchanged and stay at its previous value until
either the <code>value</code> attribute is directly set, or
The computation of the value of an {{AudioParam}} consists of two parts:
- the <var>paramIntrinsicValue</var> value that is computed from the {{AudioParam/value}}
attribute and any <a href="#dfn-automation-event">automation events</a>.
- the <var>paramComputedValue</var> that is the final value controlling the
audio DSP and is computed by the audio rendering thread during each
<a>render quantum</a>.

These values MUST be computed as follows:

1. <var>paramIntrinsicValue</var> will be calculated at
each time, which is either the value set directly to
the {{AudioParam/value}} attribute, or, if there are
any <a href="#dfn-automation-event">automation
events</a> with times before or at this time, the
value as calculated from these events. If automation
events are removed from a given time range, then the
<var>paramIntrinsicValue</var> value will remain
unchanged and stay at its previous value until either
the {{AudioParam/value}} attribute is directly set, or
automation events are added for the time range.

2. The <em>computedValue</em> is the sum of the <em>intrinsic</em>
1. Set {{[[current value]]}} to the value of
<var>paramIntrinsicValue</var> at the beginning of
this <a>render quantum</a>.

2. <var>paramComputedValue</var> is the sum of the <var>paramIntrinsicValue</var>
value and the value of the <a href="#input-audioparam-buffer">input
AudioParam buffer</a>. When read, the
<code>value</code> attribute always returns the
<em>computedValue</em> for the current time.
AudioParam buffer</a>.

3. If this {{AudioParam}} is a <a>compound parameter</a>,
compute its final value with other {{AudioParam}}s.

4. Set <a>computedValue</a> to <var>paramComputedValue</var>.
</div>

The <dfn>nominal range</dfn> for a <a>computedValue</a> are the
Expand Down Expand Up @@ -10921,8 +10934,7 @@ operation such as resolution of {{Promise}}s in the {{AudioWorkletGlobalScope}}.
{{AudioParam}} for this block.

3. [=Queue a control message=] to set the {{[[current value]]}} slot
of this {{AudioParam}} to the last value computed in the preceding
step.
of this {{AudioParam}} according to [[#computation-of-value]].

2. If this {{AudioNode}} has any {{AudioNode}}s connected to its input,
[[#SummingJunction|sum]] the buffers
Expand Down

0 comments on commit d7b9c7e

Please sign in to comment.