Re: AudioParam.setValueCurveAtTime

On Sun, Jun 22, 2014 at 10:18 AM, Andy Harman <andyh.at.pendragon@gmail.com>
wrote:

> I am trying to write tests for w3c/web-platform-tests and have a few
> questions and observations about the setValueCurveAtTime method.
>
> The Chrome and Firefox implementations give different results.  If you
> have a 5 element curve - stretched over 1 second then:
>
>    - Chrome changes from element 0 to element 1 at around 0.1 seconds.
>    - Firefox changes from element 0 to element 1 at around 0.2 seconds.
>
> The difference indicates that Firefox is rounding the index down and
> Chrome is rounding to the nearest whole number.
>

I'm not 100% sure, but I think this rounding was added in Chrome to make
Chrome's layout tests in Javascript produce the same numbers as the
internal implementation.

>
> The specification states that the values should be calculated as:
>   v(t) = values[N * (t - startTime) / duration]
>
> Wouldn't it be more useful to calculate the value as:
>   v(t) = values[Floor((N-1) * (t - startTime) / duration)]
>
> As this means that the curve would start at startTime, and end at
> startTime+duration.
>
> Also, the "curve" part of the name infers that we should be interpolating
> the values.  However the specification and browser implementations only
> give discrete values.  This means the method is useless for envelopes.
>

I think the intent was that if you need more fine-grained values, you use a
larger array, perhaps at the sample rate.

--
Ray

Received on Monday, 23 June 2014 18:01:54 UTC