Re: Value of currentTime

Hi Julia,

Setting aside the part of your post that relates to the rate at which currentTime is updated, I wanted to note that it is easy to start two sources at a specific time:

On May 27, 2014, at 10:06 AM, Arnau Julia <Arnau.Julia@ircam.fr> wrote:
> Therefore, as I understand, if I want to start two sources at a specific time I can't do something like this,
> 
> function start(){
> 	source1.start(audioContext.currentTime+1);
> 	source2.start(audioContext.currentTime+1);
> }
> 
> because it's not possible to guarantee that the currentTime for these two instructions will be the same.


You could, however, do this, if you wanted to be completely sure:

function start(){
	var t = audioContext.currentTime+1;
	source1.start(t);
	source2.start(t);
}

Overall I don’t think it is a good idea (even if it were possible) to rely on sample-accurate ("a-rate") updates of the currentTime clock in the main thread, because there is always some unpredictability in the thread’s timing, and it’s likely to be large relative to the duration of a sample frame. The main browser thread can yield CPU time to other interrupt-driven processes (including things outside the browser) at some point between acquiring currentTime’s value and employing that value for scheduling purposes.

.            .       .    .  . ...Joe

Joe Berkovitz
President

Noteflight LLC
Boston, Mass.
phone: +1 978 314 6271
www.noteflight.com
"Your music, everywhere"

Received on Tuesday, 27 May 2014 15:18:15 UTC