Changes

Jump to: navigation, search

Audio Data API

410 bytes added, 03:03, 26 May 2010
nsIDOMHTMLAudioElement additions
void mozSetup(in long channels, in long rate, in float volume);
void unsigned long mozWriteAudio(array); // array is Array() or Float32Array()
void mozCurrentSampleOffset();
# '''array''' - this is a JS Array (i.e., new Array()) or a typed float array (i.e., new Float32Array()) containing the audio data (floats) you wish to write. It must be 0 or N (where N % channels == 0) elements in length, otherwise a DOM error occurs.
 
The '''mozWriteAudio()''' method returns the number of samples that were just written, which may or may not be the same as the number in '''array'''. Only the number of samples that can be written without blocking the audio hardware will be written. It is the responsibility of the caller to deal with any samples that don't get written in the first pass (e.g., buffer and write in the next call).
The '''mozCurrentSampleOffset()''' method can be called after '''mozSetup()'''. It returns the current position (measured in samples) of the audio stream. This is useful when determining how much data to write with '''mozWriteAudio()'''.
Confirm
656
edits

Navigation menu