Accessor: audio/AudioPlayer


Accessor to play an audio signal. This accessor accepts as input in a variety of formats and plays back the audio encoded in those input values.

This accessor queues the data to be played by the audio system. When the data has been accepted by the audio system to be played, it produces an output with value true. That output should be used as a trigger to provide more audio data. If that new output data is provided before the previously data has been drained by the audio queue, then continuous audio with no gaps is possible. If on the other hand input data is provided too quickly, then it will overwrite the data in the output buffer, thereby creating considerable distortion. If it is provided too slowly, then there will be gaps in the output audio.

The inputFormat parameter specifies the form in which the audio input will be provided. The available formats include:

  • "raw": The input is a byte array representing audio data exactly as captured by default on the host.
  • "array": The audio input data is an array of arrays of numbers, where each number is in the range from -1.0 to 1.0. The first index of the input specifies the channel number.
  • "encoded": The audio input data is a byte array containing audio data encoded in one of the file format standards such as AIFF (historically associated with Apple computers), AIFF-C (a compressed version of AIFF), AU (historically associated with Sun Microsystems and Unix computers), or WAVE (historically associated with Windows PCs).

    The playbackOptions parameter is an object with the following properties, all of which are optional:

  • bigEndian: 1 if the the sample is big endian, 0 if it is little endian If bigEndian is not present, then the default is big endian.

  • bitsPerSample: The number of bits per sample. This is an integer that defaults to 16.
  • channels: The number of channels. This defaults to 1.
  • sampleRate: The sample rate. This is an integer that defaults to 8000. Typical supported sample rates are 8000, 11025, 22050, 44100, and 48000.

    WAVE (aka .wav) is 16 bits, 1 channel, little endian, 44100 Hz. This accessor requires the optional 'audio' module, which may or may not be provided by an accessor host. Moreover, a host may not support all capture formats and all output formats.

  • $$Id$$
  • Edward A. Lee (
Name Type Description
input The audio data.
Name Type Description
accepted An indicator that the audio data has been queued to the audio system.
Name Type Description
inputFormat The format of the input data.
playbackOptions The playback options.