1

Web audio provides a high-precision clock for scheduling events. It seems, though, that this value is read from the hardware clock only at certain times, such as the beginning of each loop through the web audio network. It is NOT updated while processing dataflow through the network. If I have two Script nodes in my network, for example, the value of the clock is the same when each script is run, even though they are executed sequentially in the web audio model (single-threaded). I can find no documentation on this issue. Can anyone point me to documentation, or provide an answer?

Sebastian Simon
  • 18,263
  • 7
  • 55
  • 75
Pete T
  • 76
  • 1
  • 7

1 Answers1

1

The audio clock is used for scheduling parameters and audio events throughout the Web Audio API - for start() and stop().

However, if you want to change the tempo in the middle of those two bars - or stop playing before the two bars are up - you’re out of luck.

The up-and-coming High Resolution Time specification actually does give us a much better precision current time through window.performance.now(); it’s even implemented (albeit prefixed) in many current browsers.

Scheduling Web Audio with Precision

timeupdate

Community
  • 1
  • 1
Esko
  • 683
  • 9
  • 23
  • Thanks for you quick answer. I understand HOW the currentTime is used in the API. My question is, at what point does the change in the clock's value become visible? – Pete T Oct 09 '15 at 22:33
  • 1
    currentTime should be updated every 128 sample frames. There isn't a specified relationship between currentTime and window.performance.now(). – Raymond Toy Oct 12 '15 at 15:30