Reputation: 69
I am trying to use web audio api 'noteOn(time)' to play a sound, but I am not sure what the time unit is.
Is it in millisecond? or in second?
Upvotes: 1
Views: 438
Reputation: 2641
It's seconds.
The time is relative to the audio context's currentTime, which can be accessed like so:
var context = new audioContext();
//....
note.noteOn(context.currentTime); //will play now
//....
note.noteOn(context.currentTime + 1); //will play in one second
Upvotes: 2