user2206436
user2206436

Reputation: 69

what is the time unit for Web Audio API 'noteOn()'

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

Answers (1)

Oskar Eriksson
Oskar Eriksson

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

Related Questions