W3C home > Mailing lists > Public > public-audio@w3.org > October to December 2012

Re: Questions about AudioParam

From: Robert O'Callahan <robert@ocallahan.org>
Date: Tue, 11 Dec 2012 11:31:59 +1300
Message-ID: <CAOp6jLY0qsiEzJGVNEFp7aPL-1gRO0qRBzH6fhizUhWFa1fxvQ@mail.gmail.com>
To: Chris Rogers <crogers@google.com>
Cc: Ehsan Akhgari <ehsan.akhgari@gmail.com>, public-audio@w3.org
On Thu, Oct 25, 2012 at 12:26 PM, Chris Rogers <crogers@google.com> wrote:

> WebKit hasn't yet implemented this attribute, but I'm thinking that each
> AudioParam will keep track of the latest .computedValue which is computed
> every single render quantum in the audio thread.  Then the main JS thread
> simply can read the latest value of this attribute.  WebKit *is* basically
> computing this value every render quantum, but doesn't store it away to be
> read by the attribute...

I don't think it's a good idea to expose this kind of asynchronously
varying data to Javascript.

The basic issue is that since there's no way to synchronize the use of
computedValue with any other operation, whatever value script reads from
computedValue could be "wrong" as soon as it has read the value. (There
could be an arbitrary delay between reading the value and returning it to
the script.) That makes it almost impossible to use in a reliable way.

I'm not sure what the intended use-cases are for computedValue, so it's
hard to illustrate how this would cause problems in real applications. But
for example, suppose an author tried to use computedValue to plot the
values of several AudioParams against AudioContext.currentTime, using code
like this:
var x = context.currentTime;
for (var i = 0; i < count; ++i) {
  plot(x, audioParam[i].computedValue);
This obvious-looking code doesn't actually work reliably, since the values
obtained by computedValue may not correspond to the values those params had
at currentTime. In fact, if computedValue changes asynchronously there is
no way to implement this example reliably.

Assuming there are good use-cases for computedValue (what are they?), I
propose that AudioContext.currentTime and computedValue reflect a
consistent snapshot of the graph state. This snapshot would only be allowed
to change during HTML5 stable states, when we know no script is running.

Jesus called them together and said, “You know that the rulers of the
Gentiles lord it over them, and their high officials exercise authority
over them. Not so with you. Instead, whoever wants to become great among
you must be your servant, and whoever wants to be first must be your
slave — just
as the Son of Man did not come to be served, but to serve, and to give his
life as a ransom for many.” [Matthew 20:25-28]
Received on Monday, 10 December 2012 22:32:44 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:50:04 UTC