Search completed in 1.25 seconds.
Introducing the Audio API extension - Archive of obsolete content
.mozsetup(1, 44100); var samples = new float32array(22050); for (var i = 0; i < samples.length ; i++) { samples[i] = math.sin( i / 20 ); } output.mozwriteaudio(samples); } </script> </head> <body> <p>this demo plays a one second tone when you click the button below.</p> <button onclick="playtone();">play</button> </body> </html> the
mozcurrentsampleoffset() method gives the audible position of the audio stream, meaning the position of the last heard sample.
...var currentsampleoffset = audiooutput.
mozcurrentsampleoffset(); audio data written using the mozwriteaudio() method needs to be written at a regular interval in equal portions, in order to keep a little ahead of the current sample offset (the sample offset that is currently being played by the hardware can be obtained with
mozcurrentsampleoffset()), where "a little" means something on the order of 500 ms of samples.
...to do this start writing the data in small portions and wait for the value returned by
mozcurrentsampleoffset() to be greater than 0.
...// auto latency detection if (autolatency) { prebuffersize = math.floor(samplerate * (new date().valueof() - started) / 1000); if (audio.
mozcurrentsampleoffset()) { // play position moved?
Creating a Web based tone generator - Archive of obsolete content
the function
mozcurrentsampleoffset() is used to know the position of the samples being played so that we can fill a 500 ms buffer of audio samples.
... var currentposition = audio.
mozcurrentsampleoffset(); var available = currentposition + prebuffersize - currentwriteposition; if(available > 0) { // request some sound data from the callback function.
nsIDOMHTMLAudioElement
last changed in gecko 2.0 (firefox 4 / thunderbird 3.3 / seamonkey 2.1) inherits from: nsidomhtmlmediaelement method overview unsigned long long
mozcurrentsampleoffset(); void mozsetup(in pruint32 channels, in pruint32 rate); [implicit_jscontext] unsigned long mozwriteaudio(in jsval data); methods
mozcurrentsampleoffset() non-standard this feature is non-standard and is not on a standards track.
...unsigned long long
mozcurrentsampleoffset(); parameters none.