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?

1 Answer 1

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

2
  • 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 9, 2015 at 22:33
  • 1
    currentTime should be updated every 128 sample frames. There isn't a specified relationship between currentTime and window.performance.now(). Oct 12, 2015 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.